noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
operation_payment.js
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 dany
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program 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.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19
20///////////////////////////////////////////////////////////////////////
21// Operation payement
22// Selection on operation history : payment
23var Operation_Payment = function (range_name, dossier_id, ac) {
24 this.lastcheck = null;
25 this.endcheck = null;
26 this.range_name = range_name;
27 this.dossier_id = dossier_id;
28 this.ac = ac;
29};
30
31Operation_Payment.prototype.activate_checkbox_range = function () {
32 let node_lstCheckBox = document.getElementsByClassName(this.range_name);
33 var aCheckBox = Array.from(node_lstCheckBox)
34 if (aCheckBox == undefined) {
35 console.error("activate_checkbox_range_failed")
36 }
37 var here = this;
38 aCheckBox.forEach(elt => elt.addEventListener('click', function (event) {
39 here.checkbox_set_range(event, elt);
40 }, false));
41};
42
43Operation_Payment.prototype.checkbox_set_range = function (event, elt)
44{
45
46 if (!event.shiftKey) {
47 this.lastcheck = elt;
48 return;
49 }
50 waiting_box();
51 var aName = document.getElementsByClassName(this.range_name);
52
53 var from = 0;
54 var end = 0;
55 for (var i = 0; i < aName.length; i++) {
56 if (aName[i] == elt) {
57 this.endcheck = aName[i];
58 from = i;
59 }
60 if (aName[i] == this.lastcheck) {
61 end = i;
62 }
63 }
64 if (from > end) {
65 let a = from;
66 from = end;
67 end = a;
68 }
69 var check = (aName[from].checked) ? true : false;
70 for (x = from + 1; x < end; x++) {
71 if (aName[x].parentNode.parentNode.visible()) {
72 aName[x].checked=check;
73 this.check_item(aName[x],true)
74 }
75 }
76 remove_waiting_box();
77};
78
79Operation_Payment.prototype.check_item = function (dom_elt,flag_waiting_box)
80{
81 console.debug(`element = ${dom_elt.name}`);
82 console.debug(`dossier ${this.dossier_id} ac ${this.ac}`)
83 try
84 {
85 if ( ! flag_waiting_box ) waiting_box();
86 var queryString = {op:'payment_status',operation_id:dom_elt.name,gDossier:this.dossier_id,ac:this.ac,state:dom_elt.checked};
87 console.debug (`queryString : `)
88 console.debug (queryString)
89
90 var action = new Ajax.Request(
91 "ajax_misc.php",
92 {
93 method: 'POST',
94 parameters: queryString,
95 onFailure: ajax_misc_failure,
96 onSuccess: function (req) {
97 if ( ! flag_waiting_box )remove_waiting_box();
98 if (req.responseText == 'NOCONX') {
99 reconnect();
100 return;
101 }
102 if ( req.responseText == 1) { dom_elt.checked=true}
103 else
104 if ( req.responseText == 0) { dom_elt.checked=false}
105 else {
106 console.error(req.responseText)
107 }
108
109 }
110 }
111 );
112 } catch (e)
113 {
114 alert_box(e.message);
115 }
116
117};
118//Operation_Payment.prototype.check_all=function()
119//{
120// var aName = document.getElementsByClassName(this.range_name);
121// for (x = 0; x < aName.lenght; x++) {
122// if (aName[x].parentNode.parentNode.visible()) {
123// aName[x].checked=true;
124// this.check_item(aName[x]);
125// }
126// }
127//
128//}
129//Operation_Payment.prototype.invert_selection=function()
130//{
131// var aName = document.getElementsByClassName(this.range_name);
132// for (x = 0; x < aName.lenght; x++) {
133// if (aName[x].parentNode.parentNode.visible()) {
134// if ( aName[x].checked ) {
135// aName[x].checked=false;
136// } else {
137// aName[x].checked=true;
138// }
139// this.check_item(aName[x]);
140// }
141// }
142//
143//}
144