noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
accounting_item.js
Go to the documentation of this file.
1/*
2 * This file is part of NOALYSS.
3 *
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/
18/* $Revision$ */
19/**
20 * @file
21 * manage accounting
22 */
23
24// Copyright Author Dany De Bontridder danydb@aevalys.eu
25/**
26 * show the popup for search an accounting item
27 *@param object this, it must contains some attribute as
28 * - jrn if set and different to 0, will filter the accounting item for a
29 * ledger
30 * - account the tag which will contains the number
31 * - label the tag which will contains the label
32 * - bracket if the value must be surrounded by [ ]
33 * - acc_query for the initial query
34 *@see ajax_poste.php
35 */
36function search_accounting(obj)
37{
38 var sx=0;
39 if ( window.scrollY)
40 {
41 sx=window.scrollY+40;
42 }
43 else
44 {
45 sx=document.body.scrollTop+60;
46 }
47
48 var div_style="top:"+sx+"px";
49 removeDiv('search_account');
50 add_div({id:'search_account',cssclass:'inner_box',html:loading(),style:div_style,drag:false});
51
52 var dossier=$('gDossier').value;
53
54 var queryString="gDossier="+dossier;
55
56 queryString+="&op2=sf";
57 queryString+="&op=account";
58 try
59 {
60 if ( obj.jrn)
61 {
62 queryString+="&j="+obj.jrn;
63 }else {
64 if ($("p_jrn")) {
65 queryString+="&j="+$("p_jrn").value;
66 }
67 }
68 if ( obj.account)
69 {
70 queryString+="&c="+obj.account;
71 }
72 if ( obj.label)
73 {
74 queryString+="&l="+obj.label;
75 }
76 if ( obj.bracket)
77 {
78 queryString+="&b="+obj.bracket;
79 }
80 if( obj.noquery)
81 {
82 queryString+="&nq";
83 }
84 if( obj.no_overwrite)
85 {
86 queryString+="&nover";
87 }
88 if( obj.bracket)
89 {
90 queryString+="&bracket";
91 }
92 if ( ! obj.noquery)
93 {
94 if( obj.acc_query)
95 {
96 queryString+="&q="+obj.acc_query;
97 }
98 else
99 {
100 if ($(obj).account)
101 {
102 var e=$(obj).account;
103 var str_account=$(e).value;
104 queryString+="&q="+str_account;
105 }
106 }
107 }
108
109 queryString+="&ctl="+'search_account';
110 queryString=encodeURI(queryString);
111 var action=new Ajax.Request ( 'ajax_misc.php',
112 {
113 method:'get',
114 parameters:queryString,
115 onFailure:errorPoste,
116 onSuccess:result_poste_search
117 }
118 );
119 }
120 catch (e)
121 {
122 alert_box(e.message);
123 }
124}
125/**
126 * when you submit the form for searching a accounting item
127 *@param obj form
128 *@note the same as search_poste, except it answer to a FORM and not
129 * to a click event
130 */
131function search_get_poste(obj)
132{
133 var dossier=$('gDossier').value;
134 var queryString="gDossier="+dossier;
135
136 queryString+="&op=account";
137 queryString+="&op2=sf";
138
139 if ( obj.elements['jrn'] )
140 {
141 queryString+="&j="+$F('jrn');
142 }
143 if ( obj.elements['account'])
144 {
145 queryString+="&c="+$F('account');
146 }
147 if ( obj.elements['label'])
148 {
149 queryString+="&l="+$F('label');
150 }
151 if( obj.elements['acc_query'])
152 {
153 queryString+="&q="+$F('acc_query');
154 }
155 if (obj.ctl )
156 {
157 queryString+="&ctl="+obj.ctl;
158 }
159 if( obj.elements['nosearch'])
160 {
161 queryString+="&nq";
162 }
163 if( obj.elements['nover'])
164 {
165 queryString+="&nover";
166 }
167 if( obj.elements['bracket'])
168 {
169 queryString+="&bracket";
170 }
171
172 $('asearch').innerHTML=loading();
173 var action=new Ajax.Request ( 'ajax_misc.php',
174 {
175 method:'get',
176 parameters:queryString,
177 onFailure:errorPoste,
178 onSuccess:result_poste_search
179 }
180 );
181}
182
183/**
184 * show the answer of ajax request
185 *@param answer in XML
186 */
187function result_poste_search(req)
188{
189 try
190 {
191 var answer=req.responseXML;
192 var a=answer.getElementsByTagName('ctl');
193 if ( a.length == 0 )
194 {
195 var rec=req.responseText;
196 alert_box ('erreur :'+rec);
197 }
198 var html=answer.getElementsByTagName('code');
199
200 var name_ctl=a[0].firstChild.nodeValue;
201 var nodeXml=html[0];
202 var code_html=getNodeText(nodeXml);
203 code_html=unescape_xml(code_html);
204 $('search_account').innerHTML=code_html;
205 }
206 catch (e)
207 {
208 alert_box(e.message);
209 }
210 try
211 {
212 code_html.evalScripts();
213 }
214 catch(e)
215 {
216 alert_box("RESPOSEAR"+content[48]+e.message);
217 }
218
219}
220/**
221* error for ajax
222*/
223function errorPoste()
224{
225 alert_box(content[53]);
226}
227
228/**
229 * Display the list of card using a given accounting
230 * @param dossier
231 * @param accounting
232 *
233 */
234function display_all_card(p_dossier,p_accounting)
235{
236 waiting_box();
237 var div_dest=add_div({id:'info_card_accounting',cssclass:"inner_box",style:fixed_position(100,250)+";width:auto"});
238 var action=new Ajax.Request ( 'ajax_misc.php',
239 {
240 method:'get',
241 parameters:{op:"display_all_card",
242 gDossier:p_dossier,
243 p_accounting:p_accounting
244 },
245 onSuccess:function (req)
246 {
247 div_dest.innerHTML=req.responseText;
248 remove_waiting_box();
249 }
250 }
251 );
252}
253
254/**
255 * Search an account or an analytic account or a card, used in REPORT
256 * @param {json} p_obj ,
257 * property : - op for ajax_misc ,
258 * - gDossier,
259 * - target DOM element to update with the result
260 * - query for the search
261 * @returns {void}
262 */
263function search_account_card(p_obj)
264{
265 p_obj['op']=p_obj['op']||"search_account_card";
266 var query=p_obj;
267 if (p_obj.tagName && p_obj.tagName=='FORM') {
268 query=p_obj.serialize(true);
269 }
270
271 waiting_box();
272 new Ajax.Request("ajax_misc.php",{method:"get",parameters:query,
273 onSuccess: function (req){
274
275 var pos=calcy(50);
276 var obj={id:"search_account_div",cssclass:"inner_box",style:"top:"+pos+"px",
277 html:req.responseText};
278 add_div(obj);
279 remove_waiting_box();
280 }
281 });
282 return false;
283}