Merge pull request #23143 from milenmk/massaction-delete-project-tasks
NEW|New [Bulk delete Project tasks]
This commit is contained in:
commit
3bac52d053
@ -1708,6 +1708,66 @@ if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday
|
||||
}
|
||||
}
|
||||
|
||||
//if (!$error && $massaction == 'clonetasks' && $user->rights->projet->creer) {
|
||||
if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $confirm == 'yes'))) {
|
||||
$num = 0;
|
||||
|
||||
dol_include_once('/projet/class/task.class.php');
|
||||
|
||||
$origin_task = new Task($db);
|
||||
$clone_task = new Task($db);
|
||||
|
||||
foreach (GETPOST('selected') as $task) {
|
||||
$origin_task->fetch($task, $ref = '', $loadparentdata = 0);
|
||||
|
||||
$defaultref = '';
|
||||
$obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON;
|
||||
if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) {
|
||||
require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php';
|
||||
$modTask = new $obj;
|
||||
$defaultref = $modTask->getNextValue(0, $clone_task);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$clone_task->fk_project = GETPOST('projectid', 'int');
|
||||
$clone_task->ref = $defaultref;
|
||||
$clone_task->label = $origin_task->label;
|
||||
$clone_task->description = $origin_task->description;
|
||||
$clone_task->planned_workload = $origin_task->planned_workload;
|
||||
$clone_task->fk_task_parent = $origin_task->fk_task_parent;
|
||||
$clone_task->date_c = dol_now();
|
||||
$clone_task->date_start = $origin_task->date_start;
|
||||
$clone_task->date_end = $origin_task->date_end;
|
||||
$clone_task->progress = $origin_task->progress;
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $clone_task);
|
||||
|
||||
$taskid = $clone_task->create($user);
|
||||
|
||||
if ($taskid > 0) {
|
||||
$result = $clone_task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal');
|
||||
$num++;
|
||||
} else {
|
||||
if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
|
||||
$langs->load("projects");
|
||||
setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings');
|
||||
$duplicate_code_error = true;
|
||||
} else {
|
||||
setEventMessages($clone_task->error, $clone_task->errors, 'errors');
|
||||
}
|
||||
$action = 'list';
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessage($langs->trans('NumberOfTasksCloned', $num));
|
||||
header("Refresh: 1;URL=".DOL_URL_ROOT.'/projet/tasks.php?id=' . GETPOST('projectid', 'int'));
|
||||
}
|
||||
}
|
||||
|
||||
$parameters['toselect'] = (empty($toselect) ? array() : $toselect);
|
||||
$parameters['uploaddir'] = $uploaddir;
|
||||
$parameters['massaction'] = $massaction;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -40,6 +40,18 @@ if ($massaction == 'predelete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1);
|
||||
}
|
||||
|
||||
if ($massaction == 'preclonetasks') {
|
||||
$selected = '';
|
||||
foreach (GETPOST('toselect') as $tmpselected) {
|
||||
$selected .= '&selected[]=' . $tmpselected;
|
||||
}
|
||||
|
||||
$formquestion = array(
|
||||
array('type' => 'other', 'name' => 'projectid', 'label' => $langs->trans('Project') .': ', 'value' => $form->selectProjects('', 'projectid', '', '', '', '', '', '', '', 1, 1)),
|
||||
);
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'] . '?id=' . $object->id . $selected . '', $langs->trans('ConfirmMassClone'), '', 'clonetasks', $formquestion, '', 1, 300, 590);
|
||||
}
|
||||
|
||||
if ($massaction == 'preaffecttag' && isModEnabled('category')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
$categ = new Categorie($db);
|
||||
|
||||
@ -898,6 +898,9 @@ MassFilesArea=Area for files built by mass actions
|
||||
ShowTempMassFilesArea=Show area of files built by mass actions
|
||||
ConfirmMassDeletion=Bulk Delete confirmation
|
||||
ConfirmMassDeletionQuestion=Are you sure you want to delete the %s selected record(s)?
|
||||
ConfirmMassClone=Bulk clone confirmation
|
||||
ConfirmMassCloneQuestion=Select project to clone to
|
||||
ConfirmMassCloneToOneProject=Clone to project %s
|
||||
RelatedObjects=Related Objects
|
||||
ClassifyBilled=Classify billed
|
||||
ClassifyUnbilled=Classify unbilled
|
||||
|
||||
@ -259,6 +259,7 @@ RecordsClosed=%s project(s) closed
|
||||
SendProjectRef=Information project %s
|
||||
ModuleSalaryToDefineHourlyRateMustBeEnabled=Module 'Salaries' must be enabled to define employee hourly rate to have time spent valorized
|
||||
NewTaskRefSuggested=Task ref already used, a new task ref is required
|
||||
NumberOfTasksCloned=%s task(s) cloned
|
||||
TimeSpentInvoiced=Time spent billed
|
||||
TimeSpentForIntervention=Time spent
|
||||
TimeSpentForInvoice=Time spent
|
||||
@ -298,4 +299,4 @@ EnablePublicLeadForm=Enable the public form for contact
|
||||
NewLeadbyWeb=Your message or request has been recorded. We will answer or contact your soon.
|
||||
NewLeadForm=New contact form
|
||||
LeadFromPublicForm=Online lead from public form
|
||||
ExportAccountingReportButtonLabel=Get report
|
||||
ExportAccountingReportButtonLabel=Get report
|
||||
|
||||
@ -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ó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,18 @@ if ($id > 0 || !empty($ref)) {
|
||||
// Add $param from extra fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
|
||||
|
||||
$arrayofmassactions = array();
|
||||
if ($user->rights->projet->creer) {
|
||||
$arrayofmassactions['preclonetasks'] = 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>';
|
||||
@ -849,7 +870,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.' '.$linktocreatetask, 'projecttask');
|
||||
print load_fiche_titre($title, $linktotasks.' '.$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).
|
||||
@ -884,6 +909,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" : "").'">';
|
||||
|
||||
@ -994,6 +1024,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"> </td>';
|
||||
|
||||
// Action column
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterButtons();
|
||||
@ -1062,6 +1094,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";
|
||||
|
||||
@ -1069,7 +1102,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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user