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 function add_row(p_table,p_seq)
00030 {
00031 var mytable=g(p_table).tBodies[0];
00032 var max=parseFloat(g('amount_t'+p_seq).value);
00033 if ( ! mytable )
00034 {
00035 return;
00036 }
00037 var new_value=mytable.rows.length+1;
00038
00039
00040 if ( mytable.rows.length > 5 )
00041 {
00042 alert("Maximum 5 lignes ");
00043 return;
00044 }
00045 amount=compute_total_table(p_table,p_seq);
00046 if ( max < amount )
00047 {
00048 alert('Montant incorrect : max = '+max+" calculé="+amount);
00049 return;
00050 }
00051
00052
00053 var rowToCopy=mytable.rows[1];
00054 var row=mytable.insertRow(mytable.rows.length);
00055
00056 for ( var i=0;i< rowToCopy.cells.length;i++)
00057 {
00058 var cell=row.insertCell(i);
00059 var txt=rowToCopy.cells[i].innerHTML;
00060
00061 cell.innerHTML=txt;
00062 }
00063 var col=document.getElementsByName("val["+p_seq+"][]");
00064 col[col.length-1].value=max-amount;
00065 anc_refresh_remain(p_table,p_seq);
00066 }
00067
00068
00069
00070
00071
00072
00073 function compute_total_table(p_table,seq)
00074 {
00075 try{
00076
00077 var i=0;var tot=0;
00078 var col=document.getElementsByName("val["+seq+"][]");
00079 for (i=0;i<col.length;i++)
00080 {
00081
00082 tot+=parseFloat(col[i].value);
00083
00084 }
00085 return tot;
00086 }
00087 catch(e)
00088 {
00089 alert(e.message);
00090 }
00091 }
00092
00093
00094
00095
00096
00097
00098 function anc_refresh_remain(p_table,p_seq)
00099 {
00100 try
00101 {
00102 var tot_line=parseFloat(g('amount_t'+p_seq).value);
00103 var tot_table=compute_total_table(p_table,p_seq);
00104 var remain = tot_line-tot_table;
00105 remain=Math.round(remain *100)/100;
00106 var popup_table=p_table.toString();
00107 p_table=popup_table.replace("popup","");
00108 $('remain'+p_table).innerHTML=remain;
00109 if (remain == 0)
00110 {$('remain'+p_table).style.color="green"}
00111 else
00112 {$('remain'+p_table).style.color="red"}
00113 }catch (a)
00114 {
00115 alert(a.message);
00116 }
00117 }
00118
00119
00120
00121
00122
00123
00124
00125 function verify_ca(div)
00126 {
00127 try
00128 {
00129
00130 var idx=0;
00131 var amount_error=0;
00132
00133 while (idx < 50 )
00134 {
00135 var table=div+'t'+idx;
00136 if ( g(table) )
00137 {
00138 var total_amount=0;
00139
00140 var array_value=document.getElementsByName('val['+idx+'][]');
00141
00142 for (var i=0;i < array_value.length;i++ )
00143 {
00144 if ( isNaN(array_value[i].value))
00145 {
00146 array_value[i].value=0;
00147 }
00148
00149 total_amount+=parseFloat(array_value[i].value);
00150 }
00151 var amount=parseFloat(g('amount_t'+idx).value);
00152 var diff=amount-total_amount;
00153
00154 if ( Math.round(diff,2)!= 0.0)
00155 {
00156 g(table).style.backgroundColor='red';
00157 amount_error++;
00158 }
00159 else
00160 {
00161 g(table).style.backgroundColor='lightgreen';
00162
00163 }
00164 idx++;
00165 }
00166 else break;
00167 }
00168 if ( amount_error != 0 )
00169 {
00170 alert('Désolé, les montants pour la comptabilité analytique sont incorrects');
00171 return false;
00172 }
00173 return true;
00174 }
00175 catch (e)
00176 {
00177 alert(e.message);
00178 return false;
00179 }
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 function search_ca (p_dossier,p_target,p_source)
00191 {
00192 var pa_id=g(p_source).value;
00193 waiting_box();
00194 removeDiv('search_anc');
00195 var qs="op=openancsearch&gDossier="+p_dossier+"&ctl=searchanc";
00196 qs+="&c2="+pa_id+"&c1="+p_target;
00197
00198 var action=new Ajax.Request ( 'ajax_misc.php',
00199 {
00200 method:'get',
00201 parameters:qs,
00202 onFailure:null,
00203 onSuccess:function(req){
00204 try{
00205 remove_waiting_box();
00206 var pos=fixed_position(250,150)+";width:30%;height:50%";
00207 add_div({
00208 id:"searchanc",
00209 drag:1,
00210 cssclass:"inner_box",
00211 style:pos
00212 });
00213 $('searchanc').innerHTML=req.responseText;
00214
00215 } catch(e){
00216 alert(e.message);
00217 }
00218 }
00219 }
00220 );
00221
00222 }
00223 function search_anc_form(obj)
00224 {
00225 var qs="op=resultancsearch&ctl=searchanc&";
00226 var name=obj.id;
00227 qs+=$(name).serialize(false);
00228 waiting_box();
00229 var action=new Ajax.Request ( 'ajax_misc.php',
00230 {
00231 method:'get',
00232 parameters:qs,
00233 onFailure:null,
00234 onSuccess:function(req){
00235 try{
00236 remove_waiting_box();
00237 $('searchanc').innerHTML=req.responseText;
00238 req.responseText.evalScripts();
00239
00240 } catch(e){
00241 alert(e.message);
00242 }
00243 }
00244 }
00245 );
00246 return false;
00247 }
00248 function caod_checkTotal()
00249 {
00250 var ie4=false;
00251 if ( document.all )
00252 {
00253 ie4=true;
00254 }
00255 var total_deb=0.0;
00256 var total_cred=0.0;
00257 var nb_item=g('nbrow').value;
00258
00259 for (var i=0;i <nb_item ;i++)
00260 {
00261 var doc_amount=g("pamount"+i);
00262 if ( ! doc_amount )
00263 {
00264 return;
00265 }
00266 var side=g("pdeb"+i);
00267 if ( ! side )
00268 {
00269 return;
00270 }
00271 var amount=parseFloat(doc_amount.value);
00272
00273 if ( isNaN(amount) == true)
00274 {
00275 amount=0.0;
00276 }
00277 if ( side.checked == false )
00278 {
00279 total_cred+=amount;
00280 }
00281 if ( side.checked == true )
00282 {
00283 total_deb+=amount;
00284 }
00285 }
00286
00287
00288
00289 r_total_cred=Math.round(total_cred*100)/100;
00290 r_total_deb=Math.round(total_deb*100)/100;
00291 g('totalDeb').innerHTML=r_total_deb;
00292 g('totalCred').innerHTML=r_total_cred;
00293
00294 if ( r_total_deb != r_total_cred )
00295 {
00296 g("totalDiff").style.color="red";
00297 g("totalDiff").style.fontWeight="bold";
00298 g("totalDiff").innerHTML="Différence";
00299 diff=total_deb-total_cred;
00300 diff=Math.round(diff*100)/100;
00301 g("totalDiff").innerHTML=diff;
00302
00303 }
00304 else
00305 {
00306 g("totalDiff").innerHTML="0.0";
00307 }
00308 }
00309
00310
00311
00312
00313
00314
00315 function anc_remove_operation(p_dossier,p_oa_group)
00316 {
00317 var a=confirm("Etes-vous sur de vouloir effacer cette operation ?\n");
00318 if ( a == false ) return;
00319 var obj={"oa":
00320 p_oa_group,"gDossier":
00321 p_dossier,"op":"remove_anc"};
00322 var queryString=encodeJSON(obj);
00323 g(p_oa_group).style.display='none';
00324 var e=new Ajax.Request("ajax_misc.php",
00325 {method:'get',parameters:queryString});
00326
00327 }
00328
00329
00330
00331
00332 function anc_add_row(tableid)
00333 {
00334 style='class="input_text"';
00335 var mytable=g(tableid).tBodies[0];
00336 var nNumberRow=mytable.rows.length;
00337 var oRow=mytable.insertRow(nNumberRow);
00338 var rowToCopy=mytable.rows[1];
00339 var nNumberCell=rowToCopy.cells.length;
00340 var nb=g("nbrow");
00341 var oNewRow = mytable.insertRow(nNumberRow);
00342 for ( var e=0;e < nNumberCell;e++)
00343 {
00344 var newCell=oRow.insertCell(e);
00345 var tt=rowToCopy.cells[e].innerHTML;
00346 new_tt=tt.replace(/pop0/g,"pop"+nb.value);
00347 new_tt=new_tt.replace(/pamount0/g,"pamount"+nb.value);
00348 new_tt=new_tt.replace(/pdeb0/g,"pdeb"+nb.value);
00349 newCell.innerHTML=new_tt;
00350 new_tt.evalScripts();
00351 }
00352 $("pamount"+nb.value).value="0";
00353 nb.value++;
00354 }
00355
00356
00357
00358
00359
00360
00361
00362 function filter_anc(obj,queryString)
00363 {
00364 var pa_id=obj.plan_ctl;
00365 queryString=queryString+"&pa_id="+pa_id;
00366 return queryString;
00367 }