NEW|New [Bulk delete Project tasks]

Massaction to delete multiple tasks from tab Taks of Project
This commit is contained in:
Milen Karaganski 2022-12-07 13:49:54 +02:00
parent 291cb1908d
commit 3f2367dc16
2 changed files with 46 additions and 3 deletions

View File

@ -569,9 +569,10 @@ function project_admin_prepare_head()
* @param string $filterprogresscalc filter text
* @param string $showbilltime Add the column 'TimeToBill' and 'TimeBilled'
* @param array $arrayfields Array with displayed coloumn information
* @param array $arrayofselected Array with selected fields
* @return int Nb of tasks shown
*/
function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc = '', $showbilltime = 0, $arrayfields = array())
function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole, $projectsListId = '', $addordertick = 0, $projectidfortotallink = 0, $filterprogresscalc = '', $showbilltime = 0, $arrayfields = array(), $arrayofselected = array())
{
global $user, $langs, $conf, $db, $hookmanager;
global $projectstatic, $taskstatic, $extrafields;
@ -910,6 +911,16 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
// Tick to drag and drop
print '<td class="tdlineupdown center"></td>';
// Action column
print '<td class="nowrap" align="center">';
$selected = 0;
if (in_array($lines[$i]->id, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb' . $lines[$i]->id . '" class="flat checkforselect" type="checkbox" name="toselect[]" value="' . $lines[$i]->id . '"' . ($selected ? ' checked="checked"' : '') . '>';
print '</td>';
print "</tr>\n";
if (!$showlineingray) {

View File

@ -183,6 +183,14 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
* Actions
*/
if (GETPOST('cancel', 'alpha')) {
$action = 'list';
$massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array('id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) {
@ -413,6 +421,7 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("", $title, $help_url);
$arrayofselected = is_array($toselect) ? $toselect : array();
if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref);
@ -544,6 +553,17 @@ if ($id > 0 || !empty($ref)) {
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
$arrayofmassactions = array(
'clone'=>img_picto('', 'rightarrow', 'class="pictofixedwidth"').$langs->trans("Clone"),
);
if ($permissiontodelete) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
// Project card
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -842,7 +862,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
$linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly'));
//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1);
print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask');
print load_fiche_titre($title, $linktotasks.' &nbsp; '.$linktocreatetask, 'projecttask', '', '', '', $massactionbutton);
$objecttmp = new Task($db);
$trackid = 'task'.$taskstatic->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him).
@ -877,6 +901,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
print '</div>';
}
// Show the massaction checkboxes only when this page is not opend from the Extended POS
if ($massactionbutton && $contextpage != 'poslist') {
$selectedfields = $form->showCheckAddButtons('checkforselect', 1);
}
print '<div class="div-table-responsive">';
print '<table id="tablelines" class="tagtable nobottom liste'.($moreforfilter ? " listwithfilterbefore" : "").'">';
@ -987,6 +1016,8 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
print '<td class="liste_titre maxwidthsearch">&nbsp;</td>';
// Action column
print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterButtons();
@ -1055,6 +1086,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '<td></td>';
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
@ -1062,7 +1094,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
if (count($tasksarray) > 0) {
// Show all lines in taskarray (recursive function to go down on tree)
$j = 0; $level = 0;
$nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields);
$nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields, $arrayofselected);
} else {
$colspan = 10;
if ($object->usage_bill_time) {