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 aName[x].checked = check;
67 aName[x].checked = check;
74 * For each checkbox , add an event on click
75 * @param {string} p_range_name name of the checkbox object
76 * @returns {undefined}
78function activate_checkbox_range(p_range_name) {
79 let node_lstCheckBox = document.getElementsByClassName(p_range_name);
80 var aCheckBox=Array.from(node_lstCheckBox)
81 if (aCheckBox == undefined) {
82 console.error("activate_checkbox_range_failed")
85 aCheckBox.forEach(elt => elt.addEventListener ('click',function (event) {
86 checkbox_set_range(event, elt, p_range_name);
91 * Checkbox for Debit - Credit , from Misc Operation
93function activate_checkbox_side()
95 var aCheckBox=$$('.debit-credit')
96 aCheckBox.forEach((item)=>item.addEventListener('click',function (event) {
97 display_range_dcside(event,item);
101 aCheckBox.forEach((item)=>display_dcside(item))
105 * Update the range of checkbox in Misc Operation
106 * @see Acc_Ledger::input
107 * @param item checkbox to change
110function display_range_dcside(evt,item)
116 var p_name='debit-credit'
117 var aName = document.getElementsByClassName(p_name);
121 for (var i = 0; i < aName.length; i++) {
122 if (aName[i] == item) {
126 if (aName[i] == lastcheck) {
135 var check = (aName[from].checked) ? true : false;
136 for (x = from; x <= end; x++) {
137 aName[x].checked = check;
138 display_dcside(aName[x]);
144 * Update the SPAN for the range , id based on checkbox id (txtck0), if checked , display Debit otherwise Credit
147function display_dcside(item)
149 if (item.checked == true) {
150 $('txt'+item.id).update("Débit")
152 $('txt'+item.id).update("Crédit")