2 * This file is part of NOALYSS.
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.
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.
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
24// Copyright Author Dany De Bontridder danydb@aevalys.eu
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
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
36function search_accounting(obj)
45 sx=document.body.scrollTop+60;
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});
52 var dossier=$('gDossier').value;
54 var queryString="gDossier="+dossier;
56 queryString+="&op2=sf";
57 queryString+="&op=account";
62 queryString+="&j="+obj.jrn;
65 queryString+="&j="+$("p_jrn").value;
70 queryString+="&c="+obj.account;
74 queryString+="&l="+obj.label;
78 queryString+="&b="+obj.bracket;
86 queryString+="&nover";
90 queryString+="&bracket";
96 queryString+="&q="+obj.acc_query;
102 var e=$(obj).account;
103 var str_account=$(e).value;
104 queryString+="&q="+str_account;
109 queryString+="&ctl="+'search_account';
110 queryString=encodeURI(queryString);
111 var action=new Ajax.Request ( 'ajax_misc.php',
114 parameters:queryString,
115 onFailure:errorPoste,
116 onSuccess:result_poste_search
122 alert_box(e.message);
126 * when you submit the form for searching a accounting item
128 *@note the same as search_poste, except it answer to a FORM and not
131function search_get_poste(obj)
133 var dossier=$('gDossier').value;
134 var queryString="gDossier="+dossier;
136 queryString+="&op=account";
137 queryString+="&op2=sf";
139 if ( obj.elements['jrn'] )
141 queryString+="&j="+$F('jrn');
143 if ( obj.elements['account'])
145 queryString+="&c="+$F('account');
147 if ( obj.elements['label'])
149 queryString+="&l="+$F('label');
151 if( obj.elements['acc_query'])
153 queryString+="&q="+$F('acc_query');
157 queryString+="&ctl="+obj.ctl;
159 if( obj.elements['nosearch'])
163 if( obj.elements['nover'])
165 queryString+="&nover";
167 if( obj.elements['bracket'])
169 queryString+="&bracket";
172 $('asearch').innerHTML=loading();
173 var action=new Ajax.Request ( 'ajax_misc.php',
176 parameters:queryString,
177 onFailure:errorPoste,
178 onSuccess:result_poste_search
184 * show the answer of ajax request
185 *@param answer in XML
187function result_poste_search(req)
191 var answer=req.responseXML;
192 var a=answer.getElementsByTagName('ctl');
195 var rec=req.responseText;
196 alert_box ('erreur :'+rec);
198 var html=answer.getElementsByTagName('code');
200 var name_ctl=a[0].firstChild.nodeValue;
202 var code_html=getNodeText(nodeXml);
203 code_html=unescape_xml(code_html);
204 $('search_account').innerHTML=code_html;
208 alert_box(e.message);
212 code_html.evalScripts();
216 alert_box("RESPOSEAR"+content[48]+e.message);
225 alert_box(content[53]);
229 * Display the list of card using a given accounting
234function display_all_card(p_dossier,p_accounting)
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',
241 parameters:{op:"display_all_card",
243 p_accounting:p_accounting
245 onSuccess:function (req)
247 div_dest.innerHTML=req.responseText;
248 remove_waiting_box();
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 ,
259 * - target DOM element to update with the result
260 * - query for the search
263function search_account_card(p_obj)
265 p_obj['op']=p_obj['op']||"search_account_card";
267 if (p_obj.tagName && p_obj.tagName=='FORM') {
268 query=p_obj.serialize(true);
272 new Ajax.Request("ajax_misc.php",{method:"get",parameters:query,
273 onSuccess: function (req){
276 var obj={id:"search_account_div",cssclass:"inner_box",style:"top:"+pos+"px",
277 html:req.responseText};
279 remove_waiting_box();