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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
22 * show the popup for search an accounting item
23 *@param object this, it must contains some attribute as
24 * - jrn if set and different to 0, will filter the accounting item for a
26 * - account the tag which will contains the number
27 * - label the tag which will contains the label
28 * - bracket if the value must be surrounded by [ ]
29 * - acc_query for the initial query
32function search_accounting(obj)
41 sx=document.body.scrollTop+60;
44 var div_style="top:"+sx+"px";
45 removeDiv('search_account');
46 add_div({id:'search_account',cssclass:'inner_box',html:loading(),style:div_style,drag:false});
48 var dossier=$('gDossier').value;
50 var queryString="gDossier="+dossier;
52 queryString+="&op2=sf";
53 queryString+="&op=account";
58 queryString+="&j="+obj.jrn;
61 queryString+="&j="+$("p_jrn").value;
66 queryString+="&c="+obj.account;
70 queryString+="&l="+obj.label;
74 queryString+="&b="+obj.bracket;
82 queryString+="&nover";
86 queryString+="&bracket";
92 queryString+="&q="+obj.acc_query;
99 var str_account=$(e).value;
100 queryString+="&q="+str_account;
105 queryString+="&ctl="+'search_account';
106 queryString=encodeURI(queryString);
107 var action=new Ajax.Request ( 'ajax_misc.php',
110 parameters:queryString,
111 onFailure:errorPoste,
112 onSuccess:result_poste_search
118 alert_box(e.message);
122 * when you submit the form for searching a accounting item
124 *@note the same as search_poste, except it answer to a FORM and not
127function search_get_poste(obj)
129 var dossier=$('gDossier').value;
130 var queryString="gDossier="+dossier;
132 queryString+="&op=account";
133 queryString+="&op2=sf";
135 if ( obj.elements['jrn'] )
137 queryString+="&j="+$F('jrn');
139 if ( obj.elements['account'])
141 queryString+="&c="+$F('account');
143 if ( obj.elements['label'])
145 queryString+="&l="+$F('label');
147 if( obj.elements['acc_query'])
149 queryString+="&q="+$F('acc_query');
153 queryString+="&ctl="+obj.ctl;
155 if( obj.elements['nosearch'])
159 if( obj.elements['nover'])
161 queryString+="&nover";
163 if( obj.elements['bracket'])
165 queryString+="&bracket";
168 $('asearch').innerHTML=loading();
169 var action=new Ajax.Request ( 'ajax_misc.php',
172 parameters:queryString,
173 onFailure:errorPoste,
174 onSuccess:result_poste_search
180 * show the answer of ajax request
181 *@param answer in XML
183function result_poste_search(req)
187 var answer=req.responseXML;
188 var a=answer.getElementsByTagName('ctl');
191 var rec=req.responseText;
192 alert_box ('erreur :'+rec);
194 var html=answer.getElementsByTagName('code');
196 var name_ctl=a[0].firstChild.nodeValue;
198 var code_html=getNodeText(nodeXml);
199 code_html=unescape_xml(code_html);
200 $('search_account').innerHTML=code_html;
204 alert_box(e.message);
208 code_html.evalScripts();
212 alert_box("RESPOSEAR"+content[48]+e.message);
221 alert_box(content[53]);
225 * Display the list of card using a given accounting
230function display_all_card(p_dossier,p_accounting)
233 var div_dest=add_div({id:'info_card_accounting',cssclass:"inner_box",style:fixed_position(100,250)+";width:auto"});
234 var action=new Ajax.Request ( 'ajax_misc.php',
237 parameters:{op:"display_all_card",
239 p_accounting:p_accounting
241 onSuccess:function (req)
243 div_dest.innerHTML=req.responseText;
244 remove_waiting_box();
251 * Search an account or an analytic account or a card, used in REPORT
252 * @param {json} p_obj ,
253 * property : - op for ajax_misc ,
255 * - target DOM element to update with the result
256 * - query for the search
259function search_account_card(p_obj)
261 p_obj['op']=p_obj['op']||"search_account_card";
263 if (p_obj.tagName && p_obj.tagName=='FORM') {
264 query=p_obj.serialize(true);
268 new Ajax.Request("ajax_misc.php",{method:"get",parameters:query,
269 onSuccess: function (req){
272 var obj={id:"search_account_div",cssclass:"inner_box",style:"top:"+pos+"px",
273 html:req.responseText};
275 remove_waiting_box();