Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 function clean_Fid(p_ctl)
00032 {
00033 nSell=p_ctl+"_price";
00034 nTvaAmount=p_ctl+"_tva_amount";
00035 nBuy=p_ctl+"_price";
00036 nTva_id=p_ctl+"_tva_id";
00037 if ( $(nSell) )
00038 {
00039 $(nSell).value="";
00040 }
00041 if ( $(nBuy) )
00042 {
00043 $(nBuy).value="";
00044 }
00045 if ( $(nTva_id) )
00046 {
00047 $(nTva_id).value="-1";
00048 }
00049 if ( $(nTvaAmount))
00050 {
00051 $(nTvaAmount).value=0;
00052 }
00053 }
00054 function errorFid(request,json)
00055 {
00056 alert('erreur : ajax fiche');
00057 }
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 function ajaxFid(p_ctl)
00068 {
00069 try
00070 {
00071 var gDossier=$('gDossier').value;
00072 var jrn=$(p_ctl).jrn;
00073 $(p_ctl).value=$(p_ctl).value.toUpperCase();
00074 if ( jrn == undefined )
00075 {
00076 if ($('p_jrn')!=undefined)
00077 {
00078 jrn=$('p_jrn').value;
00079 }
00080 }
00081 if ( jrn == undefined )
00082 {
00083 jrn=-1;
00084 }
00085 if ( trim($(p_ctl).value)=="" )
00086 {
00087 nLabel=$(p_ctl).label;
00088 if ($(nLabel) )
00089 {
00090 $(nLabel).value="";
00091 $(nLabel).innerHTML=" ";
00092 clean_Fid(p_ctl);
00093 return;
00094 }
00095 }
00096 var queryString="FID="+trim($(p_ctl).value);
00097 if ( $(p_ctl).label)
00098 {
00099 queryString+='&l='+$(p_ctl).label;
00100 }
00101 if ( $(p_ctl).tvaid)
00102 {
00103 queryString+='&t='+$(p_ctl).tvaid;
00104 }
00105 if ( $(p_ctl).price)
00106 {
00107 queryString+='&p='+$(p_ctl).price;
00108 }
00109 if ( $(p_ctl).purchase)
00110 {
00111 queryString+='&b='+$(p_ctl).purchase;
00112 }
00113 if ( $(p_ctl).typecard)
00114 {
00115 queryString+='&d='+$(p_ctl).typecard;
00116 }
00117 queryString=queryString+"&j="+jrn+'&gDossier='+gDossier;
00118 queryString=queryString+'&ctl='+p_ctl.id;
00119
00120 var action=new Ajax.Request (
00121 "fid.php",
00122 {
00123 method:'get',
00124 parameters:queryString,
00125 onFailure:errorFid,
00126 onSuccess:successFid
00127 }
00128
00129 );
00130 }catch (e) {
00131 alert(e.message);
00132 alert(p_ctl);
00133 }
00134
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 function successFid(request,json)
00152 {
00153 var answer=request.responseText.evalJSON(true);
00154 var flabel=answer.flabel;
00155 if ( answer.answer=='nok' )
00156 {
00157 set_value(flabel," Fiche inexistante");
00158 return;
00159 }
00160
00161 var ftva_id=answer.ftva_id;
00162 var fsale=answer.fPrice_sale;
00163 var fpurchase=answer.fPrice_purchase;
00164
00165 if ( ftva_id != 'none')
00166 {
00167 set_value(ftva_id,answer.tva_id);
00168 }
00169 if ( flabel != 'none')
00170 {
00171 set_value(flabel,answer.name);
00172 }
00173 if ( fsale != 'none')
00174 {
00175 set_value(fsale,answer.sell);
00176 }
00177 if ( fpurchase != 'none')
00178 {
00179 set_value(fpurchase,answer.buy);
00180 }
00181
00182
00183 }
00184 function ajax_error_saldo(request,json)
00185 {
00186 alert('erreur : ajax solde ');
00187 }
00188
00189
00190
00191 function ajax_saldo(p_ctl)
00192 {
00193 var gDossier=$('gDossier').value;
00194 var ctl_value=trim($(p_ctl).value);
00195 var jrn=$('p_jrn').value;
00196 queryString="FID="+ctl_value+"&op=saldo";
00197 queryString=queryString+'&gDossier='+gDossier+'&j='+jrn;
00198 queryString=queryString+'&ctl='+ctl_value;
00199
00200 var action=new Ajax.Request (
00201 "ajax_misc.php",
00202 {
00203 method:'get',
00204 parameters:queryString,
00205 onFailure:ajax_error_saldo,
00206 onSuccess:ajax_success_saldo
00207 }
00208
00209 );
00210
00211 }
00212
00213
00214
00215 function ajax_success_saldo(request,json)
00216 {
00217 var answer=request.responseText.evalJSON(true);
00218 $('first_sold').value=answer.saldo;
00219
00220 }
00221
00222
00223
00224
00225
00226
00227
00228 function ajax_card(p_dossier,f_id,p_operation,ctl,page)
00229 {
00230 $(ctl).show();
00231 var queryString="gDossier="+p_dossier+"&f_id="+f_id+"&op="+p_operation+"&p="+page+'&ctl='+ctl;
00232 var action = new Ajax.Request(
00233 "ajax_card.php" , { method:'get', parameters:queryString,onFailure:ajax_get_failure,onSuccess:ajax_get_success}
00234 );
00235 }
00236
00237
00238 function ajax_get_success(request,json)
00239 {
00240 var answer=request.responseText.evalJSON(false);
00241 $(answer.ctl).show();
00242 $(answer.ctl).innerHTML=answer.html;
00243 }
00244
00245
00246 function ajax_get_failure(request,json)
00247 {
00248 alert("Ajax do not work for ajax_get");
00249
00250 }
00251
00252