Merge branch 'checkbox-range'
* checkbox-range: Task #0001861: Plage de cases à cocher
This commit is contained in:
commit
fdf9df4db2
13 changed files with 218 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
84
html/js/noalyss_checkbox.js
Normal file
84
html/js/noalyss_checkbox.js
Normal file
|
|
@ -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));
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
|
|
@ -3803,4 +3803,4 @@ function json_concat(p_json1,p_json2)
|
|||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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>';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() . "')";
|
||||
|
|
|
|||
|
|
@ -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>';
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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");?>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
<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>
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue