Merge pull request #8404 from OPEN-DSI/project_add_close_to_mass_update

NEW Add mass action on project's list to close projects
This commit is contained in:
Laurent Destailleur 2018-03-18 12:28:03 +01:00 committed by GitHub
commit 0c1e0f38d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 1 deletions

View File

@ -222,4 +222,6 @@ NoAssignedTasks=No assigned tasks (assign project/tasks the current user from th
# Comments trans
AllowCommentOnTask=Allow user comments on tasks
AllowCommentOnProject=Allow user comments on projects
DontHavePermissionForCloseProject=You do not have permissions to close the project %s
DontHaveTheValidateStatus=The project %s must be open to be closed
RecordsClosed=%s project(s) closed

View File

@ -195,6 +195,52 @@ if (empty($reshook))
$permtodelete = $user->rights->projet->supprimer;
$uploaddir = $conf->projet->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Close records
if (! $error && $massaction == 'close' && $user->rights->projet->creer)
{
$db->begin();
$objecttmp=new $objectclass($db);
$nbok = 0;
foreach($toselect as $toselectid)
{
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
{
$userWrite = $object->restrictedProjectArea($user,'write');
if ($userWrite > 0 && $objecttmp->statut == 1) {
$result = $objecttmp->setClose($user);
if ($result <= 0) {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
} else $nbok++;
} elseif($userWrite <= 0) {
setEventMessages($langs->trans("DontHavePermissionForCloseProject", $objecttmp->ref), null, 'warnings');
} else {
setEventMessages($langs->trans("DontHaveTheValidateStatus", $objecttmp->ref), null, 'warnings');
}
}
else
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++;
break;
}
}
if (! $error)
{
if ($nbok > 1) setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordsClosed", $nbok), null, 'mesgs');
$db->commit();
}
else
{
$db->rollback();
}
}
}
@ -390,7 +436,9 @@ $arrayofmassactions = array(
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
if ($user->rights->projet->creer) $arrayofmassactions['close']=$langs->trans("Close");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';