[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 28/29: Task #0001861: Plage de cases à cocher
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 28/29: Task #0001861: Plage de cases à cocher |
Date: |
Wed, 4 Nov 2020 11:08:47 -0500 (EST) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 5b75b8127a1e70e876c9ea4db752667922e3f37c
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Nov 4 17:06:53 2020 +0100
Task #0001861: Plage de cases à cocher
---
html/js/card.js | 3 ++
html/js/noalyss_checkbox.js | 84 +++++++++++++++++++++++++++++++
html/js/scripts.js | 2 +-
include/ajax/ajax_add_concerned_card.php | 3 +-
include/class/acc_ledger_search.class.php | 1 +
include/class/anc_grandlivre.class.php | 2 +
include/class/follow_up.class.php | 4 +-
include/compta_fin_rec.inc.php | 45 ++++++++++++++++-
include/history_operation.inc.php | 6 ++-
include/lib/function_javascript.php | 1 +
include/lib/icheckbox.class.php | 29 +++++++++--
include/template/fiche_list.php | 9 +++-
scenario/HtmlInput.test.php | 41 ++++++++++++++-
13 files changed, 218 insertions(+), 12 deletions(-)
diff --git a/html/js/card.js b/html/js/card.js
index 3e9c112..aba3058 100644
--- a/html/js/card.js
+++ b/html/js/card.js
@@ -161,6 +161,8 @@ function action_concerned_save_card(obj)
code_html = unescape_xml(code_html);
$(namectl).update(code_html);
removeDiv('search_card');
+
+
}
});
} catch (e)
@@ -277,6 +279,7 @@ function action_concerned_search_card(obj)
if ( ! $('search_card')) { add_div({id: 'search_card',
cssclass: 'inner_box', html: "", style: div_style, drag: true}); }
$('search_card').innerHTML = code_html;
$('query').focus();
+ activate_checkbox_range('select_card_ck');
}catch (e) {
alert_box(e.message);
}
diff --git a/html/js/noalyss_checkbox.js b/html/js/noalyss_checkbox.js
new file mode 100644
index 0000000..04c44b2
--- /dev/null
+++ b/html/js/noalyss_checkbox.js
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2020 Dany De Bontridder <dany@alchimerys.be>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/**
+ *
+ * @param {event} evt event
+ * @param {object} elt checkbox elt
+ * @param {string} p_name name of the checkbox object
+
+ * @returns {undefined}
+ */
+
+var lastcheck = null;
+var endcheck = null;
+
+/**
+ * Check or uncheck checkbox if shift key is pressed and between the last
checked elemet and the current one
+ * @param {type} evt event
+ * @param {type} elt Dom element
+ * @param {type} p_name name of range
+ */
+function checkbox_set_range(evt, elt, p_name) {
+ if (!evt.shiftKey) {
+ lastcheck = elt;
+ return;
+ }
+ var aName = document.getElementsByClassName(p_name);
+
+ var from = 0;
+ var end = 0;
+ for (var i = 0; i < aName.length; i++) {
+ if (aName[i] == elt) {
+ endcheck = aName[i];
+ from = i;
+ }
+ if (aName[i] == lastcheck) {
+ end = i;
+ }
+ }
+ if (from > end) {
+ let a = from;
+ from = end;
+ end = a;
+ }
+ var check = (aName[from].checked) ? true : false;
+ for (x = from; x <= end; x++) {
+ aName[x].checked = check;
+ }
+}
+
+
+/**
+ * For each checkbox , add an event on click
+ * @param {string} p_range_name name of the checkbox object
+ * @returns {undefined}
+ */
+function activate_checkbox_range(p_range_name) {
+ let node_lstCheckBox = document.getElementsByClassName(p_range_name);
+ var aCheckBox=Array.from(node_lstCheckBox)
+ if (aCheckBox == undefined) {
+ console.error("activate_checkbox_range_failed")
+ }
+
+ aCheckBox.forEach(elt => elt.addEventListener ('click',function (event) {
+ checkbox_set_range(event, elt, p_range_name);
+ },false));
+}
+;
+
+
diff --git a/html/js/scripts.js b/html/js/scripts.js
index a13ab26..25307b8 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -3803,4 +3803,4 @@ function json_concat(p_json1,p_json2)
}
return result;
-}
\ No newline at end of file
+}
diff --git a/include/ajax/ajax_add_concerned_card.php
b/include/ajax/ajax_add_concerned_card.php
index 9187a70..bda4c60 100644
--- a/include/ajax/ajax_add_concerned_card.php
+++ b/include/ajax/ajax_add_concerned_card.php
@@ -120,6 +120,7 @@ for ($i=0; $i<count($a); $i++)
{
$ic=new ICheckBox("selected_card[]");
$ic->value=$a[$i]['f_id'];
+ $ic->set_range("select_card_ck");
$array[$i]['checkbox']=$ic->input();
$array[$i]['quick_code']=$a[$i]['quick_code'];
$array[$i]['name']=h($a[$i]['vw_name']);
@@ -141,8 +142,6 @@ echo HtmlInput::button_close("search_card");
echo '</li>';
echo '</ul>';
echo '</form>';
-
-
$response=ob_get_contents();
ob_end_clean();
diff --git a/include/class/acc_ledger_search.class.php
b/include/class/acc_ledger_search.class.php
index ae2a6e8..801e98b 100644
--- a/include/class/acc_ledger_search.class.php
+++ b/include/class/acc_ledger_search.class.php
@@ -897,6 +897,7 @@ class Acc_Ledger_Search
if ($p_paid!=0)
{
$w=new ICheckBox();
+ $w->set_range("paid_operation_ck");
$w->name="rd_paid".$row['jr_id'];
$w->selected=($row['jr_rapt']=='paid')?true:false;
// if p_paid == 2 then readonly
diff --git a/include/class/anc_grandlivre.class.php
b/include/class/anc_grandlivre.class.php
index 2965087..d8d7991 100644
--- a/include/class/anc_grandlivre.class.php
+++ b/include/class/anc_grandlivre.class.php
@@ -272,6 +272,7 @@ class Anc_GrandLivre extends Anc_Print
if ($str_document != "")
{
$ck = new ICheckBox('ck[]', $row['jr_id']);
+ $ck->set_range("document_export_ck");
$str_ck = $ck->input();
}
}
@@ -298,6 +299,7 @@ class Anc_GrandLivre extends Anc_Print
$r.=td('') . td('') . td('') . td('') . td('') . td(nbm($tot_deb), '
class="num"') . td(nbm($tot_cred), ' class="num"') . td(nbm($tot_solde) .
$sign, ' class="num"');
$r.= '</table>';
+ $r.=ICheckBox::javascript_set_range("document_export_ck");
return $r;
}
/*!
diff --git a/include/class/follow_up.class.php
b/include/class/follow_up.class.php
index 4cbd133..0ad9fdc 100644
--- a/include/class/follow_up.class.php
+++ b/include/class/follow_up.class.php
@@ -692,6 +692,7 @@ class Follow_Up
$today=date('d.m.Y');
$i=0;
$checkbox=new ICheckBox("mag_id[]");
+ $checkbox->set_range("action_followup_ck");
//show the sub_action
foreach ($a_row as $row)
{
@@ -762,6 +763,7 @@ class Follow_Up
$r.="</table>";
$r.='<p>'.$bar.'</p>';
+ $r.=ICheckBox::javascript_set_range("action_followup_ck");
return $r;
}
@@ -1928,7 +1930,7 @@ class Follow_Up
{
$showAction='<a class="line"
href="'.$base."&ag_id=".$action[$o]['aga_greatest'].'">';
echo '<li '.$class.'
>'.$margin.$showAction.$action[$o]['str_date']." ".
-
h($action[$o]['sub_title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
"
+
h($action[$o]['title']).'('.h($action[$o]['action_ref']).')'.$direct_parent.'</a>'."
"
.'</li>';
}
}
diff --git a/include/compta_fin_rec.inc.php b/include/compta_fin_rec.inc.php
index 7ca464e..8b53fa8 100644
--- a/include/compta_fin_rec.inc.php
+++ b/include/compta_fin_rec.inc.php
@@ -32,7 +32,43 @@ require_once
NOALYSS_INCLUDE.'/class/acc_ledger_fin.class.php';
bcscale(2);
?>
<script>
+ function checkbox_set_range(evt, elt, p_name) {
+ if (!evt.shiftKey) {
+ lastcheck = elt;
+ return;
+ }
+ var aName = document.getElementsByClassName(p_name);
+
+ var from = 0;
+ var end = 0;
+ for (var i = 0; i < aName.length; i++) {
+ if (aName[i] == elt) {
+ endcheck = aName[i];
+ from = i;
+ }
+ if (aName[i] == lastcheck) {
+ end = i;
+ }
+ }
+ if (from > end) {
+ let a = from;
+ from = end;
+ end = a;
+ }
+ var check = (aName[from].checked) ? true : false;
+ for (x = from; x <= end; x++) {
+ aName[x].checked = check;
+ if( x < end && x > from ) {
+
update_selected(aName[x],aName[x].getAttribute('amount_operation'));
+
update_remain(aName[x],aName[x].getAttribute('amount_operation'));
+ }
+ }
+ }
+
+
function update_selected(p_node,p_amount) {
+ p_amount=parseFloat(p_amount);
+ console.log("update_selected"+p_amount);
try {
if (p_node.checked )
{
@@ -48,6 +84,7 @@ bcscale(2);
}
}
function update_remain(p_node,p_amount) {
+ p_amount=parseFloat(p_amount);
try {
if ( parseFloat($('delta_amount').innerHTML) == 0) return;
if (p_node.checked )
@@ -239,7 +276,7 @@ $r.=th('N° interne');
$r.=th('Montant', ' style="text-align:right"');
$r.=th('Selection', ' style="text-align:center" ');
echo tr($r);
-$iradio = new ICheckBox('op[]');
+
$tot_not_reconcilied = 0;
$diff = 0;
$delta=bcsub($end_extrait,$start_extrait);
@@ -247,6 +284,8 @@ $selected_amount=0;
$remain_amount=$delta;
for ($i = 0; $i < count($operation); $i++)
{
+ $iradio = new ICheckBox('op[]');
+ $iradio->set_range("operation_ck");
$row = $operation[$i];
$r = '';
$js = HtmlInput::detail_op($row['jr_id'], $row['jr_internal']);
@@ -254,12 +293,13 @@ for ($i = 0; $i < count($operation); $i++)
$r.=td($row['jr_comment']);
$r.=td($js);
$amount=$cn->get_value('select qf_amount from quant_fin where
jr_id=$1', array($row['jr_id']));
- $r.='<td class="num" class="sorttable_numeric"
sorttable_customkey="'.$amount.'" style="text-align:right">'.nbm
($amount).'</td>';
+ $r.='<td class="num" class="sorttable_numeric"
sorttable_customkey="'.$amount.'" style="text-align:right">'.nbm
($amount).'</td>';
$diff=bcadd($diff,$amount);
$tot_not_reconcilied+=$row['jr_montant'];
$iradio->value = $row['jr_id'];
$iradio->selected=false;
+ $iradio->set_attribute("amount_operation", $amount);
$iradio->javascript=sprintf(' onchange =
"update_selected(this,%s);update_remain(this,%s)"',$amount,$amount);
if (isset($_POST['op']))
{
@@ -281,6 +321,7 @@ for ($i = 0; $i < count($operation); $i++)
echo tr($r,' class="even" ');
}
echo '</table>';
+if ( $i>0) { echo $iradio->javascript_set_range("operation_ck"); }
$bk_card = new Fiche($cn);
$bk_card->id = $Ledger->get_bank();
$filter_year = " j_tech_per in (select p_id from parm_periode where
p_exercice='" . $g_user->get_exercice() . "')";
diff --git a/include/history_operation.inc.php
b/include/history_operation.inc.php
index da5aefc..5e7aac3 100644
--- a/include/history_operation.inc.php
+++ b/include/history_operation.inc.php
@@ -127,6 +127,8 @@ echo HtmlInput::hidden('ledger_type',$ledger_type);
echo dossier::hidden();
list($count, $html) = $Ledger->list_operation($sql, $offset, $ask_pay);
+
+
echo $html;
echo $bar;
$r = HtmlInput::get_to_hidden(array('search_opnb_jrn',
@@ -162,8 +164,10 @@ if (isset($_GET['search_opr_jrn']))
}
echo $r;
-if ($ask_pay)
+if ($ask_pay) {
echo '<p>' . HtmlInput::submit('paid', _('Mise à jour paiement')) .
IButton::select_checkbox('fpaida') . IButton::unselect_checkbox('fpaida') .
'</p>';
+ echo ICheckBox::javascript_set_range("paid_operation_ck");
+}
echo '</form>';
/*
diff --git a/include/lib/function_javascript.php
b/include/lib/function_javascript.php
index b34b68c..846adcd 100644
--- a/include/lib/function_javascript.php
+++ b/include/lib/function_javascript.php
@@ -2783,6 +2783,7 @@ function load_all_script()
echo js_include('nicEdit.js');
echo js_include('managetable.js');
echo js_include('taggroup.js');
+ echo js_include('noalyss_checkbox.js');
}
diff --git a/include/lib/icheckbox.class.php b/include/lib/icheckbox.class.php
index 13177dc..b934bed 100644
--- a/include/lib/icheckbox.class.php
+++ b/include/lib/icheckbox.class.php
@@ -25,6 +25,20 @@
require_once NOALYSS_INCLUDE.'/lib/html_input.class.php';
class ICheckBox extends HtmlInput
{
+ var $range;
+
+ function __construct($p_name="", $p_value="", $p_id="")
+ {
+ parent::__construct($p_name, $p_value, $p_id);
+ $this->range="";
+ }
+
+ function get_range($p_name) {
+ return $this->range;
+ }
+ function set_range($p_name) {
+ $this->range=' class="'.$p_name.'" ';
+ }
/*!\brief show the html input of the widget*/
public function input($p_name=null,$p_value=null,$id="")
{
@@ -36,6 +50,7 @@ class ICheckBox extends HtmlInput
$check=( $this->selected==true )?"checked":"unchecked";
$r='<input type="CHECKBOX" id="'.$this->id.'"
name="'.$this->name.'"'.' value="'.$this->value.'"';
$r.=" $check";
+ $r.= $this->range;
$r.=$this->get_node_attribute();
$r.=' '.$this->disabled." ".$this->javascript.'>';
@@ -69,7 +84,15 @@ class ICheckBox extends HtmlInput
$a->javascript='onclick="toggle_checkbox(\''.$p_form.'\')"';
return $a->input();
}
- static public function test_me()
- {
+ /**
+ * Before calling this function , you must set a range with the function
set_range. It will add the event on
+ * click (checkbox_set_range)
+ *
+ * @param string $p_name
+ * @returns javascript to execute string
+ */
+ static function javascript_set_range($p_name) {
+ $js=sprintf("(function () {activate_checkbox_range('%s');})();",$p_name);
+ return create_script($js);
}
-}
+}
\ No newline at end of file
diff --git a/include/template/fiche_list.php b/include/template/fiche_list.php
index 9282b22..e825636 100644
--- a/include/template/fiche_list.php
+++ b/include/template/fiche_list.php
@@ -73,7 +73,10 @@
if ($write == 1)
{
$ck = new ICheckBox('f_id[]',
$row['f_id']);
- echo $ck->input();
+ if ( $allcard != 1 ) {
+
$ck->set_range("range".$p_cat);
+ }
+ echo $ck->input();
}
?>
</td>
@@ -83,6 +86,10 @@
</table>
<?php echo $str_add_card?>
+<?php
+if ( $allcard != 1 ) { echo ICheckBox::javascript_set_range("range".$p_cat); }
+
+?>
<?php echo HtmlInput::hidden('action',"1");?>
<?php echo HtmlInput::hidden('delete',"0");?>
<?php echo HtmlInput::hidden('move',"0");?>
diff --git a/scenario/HtmlInput.test.php b/scenario/HtmlInput.test.php
index 363a8fd..794771e 100644
--- a/scenario/HtmlInput.test.php
+++ b/scenario/HtmlInput.test.php
@@ -47,9 +47,11 @@ require_once NOALYSS_INCLUDE.'/lib/itext.class.php';
require_once NOALYSS_INCLUDE.'/lib/itextarea.class.php';
require_once NOALYSS_INCLUDE.'/lib/itva_popup.class.php';
require_once NOALYSS_INCLUDE.'/lib/input_switch.class.php';
+require_once NOALYSS_INCLUDE.'/lib/input_checkbox.class.php';
$http=new HttpInput();
?>
+<script src="js/noalyss_checkbox.js"></script>
<pre>
<?php var_dump($_GET);?>
</pre>
@@ -67,6 +69,7 @@ $http=new HttpInput();
<?php
$input_switch=new
InputSwitch('input_switch_value',$http->get("input_switch_value","string","0"));
+
echo $input_switch->input();
?>
<h2>ReadOnly</h2>
@@ -81,6 +84,20 @@ $http=new HttpInput();
$input_switch->readOnly=TRUE;
echo $input_switch->input();
?>
+ <h2>InputCheckBox (Check Box)</h2>
+ <ul>
+
+
+ <?php
+ for ($i = 0 ; $i < 10 ; $i ++) :
+ echo '<li>';
+ $check[$i]=new InputCheckBox("check[]",1,"checkid".$i);
+ echo $i, " - name = ",$check[$i]->value_container,",id = " ,
$check[$i]->id_icon,$check[$i]->input();
+ echo '</li>';
+ endfor;
+ ?>
+ </ul>
+
<h1>Submit</h1>
<pre>
echo HtmlInput::submit("submit", _("Envoi"));
@@ -88,4 +105,26 @@ $http=new HttpInput();
<p>
<?php echo HtmlInput::submit("submit", _("Envoi"));?>
</p>
-</form>
\ No newline at end of file
+ <h2>ICheckBox</h2>
+ <p>
+ For using range all the checkbox must have the same name , like
checkbox[]
+ </p>
+ <ol>
+ <?php
+
+ for ($i=0;$i<10;$i++) {
+ $icheckbox=new ICheckBox('icheckbox[]',0);
+ $icheckbox->id=uniqid();
+ $icheckbox->set_range("icheckbox11");
+ echo '<li>';
+ printf ("%s ".$icheckbox->input(),$i);
+ echo '</li>';
+
+ }
+ echo ICheckBox::javascript_set_range("icheckbox11");
+ ?>
+ </ol>
+</form>
+<div id="debug_box"></div>
+
+
\ No newline at end of file
- [Noalyss-commit] [noalyss] 20/29: Cosmetic Admin List Folders : add close button, (continued)
- [Noalyss-commit] [noalyss] 20/29: Cosmetic Admin List Folders : add close button, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 02/29: Sort by earliest one, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 07/29: 0001827: Delta des opérations liées basé sur le montant d'une seule opération, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 09/29: Adapt for Textarea, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 04/29: Followup : change moyenne par normale, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 08/29: FollowUp commentaire unique et modifiable, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 18/29: Follow UP detail do not show the "Add Rows button" in READ mode, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 23/29: Cosmetic : ledger name, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 24/29: Contact : navigation bar was not correct, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 29/29: Merge branch 'checkbox-range', Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 28/29: Task #0001861: Plage de cases à cocher,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 12/29: Suivi : description modifiable, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 15/29: Document_State : rewriting, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 17/29: Security For document_state and tag_group, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 14/29: cosmetic : set the total and compute button outside of the frame, Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 26/29: Cosmetic : add waiting box when searching by card category for Management customer, supplier, ..., Dany De Bontridder, 2020/11/04
- [Noalyss-commit] [noalyss] 27/29: code : fix deprecated unparenthized (a)?b:c?e:x, Dany De Bontridder, 2020/11/04