From 81aae30253ff494a4f38624238845fc632f28564 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 7 Feb 2016 19:55:41 +0100 Subject: [PATCH] NEW Add a checkbox to select/unselect all lines on page that support mass actions (like invoice list page) --- htdocs/compta/facture/list.php | 4 ++-- htdocs/compta/facture/mergepdftool.php | 10 +------- htdocs/core/class/html.form.class.php | 33 ++++++++++++++++++++------ htdocs/theme/eldy/style.css.php | 8 +++++-- htdocs/theme/md/style.css.php | 5 ++++ 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 1c32462b884..1b81c3cda50 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -783,8 +783,8 @@ if ($resql) $liststatus=array('0'=>$langs->trans("BillShortStatusDraft"), '1'=>$langs->trans("BillShortStatusNotPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); print $form->selectarray('search_status', $liststatus, $search_status, 1); print '</td>'; - print '<td class="liste_titre" align="right">'; - $searchpitco=$form->showFilterAndCheckAddButtons(0); + print '<td class="liste_titre" align="center">'; + $searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1); print $searchpitco; print '</td>'; print "</tr>\n"; diff --git a/htdocs/compta/facture/mergepdftool.php b/htdocs/compta/facture/mergepdftool.php index 19c1d083018..27325bdef1d 100644 --- a/htdocs/compta/facture/mergepdftool.php +++ b/htdocs/compta/facture/mergepdftool.php @@ -848,16 +848,8 @@ if ($resql) print $form->selectarray('filtre', $liststatus, $filter, 1); print '</td>'; print '<td class="liste_titre" align="center">'; - $searchpitco=$form->showFilterAndCheckAddButtons(0); + $searchpitco=$form->showFilterAndCheckAddButtons(1, empty($mode)?'checkformerge':'checkforsend'); print $searchpitco; - if (empty($mode)) - { - if ($conf->use_javascript_ajax) print '<a href="#" id="checkall">'.$langs->trans("All").'</a> / <a href="#" id="checknone">'.$langs->trans("None").'</a>'; - } - else - { - if ($conf->use_javascript_ajax) print '<a href="#" id="checkallsend">'.$langs->trans("All").'</a> / <a href="#" id="checknonesend">'.$langs->trans("None").'</a>'; - } print '</td>'; print "</tr>\n"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ca4d9550bcb..633ff76117c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -508,7 +508,6 @@ class Form $ret.='<!-- JS CODE TO ENABLE mass action select --> <script type="text/javascript"> - jQuery(document).ready(function () { function initCheckForSelect() { atleastoneselected=0; @@ -526,6 +525,8 @@ class Form jQuery(".massaction").hide(); } } + + jQuery(document).ready(function () { initCheckForSelect(); jQuery(".checkforselect").click(function() { initCheckForSelect(); @@ -5679,20 +5680,38 @@ class Form /** * Return HTML to show the search and clear seach button * - * @param int $addcheckuncheckall Add the check all uncheck al button + * @param int $addcheckuncheckall Add the check all uncheck al button + * @param string $cssclass CSS class + * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes * @return string */ - function showFilterAndCheckAddButtons($addcheckuncheckall=0) + function showFilterAndCheckAddButtons($addcheckuncheckall=0, $cssclass='checkforaction', $calljsfunction=0) { - global $langs; - + global $conf, $langs; + $out=''; $out.='<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; + $out.='<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; if ($addcheckuncheckall) { - + if (! empty($conf->use_javascript_ajax)) $out.='<input type="checkbox" id="checkallactions" name="checkallactions" class="checkallactions">'; } - $out.='<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">'; + $out.='<script type="text/javascript"> + $(document).ready(function() { + $("#checkallactions").click(function() { + if($(this).is(\':checked\')){ + console.log("We check all"); + $(".'.$cssclass.'").prop(\'checked\', true); + } + else + { + console.log("We uncheck all"); + $(".'.$cssclass.'").prop(\'checked\', false); + }'; + if ($calljsfunction) $out.='initCheckForSelect();'; + $out.=' }); + }); + </script>'; return $out; } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 30f97b557d4..4f1e049ba65 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -263,7 +263,7 @@ input, input.flat, textarea, textarea.flat, form.flat select, select, select.fla font-size: <?php print $fontsize ?>px; font-family: <?php print $fontlist ?>; background: #FFF; - color: #111; + /* color: #111; */ border: 1px solid #C0C0C0; margin: 0px 0px 0px 0px; } @@ -515,7 +515,11 @@ div.myavailability { padding-top: 4px; padding-bottom: 4px; } - +.checkallactions { + vertical-align: top; + margin-top: 6px; + margin-left: 4px; +} /* ============================================================================== */ /* Styles to hide objects */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 02896756c64..b60c3c5be06 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -503,6 +503,11 @@ div.myavailability { padding-top: 4px; padding-bottom: 4px; } +.checkallactions { + vertical-align: top; + margin-top: 6px; + margin-left: 4px; +} /* ============================================================================== */ /* Styles to hide objects */ -- GitLab