Add mass action on project's list to close projects
This commit is contained in:
parent
9997a6c787
commit
452c9e22bb
@ -222,4 +222,6 @@ NoAssignedTasks=No assigned tasks (assign project/tasks the current user from th
|
|||||||
# Comments trans
|
# Comments trans
|
||||||
AllowCommentOnTask=Allow user comments on tasks
|
AllowCommentOnTask=Allow user comments on tasks
|
||||||
AllowCommentOnProject=Allow user comments on projects
|
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
|
||||||
|
|||||||
@ -195,6 +195,52 @@ if (empty($reshook))
|
|||||||
$permtodelete = $user->rights->projet->supprimer;
|
$permtodelete = $user->rights->projet->supprimer;
|
||||||
$uploaddir = $conf->projet->dir_output;
|
$uploaddir = $conf->projet->dir_output;
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
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->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
|
||||||
if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
|
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();
|
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
|
||||||
|
|
||||||
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
|
||||||
|
|
||||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user