noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
accounting_item.js
Go to the documentation of this file.
00001 /*
00002  *   This file is part of NOALYSS.
00003  *
00004  *   NOALYSS is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   NOALYSS is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with NOALYSS; if not, write to the Free Software
00016  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 /* $Revision$ */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*! \file
00023  * \brief
00024  * containing the javascript for opening a windows to search an account (poste comptable)
00025  */
00026 
00027 function set_poste_parent(p_ctl,p_value)
00028 {
00029     var f=g(p_ctl);
00030     f.value+='['+p_value+']';
00031 }
00032 
00033 function set_jrn_parent(p_ctl,p_value)
00034 {
00035     var f=g(p_ctl);
00036     if ( f )
00037     {
00038         if ( trim(f.value)!="") f.value+=' ';
00039         f.value+=p_value;
00040     }
00041 }
00042 
00043 
00044 function PcmnUpdate(p_value,p_lib,p_parent,p_type,p_dossier)
00045 {
00046     $('p_valu').value=p_value;
00047     $('p_oldu').value=p_value;
00048     $('p_libu').value=p_lib;
00049     $('p_parentu').value=p_parent;
00050     $('p_typeu').value=p_type;
00051     $('acc_update').style.top=posY+offsetY+"px";
00052     $('acc_update').style.left=posX+offsetX+"px";
00053     $('acc_update').show();
00054 }
00055 /**
00056  *@brief show the popup for search an accounting item
00057  *@param object this, it must contains some attribute as
00058  * - jrn if set and different to 0, will filter the accounting item for a
00059  *   ledger
00060  * - account the tag which will contains the  number
00061  * - label the tag which will contains the label
00062  * - bracket if the value must be surrounded by [ ]
00063  * - acc_query for the initial query
00064  *\see ajax_poste.php
00065  */
00066 function search_poste(obj)
00067 {
00068         var sx=0;
00069         if ( window.scrollY)
00070         {
00071             sx=window.scrollY+40;
00072         }
00073         else
00074         {
00075             sx=document.body.scrollTop+60;
00076         }
00077 
00078         var div_style="top:"+sx+"px";
00079         removeDiv('search_account');
00080         add_div({id:'search_account',cssclass:'inner_box',html:loading(),style:div_style,drag:true});
00081 
00082     var dossier=$('gDossier').value;
00083 
00084     var queryString="gDossier="+dossier;
00085 
00086     queryString+="&op=sf";
00087     try
00088     {
00089         if ( obj.jrn)
00090         {
00091             queryString+="&j="+obj.jrn;
00092         }
00093         if ( obj.account)
00094         {
00095             queryString+="&c="+obj.account;
00096         } 
00097         if ( obj.label)
00098         {
00099             queryString+="&l="+obj.label;
00100         }
00101         if ( obj.bracket)
00102         {
00103             queryString+="&b="+obj.bracket;
00104         }
00105         if( obj.noquery)
00106         {
00107             queryString+="&nq";
00108         }
00109         if( obj.no_overwrite)
00110         {
00111             queryString+="&nover";
00112         }
00113         if( obj.bracket)
00114         {
00115             queryString+="&bracket";
00116         }
00117         if ( ! obj.noquery)
00118         {
00119             if( obj.acc_query)
00120             {
00121                 queryString+="&q="+obj.acc_query;
00122             }
00123             else
00124             {
00125                 if ($(obj).account)
00126                 {
00127                     var e=$(obj).account;
00128                     var str_account=$(e).value;
00129                     queryString+="&q="+str_account;
00130                 }
00131             }
00132         }
00133 
00134         queryString+="&ctl="+'search_account';
00135         queryString=encodeURI(queryString);
00136         var action=new Ajax.Request ( 'ajax_poste.php',
00137                                       {
00138                                   method:'get',
00139                                   parameters:queryString,
00140                                   onFailure:errorPoste,
00141                                   onSuccess:result_poste_search
00142                                       }
00143                                     );
00144     }
00145     catch (e)
00146     {
00147         alert(e.getMessage);
00148     }
00149 }
00150 /**
00151  *@brief when you submit the form for searching a accounting item
00152  *@param obj form
00153  *@note the same as search_poste, except it answer to a FORM and not
00154  * to a click event
00155  */
00156 function search_get_poste(obj)
00157 {
00158     var dossier=$('gDossier').value;
00159     var queryString="gDossier="+dossier;
00160 
00161     queryString+="&op=sf";
00162 
00163     if ( obj.elements['jrn'] )
00164     {
00165         queryString+="&j="+$F('jrn');
00166     }
00167     if ( obj.elements['account'])
00168     {
00169         queryString+="&c="+$F('account');
00170     }
00171     if ( obj.elements['label'])
00172     {
00173         queryString+="&l="+$F('label');
00174     }
00175     if( obj.elements['acc_query'])
00176     {
00177         queryString+="&q="+$F('acc_query');
00178     }
00179     if (obj.ctl )
00180     {
00181         queryString+="&ctl="+obj.ctl;
00182     }
00183     if( obj.elements['nosearch'])
00184     {
00185         queryString+="&nq";
00186     }
00187     if( obj.elements['nover'])
00188     {
00189         queryString+="&nover";
00190     }
00191     if( obj.elements['bracket'])
00192     {
00193         queryString+="&bracket";
00194     }
00195 
00196     $('asearch').innerHTML=loading();
00197     var action=new Ajax.Request ( 'ajax_poste.php',
00198                                   {
00199                                   method:'get',
00200                                   parameters:queryString,
00201                                   onFailure:errorPoste,
00202                                   onSuccess:result_poste_search
00203                                   }
00204                                 );
00205 }
00206 
00207 /**
00208  *@brief show the answer of ajax request
00209  *@param  answer in XML
00210  */
00211 function result_poste_search(req)
00212 {
00213     try
00214     {
00215         var answer=req.responseXML;
00216         var a=answer.getElementsByTagName('ctl');
00217         if ( a.length == 0 )
00218         {
00219             var rec=req.responseText;
00220             alert ('erreur :'+rec);
00221         }
00222         var html=answer.getElementsByTagName('code');
00223 
00224         var name_ctl=a[0].firstChild.nodeValue;
00225         var nodeXml=html[0];
00226         var code_html=getNodeText(nodeXml);
00227         code_html=unescape_xml(code_html);
00228         $('search_account').innerHTML=code_html;
00229     }
00230     catch (e)
00231     {
00232         alert(e.message);
00233     }
00234     try
00235     {
00236         code_html.evalScripts();
00237     }
00238     catch(e)
00239     {
00240         alert("Impossible executer script de la reponse\n"+e.message);
00241     }
00242 
00243 }
00244 /**
00245 *@brief error for ajax
00246 */
00247 function errorPoste()
00248 {
00249     alert('Ajax failed');
00250 }
 All Data Structures Namespaces Files Functions Variables Enumerations