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 var ask_reload = 0;
00027 var tag_choose = '';
00028
00029
00030
00031
00032
00033 function infodiv(req, json)
00034 {
00035 try
00036 {
00037 remove_waiting_box();
00038 var answer = req.responseXML;
00039 var a = answer.getElementsByTagName('ctl');
00040 var html = answer.getElementsByTagName('code');
00041 if (a.length === 0)
00042 {
00043 var rec = req.responseText;
00044 alert('erreur :' + rec);
00045 }
00046 var name_ctl = a[0].firstChild.nodeValue;
00047 var code_html = getNodeText(html[0]);
00048
00049 code_html = unescape_xml(code_html);
00050 g(name_ctl + "info").innerHTML = code_html;
00051 }
00052 catch (e)
00053 {
00054 alert("success_box" + e.message);
00055 }
00056 try
00057 {
00058 code_html.evalScripts();
00059 }
00060 catch (e)
00061 {
00062 alert("answer_box Impossible executer script de la reponse\n" + e.message);
00063 }
00064
00065 }
00066
00067
00068
00069
00070 function deleteRow(tb, obj)
00071 {
00072 if (confirm('Confirmez effacement'))
00073 {
00074 var td = obj.parentNode;
00075 var tr = td.parentNode;
00076 var lidx = tr.rowIndex;
00077 g(tb).deleteRow(lidx);
00078 }
00079 }
00080 function deleteRowRec(tb, obj)
00081 {
00082 var td = obj.parentNode;
00083 var tr = td.parentNode;
00084 var lidx = tr.rowIndex;
00085 g(tb).deleteRow(lidx);
00086 }
00087
00088
00089
00090
00091 function trim(s)
00092 {
00093 return s.replace(/^\s+/, '').replace(/\s+$/, '');
00094 }
00095
00096
00097
00098
00099
00100
00101 function g(ID)
00102 {
00103 if (document.getElementById)
00104 {
00105 return this.document.getElementById(ID);
00106 }
00107 else if (document.all)
00108 {
00109 return document.all[ID];
00110 }
00111 else
00112 {
00113 return undefined;
00114 }
00115 }
00116
00117
00118
00119 function enable_type_periode()
00120 {
00121 if ($("type_periode").options[$("type_periode").selectedIndex].value == 0)
00122 {
00123 $('from_periode').enable();
00124 $('to_periode').enable ();
00125 $('from_date').disable();
00126 $('to_date').disable();
00127 $('p_step').enable();
00128 }
00129 else
00130 {
00131 $('from_periode').disable();
00132 $('to_periode').disable ();
00133 $('from_date').enable();
00134 $('to_date').enable();
00135 $('p_step').disable();
00136 }
00137 }
00138
00139
00140
00141
00142
00143 function refresh_window()
00144 {
00145 window.location.reload();
00146 }
00147
00148
00149
00150
00151
00152
00153 function encodeJSON(obj)
00154 {
00155 if (typeof obj != 'object')
00156 {
00157 alert('encodeParameter obj n\'est pas un objet');
00158 }
00159 try
00160 {
00161 var str = '';
00162 var e = 0;
00163 for (i in obj)
00164 {
00165 if (e !== 0)
00166 {
00167 str += '&';
00168 }
00169 else
00170 {
00171 e = 1;
00172 }
00173 str += i;
00174 str += '=' + encodeURI(obj[i]);
00175 }
00176 return str;
00177 }
00178 catch (e)
00179 {
00180 alert('encodeParameter ' + e.message);
00181 return "";
00182 }
00183 }
00184 function hide(p_param)
00185 {
00186 g(p_param).style.display = 'none';
00187 }
00188 function show(p_param)
00189 {
00190 g(p_param).style.display = 'block';
00191 }
00192
00193
00194
00195
00196
00197
00198 function SetFocus(Field, SelectIt)
00199 {
00200 var elem = g(Field);
00201 if (elem)
00202 {
00203 elem.focus();
00204 }
00205 return true;
00206 }
00207
00208
00209
00210
00211
00212
00213 function set_inparent(p_ctl, p_value, p_add)
00214 {
00215 self.opener.set_value(p_ctl, p_value, p_add);
00216 }
00217
00218
00219
00220
00221
00222
00223
00224
00225 function set_value(p_ctl, p_value, p_add)
00226 {
00227 if (g(p_ctl))
00228 {
00229 var g_ctrl = g(p_ctl);
00230 if (p_add != undefined && p_add === 1)
00231 {
00232 if (g_ctrl.value)
00233 {
00234 p_value = g_ctrl.value + ',' + p_value;
00235 }
00236 }
00237 if (g_ctrl.tagName === 'INPUT')
00238 {
00239 g(p_ctl).value = p_value;
00240 }
00241 if (g_ctrl.tagName === 'SPAN')
00242 {
00243 g(p_ctl).innerHTML = p_value;
00244 }
00245 if (g_ctrl.tagName === 'SELECT')
00246 {
00247 g(p_ctl).value = p_value;
00248 }
00249 }
00250 }
00251
00252
00253
00254
00255 function format_number(obj, p_prec)
00256 {
00257 var precision = 2;
00258 if (p_prec === undefined)
00259 {
00260 precision = 2;
00261 } else {
00262 precision = p_prec;
00263 }
00264 var value = obj.value;
00265 value = value.replace(/,/, '.');
00266 value = parseFloat(value);
00267 if (isNaN(value))
00268 {
00269 value = 0;
00270 }
00271 var arrondi = Math.pow(10, precision);
00272
00273 value = Math.round(value * arrondi) / arrondi;
00274
00275 $(obj).value = value;
00276 }
00277
00278
00279
00280
00281
00282 function toggleHideShow(p_obj, p_button)
00283 {
00284 var stat = g(p_obj).style.display;
00285 var str = g(p_button).value;
00286 if (stat === 'none')
00287 {
00288 show(p_obj);
00289 str = str.replace(/Afficher/, 'Cacher');
00290 g(p_button).value = str;
00291 }
00292 else
00293 {
00294 hide(p_obj);
00295 str = str.replace(/Cacher/, 'Afficher');
00296 g(p_button).value = str;
00297 }
00298 }
00299
00300
00301
00302
00303
00304 function popup_recherche(p_dossier)
00305 {
00306 var w = window.open("recherche.php?gDossier=" + p_dossier + "&ac=SEARCH", '', 'statusbar=no,scrollbars=yes,toolbar=no');
00307 w.focus();
00308 }
00309
00310
00311
00312
00313 function unescape_xml(code_html)
00314 {
00315 code_html = code_html.replace(/\</, '<');
00316 code_html = code_html.replace(/\>/, '>');
00317 code_html = code_html.replace(/\"/, '"');
00318 code_html = code_html.replace(/\'/, "'");
00319 code_html = code_html.replace(/\&/, '&');
00320 return code_html;
00321 }
00322
00323
00324
00325
00326
00327
00328 function getNodeText(xmlNode)
00329 {
00330 if (!xmlNode)
00331 return '';
00332 if (typeof (xmlNode.textContent) != "undefined")
00333 {
00334 return xmlNode.textContent;
00335 }
00336 if (xmlNode.firstChild && xmlNode.firstChild.nodeValue)
00337 return xmlNode.firstChild.nodeValue;
00338 return "";
00339 }
00340
00341
00342
00343
00344 function change_month(obj)
00345 {
00346 var queryString = "gDossier=" + obj.gDossier + "&op=cal" + "&per=" + obj.value+"&t="+obj.type_display;
00347 var action = new Ajax.Request(
00348 "ajax_misc.php", {method: 'get', parameters: queryString, onFailure: ajax_misc_failure, onSuccess: success_misc}
00349 );
00350
00351 }
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361 function success_misc(req)
00362 {
00363 try
00364 {
00365 var answer = req.responseXML;
00366 var html = answer.getElementsByTagName('code');
00367 if (html.length === 0)
00368 {
00369 var rec = req.responseText;
00370 alert('erreur :' + rec);
00371 }
00372 var nodeXml = html[0];
00373 var code_html = getNodeText(nodeXml);
00374 code_html = unescape_xml(code_html);
00375 $("user_cal").innerHTML = code_html;
00376 }
00377 catch (e)
00378 {
00379 alert(e.message);
00380 }
00381 try
00382 {
00383 code_html.evalScripts();
00384 }
00385 catch (e)
00386 {
00387 alert("Impossible executer script de la reponse\n" + e.message);
00388 }
00389
00390
00391 }
00392 function loading()
00393 {
00394 var str = '<h2> Un instant ...</h2>';
00395 str = str + '<image src="image/loading.gif" alt="chargement"></image>';
00396 return str;
00397 }
00398
00399 function ajax_misc_failure()
00400 {
00401 alert('Ajax Misc failed');
00402 }
00403
00404
00405
00406 function cat_doc_remove(p_dt_id, p_dossier)
00407 {
00408 var queryString = "gDossier=" + p_dossier + "&op=rem_cat_doc" + "&dt_id=" + p_dt_id;
00409 var action = new Ajax.Request(
00410 "ajax_misc.php", {method: 'get', parameters: queryString, onFailure: ajax_misc_failure, onSuccess: success_cat_doc_remove}
00411 );
00412 }
00413
00414
00415
00416 function cat_doc_change(p_dt_id, p_dossier)
00417 {
00418 var queryString = "gDossier=" + p_dossier + "&op=mod_cat_doc" + "&dt_id=" + p_dt_id;
00419 var nTop = calcy(posY);
00420 var nLeft = "200px";
00421 var str_style = "top:" + nTop + "px;left:" + nLeft + ";width:50em;height:auto";
00422
00423 removeDiv('change_doc_div');
00424 waiting_box();
00425 var action = new Ajax.Request(
00426 "ajax_misc.php",
00427 {
00428 method: 'get', parameters: queryString,
00429 onFailure: ajax_misc_failure,
00430 onSuccess: function(req) {
00431 remove_waiting_box();
00432 add_div({id: 'change_doc_div', style: str_style, cssclass: 'inner_box', drag: "1"});
00433 $('change_doc_div').innerHTML = req.responseText;
00434
00435 }
00436 }
00437 );
00438 }
00439
00440 function success_cat_doc_remove(req)
00441 {
00442 try
00443 {
00444 var answer = req.responseXML;
00445 var html = answer.getElementsByTagName('dtid');
00446 if (html.length === 0)
00447 {
00448 var rec = req.responseText;
00449 alert('erreur :' + rec);
00450 }
00451 nodeXML = html[0];
00452 row_id = getNodeText(nodeXML);
00453 if (row_id === 'nok')
00454 {
00455 alert('Error');
00456 return;
00457 }
00458 $('row' + row_id).style.textDecoration = "line-through";
00459 $('X' + row_id).style.display = 'none';
00460 }
00461 catch (e)
00462 {
00463 alert(e.message);
00464 }
00465 }
00466
00467
00468
00469
00470 function popup_select_tva(obj)
00471 {
00472 try
00473 {
00474 if ($('tva_select')) {
00475 removeDiv('tva_select');
00476 }
00477
00478
00479 var nTop = posY - 50;
00480 var nLeft = "35%";
00481 var str_style = "top:" + nTop + "px;left:" + nLeft + ";width:55em;height:auto";
00482
00483 var popup = {'id': 'tva_select', 'cssclass': 'inner_box', 'style': str_style, 'html': loading(), 'drag': true};
00484 add_div(popup);
00485 var queryString = "gDossier=" + obj.gDossier + "&op=dsp_tva" + "&ctl=" + obj.ctl + '&popup=' + 'tva_select';
00486 if (obj.jcode)
00487 queryString += '&code=' + obj.jcode;
00488 if (obj.compute)
00489 queryString += '&compute=' + obj.compute;
00490 var action = new Ajax.Request(
00491 "ajax_misc.php",
00492 {method: 'get',
00493 parameters: queryString,
00494 onFailure: ajax_misc_failure,
00495 onSuccess: success_popup_select_tva
00496 }
00497 );
00498 }
00499 catch (e)
00500 {
00501 alert("popup_select_tva " + e.message);
00502 }
00503 }
00504
00505
00506
00507 function success_popup_select_tva(req)
00508 {
00509 try
00510 {
00511 var answer = req.responseXML;
00512 var popup = answer.getElementsByTagName('popup');
00513 if (popup.length === 0)
00514 {
00515 var rec = req.responseText;
00516 alert('erreur :' + rec);
00517 }
00518 var html = answer.getElementsByTagName('code');
00519
00520 var name_ctl = popup[0].firstChild.nodeValue;
00521 var nodeXml = html[0];
00522 var code_html = getNodeText(nodeXml);
00523 code_html = unescape_xml(code_html);
00524 $(name_ctl).innerHTML = code_html;
00525 }
00526 catch (e)
00527 {
00528 alert("success_popup_select_tva " + e.message);
00529 }
00530
00531 }
00532
00533
00534
00535
00536
00537 function set_tva_label(obj)
00538 {
00539 try
00540 {
00541 var queryString = "gDossier=" + obj.gDossier + "&op=label_tva" + "&id=" + obj.value;
00542 if (obj.jcode)
00543 queryString += '&code=' + obj.jcode;
00544 var action = new Ajax.Request(
00545 "ajax_misc.php",
00546 {method: 'get',
00547 parameters: queryString,
00548 onFailure: ajax_misc_failure,
00549 onSuccess: success_set_tva_label
00550 }
00551 );
00552 }
00553 catch (e)
00554 {
00555 alert("set_tva_label " + e.message);
00556 }
00557 }
00558
00559
00560
00561 function success_set_tva_label(req)
00562 {
00563 try
00564 {
00565 var answer = req.responseXML;
00566 var code = answer.getElementsByTagName('code');
00567 var value = answer.getElementsByTagName('value');
00568
00569 if (code.length === 0)
00570 {
00571 var rec = req.responseText;
00572 alert('erreur :' + rec);
00573 }
00574
00575 var label_code = code[0].firstChild.nodeValue;
00576 var label_value = value[0].firstChild.nodeValue;
00577 set_value(label_code, label_value);
00578 }
00579 catch (e)
00580 {
00581 alert("success_set_tva_label " + e.message);
00582 }
00583
00584 }
00585
00586
00587
00588
00589
00590 function set_wait(name)
00591 {
00592 var content = name + "_content";
00593 $(content).innerHTML = 'Un instant...<image src="image/loading.gif" border="0" alt="Chargement...">';
00594 }
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605 function add_div(obj)
00606 {
00607 try
00608 {
00609 var top = document;
00610
00611 if (!$(obj.id)) {
00612 var elt = top.createElement('div');
00613 }
00614 else {
00615 var elt = $(obj.id);
00616 }
00617 if (obj.id)
00618 {
00619 elt.setAttribute('id', obj.id);
00620 }
00621 if (obj.style)
00622 {
00623 if (elt.style.setAttribute)
00624 {
00625 elt.style.setAttribute('cssText', obj.style);
00626 }
00627 else
00628 {
00629 elt.setAttribute('style', obj.style);
00630 }
00631 }
00632 if (obj.cssclass)
00633 {
00634 elt.setAttribute('class', obj.cssclass);
00635 elt.setAttribute('className', obj.cssclass);
00636 }
00637 if (obj.html)
00638 {
00639 elt.innerHTML = obj.html;
00640 }
00641
00642 var bottom_div = document.body;
00643 bottom_div.appendChild(elt);
00644 if (obj.drag)
00645 {
00646 new Draggable(obj.id, {starteffect: function()
00647 {
00648 new Effect.Highlight(obj.id, {scroll: window, queue: 'end'});
00649 }}
00650 );
00651 }
00652 }
00653 catch (e)
00654 {
00655 alert("add_div " + e.message);
00656 }
00657 }
00658
00659
00660
00661
00662 function removeDiv(elt)
00663 {
00664 if (g(elt))
00665 {
00666 document.body.removeChild(g(elt));
00667 }
00668
00669
00670 if (ask_reload === 1)
00671 {
00672
00673 window.location.reload();
00674 }
00675 }
00676
00677
00678
00679
00680
00681 function waiting_box()
00682 {
00683 obj = {
00684 id: 'wait_box', html: '<h2 class="title">Chargement</h2>'+loading()
00685 };
00686 var y = calcy(posY);
00687 obj.style = fixed_position(posX, y) + ";width:200px";
00688 if ($('wait_box')) {
00689 removeDiv('wait_box');
00690 }
00691 add_div(obj);
00692 $('info_div').innerHTML = 'Un instant';
00693 $('info_div').style.display = "block";
00694
00695 }
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708 function show_box(obj)
00709 {
00710 add_div(obj);
00711 if (!obj.fixed)
00712 {
00713 var sx = 0;
00714 if (window.scrollY)
00715 {
00716 sx = window.scrollY + 40;
00717 }
00718 else
00719 {
00720 sx = document.body.scrollTop + 40;
00721 }
00722 g(obj.id).style.top = sx+"px";
00723 show(obj.id);
00724 }
00725 else
00726 {
00727 show(obj.id);
00728 }
00729
00730 var action = new Ajax.Request(
00731 obj.callback,
00732 {
00733 method: 'GET',
00734 parameters: obj.qs,
00735 onFailure: eval(obj.js_error),
00736 onSuccess: eval(obj.js_success)
00737 });
00738 }
00739
00740
00741
00742
00743
00744
00745 function success_box(req, json)
00746 {
00747 try
00748 {
00749 var answer = req.responseXML;
00750 var a = answer.getElementsByTagName('ctl');
00751 var html = answer.getElementsByTagName('code');
00752 if (a.length === 0)
00753 {
00754 var rec = req.responseText;
00755 alert('erreur :' + rec);
00756 }
00757 var name_ctl = a[0].firstChild.nodeValue;
00758 var code_html = getNodeText(html[0]);
00759
00760 code_html = unescape_xml(code_html);
00761 g(name_ctl).innerHTML = code_html;
00762 g(name_ctl).style.height = 'auto';
00763
00764 if (name_ctl != 'popup')
00765 g(name_ctl).style.width = '60%';
00766 else
00767 g(name_ctl).style.width = 'auto';
00768 }
00769 catch (e)
00770 {
00771 alert("success_box" + e.message);
00772 }
00773 try
00774 {
00775 code_html.evalScripts();
00776 }
00777 catch (e)
00778 {
00779 alert("answer_box Impossible executer script de la reponse\n" + e.message);
00780 }
00781 }
00782
00783 function error_box()
00784 {
00785 alert('IBOX : error_box ajax not implemented');
00786 }
00787
00788
00789
00790 function show_ledger_choice(json_obj)
00791 {
00792 try
00793 {
00794 waiting_box();
00795 var i = 0;
00796 var query = "gDossier=" + json_obj.dossier + '&type=' + json_obj.type + '&div=' + json_obj.div + '&op=ledger_show';
00797 query = query + '&nbjrn=' + $( json_obj.div+'nb_jrn').value;
00798 query = query + '&all_type=' + json_obj.all_type;
00799 for (i = 0; i < $( json_obj.div+'nb_jrn').value; i++) {
00800 query = query + "&r_jrn[]=" + $( json_obj.div+'r_jrn[' + i + ']').value;
00801 }
00802 var action = new Ajax.Request(
00803 "ajax_misc.php",
00804 {method: 'get',
00805 parameters: query,
00806 onFailure: ajax_misc_failure,
00807 onSuccess: function(req, json) {
00808 try {
00809 var obj = {
00810 id: json_obj.div + 'jrn_search',
00811 cssclass: 'inner_box',
00812 style: ';position:absolute;width:60%;z-index:20;margin-left:20%',
00813 drag: 1
00814 };
00815
00816 var y=posY;
00817 if (json_obj.div != '')obj.cssclass="";
00818 obj.style="top:"+y+'px;'+obj.style;
00819
00820
00821
00822
00823 add_div(obj);
00824
00825
00826 var answer = req.responseXML;
00827 var a = answer.getElementsByTagName('ctl');
00828 var html = answer.getElementsByTagName('code');
00829 if (a.length === 0) {
00830 var rec = req.responseText;
00831 alert('erreur :' + rec);
00832 }
00833 var name_ctl = a[0].firstChild.nodeValue;
00834 var code_html = getNodeText(html[0]);
00835
00836 code_html = unescape_xml(code_html);
00837 remove_waiting_box();
00838 g(obj.id).innerHTML = code_html;
00839
00840 }
00841 catch (e) {
00842 alert("show_ledger_callback" + e.message);
00843 }
00844 try {
00845 code_html.evalScripts();
00846 }
00847 catch (e) {
00848 alert("answer_box Impossible executer script de la reponse\n" + e.message);
00849 }
00850
00851 }
00852
00853 }
00854 );
00855 } catch (e) {
00856 alert('show_ledger_choice'+e.message);
00857 }
00858 }
00859
00860
00861
00862 function hide_ledger_choice(p_frm_search)
00863 {
00864 try
00865 {
00866 var nb = $(p_frm_search).nb_jrn.value;
00867 var div = $(p_frm_search).div.value;
00868 var i = 0;
00869 var str = "";
00870 var name = "";
00871 var n_name = "";
00872 var sel=0;
00873 for (i = 0; i < nb; i++) {
00874 n_name = div + "r_jrn[" + sel+"]";
00875 name = div + "r_jrn" + i;
00876 if ($(name).checked) {
00877 str += '<input type="hidden" id="' + n_name + '" name="' + n_name + '" value="' + $(name).value + '">';
00878 sel++;
00879 }
00880 }
00881 str += '<input type="hidden" name="'+div+'nb_jrn" id="'+div+'nb_jrn" value="' + sel + '">';
00882 $('ledger_id'+div).innerHTML = str;
00883 removeDiv(div+'jrn_search');
00884 return false;
00885 } catch (e) {
00886 alert('hide_ledger_choice'+e.message);
00887 return false;
00888 }
00889
00890 }
00891
00892
00893
00894 function show_cat_choice()
00895 {
00896 g('div_cat').style.visibility = 'visible';
00897 }
00898
00899
00900
00901 function hide_cat_choice()
00902 {
00903 g('div_cat').style.visibility = 'hidden';
00904 }
00905
00906
00907
00908 function for_add_row(tableid)
00909 {
00910 style = 'class="input_text"';
00911 var mytable = g(tableid).tBodies[0];
00912 var nNumberRow = mytable.rows.length;
00913 var oRow = mytable.insertRow(nNumberRow);
00914 var rowToCopy = mytable.rows[1];
00915 var nNumberCell = rowToCopy.cells.length;
00916 var nb = g("nbrow");
00917 var oNewRow = mytable.insertRow(nNumberRow);
00918 for (var e = 0; e < nNumberCell; e++)
00919 {
00920 var newCell = oRow.insertCell(e);
00921 var tt = rowToCopy.cells[e].innerHTML;
00922 new_tt = tt.replace(/an_cat0/g, "an_cat" + nb.value);
00923 new_tt = new_tt.replace(/an_cat_acc0/g, "an_cat_acc" + nb.value);
00924 new_tt = new_tt.replace(/an_qc0/g, "an_qc" + nb.value);
00925 new_tt = new_tt.replace(/an_label0/g, "an_label" + nb.value);
00926 new_tt = new_tt.replace(/month0/g, "month" + nb.value);
00927 new_tt = new_tt.replace(/an_cat_amount0/g, "an_cat_amount" + nb.value);
00928 new_tt = new_tt.replace(/an_deb0/g, "an_deb" + nb.value);
00929 newCell.innerHTML = new_tt;
00930 new_tt.evalScripts();
00931 }
00932 $("an_cat_acc" + nb.value).value = "";
00933 $("an_qc" + nb.value).value = "";
00934 $("an_label" + nb.value).value = "";
00935 $("an_cat_amount" + nb.value).value = "0";
00936 nb.value++;
00937 }
00938
00939
00940
00941
00942 function toggle_checkbox(form_id)
00943 {
00944 var form = g(form_id);
00945 for (var i = 0; i < form.length; i++)
00946 {
00947 var e = form.elements[i];
00948 if (e.type === 'checkbox')
00949 {
00950 if (e.checked === true)
00951 {
00952 e.checked = false;
00953 }
00954 else
00955 {
00956 e.checked = true;
00957 }
00958 }
00959 }
00960 }
00961
00962
00963
00964
00965 function select_checkbox(form_id)
00966 {
00967 var form = $(form_id);
00968 for (var i = 0; i < form.length; i++)
00969 {
00970 var e = form.elements[i];
00971 if (e.type === 'checkbox')
00972 {
00973 e.checked = true;
00974 }
00975 }
00976 }
00977
00978
00979
00980
00981 function unselect_checkbox(form_id)
00982 {
00983 var form = $(form_id);
00984 for (var i = 0; i < form.length; i++)
00985 {
00986 var e = form.elements[i];
00987 if (e.type === 'checkbox')
00988 {
00989 e.checked = false;
00990 }
00991 }
00992 }
00993
00994
00995
00996 function show_calc()
00997 {
00998 if (g('calc1'))
00999 {
01000 this.document.getElementById('inp').value = "";
01001 this.document.getElementById('inp').focus();
01002 return;
01003 }
01004 var sid = 'calc1';
01005 var shtml = '';
01006 shtml += '<div style="float:right;height:10px;display:block;margin-top:2px;margin-right:2px"> <a onclick="removeDiv(\'calc1\');" href="javascript:void(0)" id="close_div">Fermer</a></div>';
01007 shtml += '<div> <h2 class="info">Calculatrice</h2></div>';
01008 shtml += '<form name="calc_line" method="GET" onSubmit="cal();return false;" >Calculatrice simplifiée: écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) <input class="input_text" type="text" size="30" id="inp" name="calculator"> <input type="button" value="Efface tout" class="button" onClick="Clean();return false;" > <input type="button" class="button" value="Fermer" onClick="removeDiv(\'calc1\')" >';
01009 shtml += '</form><span id="result"> </span><br><span id="sub_total"> Taper une formule (ex 20*5.1) puis enter </span><br><span id="listing"> </span>';
01010
01011 var obj = {id: sid, html: shtml,
01012 drag: true, style: ''
01013 };
01014 add_div(obj);
01015 this.document.getElementById('inp').focus();
01016 }
01017 function display_periode(p_dossier, p_id)
01018 {
01019
01020 try
01021 {
01022 var queryString = "gDossier=" + p_dossier + "&op=input_per" + "&p_id=" + p_id;
01023 var popup = {'id': 'mod_periode', 'cssclass': 'inner_box', 'html': loading(), 'style': 'width:30em', 'drag': true};
01024 if (!$('mod_periode')) {
01025 add_div(popup);
01026 }
01027 var action = new Ajax.Request(
01028 "ajax_misc.php",
01029 {method: 'get',
01030 parameters: queryString,
01031 onFailure: ajax_misc_failure,
01032 onSuccess: success_display_periode
01033 }
01034 );
01035 $('mod_periode').style.top = (posY - 70)+"px";
01036 $('mod_periode').style.left = (posX - 70)+"px";
01037 }
01038 catch (e)
01039 {
01040 alert("display_periode " + e.message);
01041 }
01042
01043 }
01044 function success_display_periode(req)
01045 {
01046 try
01047 {
01048
01049 var answer = req.responseXML;
01050 var html = answer.getElementsByTagName('data');
01051
01052 if (html.length === 0)
01053 {
01054 var rec = req.responseText;
01055 alert('erreur :' + rec);
01056 }
01057
01058 var code_html = getNodeText(html[0]);
01059 code_html = unescape_xml(code_html);
01060
01061 $('mod_periode').innerHTML = code_html;
01062 }
01063 catch (e)
01064 {
01065 alert("success_display_periode".e.message);
01066 }
01067 try
01068 {
01069 code_html.evalScripts();
01070 }
01071 catch (e)
01072 {
01073 alert("success_display_periode Impossible executer script de la reponse\n" + e.message);
01074 }
01075
01076 }
01077 function save_periode(obj)
01078 {
01079 try
01080 {
01081 var queryString = $(obj).serialize() + "&op=save_per";
01082
01083 var action = new Ajax.Request(
01084 "ajax_misc.php",
01085 {method: 'post',
01086 parameters: queryString,
01087 onFailure: ajax_misc_failure,
01088 onSuccess: success_display_periode
01089 }
01090 );
01091
01092 }
01093 catch (e)
01094 {
01095 alert("display_periode " + e.message);
01096 }
01097
01098 return false;
01099 }
01100
01101
01102
01103
01104
01105
01106
01107
01108 function fill_box(req)
01109 {
01110 try {
01111
01112 remove_waiting_box();
01113
01114 var answer = req.responseXML;
01115 var a = answer.getElementsByTagName('ctl');
01116 var html = answer.getElementsByTagName('code');
01117 if (a.length === 0) {
01118 var rec = req.responseText;
01119 alert('erreur :' + rec);
01120 }
01121 var name_ctl = a[0].firstChild.nodeValue;
01122 var code_html = getNodeText(html[0]);
01123 code_html = unescape_xml(code_html);
01124 $(name_ctl).innerHTML = code_html;
01125 }
01126 catch (e) {
01127 alert(e.message);
01128 }
01129 try {
01130 code_html.evalScripts();
01131 }
01132 catch (e) {
01133 alert("Impossible executer script de la reponse\n" + e.message);
01134 }
01135
01136
01137 }
01138
01139
01140
01141
01142
01143 function mod_predf_op(dossier_id, od_id)
01144 {
01145 var target = "mod_predf_op";
01146 removeDiv(target);
01147 var sx = '20%';
01148 var sy = '10%';
01149 var str_style = "top:" + sx + ";left:" + sy+";";
01150
01151 var div = {id: target, cssclass: 'inner_box', style: str_style, html: loading(), drag: 1};
01152
01153 add_div(div);
01154
01155 var qs = "gDossier=" + dossier_id + '&op=mod_predf&id=' + od_id;
01156
01157 var action = new Ajax.Request('ajax_misc.php',
01158 {
01159 method: 'get',
01160 parameters: qs,
01161 onFailure: null,
01162 onSuccess: fill_box
01163 }
01164 );
01165
01166 }
01167
01168 function save_predf_op(obj)
01169 {
01170 waiting_box();
01171 var querystring = $(obj).serialize() + '&op=save_predf';
01172
01173 var action = new Ajax.Request('ajax_misc.php',
01174 {
01175 method: 'post',
01176 parameters: querystring,
01177 onFailure: null,
01178 onSuccess: refresh_window
01179 }
01180 );
01181
01182 return false;
01183 }
01184
01185
01186
01187
01188 function search_reconcile(dossier, ctl_concern, amount_id, ledger)
01189 {
01190 var dossier = g('gDossier').value;
01191 if (amount_id === undefined)
01192 {
01193 amount_id = 0;
01194 }
01195 else if ($(amount_id))
01196 {
01197 if ($(amount_id).value)
01198 {
01199 amount_id = $(amount_id).value;
01200 }
01201 else if
01202 ($(amount_id).innerHTML) {
01203 amount_id = $(amount_id).innerHTML;
01204 }
01205 }
01206
01207 var target = "search_op";
01208 removeDiv(target);
01209 var str_style = fixed_position(77, 99);
01210 str_style += ";width:92%;overflow:auto;";
01211
01212 var div = {id: target, cssclass: 'inner_box', style: str_style, html: loading(), drag: 1};
01213
01214 add_div(div);
01215 var target = {gDossier: dossier,
01216 ctlc: ctl_concern,
01217 op: 'search_op',
01218 ctl: target,
01219 ac: 'JSSEARCH',
01220 amount_id: amount_id,
01221 ledger: ledger};
01222
01223 var qs = encodeJSON(target);
01224
01225 var action = new Ajax.Request('ajax_misc.php',
01226 {
01227 method: 'get',
01228 parameters: qs,
01229 onFailure: null,
01230 onSuccess: function(req) {
01231 remove_waiting_box();
01232 $('search_op').innerHTML = req.responseText;
01233 req.responseText.evalScripts();
01234 }
01235 }
01236 );
01237 }
01238
01239
01240
01241 function search_operation(obj)
01242 {
01243 try {
01244 var dossier = g('gDossier').value;
01245 waiting_box();
01246 var target = "search_op";
01247 var qs = Form.serialize('search_form_ajx') + "&op=search_op&ctl=search_op";
01248 var action = new Ajax.Request('ajax_misc.php',
01249 {
01250 method: 'get',
01251 parameters: qs,
01252 onFailure: null,
01253 onSuccess: function(req) {
01254 remove_waiting_box();
01255 $('search_op').innerHTML = req.responseText;
01256 req.responseText.evalScripts();
01257 }
01258 }
01259 );
01260 } catch (e)
01261 {
01262 remove_waiting_box();
01263 alert(e.message);
01264 }
01265 }
01266
01267 function set_reconcile(obj)
01268 {
01269
01270 try
01271 {
01272 var ctlc = obj.elements['ctlc'];
01273
01274 for (var e = 0; e < obj.elements.length; e++)
01275 {
01276
01277 var elmt = obj.elements[e];
01278 if (elmt.type === "checkbox")
01279 {
01280 if (elmt.checked === true)
01281 {
01282 var str_name = elmt.name;
01283 var nValue = str_name.replace("jr_concerned", "");
01284 if ($(ctlc.value).value != '') {
01285 $(ctlc.value).value += ',';
01286 }
01287 $(ctlc.value).value += nValue;
01288 }
01289 }
01290 }
01291 removeDiv('search_op');
01292 }
01293 catch (e)
01294 {
01295 alert(e.message)
01296 }
01297 }
01298 function remove_waiting_box()
01299 {
01300 removeDiv('wait_box');
01301 $('info_div').innerHTML = "";
01302 $('info_div').style.display = "none";
01303 }
01304 function get_profile_detail(gDossier, profile_id)
01305 {
01306 waiting_box();
01307 var qs = "op=display_profile&gDossier=" + gDossier + "&p_id=" + profile_id + "&ctl=detail_profile";
01308 var action = new Ajax.Request('ajax_misc.php',
01309 {
01310 method: 'get',
01311 parameters: qs,
01312 onFailure: null,
01313 onSuccess: function(req) {
01314 remove_waiting_box();
01315 $('detail_profile').innerHTML = req.responseText;
01316 req.responseText.evalScripts();
01317 $('detail_profile').show();
01318 if (profile_id != "-1")
01319 profile_show('profile_gen_div');
01320 }
01321 }
01322 );
01323 }
01324 function get_profile_detail_success(xml)
01325 {
01326 remove_waiting_box();
01327
01328 }
01329
01330
01331
01332
01333 function fixed_position(p_sx, p_sy)
01334 {
01335 var sx = p_sx;
01336 var sy = calcy(p_sy);
01337
01338 var str_style = "top:" + sy + "px;left:" + sx + "px;position:absolute";
01339 return str_style;
01340
01341 }
01342
01343
01344
01345
01346 function calcy(p_sy)
01347 {
01348 var sy = p_sy;
01349 if (window.scrollY)
01350 {
01351 sy = window.scrollY + p_sy;
01352 }
01353 else
01354 {
01355 sy = document.body.scrollTop + p_sy;
01356 }
01357 return sy;
01358
01359 }
01360 function mod_menu(gdossier, pm_id)
01361 {
01362 waiting_box();
01363 removeDiv('divdm' + pm_id);
01364 var qs = "op=det_menu&gDossier=" + gdossier + "&pm_id=" + pm_id + "&ctl=divdm" + pm_id;
01365 var pos = fixed_position(250, 150);
01366 var action = new Ajax.Request('ajax_misc.php',
01367 {
01368 method: 'get',
01369 parameters: qs,
01370 onFailure: null,
01371 onSuccess: function(req) {
01372 try {
01373 remove_waiting_box();
01374 add_div({id: "divdm" + pm_id, drag: 1, cssclass: "inner_box", style: pos});
01375 $('divdm' + pm_id).innerHTML = req.responseText;
01376 } catch (e) {
01377 alert(e.message);
01378 }
01379 }
01380 }
01381 );
01382 }
01383 function add_menu(obj)
01384 {
01385 var pdossier = obj.dossier;
01386 var p_id = obj.p_id;
01387 var p_type = obj.type;
01388 waiting_box();
01389 removeDiv('divdm' + p_id);
01390 var qs = "op=add_menu&gDossier=" + pdossier + "&p_id=" + p_id + "&ctl=divdm" + p_id + "&type=" + p_type;
01391 var pos = fixed_position(250, 150);
01392 var action = new Ajax.Request('ajax_misc.php',
01393 {
01394 method: 'get',
01395 parameters: qs,
01396 onFailure: null,
01397 onSuccess: function(req) {
01398 try {
01399 remove_waiting_box();
01400 add_div({id: "divdm" + p_id, drag: 1, cssclass: "inner_box", style: pos});
01401 $('divdm' + p_id).innerHTML = req.responseText;
01402 } catch (e) {
01403 alert(e.message);
01404 }
01405 }
01406 }
01407 );
01408 }
01409 function add_plugin(p_dossier)
01410 {
01411 waiting_box();
01412 removeDiv('divplugin');
01413 var qs = "op=add_plugin&gDossier=" + p_dossier + "&ctl=divplugin";
01414
01415 var action = new Ajax.Request('ajax_misc.php',
01416 {
01417 method: 'get',
01418 parameters: qs,
01419 onFailure: null,
01420 onSuccess: function(req) {
01421 try {
01422 remove_waiting_box();
01423 var pos = fixed_position(250, 150) + ";width:30%";
01424 add_div({id: "divplugin", drag: 1, cssclass: "inner_box", style: pos});
01425 $('divplugin').innerHTML = req.responseText;
01426 } catch (e) {
01427 alert(e.message);
01428 }
01429 }
01430 }
01431 );
01432 }
01433 function mod_plugin(p_dossier, me_code)
01434 {
01435 waiting_box();
01436 removeDiv('divplugin');
01437 var qs = "op=mod_plugin&gDossier=" + p_dossier + "&ctl=divplugin&me_code=" + me_code;
01438
01439 var action = new Ajax.Request('ajax_misc.php',
01440 {
01441 method: 'get',
01442 parameters: qs,
01443 onFailure: null,
01444 onSuccess: function(req) {
01445 try {
01446 remove_waiting_box();
01447 var pos = fixed_position(250, 150) + ";width:30%";
01448 add_div({id: "divplugin", drag: 1, cssclass: "inner_box", style: pos});
01449 $('divplugin').innerHTML = req.responseText;
01450
01451 } catch (e) {
01452 alert(e.message);
01453 }
01454 }
01455 }
01456 );
01457 }
01458 function create_menu(p_dossier)
01459 {
01460 waiting_box();
01461 removeDiv('divmenu');
01462 var qs = "op=create_menu&gDossier=" + p_dossier + "&ctl=divmenu";
01463
01464 var action = new Ajax.Request('ajax_misc.php',
01465 {
01466 method: 'get',
01467 parameters: qs,
01468 onFailure: null,
01469 onSuccess: function(req) {
01470 try {
01471 remove_waiting_box();
01472 var pos = fixed_position(250, 150) + ";width:30%";
01473 add_div({
01474 id: "divmenu",
01475 drag: 1,
01476 cssclass: "inner_box",
01477 style: pos
01478 });
01479 $('divmenu').innerHTML = req.responseText;
01480 } catch (e) {
01481 alert(e.message);
01482 }
01483 }
01484 }
01485 );
01486 }
01487 function modify_menu(p_dossier, me_code)
01488 {
01489 waiting_box();
01490 removeDiv('divmenu');
01491 var qs = "op=modify_menu&gDossier=" + p_dossier + "&ctl=divmenu&me_code=" + me_code;
01492
01493 var action = new Ajax.Request('ajax_misc.php',
01494 {
01495 method: 'get',
01496 parameters: qs,
01497 onFailure: null,
01498 onSuccess: function(req) {
01499 try {
01500 remove_waiting_box();
01501 var pos = fixed_position(250, 150) + ";width:30%";
01502 add_div({
01503 id: "divmenu",
01504 drag: 1,
01505 cssclass: "inner_box",
01506 style: pos
01507 });
01508 $('divmenu').innerHTML = req.responseText;
01509
01510 } catch (e) {
01511 alert(e.message);
01512 }
01513 }
01514 }
01515 );
01516 }
01517 function get_properties(obj)
01518 {
01519 var a_array = [];
01520 var s_type = "[" + typeof obj + "]";
01521 for (var m in obj)
01522 {
01523 a_array.push(m);
01524 }
01525 alert(s_type + a_array.join(","));
01526 }
01527
01528
01529
01530
01531 function rapport_add_row(p_dossier)
01532 {
01533 style = 'style="border: 1px solid blue;"';
01534 var table = $("rap1");
01535 var line = table.rows.length;
01536
01537 var row = table.insertRow(line);
01538
01539 var cellPos = row.insertCell(0);
01540 cellPos.innerHTML = '<input type="text" ' + style + ' size="3" id="pos' + line + '" name="pos' + line + '" value="' + line + '">';
01541
01542
01543 var cellName = row.insertCell(1);
01544 cellName.innerHTML = '<input type="text" ' + style + ' size="40" id="text' + line + '" name="text' + line + '">';
01545
01546
01547 var cellbutton = row.insertCell(2);
01548 var but_html = table.rows[1].cells[2].innerHTML;
01549 but_html = but_html.replace(/form0/g, "form" + line);
01550 cellbutton.innerHTML = but_html;
01551 but_html.evalScripts();
01552
01553 g('form' + line).value = '';
01554 }
01555
01556
01557
01558 function search_action(dossier, ctl_concern)
01559 {
01560 try
01561 {
01562 var dossier = g('gDossier').value;
01563
01564 var target = "search_action_div";
01565 removeDiv(target);
01566 var str_style = fixed_position(77, 99);
01567 str_style += ";width:80%";
01568
01569 var div = {id: target, cssclass: 'inner_box', style: str_style, html: loading(), drag: 1};
01570
01571 add_div(div);
01572 var target = {gDossier: dossier,
01573 ctlc: ctl_concern,
01574 op: 'search_action',
01575 ctl: target
01576 };
01577
01578 var qs = encodeJSON(target);
01579
01580 var action = new Ajax.Request('ajax_misc.php',
01581 {
01582 method: 'get',
01583 parameters: qs,
01584 onFailure: null,
01585 onSuccess: function(req) {
01586 try {
01587 remove_waiting_box();
01588 $('search_action_div').innerHTML = req.responseText;
01589 req.responseText.evalScripts();
01590 } catch (e) {
01591 alert(e.message);
01592 }
01593 }
01594 }
01595 );
01596 } catch (e) {
01597 alert(e.message);
01598 }
01599 }
01600
01601 function result_search_action(obj)
01602 {
01603 try
01604 {
01605 var queryString = $(obj).serialize() + "&op=search_action";
01606 var action = new Ajax.Request(
01607 "ajax_misc.php",
01608 {method: 'get',
01609 parameters: queryString,
01610 onFailure: ajax_misc_failure,
01611 onSuccess: function(req) {
01612 try {
01613 remove_waiting_box();
01614 $('search_action_div').innerHTML = req.responseText;
01615 req.responseText.evalScripts();
01616 } catch (e) {
01617 alert(e.message);
01618 }
01619 }
01620 }
01621 )
01622
01623 }
01624 catch (e)
01625 {
01626 alert("display_periode " + e.message);
01627 }
01628
01629 return false;
01630 }
01631
01632 function set_action_related(p_obj)
01633 {
01634
01635 try
01636 {
01637 var obj = $(p_obj);
01638 var ctlc = obj.elements['ctlc'];
01639
01640 for (var e = 0; e < obj.elements.length; e++)
01641 {
01642
01643 var elmt = obj.elements[e];
01644 if (elmt.type === "checkbox")
01645 {
01646 if (elmt.checked === true)
01647 {
01648 var str_name = elmt.name;
01649 var nValue = elmt.value;
01650 if ($(ctlc.value).value != '') {
01651 $(ctlc.value).value += ',';
01652 }
01653 $(ctlc.value).value += nValue;
01654 }
01655 }
01656 }
01657 removeDiv('search_action_div');
01658 return false;
01659 }
01660 catch (e)
01661 {
01662 alert(e.message);
01663 return false;
01664 }
01665 }
01666
01667
01668
01669 function stock_repo_change(p_dossier, r_id)
01670 {
01671 var queryString = "gDossier=" + p_dossier + "&op=mod_stock_repo" + "&r_id=" + r_id;
01672 var nTop = calcy(posY);
01673 var nLeft = "200px";
01674 var str_style = "top:" + nTop + "px;left:" + nLeft + ";width:50em;height:auto";
01675
01676 removeDiv('change_stock_repo_div');
01677 waiting_box();
01678 var action = new Ajax.Request(
01679 "ajax_misc.php",
01680 {
01681 method: 'get', parameters: queryString,
01682 onFailure: ajax_misc_failure,
01683 onSuccess: function(req) {
01684 remove_waiting_box();
01685 add_div({id: 'change_stock_repo_div', style: str_style, cssclass: 'inner_box', drag: "1"});
01686 $('change_stock_repo_div').innerHTML = req.responseText;
01687
01688 }
01689 }
01690 );
01691 }
01692 function stock_inv_detail(p_dossier, p_id)
01693 {
01694 var queryString = "gDossier=" + p_dossier + "&op=view_mod_stock" + "&c_id=" + p_id + "&ctl=view_mod_stock_div";
01695 var nTop = calcy(posY);
01696 var nLeft = "200px";
01697 var str_style = "top:" + nTop + "px;left:" + nLeft + ";width:75%;";
01698
01699 removeDiv('view_mod_stock_div');
01700 waiting_box();
01701 var action = new Ajax.Request(
01702 "ajax_misc.php",
01703 {
01704 method: 'get', parameters: queryString,
01705 onFailure: ajax_misc_failure,
01706 onSuccess: function(req) {
01707 remove_waiting_box();
01708 add_div({id: 'view_mod_stock_div', style: str_style, cssclass: 'inner_box', drag: "1"});
01709 $('view_mod_stock_div').innerHTML = req.responseText;
01710 req.responseText.evalScripts();
01711 }
01712 }
01713 );
01714 }
01715 function show_fin_chdate(obj_id)
01716 {
01717 try
01718 {
01719 var ch = $(obj_id).options[$(obj_id).selectedIndex].value;
01720 if (ch === 2) {
01721 $('chdate_ext').hide();
01722 $('thdate').show();
01723 }
01724 if (ch === 1) {
01725 $('chdate_ext').show();
01726 $('thdate').hide();
01727 }
01728 var nb = $('nb_item').value;
01729 for (i = 0; i < nb; i++) {
01730 if ($('tdchdate' + i)) {
01731 if (ch === 2) {
01732 $('tdchdate' + i).show();
01733 }
01734 if (ch === 1) {
01735 $('tdchdate' + i).hide();
01736
01737 }
01738 }
01739 }
01740 } catch (e) {
01741 alert(e.message);
01742 }
01743 }
01744
01745
01746
01747 function profile_show(p_div)
01748 {
01749 try {
01750 var div = ['profile_gen_div', 'profile_menu_div', 'profile_print_div', 'profile_gestion_div', 'profile_repo_div'];
01751 for (var r = 0; r < div.length; r++) {
01752 $(div[r]).hide();
01753 }
01754 $(p_div).show();
01755 } catch (e)
01756 {
01757 alert(e.message)
01758 }
01759 }
01760 function detail_category_show(p_div, p_dossier, p_id)
01761 {
01762 $(p_div).show();
01763 waiting_box();
01764 $('detail_category_div').innerHTML = "";
01765 var queryString = "gDossier=" + p_dossier + "&id=" + p_id + "&op=fddetail";
01766 var action = new Ajax.Request(
01767 "ajax_misc.php",
01768 {
01769 method: 'get', parameters: queryString,
01770 onFailure: ajax_misc_failure,
01771 onSuccess: function(req) {
01772 remove_waiting_box();
01773 $('list_cat_div').hide();
01774 $('detail_category_div').innerHTML = req.responseText;
01775 $('detail_category_div').show();
01776 req.responseText.evalScripts();
01777 }
01778 }
01779 );
01780 }
01781
01782
01783
01784
01785
01786 function check_date(p_str_date)
01787 {
01788 var format = /^\d{2}\.\d{2}\.\d{4}$/;
01789 if (!format.test(p_str_date)) {
01790 return false;
01791 }
01792 else {
01793 var date_temp = p_str_date.split('.');
01794 var nMonth = parseFloat(date_temp[1]) - 1;
01795 var ma_date = new Date(date_temp[2], nMonth, date_temp[0]);
01796 if (ma_date.getFullYear() == date_temp[2] && ma_date.getMonth() == nMonth && ma_date.getDate() == date_temp[0]) {
01797 return true;
01798 }
01799 else {
01800 return false;
01801 }
01802 }
01803
01804 }
01805
01806
01807
01808
01809
01810
01811 function check_date_id(p_id_date)
01812 {
01813 var str_date = $(p_id_date).value;
01814 return check_date(str_date);
01815 }
01816
01817
01818
01819
01820
01821
01822 function view_action(ag_id, dossier, modify)
01823 {
01824 waiting_box();
01825 layer++;
01826 id = 'action' + layer;
01827
01828 querystring = 'gDossier=' + dossier + '&op=vw_action&ag_id=' + ag_id + '&div=' + id + '&mod=' + modify;
01829 var action = new Ajax.Request(
01830 "ajax_misc.php",
01831 {
01832 method: 'get',
01833 parameters: querystring,
01834 onFailure: error_box,
01835 onSuccess: function(req) {
01836 try {
01837 remove_waiting_box();
01838 var answer = req.responseXML;
01839 var html = answer.getElementsByTagName('code');
01840 if (html.length === 0)
01841 {
01842 var rec = req.responseText;
01843 alert('erreur :' + rec);
01844 }
01845 var code_html = getNodeText(html[0]);
01846 code_html = unescape_xml(code_html);
01847 var pos = fixed_position(0, 50) + ";width:90%;left:5%;";
01848 add_div({
01849 id: id,
01850 drag: 1,
01851 cssclass: "inner_box",
01852 style: pos
01853 });
01854 $(id).innerHTML = code_html;
01855 compute_all_ledger();
01856 } catch (e) {
01857 alert('view_action' + e.message);
01858 }
01859 }
01860 }
01861 );
01862 }
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872 function filter_table(phrase, _id, colnr, start_row) {
01873 $('info_div').innerHTML = "Un instant";
01874 $('info_div').style.display = "block";
01875 var words = $(phrase).value.toLowerCase();
01876 var table = document.getElementById(_id);
01877
01878
01879 var aCol = new Array();
01880 if (colnr.indexOf(',') >= 0) {
01881 aCol = colnr.split(',');
01882 } else {
01883 aCol[0] = colnr;
01884 }
01885 var ele;
01886
01887 for (var r = start_row; r < table.rows.length; r++) {
01888 var found = 0;
01889 for (var col = 0; col < aCol.length; col++)
01890 {
01891 var idx = aCol[col];
01892 if (table.rows[r].cells[idx])
01893 {
01894 ele = table.rows[r].cells[idx].innerHTML.replace(/<[^>]+>/g, "");
01895
01896 if (ele.toLowerCase().indexOf(words) >= 0) {
01897 found = 1;
01898 }
01899 }
01900
01901 }
01902 if (found === 1) {
01903 table.rows[r].style.display = '';
01904 } else {
01905 table.rows[r].style.display = 'none';
01906 }
01907 $('info_div').style.display = "none";
01908 $('info_div').innerHTML = "";
01909 }
01910 }
01911
01912
01913
01914
01915 function display_task(p_id)
01916 {
01917 new Draggable(p_id, {starteffect: function()
01918 {
01919 new Effect.Highlight(obj.id, {scroll: window, queue: 'end'});
01920 }}
01921 );
01922 $(p_id).style.top = posY+'px';
01923 $(p_id).style.left = posX+'px';
01924 $(p_id).style.display = 'block';
01925
01926 }
01927
01928
01929
01930
01931 function info_message(p_message)
01932 {
01933 $('info_div').innerHTML = p_message;
01934 $('info_div').style.display = "block";
01935 }
01936
01937
01938
01939 function info_hide()
01940 {
01941 $('info_div').style.display = "none";
01942 }
01943
01944
01945
01946
01947 function ask_navigator(p_dossier) {
01948 try {
01949 waiting_box();
01950 removeDiv('navi_div')
01951 var queryString = "gDossier=" + p_dossier + "&op=navigator";
01952 var action = new Ajax.Request(
01953 "ajax_misc.php",
01954 {
01955 method: 'get', parameters: queryString,
01956 onFailure: ajax_misc_failure,
01957 onSuccess: function(req) {
01958 remove_waiting_box();
01959 add_div({id: 'navi_div', style: 'top:2em;left:2em;width:90%', cssclass: 'inner_box'});
01960 $('navi_div').innerHTML = req.responseText;
01961 try
01962 {
01963 req.responseText.evalScripts();
01964 sorttable.makeSortable($("navi_tb"));
01965 }
01966 catch (e)
01967 {
01968 alert("answer_box Impossible executer script de la reponse\n" + e.message);
01969 }
01970
01971 }
01972 }
01973 );
01974 } catch (e) {
01975 info_message(e.getMessage);
01976 }
01977
01978 }
01979
01980
01981
01982
01983 function set_preference(p_dossier) {
01984 try {
01985 waiting_box();
01986 removeDiv('preference_div')
01987 var queryString = "gDossier=" + p_dossier + "&op=preference";
01988 var action = new Ajax.Request(
01989 "ajax_misc.php",
01990 {
01991 method: 'get', parameters: queryString,
01992 onFailure: ajax_misc_failure,
01993 onSuccess: function(req) {
01994 remove_waiting_box();
01995 add_div({id: 'preference_div', drag: 1});
01996 $('preference_div').innerHTML = req.responseText;
01997 try
01998 {
01999 req.responseText.evalScripts();
02000 }
02001 catch (e)
02002 {
02003 alert("answer_box Impossible executer script de la reponse\n" + e.message);
02004 }
02005
02006 }
02007 }
02008 );
02009 } catch (e) {
02010 info_message(e.getMessage);
02011 }
02012
02013 }
02014
02015
02016
02017
02018 function show_bookmark(p_dossier) {
02019 try {
02020 waiting_box();
02021 removeDiv('bookmark_div');
02022 var param = window.location.search;
02023 param = param.gsub('?', '');
02024 var queryString = "gDossier=" + p_dossier + "&op=bookmark&" + param;
02025 var action = new Ajax.Request(
02026 "ajax_misc.php",
02027 {
02028 method: 'get', parameters: queryString,
02029 onFailure: ajax_misc_failure,
02030 onSuccess: function(req) {
02031 remove_waiting_box();
02032 add_div({id: 'bookmark_div', cssclass: 'inner_box', drag: 1});
02033 $('bookmark_div').innerHTML = req.responseText;
02034 try
02035 {
02036 req.responseText.evalScripts();
02037 }
02038 catch (e)
02039 {
02040 alert("answer_box Impossible executer script de la reponse\n" + e.message);
02041 }
02042
02043 }
02044 }
02045 );
02046 } catch (e) {
02047 info_message(e.getMessage);
02048 }
02049
02050 }
02051
02052
02053
02054 function save_bookmark() {
02055 try {
02056 waiting_box();
02057 var queryString = "op=bookmark&" + $("bookmark_frm").serialize();
02058 var action = new Ajax.Request(
02059 "ajax_misc.php",
02060 {
02061 method: 'get', parameters: queryString,
02062 onFailure: ajax_misc_failure,
02063 onSuccess: function(req) {
02064 remove_waiting_box();
02065
02066
02067 $('bookmark_div').innerHTML = req.responseText;
02068 try
02069 {
02070 req.responseText.evalScripts();
02071 }
02072 catch (e)
02073 {
02074 alert("answer_box Impossible executer script de la reponse\n" + e.message);
02075 }
02076
02077 }
02078 }
02079 );
02080 } catch (e) {
02081 info_message(e.getMessage);
02082 }
02083
02084 }
02085
02086
02087
02088 function remove_bookmark() {
02089 try {
02090 waiting_box();
02091 var queryString = "op=bookmark&" + $("bookmark_del_frm").serialize();
02092 var action = new Ajax.Request(
02093 "ajax_misc.php",
02094 {
02095 method: 'get', parameters: queryString,
02096 onFailure: ajax_misc_failure,
02097 onSuccess: function(req) {
02098 remove_waiting_box();
02099 $('bookmark_div').innerHTML = req.responseText;
02100 try
02101 {
02102 req.responseText.evalScripts();
02103 }
02104 catch (e)
02105 {
02106 alert("answer_box Impossible executer script de la reponse\n" + e.message);
02107 }
02108
02109 }
02110 }
02111 );
02112 } catch (e) {
02113 error_message(e.getMessage);
02114 }
02115
02116 }
02117
02118
02119
02120
02121
02122 function error_message(message)
02123 {
02124 $('error_content_div').innerHTML = message;
02125 $('error_div').style.visibility = 'visible';
02126 }
02127
02128
02129
02130 function show_tag(p_dossier, p_ac, p_tag_id, p_post)
02131 {
02132 try {
02133 waiting_box();
02134 var queryString = "op=tag_detail&tag=" + p_tag_id + "&gDossier=" + p_dossier + "&ac=" + p_ac + '&form=' + p_post;
02135 var action = new Ajax.Request(
02136 "ajax_misc.php",
02137 {
02138 method: 'get', parameters: queryString,
02139 onFailure: ajax_misc_failure,
02140 onSuccess: function(req) {
02141 var answer = req.responseXML;
02142 var html = answer.getElementsByTagName('code');
02143 if (html.length === 0)
02144 {
02145 var rec = req.responseText;
02146 alert('erreur :' + rec);
02147 }
02148 var code_html = getNodeText(html[0]);
02149 code_html = unescape_xml(code_html);
02150 remove_waiting_box();
02151 add_div({id: 'tag_div', cssclass: 'inner_box', drag: 1});
02152 $('tag_div').innerHTML = code_html;
02153 try
02154 {
02155 code_html.evalScripts();
02156 }
02157 catch (e)
02158 {
02159 alert("answer_box Impossible executer script de la reponse\n" + e.message);
02160 }
02161
02162 }
02163 }
02164 );
02165 } catch (e) {
02166 error_message(e.getMessage);
02167 }
02168 }
02169
02170
02171
02172
02173 function save_tag()
02174 {
02175 try {
02176 waiting_box();
02177 var queryString = "op=tag_save&" + $("tag_detail_frm").serialize();
02178 var action = new Ajax.Request(
02179 "ajax_misc.php",
02180 {
02181 method: 'get',
02182 parameters: queryString,
02183 onFailure: ajax_misc_failure,
02184 onSuccess: function(req, j) {
02185 remove_waiting_box();
02186 removeDiv('tag_div');
02187 }
02188 }
02189 );
02190 } catch (e) {
02191 error_message(e.getMessage);
02192 return false;
02193 }
02194 return false;
02195
02196 }
02197
02198
02199
02200
02201
02202
02203 function action_tag_select(p_dossier, ag_id)
02204 {
02205 try {
02206 waiting_box();
02207 var queryString = "ag_id=" + ag_id + "&op=tag_list&gDossier=" + p_dossier;
02208 var action = new Ajax.Request(
02209 "ajax_misc.php",
02210 {
02211 method: 'get', parameters: queryString,
02212 onFailure: ajax_misc_failure,
02213 onSuccess: function(req, j) {
02214 var answer = req.responseXML;
02215 var html = answer.getElementsByTagName('code');
02216 if (html.length === 0)
02217 {
02218 var rec = unescape_xml(req.responseText);
02219 error_message('erreur :' + rec);
02220 }
02221 var code_html = getNodeText(html[0]);
02222 code_html = unescape_xml(code_html);
02223 add_div({id: 'tag_div', style: '', cssclass: 'inner_box', drag: 1});
02224 $('tag_div').style.top = (posY - 70)+"px";
02225 $('tag_div').style.left = (posX - 70)+"px";
02226 remove_waiting_box();
02227 $('tag_div').innerHTML = code_html;
02228 }
02229 }
02230 );
02231 } catch (e) {
02232 error_message(e.getMessage);
02233 }
02234 }
02235
02236
02237
02238
02239
02240
02241 function action_tag_add(p_dossier, ag_id, t_id)
02242 {
02243 try {
02244 waiting_box();
02245 var queryString = "t_id=" + t_id + "&ag_id=" + ag_id + "&op=tag_add&gDossier=" + p_dossier;
02246 var action = new Ajax.Request(
02247 "ajax_misc.php",
02248 {
02249 method: 'get', parameters: queryString,
02250 onFailure: ajax_misc_failure,
02251 onSuccess: function(req, j) {
02252 var answer = req.responseXML;
02253 var html = answer.getElementsByTagName('code');
02254 if (html.length === 0)
02255 {
02256 var rec = unescape_xml(req.responseText);
02257 error_message('erreur :' + rec);
02258 }
02259 var code_html = getNodeText(html[0]);
02260 code_html = unescape_xml(code_html);
02261 remove_waiting_box();
02262 $('action_tag_td').innerHTML = code_html;
02263 removeDiv('tag_div');
02264 }
02265 }
02266 );
02267 } catch (e) {
02268 error_message(e.getMessage);
02269 }
02270 }
02271
02272
02273
02274
02275
02276
02277 function action_tag_remove(p_dossier, ag_id, t_id)
02278 {
02279 if (confirm('Enlevez ce tags ?') === false)
02280 return;
02281 try {
02282 waiting_box();
02283 var queryString = "t_id=" + t_id + "&ag_id=" + ag_id + "&op=tag_remove&gDossier=" + p_dossier;
02284 var action = new Ajax.Request(
02285 "ajax_misc.php",
02286 {
02287 method: 'get', parameters: queryString,
02288 onFailure: ajax_misc_failure,
02289 onSuccess: function(req, j) {
02290 var answer = req.responseXML;
02291 var html = answer.getElementsByTagName('code');
02292 if (html.length === 0)
02293 {
02294 var rec = unescape_xml(req.responseText);
02295 error_message('erreur :' + rec);
02296 }
02297 var code_html = getNodeText(html[0]);
02298 code_html = unescape_xml(code_html);
02299 remove_waiting_box();
02300 $('action_tag_td').innerHTML = code_html;
02301
02302 }
02303 }
02304 );
02305 } catch (e) {
02306 error_message(e.getMessage);
02307 }
02308 }
02309
02310
02311
02312
02313
02314
02315
02316
02317 function search_display_tag(p_dossier, p_prefix)
02318 {
02319 try {
02320 waiting_box();
02321 var queryString = "op=search_display_tag&gDossier=" + p_dossier + "&pref=" + p_prefix;
02322 var action = new Ajax.Request(
02323 "ajax_misc.php",
02324 {
02325 method: 'get', parameters: queryString,
02326 onFailure: ajax_misc_failure,
02327 onSuccess: function(req, j) {
02328 var answer = req.responseXML;
02329 var html = answer.getElementsByTagName('code');
02330 if (html.length === 0)
02331 {
02332 var rec = unescape_xml(req.responseText);
02333 error_message('erreur :' + rec);
02334 }
02335 var code_html = getNodeText(html[0]);
02336 code_html = unescape_xml(code_html);
02337 remove_waiting_box();
02338 add_div({id: p_prefix + 'tag_div', style: '', cssclass: 'inner_box', drag: 1});
02339 $(p_prefix + 'tag_div').style.top = posY - 80+"px";
02340 $(p_prefix + 'tag_div').style.left = posX - 200+"px";
02341 remove_waiting_box();
02342 $(p_prefix + 'tag_div').innerHTML = code_html;
02343
02344 }
02345 }
02346 );
02347 } catch (e) {
02348 error_message(e.getMessage);
02349 }
02350 }
02351
02352
02353
02354
02355
02356
02357 function search_add_tag(p_dossier, p_tag_id, p_prefix)
02358 {
02359 try {
02360 var clear_button = 0;
02361 if (tag_choose === '' && p_prefix === 'search') {
02362 tag_choose = $(p_prefix + 'tag_choose_td').innerHTML;
02363 clear_button = 1;
02364 }
02365 waiting_box();
02366 var queryString = "op=search_add_tag&gDossier=" + p_dossier + "&id=" + p_tag_id + "&clear=" + clear_button + '&pref=' + p_prefix;
02367 var action = new Ajax.Request(
02368 "ajax_misc.php",
02369 {
02370 method: 'get', parameters: queryString,
02371 onFailure: ajax_misc_failure,
02372 onSuccess: function(req, j) {
02373 var answer = req.responseXML;
02374 var html = answer.getElementsByTagName('html');
02375 if (html.length === 0)
02376 {
02377 var rec = unescape_xml(req.responseText);
02378 error_message('erreur :' + rec);
02379 }
02380 var code_html = getNodeText(html[0]);
02381 code_html = unescape_xml(code_html);
02382 remove_waiting_box();
02383 $(p_prefix + 'tag_choose_td').innerHTML = $(p_prefix + 'tag_choose_td').innerHTML + code_html;
02384 removeDiv(p_prefix + 'tag_div');
02385 }
02386 }
02387 );
02388 } catch (e) {
02389 error_message(e.getMessage);
02390 }
02391 }
02392
02393
02394
02395
02396 function search_clear_tag(p_dossier, p_prefix)
02397 {
02398 if (p_prefix != 'search') {
02399 $(p_prefix + 'tag_choose_td').innerHTML = "";
02400 return;
02401 }
02402 try {
02403 var queryString = "op=search_clear_tag&gDossier=" + p_dossier + "&pref=" + p_prefix;
02404 var action = new Ajax.Request(
02405 "ajax_misc.php",
02406 {
02407 method: 'get', parameters: queryString,
02408 onFailure: ajax_misc_failure,
02409 onSuccess: function(req, j) {
02410 var answer = req.responseXML;
02411 var html = answer.getElementsByTagName('html');
02412 if (html.length === 0)
02413 {
02414 var rec = unescape_xml(req.responseText);
02415 error_message('erreur :' + rec);
02416 }
02417 var code_html = getNodeText(html[0]);
02418 code_html = unescape_xml(code_html);
02419 $(p_prefix + 'tag_choose_td').innerHTML = code_html;
02420 tag_choose = "";
02421 }
02422 }
02423 );
02424 } catch (e) {
02425 error_message(e.getMessage);
02426 }
02427 }
02428 function action_show_checkbox()
02429 {
02430 var a = document.getElementsByName('ag_id_td');
02431 for (var i = 0; i < a.length; i++) {
02432 a[i].style.display = 'block';
02433 }
02434 }
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444 function calendar_zoom(obj)
02445 {
02446 try {
02447
02448 var query = "";
02449 query = "op=calendar_zoom&gDossier=" + obj.gDossier + "&in=" + $(obj.invalue).value + '&out=' + obj.outdiv;
02450 waiting_box();
02451 var action = new Ajax.Request(
02452 "ajax_misc.php",
02453 {
02454 method: 'get', parameters: query,
02455 onFailure: ajax_misc_failure,
02456 onSuccess: function(req, j) {
02457 var answer = req.responseXML;
02458 var html = answer.getElementsByTagName('html');
02459 if (html.length === 0)
02460 {
02461 var rec = unescape_xml(req.responseText);
02462 error_message('erreur :' + rec);
02463 }
02464 var code_html = getNodeText(html[0]);
02465 code_html = unescape_xml(code_html);
02466
02467
02468
02469 if (obj.outdiv === undefined) {
02470 obj.outdiv = 'calendar_zoom_div';
02471 }
02472 if ($(obj.outdiv) == undefined) {
02473 var str_style = fixed_position(0, 20);
02474 add_div({id: obj.outdiv, style: 'margin-left:3%;width:94%;height:94%;' + str_style, cssclass: "inner_box", drag: 1});
02475 }
02476 remove_waiting_box();
02477 $(obj.outdiv).innerHTML = code_html;
02478 $(obj.outdiv).show();
02479 }
02480 }
02481 );
02482 } catch (e) {
02483 error_message('calendar_zoom ' + e.getMessage);
02484 }
02485
02486
02487 }
02488
02489
02490
02491 function stock_add_row()
02492 {
02493 try {
02494 style = 'class="input_text"';
02495 var mytable = g("stock_tb").tBodies[0];
02496 var ofirstRow = mytable.rows[1];
02497 var line = mytable.rows.length;
02498 var nCell = mytable.rows[1].cells.length;
02499 var row = mytable.insertRow(line);
02500 var nb = g("row");
02501 for (var e = 0; e < nCell; e++)
02502 {
02503 var newCell = row.insertCell(e);
02504 if (mytable.rows[1].cells[e].hasClassName('num')) {
02505 newCell.addClassName("num");
02506 }
02507
02508 var tt = ofirstRow.cells[e].innerHTML;
02509 var new_tt = tt.replace(/sg_code0/g, "sg_code" + nb.value);
02510 new_tt = new_tt.replace(/sg_quantity0/g, "sg_quantity" + nb.value);
02511 new_tt = new_tt.replace(/label0/g, "label" + nb.value);
02512 newCell.innerHTML = new_tt;
02513 new_tt.evalScripts();
02514 }
02515
02516 g("sg_code" + nb.value).innerHTML = ' ';
02517 g("sg_code" + nb.value).value = '';
02518 g("label" + nb.value).innerHTML = '';
02519 g("sg_quantity" + nb.value).value = '0';
02520
02521 nb.value++;
02522
02523 new_tt.evalScripts();
02524 } catch (e) {
02525 alert(e.message);
02526 }
02527
02528 }
02529 function show_description(p_id)
02530 {
02531 $('print_desc'+p_id).hide();
02532 $('input_desc'+p_id).show();
02533
02534 }