NEW Add a checkbox to select/unselect all lines on page that support

mass actions (like invoice list page)
This commit is contained in:
Laurent Destailleur 2016-02-07 19:55:41 +01:00
parent 786f16de02
commit 81aae30253
5 changed files with 40 additions and 20 deletions

View File

@ -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";

View File

@ -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";

View File

@ -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;
}
}

View File

@ -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 */

View File

@ -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 */