2 * Copyright (C) 2020 Dany De Bontridder <dany@alchimerys.be>
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.
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.
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.
20 * @param {event} evt event
21 * @param {object} elt checkbox elt
22 * @param {string} p_name name of the checkbox object
24 * @returns {undefined}
31 * Check or uncheck checkbox if shift key is pressed and between the last checked elemet and the current one
32 * @param {type} evt event
33 * @param {type} elt Dom element
34 * @param {type} p_name name of range
36function checkbox_set_range(evt, elt, p_name) {
41 var aName = document.getElementsByClassName(p_name);
45 for (var i = 0; i < aName.length; i++) {
46 if (aName[i] == elt) {
50 if (aName[i] == lastcheck) {
59 var check = (aName[from].checked) ? true : false;
60 for (x = from; x <= end; x++) {
61 if (aName[x].parentNode.parentNode )
63 if ( window.getComputedStyle(aName[x].parentNode.parentNode).display != "none" ) {
64 /* console.debug(window.getComputedStyle(aName[x].parentNode.parentNode).display);*/
65 aName[x].checked = check;
68 aName[x].checked = check;
75 * For each checkbox , add an event on click
76 * @param {string} p_range_name name of the checkbox object
77 * @returns {undefined}
79function activate_checkbox_range(p_range_name) {
80 let node_lstCheckBox = document.getElementsByClassName(p_range_name);
81 var aCheckBox=Array.from(node_lstCheckBox)
82 if (aCheckBox == undefined) {
83 console.error("activate_checkbox_range_failed")
86 aCheckBox.forEach(elt => elt.addEventListener ('click',function (event) {
87 checkbox_set_range(event, elt, p_range_name);
92 * Checkbox for Debit - Credit , from Misc Operation
94function activate_checkbox_side()
96 var aCheckBox=$$('.debit-credit')
97 aCheckBox.forEach((item)=>item.addEventListener('click',function (event) {
98 display_range_dcside(event,item);
102 aCheckBox.forEach((item)=>display_dcside(item))
106 * Update the range of checkbox in Misc Operation
107 * @see Acc_Ledger::input
108 * @param item checkbox to change
111function display_range_dcside(evt,item)
117 var p_name='debit-credit'
118 var aName = document.getElementsByClassName(p_name);
122 for (var i = 0; i < aName.length; i++) {
123 if (aName[i] == item) {
127 if (aName[i] == lastcheck) {
136 var check = (aName[from].checked) ? true : false;
137 for (x = from; x <= end; x++) {
138 aName[x].checked = check;
139 display_dcside(aName[x]);
145 * Update the SPAN for the range , id based on checkbox id (txtck0), if checked , display Debit otherwise Credit
148function display_dcside(item)
150 if (item.checked == true) {
151 $('txt'+item.id).update("Débit")
153 $('txt'+item.id).update("Crédit")