noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
ajax_account.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief this file answer to the Ajax request from js/accounting_item.js
24 * - op
25 - sf show form of search
26 - param j : ledger -> php jrn
27 - param c : control for storing the pcm_val -> javascript account
28 - param l : control for storing the pcm_lib -> javascript label
29 - param ctl : the node to update (ipopup)
30 - param q : the acc_query -> javascript query
31 * - ctl (to return)
32 *
33 *
34 */
35if ( ! defined('ALLOWED')) die (_('Non authorisé'));
36
37require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
38require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
39mb_internal_encoding("UTF-8");
40
41extract($_REQUEST, EXTR_SKIP);
42
43$dossier_id=Dossier::id();
44
45if ($g_user->check_dossier($dossier_id) == 'X') exit();
46switch ($op2)
47{
48 /*----------------------------------------------------------------------
49 * Show the form and the result
50 *
51 ----------------------------------------------------------------------*/
52case "sf":
53 if ( ! isset($ctl)) {
54 $ctl= uniqid();
55 }
56 $ipopup=$ctl;
57 $attr=sprintf('this.ctl=\'%s\';',$ipopup);
58 $ctl.='_content';
59 $it=new IText('acc_query');
60 $it->size=30;
61 $it->value=(isset($q))?$q:'';
62 $str_poste=$it->input();
63 $str_submit=HtmlInput::submit('sf',_('Recherche'),"","smallbutton");
64 $r='';
65 $r.=HtmlInput::title_box(_('Poste Comptable'),'search_account',"close","","y");
66
67
68 $r.='<form id="sp" method="get" onsubmit="'.$attr.'search_get_poste(this);return false;">';
69 ob_start();
70 require_once NOALYSS_TEMPLATE.'/account_search.php';
71 $r.=ob_get_contents();
72 ob_end_clean();
73 $r.=dossier::hidden();
74 $r.=(isset ($c))?HtmlInput::hidden('account',$c):"";
75 $r.=(isset ($l))?HtmlInput::hidden('label',$l):"";
76 $r.=(isset ($j))?HtmlInput::hidden('jrn',$j):"";
77 $r.=(isset ($nover))?HtmlInput::hidden('nover','1'):"";
78 $r.=(isset ($nosearch))?HtmlInput::hidden('nosearch','1'):"";
79 $r.=(isset ($bracket))?HtmlInput::hidden('bracket','1'):"";
80
81
82 $r.='</form>';
83 $sql="
84 select pcm_val,pcm_lib,array_to_string(array_agg(j_qcode) , ',') as acode
85 from tmp_pcmn left join vw_poste_qcode on (j_poste=pcm_val) ";
86 $sep=" where ";
87 /* build the sql stmt */
88 if ( isset($j) && $j > 0 && isNumber($j))
89 {
90 /* create a filter on the ledger */
92 $fd_id=$ledger->build_sql_account($j);
93 if ( $fd_id != '' )
94 {
95 $sql.=" $sep (".$fd_id.')';
96 $sep=" and ";
97 }
98 }
99 /* show result */
100 if ( isset($q) && noalyss_strlentrim($q) > 0)
101 {
102 $q= sql_string($q);
103 $sql.=sprintf(" $sep ( pcm_val::text like '%s%%' or pcm_lib::text ilike '%%%s%%') ",
104 $q,$q);
105 }
106 $sql.=' group by pcm_val,pcm_lib,pcm_val_parent, pcm_type order by pcm_val::text limit 50';
107 if ( isset($q) && noalyss_strlentrim($q)> 0 )
108 {
109 $array=$cn->get_array($sql);
110 }
111 if ( ! isset($q) ) $array=array();
112 if ( isset($q) && noalyss_strlentrim($q)==0) $array=array();
113
114 /* set the javascript */
115 for ($i=0;$i<count($array);$i++)
116 {
117 $pcm_val=$array[$i]['pcm_val'];
118 if ( isset($bracket))
119 {
120 $pcm_val='['.$pcm_val.']';
121 }
122 if (isset($nover))
123 {
124 /* no overwrite */
125 $str=sprintf("$('%s').value=$('%s').value+' '+'%s';",
126 $c,$c,$pcm_val);
127
128 }
129 else
130 {
131 $str=sprintf("$('%s').value='%s';",
132 $c,$pcm_val);
133 }
134
135 if ( isset($l) )
136 {
137 $str.=sprintf("set_value('%s',g('%s').innerHTML);",
138 $l,"lib$i");
139
140 }
141 $str.="removeDiv('search_account');";
142 $array[$i]['javascript']=$str;
143 }
144 ob_start();
145
146 require_once NOALYSS_TEMPLATE.'/account_result.php';
147 $r.=ob_get_contents();
148 ob_end_clean();
149
150 $html=$r;
151 $html.=HtmlInput::button_close("search_account");
152 break;
153}
155if (headers_sent() && DEBUGNOALYSS > 0) {
156 echo $html;
157}
158else
159{
160 header('Content-type: text/xml; charset=UTF-8');
161}
162
163echo <<<EOF
164<?xml version="1.0" encoding="UTF-8"?>
165<data>
166<ctl>$ctl</ctl>
167<code>$xml</code>
168</data>
169EOF;
isNumber($p_int)
noalyss_strlentrim($p_string)
sql_string($p_string)
Fix the problem with the quote char for the database.
global $g_user
if no group available , then stop
switch($op2) $xml
$dossier_id
if(headers_sent() &&DEBUGNOALYSS > 0) $html
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$_REQUEST['ac']
_("actif, passif,charge,...")
Manage the account from the table jrn, jrnx or tmp_pcmn.
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n', $raw="", $refresh='')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input Text member :
$c
Definition compute.php:48
for($e=0; $e< count($afiche); $e++) exit
$fd_id
escape_xml($p_xml)
When data are transfered thanks ajax in a xml document, the xml can not contains some character,...