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
24 * javascript script for the ledger in accountancy,
25 * compute the sum, add a row at the table..
32 * \brief update the list of available predefined operation when we change the ledger.
34function update_predef(p_type, p_direct, p_ac) {
35 var jrn = id$("p_jrn").value;
36 var dossier = id$("gDossier").value;
37 var querystring = 'gDossier=' + dossier + '&l=' + jrn + '&t=' + p_type + '&d=' + p_direct + "&op=up_predef&ac=" + p_ac;
38 id$("p_jrn_predef").value = jrn;
39 var action = new Ajax.Request(
43 parameters: querystring,
44 onFailure: error_get_predef,
45 onSuccess: function (req) {
47 id$('info_div').innerHTML = "ok";
48 var answer = req.responseXML;
49 var a = answer.getElementsByTagName('code');
50 var html = answer.getElementsByTagName('value');
52 var rec = req.responseText;
53 alert_box(content[48] + rec);
55 var code_html = getNodeText(html[0]);
56 code_html = unescape_xml(code_html);
57 // document.getElementsByName(name_ctl)[0].value = code_html;
58 id$('modele_op_div').innerHTML = code_html;
60 id$('info_div').innerHTML = e.message;
68 * update the list of payment method when we change the ledger.
70function update_pay_method() {
72 var jrn = id$("p_jrn").value;
73 var dossier = id$("gDossier").value;
74 var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=up_pay_method";
75 var action = new Ajax.Request(
79 parameters: querystring,
80 onFailure: error_get_predef,
81 onSuccess: function (req) {
83 var answer = req.responseText;
84 id$('payment').innerHTML = answer;
91 * update the list of additional tax
93function update_other_tax() {
95 var jrn = id$("p_jrn").value;
96 var dossier = id$("gDossier").value;
97 var querystring = {gDossier: dossier, jrn_id: jrn, op: "up_other_tax"};
98 var action = new Ajax.Request(
102 parameters: querystring,
103 onFailure: error_get_predef,
104 onSuccess: function (req) {
105 remove_waiting_box();
106 var answer = req.responseText;
107 answer.evalScripts();
108 id$('additional_tax_div').innerHTML = answer;
115 * update ctl id =jrn_name with the value of p_jrn
117function update_name() {
118 var jrn_id = id$('p_jrn').value;
119 var dossier = id$("gDossier").value;
120 var querystring = 'gDossier=' + dossier + '&l=' + jrn_id + "&op=ledger_description";
121 var action = new Ajax.Request(
125 parameters: querystring,
126 onFailure: error_get_pj,
127 onSuccess: function (req) {
128 id$('jrn_name_div').innerHTML = req.responseText;
136 * update the field predef
138function error_get_predef(request, json) {
139 alert_box(content[49]);
144 * update the list of available predefined operation when we change the ledger.
146function update_receipt() {
147 var jrn = id$("p_jrn").value;
148 var dossier = id$("gDossier").value;
149 var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=upd_receipt";
150 var action = new Ajax.Request(
154 parameters: querystring,
155 onFailure: error_get_pj,
156 onSuccess: success_get_pj
162 * ask the name, quick_code of the bank for the ledger
164function update_bank() {
165 var jrn = id$('p_jrn').value;
166 var dossier = id$('gDossier').value;
167 var qs = 'gDossier=' + dossier + '&op=bkname&p_jrn=' + jrn;
168 var action = new Ajax.Request(
173 onFailure: error_get_pj,
174 onSuccess: success_update_bank
181 * Update the number of rows when changing of ledger
183function update_row(ctl) {
185 var row_to_keep = 3; /* Number of row to keep (head and foot)*/
186 if (ctl === 'quick_item') {
188 } /* for ODS , only 1 rows to keep */
189 var jrn = id$('p_jrn').value;
190 var dossier = id$('gDossier').value;
191 var qs = encodeURI('gDossier=' + dossier + '&op=minrow&j=' + jrn + '&ctl=' + ctl);
192 var current_row = parseFloat(id$('nb_item').value);
193 var action = new Ajax.Request(
199 onSuccess: function (request, json) {
201 var answer = request.responseText.evalJSON(true);
202 var row = parseFloat(answer.row);
204 var table_to_update = id$(ctl);
205 if (current_row > row) {
206 // Too many row, we always must keep 2 rows for the sum
207 var delta = id$('nb_item').value - row;
208 var idx = id$('nb_item').value;
209 for (var i = 0; i < delta; i++) {
210 var pos_row = table_to_update.rows.length;
211 var cell0 = table_to_update.rows[pos_row - row_to_keep].cells[0];
212 var cell0Element = cell0.childNodes;
213 var canDelete = true;
217 cell0Element.forEach(function (x) {
218 if (canDelete && x.nodeName == 'INPUT' && x.type === "text" && x.value) {
225 * For ODS we also need to check the second column
227 if (canDelete && ctl === 'quick_item') {
228 var cell1 = table_to_update.rows[pos_row - row_to_keep].cells[1];
229 var cell1Element = cell1.childNodes;
230 cell1Element.forEach(function (x) {
231 if (canDelete && x.nodeName == 'INPUT' && x.type === "text" && x.value) {
237 table_to_update.deleteRow(pos_row - row_to_keep);
242 id$('nb_item').value = table_to_update.rows.length - row_to_keep;
244 if (current_row < row) {
245 // We need to add rows
246 var delta = row - current_row;
247 for (var i = 0; i < delta; i++) {
248 if (ctl == 'fin_item') {
249 ledger_fin_add_row();
251 if (ctl == 'sold_item') {
254 if (ctl == 'quick_item') {
255 quick_writing_add_row();
260 alert_box("update_row:01" + e.message);
266 alert_box(e.message);
271 * @brief hide or show the column quantity
273function update_visibility_quantity() {
274 var jrn = id$("p_jrn").value;
275 var dossier = id$("gDossier").value;
276 var querystring = 'gDossier=' + dossier + '&l=' + jrn + "&op=update_visibility_quantity";
277 var action = new Ajax.Request(
281 parameters: querystring,
282 onSuccess: function (req) {
285 var quantity_col = document.getElementsByClassName("col_quant");
286 for (var i = 0; i < quantity_col.length; i++) {
287 if (req.responseText == "0") {
288 // hide the columns quantity and return
289 quantity_col[i].hide();
290 quantity_col[i].addClassName('d-none');
292 if (req.responseText == "1") {
293 // show the columns quantity and return
294 quantity_col[i].show();
295 quantity_col[i].removeClassName('d-none');
299 console.error("update_visibility_quantity" + e.message);
309 * Put into the span, the name of the bank, the bank account
312function success_update_bank(req) {
314 var answer = req.responseXML;
315 var a = answer.getElementsByTagName('code');
316 var html = answer.getElementsByTagName('value');
318 var rec = req.responseText;
319 alert_box('UPDBK-' + content[48] + rec);
321 var name_ctl = a[0].firstChild.nodeValue;
322 var code_html = getNodeText(html[0]);
323 code_html = unescape_xml(code_html);
324 id$(name_ctl).innerHTML = code_html;
326 alert_box("success_update_bank" + e.message);
331 * call ajax, ask what is the last date for the current ledger
333function get_last_date() {
334 var jrn = id$('p_jrn').value;
335 var dossier = id$('gDossier').value;
336 var qs = 'gDossier=' + dossier + '&op=lastdate&p_jrn=' + jrn;
337 var action = new Ajax.Request(
342 onFailure: error_get_pj,
343 onSuccess: success_get_last_date
349 * callback ajax, set the ctl with the last date from the ledger
351function success_get_last_date(req) {
353 var answer = req.responseXML;
354 var a = answer.getElementsByTagName('code');
355 var html = answer.getElementsByTagName('value');
357 var rec = req.responseText;
358 alert_box('GETLASTDA:' + content[48] + rec);
360 var name_ctl = a[0].firstChild.nodeValue;
361 var code_html = getNodeText(html[0]);
362 code_html = unescape_xml(code_html);
363 document.getElementsByName(name_ctl)[0].value = code_html;
365 alert_box(e.message);
370 * update the field predef
372function success_get_pj(request, json) {
374 var answer = request.responseText.evalJSON(true);
375 var obj = id$("e_pj");
377 if (answer.length == 0)
379 obj.value = answer.pj;
380 id$("e_pj_suggest").value = answer.pj;
384 * update the field predef
386function error_get_pj(request, json) {
387 alert_box("GETPJ:" + content[48]);
391 * add a line in the form for the ledger fin
393function ledger_fin_add_row() {
394 var style = 'class="input_text"';
395 var mytable = id$("fin_item").tBodies[0];
396 var line = mytable.rows.length;
397 var row = mytable.insertRow(line);
398 var nb = id$("nb_item");
399 var rowToCopy = mytable.rows[1];
400 var nNumberCell = rowToCopy.cells.length;
401 for (var e = 0; e < nNumberCell; e++) {
402 var newCell = row.insertCell(e);
404 newCell.id = 'tdchdate' + nb.value;
406 var tt = rowToCopy.cells[e].innerHTML;
407 var new_tt = tt.replace(/e_other0/g, "e_other" + nb.value);
408 new_tt = new_tt.replace(/e_other0_comment/g, "e_other" + nb.value + '_comment');
409 new_tt = new_tt.replace(/e_other_name0/g, "e_other_name" + nb.value);
410 new_tt = new_tt.replace(/e_other0_amount/g, "e_other" + nb.value + '_amount');
411 new_tt = new_tt.replace(/e_concerned0/g, "e_concerned" + nb.value);
412 new_tt = new_tt.replace(/e_other0_label/g, "e_other" + nb.value + '_label');
413 new_tt = new_tt.replace(/dateop0/g, "dateop" + nb.value);
414 newCell.innerHTML = new_tt;
415 newCell.className = rowToCopy.cells[e].className;
416 new_tt.evalScripts();
418 id$("e_other" + nb.value).value = "";
419 id$("e_other_name" + nb.value).value = "";
420 id$("e_other" + nb.value + '_amount').value = "0";
421 id$("e_other" + nb.value + '_comment').value = "";
422 id$("e_concerned" + nb.value).value = "";
424 var ch = id$('chdate').options[id$('chdate').selectedIndex].value;
426 id$('tdchdate' + nb.value).hide();
433 * @param string p_elid is the id of element with the number of rows to add, and p_elid+"_ledger" is the type of ledger : M : Misc Operation O : Sales or purchase and F for financial
435function ledger_add_multiple(p_elid) {
436 var nbrow = id$(p_elid).value;
440 var type_ledger = id$(p_elid + "_ledger").value;
442 for (i = 0; i < nbrow; i++) {
443 if (type_ledger == 'O') {
446 if (type_ledger == 'F') {
447 ledger_fin_add_row();
449 if (type_ledger == 'M') {
450 quick_writing_add_row();
453 if (type_ledger == 'M') {
454 var aCheckBox = $$('.debit-credit')
455 aCheckBox.forEach((item) => display_dcside(item))
460 * add a line in the form for the purchase ledger
461 * @param p_dossier folder id
462 * @param p_table_name
464function ledger_add_row() {
466 style = 'class="input_text"';
467 var mytable = id$("sold_item").tBodies[0];
468 var ofirstRow = mytable.rows[1];
469 var line = mytable.rows.length;
470 var nCell = mytable.rows[1].cells.length;
471 var row = mytable.insertRow(line);
472 var nb = id$("nb_item");
473 for (var e = 0; e < nCell; e++) {
474 var newCell = row.insertCell(e);
475 var tt = ofirstRow.cells[e].innerHTML;
476 var new_tt = tt.replace(/march0/g, "march" + nb.value);
477 new_tt = new_tt.replace(/quant0/g, "quant" + nb.value);
478 new_tt = new_tt.replace(/sold\(0\)/g, "sold(" + nb.value + ")");
479 new_tt = new_tt.replace(/compute_ledger\(0\)/g, "compute_ledger(" + nb.value + ")");
480 new_tt = new_tt.replace(/clean_tva\(0\)/g, "clean_tva(" + nb.value + ")");
481 newCell.innerHTML = new_tt;
482 newCell.className = ofirstRow.cells[e].className;
483 new_tt.evalScripts();
486 id$("e_march" + nb.value + "_label").innerHTML = '';
487 id$("e_march" + nb.value + "_label").value = '';
488 id$("e_march" + nb.value + "_price").value = '0';
489 id$("e_march" + nb.value).value = "";
490 id$("e_quant" + nb.value).value = "1";
491 if (document.getElementById("e_march" + nb.value + "_tva_amount"))
492 id$("e_march" + nb.value + "_tva_amount").value = 0;
496 new_tt.evalScripts();
498 alert_box(e.message);
503 * compute the sum of a purchase, update the span tvac, htva and tva
504 * all the needed data are taken from the document (hidden field : gdossier)
505 * @param the number of the changed ctrl
507function compute_ledger(p_ctl_nb) {
508 var dossier = id$("gDossier").value;
510 if (document.getElementById("e_march" + p_ctl_nb + '_tva_amount')) {
511 a = trim(id$("e_march" + p_ctl_nb + '_tva_amount').value);
512 id$("e_march" + p_ctl_nb + '_tva_amount').value = a;
514 if (!document.getElementById("e_march" + p_ctl_nb)) {
517 id$("e_march" + p_ctl_nb).value = trim(id$("e_march" + p_ctl_nb).value);
518 var qcode = id$("e_march" + p_ctl_nb).value;
520 if (qcode.length == 0) {
521 clean_ledger(p_ctl_nb);
526 * if tva_id is empty send a value of -1
529 if (document.getElementById('e_march' + p_ctl_nb + '_tva_id')) {
530 tva_id = id$('e_march' + p_ctl_nb + '_tva_id').value;
531 if (trim(tva_id) == '') {
536 id$('e_march' + p_ctl_nb + '_price').value = trim(id$('e_march' + p_ctl_nb + '_price').value);
537 var price = id$('e_march' + p_ctl_nb + '_price').value;
539 id$('e_quant' + p_ctl_nb).value = trim(id$('e_quant' + p_ctl_nb).value);
540 var quantity = id$('e_quant' + p_ctl_nb).value;
541 let other_tax = document.getElementById("other_tax");
542 let other_tax_id = (other_tax && other_tax.checked) ? other_tax.value : -1;
551 'other_tax_id': other_tax_id
553 var action = new Ajax.Request(
557 parameters: querystring,
558 onFailure: error_compute_ledger,
559 onSuccess: success_compute_ledger
565 * refresh the purchase screen, recompute vat, total...
567function refresh_ledger() {
572 nb_item = id$("nb_item").value;
573 for (var i = 0; i < nb_item; i++) {
574 if (document.getElementById('tva_march' + i))
575 tva += id$('tva_march' + i).value * 1;
576 if (document.getElementById('htva_march' + i))
577 htva += id$('htva_march' + i).value * 1;
578 if (document.getElementById('tvac_march' + i))
579 tvac += id$('tvac_march' + i).value * 1;
582 id_htva = id$("htva");
583 id_tvac = id$("tvac");
584 id_other_tax = document.getElementById("other_tax_amount");
586 id_tva.innerHTML = Math.round(tva * 100) / 100;
588 id_htva.innerHTML = Math.round(htva * 100) / 100;
590 let total_operation = tvac + parseFloat(id_other_tax.value);
591 id$('total_operation_other_tax').innerHTML = Math.round(total_operation * 100) / 100;
594 id_tvac.innerHTML = Math.round(tvac * 100) / 100;
600 * update the field htva, tva_id and tvac, callback function for compute_sold
601 * it the field TVA in the answer contains NA it means that VAT is appliable and then do not
602 * update the VAT field except htva_martc
604function success_compute_ledger(request, json) {
605 var answer = request.responseText.evalJSON(true);
606 var ctl = answer.ctl;
607 var rtva = answer.tva;
608 var rhtva = answer.htva;
609 var rtvac = answer.tvac;
610 let other_tax = id$("other_tax_amount")
612 other_tax.value = answer.other_tax;
615 var rhtva = answer.htva * 1;
616 id$('htva_march' + ctl).value = rhtva;
617 id$('tvac_march' + ctl).value = rtvac;
620 CurrencyCompute('p_currency_rate', 'p_currency_euro');
624 rtva = answer.tva * 1;
628 if (document.getElementById('e_march' + ctl + '_tva_amount').value == "" ||
629 document.getElementById('e_march' + ctl + '_tva_amount').value == 0) {
630 id$('tva_march' + ctl).value = rtva;
631 id$('e_march' + ctl + '_tva_amount').value = rtva;
633 id$('tva_march' + ctl).value = id$('e_march' + ctl + '_tva_amount').value;
635 id$('htva_march' + ctl).value = Math.round(parseFloat(rhtva) * 100) / 100;
636 var tmp1 = Math.round(parseFloat(id$('htva_march' + ctl).value) * 100) / 100;
637 var tmp2 = Math.round(parseFloat(id$('tva_march' + ctl).value) * 100) / 100;
638 id$('tvac_march' + ctl).value = Math.round((tmp1 + tmp2) * 100) / 100;
640 CurrencyCompute('p_currency_rate', 'p_currency_euro');
645 * callback error function for compute_sold
647function error_compute_ledger(request, json) {
648 alert_box('Ajax does not work');
651function compute_all_ledger() {
653 let nb_item = id$("nb_item").value;
654 for (loop = 0; loop < nb_item; loop++) {
655 compute_ledger(loop);
661 for (var i = 0; i < nb_item; i++) {
662 if (document.getElementById('tva_march'))
663 tva += id$('tva_march' + i).value * 1;
664 if (document.getElementById('htva_march' + i))
665 htva += id$('htva_march' + i).value * 1;
666 if (document.getElementById('tvac_march' + i))
667 tvac += id$('tvac_march' + i).value * 1;
669 id_other_tax = document.getElementById("other_tax_amount");
670 if (document.getElementById('tva')) id$('tva').innerHTML = Math.round(tva * 100) / 100;
671 if (document.getElementById ('htva'))
672 id$('htva').innerHTML = Math.round(htva * 100) / 100;
674 tvac += id_other_tax.value;
676 if (document.getElementById('tvac'))
677 id$('tvac').innerHTML = Math.round(tvac * 100) / 100;
682function clean_tva(p_ctl) {
683 if (document.getElementById('e_march' + p_ctl + '_tva_amount'))
684 id$('e_march' + p_ctl + '_tva_amount').value = 0;
687function clean_ledger(p_ctl_nb) {
688 if (document.getElementById("e_march" + p_ctl_nb)) {
689 id$("e_march" + p_ctl_nb).value = trim(id$("e_march" + p_ctl_nb).value);
691 if (document.getElementById('e_march' + p_ctl_nb + '_price')) {
692 id$('e_march' + p_ctl_nb + '_price').value = '';
694 if (document.getElementById('e_quant' + p_ctl_nb)) {
695 id$('e_quant' + p_ctl_nb).value = '1';
697 if (document.getElementById('tva_march' + p_ctl_nb + '_show')) {
698 id$('tva_march' + p_ctl_nb + '_show').value = '0';
700 if (document.getElementById('tva_march' + p_ctl_nb)) {
701 id$('tva_march' + p_ctl_nb).value = 0;
703 if (document.getElementById('htva_march' + p_ctl_nb)) {
704 id$('htva_march' + p_ctl_nb).value = 0;
706 if (document.getElementById('tvac_march' + p_ctl_nb)) {
707 id$('tvac_march' + p_ctl_nb).value = 0;
713 * add a line in the form for the quick_writing
715function quick_writing_add_row() {
716 style = 'class="input_text"';
717 var mytable = id$("quick_item").tBodies[0];
718 var nNumberRow = mytable.rows.length;
719 var oRow = mytable.insertRow(nNumberRow);
720 var rowToCopy = mytable.rows[1];
721 var nNumberCell = rowToCopy.cells.length;
722 var nb = id$("nb_item");
724 var oNewRow = mytable.insertRow(nNumberRow);
725 for (var e = 0; e < nNumberCell; e++) {
726 var newCell = oRow.insertCell(e);
727 var tt = rowToCopy.cells[e].innerHTML;
728 new_tt = tt.replace(/qc_0/g, "qc_" + nb.value);
729 new_tt = new_tt.replace(/amount0/g, "amount" + nb.value);
730 new_tt = new_tt.replace(/poste0/g, "poste" + nb.value);
731 new_tt = new_tt.replace(/ck0/g, "ck" + nb.value);
732 new_tt = new_tt.replace(/ld0/g, "ld" + nb.value);
733 newCell.innerHTML = new_tt;
734 newCell.className = rowToCopy.cells[e].className;
735 new_tt.evalScripts();
738 var ck = id$('ck' + nb.value);
739 ck.addEventListener('click', function (event) {
740 display_range_dcside(event, ck);
745 id$("qc_" + nb.value).value = "";
746 id$("amount" + nb.value).value = "";
747 id$("poste" + nb.value).value = "";
748 id$("ld" + nb.value).value = "";
755function RefreshMe() {
756 window.location.reload();
760function go_next_concerned() {
761 var form = document.forms[1];
763 for (var e = 0; e < form.elements.length; e++) {
764 var elmt = form.elements[e];
765 if (elmt.type == "checkbox") {
766 if (elmt.checked == true) {
767 return confirm(content[52]);
775 * View the history of an account
776 * @param {type} p_value
777 * @param {type} dossier
778 * @returns {undefined}
780function view_history_account(p_value, dossier, p_exercice) {
781 var layer=get_next_layer();
782 var idbox = 'det' + layer;
783 var popup = {'id': idbox, 'cssclass': 'inner_box', 'html': loading(), 'drag': false};
792 'exercice': p_exercice
796 var action = new Ajax.Request(
800 parameters: querystring,
801 onFailure: error_box,
802 onSuccess: function (req, xml) {
803 remove_waiting_box();
804 if (req.responseText === 'NOCONX') { reconnect();return;}
807 success_box(req, xml);
808 id$(idbox).style.top = calcy(140 + (layer * 3)) + "px";
809 id$(idbox).setStyle({top:calcy(140 + (layer * 3)) + "px"
818 * View the history of an account
819 * @param {type} p_value
820 * @param {type} dossier
821 * @returns {undefined}
823function view_history_anc_account(p_value, dossier, p_exercice) {
824 var layer=get_next_layer();
825 var idbox = 'det' + layer;
826 var popup = {'id': idbox, 'cssclass': 'inner_box', 'html': loading(), 'drag': false};
830 'op': 'history_anc_account',
835 'exercice': p_exercice
839 var action = new Ajax.Request(
843 parameters: querystring,
844 onFailure: error_box,
845 onSuccess: function (req, xml) {
846 remove_waiting_box();
847 if (req.responseText === 'NOCONX') { reconnect();return;}
852 top:calcy(140 + (layer * 3)) + "px"
863 * Change the view of account history
867function update_history_account(obj) {
872 "gDossier": obj.gDossier,
873 "pcm_val": obj.pcm_val,
874 "ex": obj.select.options[obj.select.selectedIndex].text,
876 "exercice": obj.exercice
879 var action = new Ajax.Request(
883 parameters: querystring,
884 onFailure: error_box,
885 onSuccess: function (req, xml) {
886 remove_waiting_box();
887 if (req.responseText === 'NOCONX') { reconnect();return;}
889 success_box(req, xml);
890 id$(obj.div).setStyle(
892 top:calcy(140 + (layer * 3)) + "px"
893 ,"z-index":get_next_layer()
899 alert_box("update_history_account error " + e.message);
905/*!\brief Change the view of card history
906 * \param p_value f_id of the card
908function view_history_card(p_value, dossier, p_exercice) {
909 var layer=get_next_layer();
910 var idbox = 'det' + layer;
913 'cssclass': 'inner_box',
924 "exercice": p_exercice
927 var action = new Ajax.Request(
931 parameters: querystring,
932 onFailure: error_box,
933 onSuccess: function (req, xml) {
934 remove_waiting_box();
935 if (req.responseText === 'NOCONX') { reconnect();return;}
938 success_box(req, xml);
941 top:calcy(140 + (layer * 3)) + "px"
942 ,"z-index":get_next_layer()
950 * \brief list followup of a card
951 * \param p_value int fiche.f_id of the card
953function view_followup_card(p_value, dossier) {
954 var layer=get_next_layer();
955 var idbox = 'detfu' + layer;
958 'cssclass': 'inner_box',
967 "op": "view_followup_card",
970 var action = new Ajax.Request(
974 parameters: querystring,
975 onFailure: error_box,
976 onSuccess: function (req, xml) {
977 remove_waiting_box();
978 if (req.responseText === 'NOCONX') { reconnect();return;}
981 id$(idbox).update(req.responseText);
984 top:calcy(140 + (layer * 3)) + "px"
985 ,"z-index":get_next_layer()
994 * update history view after changing the exercice
998function update_history_card(obj) {
1003 "gDossier": obj.gDossier,
1005 "ex": obj.select.options[obj.select.selectedIndex].text,
1007 "exercice": obj.exercice
1010 var action = new Ajax.Request(
1014 parameters: querystring,
1015 onFailure: error_box,
1016 onSuccess: function (req, xml) {
1017 if (req.responseText === 'NOCONX') { reconnect();return;}
1019 remove_waiting_box();
1020 success_box(req, xml);
1021 id$(obj.div).setStyle(
1023 top:calcy(140 + (layer * 3)) + "px"
1024 ,"z-index":get_next_layer()
1030 alert_box("update_history_account error " + e.message);
1037 * remove an Operation
1038 *@param p_jr_id is the jrn.jr_id
1042function removeOperation(p_jr_id, dossier, div) {
1045 "gDossier": dossier,
1056 onFailure: error_box,
1064 * reverse an Operation
1065 *@param pointer to the FORM
1067function reverseOperation(obj) {
1068 var qs = id$(obj).serialize() + "&op=ledger";
1069 id$('ext' + obj.divname).style.display = 'none';
1076 onFailure: error_box,
1077 onSuccess: function (req) {
1079 var action = new Ajax.Request(
1084 "gDossier": obj["gDossier"].value,
1087 "div": obj['div'].value,
1088 "jr_id": obj['jr_id'].value
1090 onFailure: error_box,
1091 onSuccess: function (xml, txt) {
1093 success_box(xml, txt);
1098 smoke.alert(ex.message);
1108 * \brief Show the details of an operation
1109 * \param p_value jrn.jr_id
1110 * \param dossier dossier id
1112function modifyOperation(p_value, dossier) {
1113 var layer=get_next_layer();
1114 var id_div = 'det' + layer;
1117 "gDossier": dossier,
1123 var action = new Ajax.Request(
1127 parameters: querystring,
1128 onFailure: error_box,
1129 onSuccess: function (xml, txt) {
1130 if (xml.responseText === 'NOCONX') {
1135 'id': id_div, 'cssclass': 'inner_box'
1136 , 'html': "", 'drag': false
1138 remove_waiting_box();
1140 success_box(xml, txt);
1141 id$(id_div).setStyle({
1142 top:calcy(100 + (layer * 3)) + "px"
1144 ,position:"absolute"
1152 * \param p_value jrn.jr_id
1155function viewOperation(p_value, p_dossier) {
1156 modifyOperation(p_value, p_dossier)
1159function dropLink(p_dossier, p_div, p_jr_id, p_jr_id2) {
1161 "gDossier": p_dossier,
1168 var action = new Ajax.Request('ajax_misc.php',
1171 parameters: querystring,
1179 * this function is called before the querystring is send to the
1180 * fid2.php, add a filter based on the ledger 'p_jrn'
1181 *@param obj is the input field
1182 *@param queryString is the queryString to modify
1185function filter_card(obj, queryString) {
1186 jrn = id$('p_jrn').value;
1188 type = id$('ledger_type').value;
1189 queryString = queryString + '&type=' + type;
1191 queryString = queryString + '&j=' + jrn;
1197 * to display the lettering for the operation, call
1199 *@param obj object attribut : gDossier,j_id,obj_type
1201function dsp_letter(obj) {
1203 //var queryString = 'gDossier=' + obj.gDossier + '&j_id=' + obj.j_id + '&op=dl' + '&ot=' + obj.obj_type+'&start='+obj.start;
1205 var action = new Ajax.Request(
1210 onFailure: error_dsp_letter,
1211 onSuccess: success_dsp_letter
1214 id$('search').style.display = 'none';
1215 id$('list').style.display = 'none';
1216 id$('detail').innerHTML = loading();
1217 id$('detail').style.display = 'block';
1219 alert_box('dsp_letter failed ' + e.message);
1223function success_dsp_letter(req) {
1225 var answer = req.responseXML;
1226 var a = answer.getElementsByTagName('code');
1227 var html = answer.getElementsByTagName('value');
1228 if (a.length == 0) {
1229 var rec = req.responseText;
1230 alert_box('erreur :' + rec);
1232 var name_ctl = a[0].firstChild.nodeValue;
1233 var code_html = getNodeText(html[0]);
1234 code_html = unescape_xml(code_html);
1235 id$('detail').innerHTML = code_html;
1237 alert_box(e.message);
1240 code_html.evalScripts();
1242 alert_box("DSPLETTER1:" + content[48] + e.message);
1247function error_dsp_letter(req) {
1248 alert_box("DSPLETTER2:" + content[48]);
1251function search_letter(obj) {
1254 if (obj.elements['gDossier'])
1255 str_query = 'gDossier=' + obj.elements['gDossier'].value;
1256 if (obj.elements['j_id'])
1257 str_query += '&j_id=' + obj.elements['j_id'].value;
1258 if (obj.elements['obj_type'])
1259 str_query += '&obj_type=' + obj.elements['obj_type'].value;
1260 if (obj.elements['op'])
1261 str_query += '&op=' + obj.elements['op'].value;
1262 if (obj.elements['min_amount'])
1263 str_query += '&min_amount=' + obj.elements['min_amount'].value;
1264 if (obj.elements['max_amount'])
1265 str_query += '&max_amount=' + obj.elements['max_amount'].value;
1266 if (obj.elements['search_start'])
1267 str_query += '&search_start=' + obj.elements['search_start'].value;
1268 if (obj.elements['search_end'])
1269 str_query += '&search_end=' + obj.elements['search_end'].value;
1270 if (obj.elements['side'])
1271 str_query += '&side=' + obj.elements['side'].value;
1274 var action = new Ajax.Request(
1278 parameters: str_query,
1279 onFailure: error_dsp_letter,
1280 onSuccess: success_dsp_letter
1284 id$('search').hide();
1285 id$('detail').innerHTML = loading();
1286 id$('detail').show();
1288 alert_box('search_letter ' + e.message);
1293 * save an operation in ajax, it concerns only the
1294 * comment, the pj and the rapt
1295 * the form elements are access by their name
1298function op_save(obj) {
1300 var queryString = id$(obj).serialize(true);
1301 queryString ["gDossier"] = obj.gDossier.value;
1302 var rapt2 = "rapt" + obj.whatdiv.value;
1303 queryString ["rapt"] = id$(rapt2).value;
1304 queryString ["jr_id"] = obj.jr_id.value;
1305 var jr_id = obj.jr_id.value;
1306 queryString ["div"] = obj.whatdiv.value;
1307 var divid = obj.whatdiv.value;
1308 queryString ["act"] = "save";
1309 queryString ["op"] = "ledger";
1310 queryString ["jr_note"]=encodeURI(tinyMCE.get("jrn_note"+divid).getContent());
1313 * Operation detail is in a new window
1315 if (document.getElementById('inpopup')) {
1316 var action = new Ajax.Request('ajax_misc.php',
1319 parameters: queryString,
1321 onSuccess: function (req) {
1322 remove_waiting_box();
1323 var answer = req.getElementsByTagName('code');
1324 if (answer[0] !== 'OK') {
1325 console.error("D2. op_save")
1326 smoke.alert(req.responseText);
1334 *Operation is in a modal box
1336 var action = new Ajax.Request('ajax_misc.php',
1339 parameters: queryString,
1341 onSuccess: function (req, json) {
1344 if (req.responseXML == null) {
1345 smoke.alert(req.responseText);
1347 new Ajax.Request('ajax_misc.php', {
1349 'gDossier': obj.gDossier.value,
1355 onSuccess: function (xml) {
1357 var answer = xml.responseXML;
1358 var html = answer.getElementsByTagName('code');
1359 id$(divid).innerHTML = unescape(getNodeText(html[0]));
1360 id$(divid).innerHTML.evalScripts();
1361 remove_waiting_box();
1362 noalyss.refresh_note(jr_id,obj.gDossier.value);
1364 console.error("D1. op_save")
1365 alert_box("1038" + e.message)
1375 console.error("F1. op_save")
1376 console.error(e.message)
1377 alert_box("op_save "+e.message);
1382function get_history_account(ctl, dossier) {
1383 if (document.getElementById(ctl).value != '') {
1384 view_history_account(id$(ctl).value, dossier);
1389var let_previous = "";
1391function show_reconcile(p_div, p_let) {
1393 if (previous.length != 0 || p_let == let_previous) {
1394 var count_elt = previous.length;
1396 for (i = 0; i < count_elt; i++) {
1397 previous[i].style.backgroundColor = '';
1398 previous[i].style.color = '';
1399 previous[i].style.fontWeight = "";
1402 var name = 'tr_' + p_let + '_' + p_div;
1403 var elt = document.getElementsByName(name);
1404 if (p_let != let_previous) {
1407 var count_elt = elt.length;
1409 for (i = 0; i < count_elt; i++) {
1410 elt[i].style.backgroundColor = '#000066';
1411 elt[i].style.color = 'white';
1412 elt[i].style.fontWeight = 'bolder';
1415 let_previous = p_let;
1421 alert_box(e.message);
1428 * add a line in the form for the purchase ledger
1430function gestion_add_row() {
1432 style = 'class="input_text"';
1433 var mytable = id$("art").tBodies[0];
1434 var ofirstRow = mytable.rows[1];
1435 var line = mytable.rows.length;
1436 var nCell = mytable.rows[1].cells.length;
1437 var row = mytable.insertRow(line);
1438 var nb = id$("nb_item");
1439 for (var e = 0; e < nCell; e++) {
1440 var newCell = row.insertCell(e);
1441 var tt = ofirstRow.cells[e].innerHTML;
1442 var new_tt = tt.replace(/march0/g, "march" + nb.value);
1443 new_tt = new_tt.replace(/quant0/g, "quant" + nb.value);
1444 new_tt = new_tt.replace(/sold\(0\)/g, "sold(" + nb.value + ")");
1445 new_tt = new_tt.replace(/compute_ledger\(0\)/g, "compute_ledger(" + nb.value + ")");
1446 new_tt = new_tt.replace(/clean_tva\(0\)/g, "clean_tva(" + nb.value + ")");
1447 new_tt = new_tt + '<input type="hidden" id="tva_march' + nb.value + '">';
1448 new_tt = new_tt + '<input type="hidden" id="htva_march' + nb.value + '">';
1449 newCell.innerHTML = new_tt;
1450 if (mytable.rows[1].cells[e].hasClassName("num")) {
1451 newCell.addClassName("num");
1453 new_tt.evalScripts();
1456 id$("e_march" + nb.value + "_label").innerHTML = ' ';
1457 id$("e_march" + nb.value + "_label").value = '';
1458 id$("e_march" + nb.value + "_price").value = '0';
1459 id$("e_march" + nb.value).value = "";
1460 id$("e_quant" + nb.value).value = "1";
1461 id$('tvac_march' + nb.value).value = "0";
1462 if (document.getElementById("e_march" + nb.value + "_tva_amount"))
1463 id$("e_march" + nb.value + "_tva_amount").value = 0;
1467 new_tt.evalScripts();
1469 alert_box(e.message);
1474function document_remove(p_dossier, p_div, p_jrid) {
1475 smoke.confirm(content[50], function (e) {
1477 new Ajax.Request('ajax_misc.php',
1479 parameters: {"op": "ledger", "gDossier": p_dossier, "div": p_div, "p_jrid": p_jrid, 'act': 'rmf'},
1480 onSuccess: function (x) {
1481 id$('receipt' + p_div).innerHTML = x.responseText;
1489 * receive an object and display a list of filter + form to save one
1490 * fill up the span (id : {div}search_filter_span) with the name of the selected filter
1491 * Object = '{'div':'','type':'ALL','all_type':1,'dossier':'10104'}'
1492 * @see Acc_Ledger_Search
1494function manage_search_filter(p_obj) {
1496 new Ajax.Request("ajax_misc.php", {
1499 "op": "display_search_filter",
1500 "gDossier": p_obj.dossier,
1502 "ledger_type": p_obj.ledger_type,
1503 "all_type": p_obj.all_type
1505 onSuccess: function (req) {
1506 remove_waiting_box();
1510 'id': 'boxfilter' + p_obj.div,
1511 'cssclass': 'inner_box2',
1512 'html': req.responseText,
1513 'style': 'top:' + y + 'px;left:' + x + 'px;position:absolute;width:400px',
1516 id$('boxfilter' + p_obj.div).show();
1522 * Send data from the form and record a new filter , the ajax answer is a json object
1523 * with the attribute filter_name,filter_id,status,message
1525 * @param p_div prefix id of all concerned DOM Element
1527 * @see Acc_Ledger_Search
1529function save_filter(p_div, p_dossier) {
1530 var elt = ['ledger_type', 'nb_jrn', 'date_start', 'date_end',
1531 'date_paid_start', 'date_paid_end', 'desc', 'amount_min', 'amount_max', 'qcode', 'accounting',
1532 'operation_filter', 'tag_option', 'p_currency_code', 'tva_id_search'];
1535 eltValue['gDossier'] = p_dossier;
1536 eltValue['op'] = "save_filter";
1537 eltValue['div'] = p_div;
1538 eltValue['filter_name'] = id$(p_div + "filter_new").value;
1539 // Get all elt from the form
1540 for (var i = 0; i < elt.length; i++) {
1542 eltValue[idx] = id$(p_div + elt[i]).value;
1545 if (eltValue['amount_min'] == "") eltValue["amount_min"] = 0;
1546 if (eltValue['amount_max'] == "") eltValue["amount_max"] = 0;
1548 //ledger's list r_jrn
1549 if (eltValue['nb_jrn'] > 0) {
1550 eltValue['r_jrn'] = [];
1551 for (i = 0; i < eltValue['nb_jrn']; i++) {
1552 var idx = p_div + 'r_jrn[' + i + ']';
1553 eltValue['r_jrn' + i] = id$(idx).value
1558 var aTag = Array.from(document.getElementsByName(p_div + "tag[]"));
1559 eltValue["tag[]"] = [];
1560 for (i = 0; i < aTag.length; i++) {
1561 eltValue["tag[]"][i] = aTag[i].value;
1563 new Ajax.Request('ajax_misc.php', {
1565 parameters: eltValue,
1566 onSuccess: function (req) {
1568 var answer = req.responseJSON;
1569 if (answer.status == 'OK') {
1570 /*Add the new list to the selection */
1571 var new_item = document.createElement('li');
1572 new_item.innerHTML = answer.filter_name;
1573 new_item.setAttribute("id", "manageli" + p_div + "_" + answer.filter_id);
1574 id$('manage' + p_div).appendChild(new_item);
1575 id$(p_div + "filter_new").value = "";
1577 throw answer.message;
1587 * Load a search filter and fill up the form search
1588 * @param p_div prefix id of all concerned DOM Element
1590 * @param p_filter_id filter id (SQL user_filter.id)
1591 * @see Acc_Ledger_Search
1593function load_filter(p_div, p_dossier, p_filter_id) {
1594 new Ajax.Request('ajax_misc.php', {
1596 parameters: {"gDossier": p_dossier, "div": p_div, "op": "load_filter", "filter_id": p_filter_id},
1597 onSuccess: function (req) {
1599 var answer = req.responseJSON;
1600 var elt = ['ledger_type', 'date_start', 'date_end', 'date_paid_start', 'date_paid_end',
1601 'desc', 'amount_min', 'amount_max', 'qcode', 'accounting', 'operation_filter', 'tag_option'
1602 , 'p_currency_code', 'tva_id_search'];
1603 for (var i = 0; i < elt.length; i++) {
1605 id$(p_div + idx).value = answer[elt[i]];
1607 // fillup the r_jrn array
1608 var eltLedgerId = id$("ledger_id" + p_div);
1609 eltLedgerId.innerHTML = "";
1610 var eltHidden = document.createElement("input");
1611 eltHidden.setAttribute("name", p_div + "nb_jrn");
1612 eltHidden.setAttribute("type", "hidden");
1613 eltHidden.setAttribute("id", p_div + "nb_jrn");
1614 eltHidden.setAttribute("value", answer.nb_jrn);
1615 eltLedgerId.appendChild(eltHidden);
1617 for (var i = 0; i < answer.nb_jrn; i++) {
1618 // create hidden element and add them into eltLedgerId
1619 var eltHidden = document.createElement("input");
1621 eltHidden.setAttribute("name", p_div + "r_jrn[" + i + "]");
1622 eltHidden.setAttribute("type", "hidden");
1623 eltHidden.setAttribute("id", p_div + "r_jrn[" + i + "]");
1624 eltHidden.setAttribute("value", answer.r_jrn[i]);
1625 eltLedgerId.appendChild(eltHidden);
1627 new Ajax.Request("ajax_misc.php", {
1630 "gDossier": p_dossier, "div": p_div, "op": "display_filter_tag", "filter_id": p_filter_id,
1631 uf_tag: answer.uf_tag
1633 onSuccess: function (req) {
1634 id$(p_div + 'tag_choose_td').update(req.responseText);
1640 smoke.alert(e.message);
1648 * delete a saved search filter from the db, it is limited to the current
1651 identification des elements LI manageli{div}_{filter_id}
1652 identification element UL manage{div}
1653 @parameter p_filter_id SQL user_filter.id
1656function delete_filter(p_div, p_dossier, p_filter_id) {
1657 new Ajax.Request("ajax_misc.php", {
1658 parameters: {"gDossier": p_dossier, "div": p_div, "filter_id": p_filter_id, 'op': "delete_search_operation"},
1660 onSuccess: function (req) {
1662 var answer = req.evalJSON;
1664 var child = id$("manageli" + p_div + "_" + p_filter_id);
1666 id$("manage" + p_div).removeChild(child);
1669 console.log(e.message)
1678 * Reset the search_form and reinitialize all the input but ledger_type
1679 * @param p_div prefix for DOM Element
1681function reset_filter(p_div) {
1682 // clean all the input fields but ledger_type remains
1683 var elt = ['date_start', 'date_end', 'date_paid_start', 'date_paid_end', 'desc', 'amount_min', 'amount_max', 'qcode', 'accounting', 'tva_id_search'];
1684 for (var i = 0; i < elt.length; i++) {
1686 id$(p_div + idx).value = "";
1688 if (document.getElementById(p_div + "date_start_hidden")) {
1689 id$(p_div + "date_start").value = id$(p_div + "date_start_hidden").value;
1691 if (document.getElementById(p_div + "date_end_hidden")) {
1692 id$(p_div + "date_end").value = id$(p_div + "date_end_hidden").value;
1694 // clean all the selected ledger
1695 var eltLedgerId = id$("ledger_id" + p_div);
1696 eltLedgerId.innerHTML = "";
1697 var eltHidden = document.createElement("input");
1698 eltHidden.setAttribute("name", p_div + "nb_jrn");
1699 eltHidden.setAttribute("type", "hidden");
1700 eltHidden.setAttribute("id", p_div + "nb_jrn");
1701 eltHidden.setAttribute("value", 0);
1702 eltLedgerId.appendChild(eltHidden);
1704 // By default , unpaid is uncked
1705 id$(p_div + "operation_filter").value = "all";
1707function display_list_filter(p_dossier,access_code,ledger_type)
1709 new Ajax.Request("ajax_misc.php",{
1710 parameters:{"gDossier":p_dossier
1711 ,"op":"display_list_filter"
1713 ,'ledger_type':ledger_type
1716 onSuccess: function (responseHtml) {
1719 var div = create_div({"id":"display_list_filter_div",
1720 'cssclass': "inner_box2", 'style': 'right:5%;top:'+posy+"px"});
1721 div.update(responseHtml.responseText);
1724 console.error(e.message);
1731 * propose to duplicate an operation
1733function duplicate_operation(p_dossier, p_jr_id) {
1735 var duplicate_div = create_div({id: "duplicate_operation_div", cssclass: "inner_box"});
1737 new Ajax.Request("ajax_misc.php", {
1740 "gDossier": p_dossier,
1742 "act": "duplicateop",
1743 "div": "duplicate_operation_div"
1745 onSuccess: function (req) {
1746 remove_waiting_box();
1747 var xml = req.responseXML;
1749 if (xml.getElementsByTagName("ctl").length == 0) {
1750 console.log("erreur" + req.responseText);
1752 add_div(duplicate_div);
1754 duplicate_div.setStyle({
1755 "position": "fixed", "top": "15%", "z-index": get_next_layer(),
1756 "min-width": "30rem",
1760 duplicate_div.innerHTML = getNodeText(xml.getElementsByTagName("code")[0]);
1761 duplicate_div.setStyle({display: "block"});
1767 * Go to detail of Tax for a specific period , ledger id and tva_id
1770function tax_detail_view (dossier_id,date_from,date_to,nLedger_id,nTva_id)
1774 var dgbox="detail_tax_box";
1777 // For form , most of the parameters are in the FORM
1778 // method is then POST
1779 //var queryString=id$(p_form_id).serialize(true);
1783 act: "tax_detail_view",
1784 gDossier: dossier_id,
1786 date_from:date_from,
1788 ledger_id:nLedger_id,
1791 var action = new Ajax.Request(
1795 parameters:queryString,
1796 onFailure:ajax_misc_failure,
1797 onSuccess:function(req){
1798 remove_waiting_box();
1799 if (req.responseText == 'NOCONX') {
1804 var div_style="position:absolute;"+";top:"+y+"px"+";z-index:"+get_next_layer();
1805 add_div({id:dgbox,cssclass:'inner_box',html:loading(),style:div_style,drag:true});
1806 id$(dgbox).update(req.responseText);
1813 alert_box(e.message);
1817 * For operation_exercice let update periode when changing folder
1818 * @type {{update_periode: operation_exercice.update_periode}}
1820var operation_exercice = {
1821 update_periode: function (dossier_id) {
1825 op: 'operation_exercice+update_periode',
1826 folder: id$('dos_id').value,
1827 gDossier: dossier_id
1829 var action = new Ajax.Request(
1833 parameters: queryString,
1834 onFailure: ajax_misc_failure,
1835 onSuccess: function (req) {
1836 remove_waiting_box();
1837 if (req.responseText == 'NOCONX') {
1842 id$("select_exercice_id").update(req.responseText);
1848 console.error('oe-update_periode', e.message);
1851 modify_row: function (row_operation_exercice, oe_id) {
1853 var dgbox = "operation_exercice_bx";
1856 // For form , most of the parameters are in the FORM
1857 // method is then POST
1858 //var queryString=id$(p_form_id).serialize(true);
1860 op: 'operation_exercice+modify_row',
1862 row_id: row_operation_exercice,
1863 gDossier: id$('gDossier').value
1865 var action = new Ajax.Request(
1869 parameters: queryString,
1870 onFailure: ajax_misc_failure,
1871 onSuccess: function (req) {
1872 remove_waiting_box();
1873 if (req.responseText == 'NOCONX') {
1878 var div_style = "position:absolute;" + ";top:" + y + "px"+";z-index:"+get_next_layer();
1879 add_div({id: dgbox, cssclass: 'inner_box', html: loading(), style: div_style, drag: true});
1880 id$(dgbox).update(req.responseText);
1885 console.error('oe-modify_row', e.message);
1889 * Save data from modify_row
1891 save_row: function () {
1893 var dgbox = "operation_exercice_bx";
1896 // For form , most of the parameters are in the FORM
1897 // method is then POST
1898 //var queryString=id$(p_form_id).serialize(true);
1900 var queryString = id$('operation_exercice_input_row_frm').serialize(true);
1902 var action = new Ajax.Request(
1906 parameters: queryString,
1907 onFailure: ajax_misc_failure,
1908 onSuccess: function (req) {
1909 remove_waiting_box();
1910 if (req.responseText == 'NOCONX') {
1915 if (req.responseJSON['status'] == "OK") {
1916 rowid = req.responseJSON['row_id'];
1917 if (queryString['row_id'] == -1) {
1918 var row = new Element("tr");
1919 row.id = "oe_" + rowid;
1920 row.setAttribute("oed_id", rowid);
1921 row.setAttribute("oe_id", req.responseJSON['oe_id']);
1922 row.update(req.responseJSON['content']);
1923 id$("operation_exercice_tb").appendChild(row);
1924 row.addEventListener("click", function (event) {
1925 operation_exercice.click_modify_row(row)
1929 id$("oe_" + rowid).update(req.responseJSON['content']);
1931 new Effect.Highlight("oe_" + req.responseJSON['row_id'], {
1932 startcolor: '#FAD4D4',
1935 operation_exercice.display_total(rowid)
1936 id$(dgbox).remove();
1940 id$(dgbox).update(req.responseText);
1946 console.error('oe-save_row' + e.message);
1950 * display the balance
1952 display_total: function (row_id) {
1954 var dgbox = "tot_ope_exe";
1956 op: 'operation_exercice+display_total',
1958 gDossier: id$('gDossier').value
1960 var action = new Ajax.Request(
1964 parameters: queryString,
1965 onFailure: ajax_misc_failure,
1966 onSuccess: function (req) {
1967 remove_waiting_box();
1968 if (req.responseText == 'NOCONX') {
1973 id$(dgbox).update(req.responseText);
1979 console.error('oe-display_total' + e.message);
1985 delete_row: function (row_id) {
1988 op: 'operation_exercice+delete_row',
1990 gDossier: id$('gDossier').value
1992 var action = new Ajax.Request(
1996 parameters: queryString,
1997 onFailure: ajax_misc_failure,
1998 onSuccess: function (req) {
1999 remove_waiting_box();
2000 if (req.responseText == 'NOCONX') {
2004 if (req.responseJSON["row_id"] != "") {
2005 operation_exercice.display_total(req.responseJSON["row_id"])
2007 id$('oe_' + queryString['row_id']).remove();
2008 id$('operation_exercice_bx').remove();
2013 alert_box("oe+delete_row", e.message);
2016 click_modify_row: function (item) {
2017 operation_exercice.modify_row(item.getAttribute("oed_id"), item.getAttribute("oe_id"));
2020 * check and transfer if it is good
2022 transfer: function () {
2024 var dgbox = "oe_transfer_div";
2027 var queryString = id$("operation_exercice_transfer_frm").serialize(true);
2028 var action = new Ajax.Request(
2032 parameters: queryString,
2033 onFailure: ajax_misc_failure,
2034 onSuccess: function (req) {
2035 remove_waiting_box();
2036 if (req.responseText == 'NOCONX') {
2040 var answer=req.responseJSON;
2042 id$('operation_exercice_transfer_info').update(answer.content);
2049 alert_box(e.message);
2055var Supplement_Document={
2059 * see ledger_detail_sup_files.php
2060 * $rowid=sprintf("row_js_%s_%s",$div,$item->js_id);
2061 * @param {int} nDossier
2062 * @param {string} sDiv
2063 * @param {int} nJS_ID
2066Supplement_Document.delete_document=function (nDossier,sDiv,nJS_ID,nJR_ID)
2081 var action = new Ajax.Request(
2085 parameters: queryString,
2086 onSuccess: function (req) {
2087 remove_waiting_box();
2088 if (req.responseText == 'NOCONX') {
2092 id$("row_js_"+sDiv+"_"+nJS_ID).remove();
2093 Supplement_Document.refresh_list(nDossier,sDiv,nJR_ID);
2099 alert_box(e.message);
2105Supplement_Document.input_file=function(nDossier,sDiv,nJR_ID)
2109 var dgbox = "sup_doc_input_file"+sDiv;
2120 var action = new Ajax.Request(
2124 parameters: queryString,
2125 onFailure: ajax_misc_failure,
2126 onSuccess: function (req) {
2127 remove_waiting_box();
2128 if (req.responseText == 'NOCONX') {
2133 var div_style = "position:absolute;" + ";top:" + y + "px"+";z-index:"+get_next_layer();
2134 add_div({id: dgbox, cssclass: 'inner_box2', html: loading(), style: div_style, drag: true});
2135 $(dgbox).innerHTML = req.responseText;
2142 alert_box(e.message);
2148 * @param {string} FORM ID
2149 * @returns {Boolean}
2151Supplement_Document.save_file=function(form_dom_id)
2156 var form_data=$(form_dom_id).serialize();
2158 var xhr = new XMLHttpRequest();
2159 var div=id$(form_dom_id).elements["div"].value;
2162 var file_to_upload=id$("doc_sup");
2163 var max_size=id$(form_dom_id).elements["MAX_FILE_SIZE"].value;
2164 var post_max_size=id$(form_dom_id).elements["post_max_size"].value;
2165 var feedback_div=id$('feedback'+div);
2167 for (var e=0;e<file_to_upload.files.length;e++) {
2170 if (file_to_upload.files[e].size > max_size) {
2171 // if size > accepted size , push filename with error in an array feedback,
2172 feedback_div.innerHTML += '<p class="notice">' + file_to_upload.files[e].name
2173 +content[78]+ "</p>";
2174 remove_waiting_box();
2176 } else if ( total_size+file_to_upload.files[e].size >= post_max_size )
2178 feedback_div.innerHTML += '<p > limite '+content[78]+" </p>";
2179 remove_waiting_box();
2183 total_size+=file_to_upload.files[e].size;
2186 feedback_div.innerHTML="loading....";
2187 document.getElementById("progress_upload1b").setAttribute("value", 0);
2189 xhr.upload.onprogress = function (e) {
2190 document.getElementById("progress_upload1b").setAttribute("max", e.total) + "<br/>";
2191 document.getElementById("progress_upload1b").setAttribute("value", e.loaded) + "<br/>";
2195 xhr.onreadystatechange = function (event) {
2196 if (this.readyState == XMLHttpRequest.DONE)
2198 remove_waiting_box();
2200 if (this.status === 200) {
2201 document.getElementById("supplement_div_list"+div).innerHTML += this.responseText ;
2202 let dgbox=id$(form_dom_id).elements["dgbox"].value;
2204 json_form['gDossier']=id$(form_dom_id).elements['gDossier'].value;
2205 json_form['div']=id$(form_dom_id).elements['div'].value;
2206 json_form['jr_id']=id$(form_dom_id).elements['jr_id'].value;
2207 Supplement_Document.refresh_list(json_form["gDossier"],json_form["div"],json_form["jr_id"]);
2210 document.getElementById("supplement_div_list"+div).innerHTML += "status" + this.statusText + "<br/>";
2215 xhr.open("POST", "ajax_misc.php?"+form_data, true);
2216 // works xhr.send(new FormData(input.parentElement));
2217 var formData = new FormData(document.getElementById(form_dom_id));
2221 console.error("Supplement_Document.save_file "+e.message)
2223 remove_waiting_box();
2226Supplement_Document.refresh_list=function (nDossier,sDiv,nJR_id)
2237 var action = new Ajax.Request(
2241 parameters: queryString,
2242 onSuccess: function (req) {
2243 var json=req.responseJSON;
2244 $("supplement_div_list"+sDiv).update(json.html);
2245 id$('doc_supp_'+sDiv).removeClassName("nb-round")
2246 if ( json.count > 0) {
2247 id$('doc_supp_'+sDiv).update(json.count);
2248 id$('doc_supp_'+sDiv).addClassName("nb-round")
2255 console.error(e.message);