mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix deadlock feature, can't process a leave request when validator has
left company.
This commit is contained in:
parent
11f58c7bda
commit
5d115bcf69
|
|
@ -570,14 +570,43 @@ if ($action == 'confirm_refuse')
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Si Validation de la demande
|
||||
if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
$oldstatus = $object->statut;
|
||||
$object->statut = 1;
|
||||
|
||||
$result = $object->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error = $langs->trans('ErrorBackToDraft');
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Si Validation de la demande
|
||||
if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes')
|
||||
{
|
||||
$object = new Holiday($db);
|
||||
$object->fetch($id);
|
||||
|
||||
// Si statut en attente de validation et valideur = utilisateur
|
||||
if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user))
|
||||
// Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres
|
||||
if (($object->statut == 2 || $object->statut == 3) && ($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)))
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
|
|
@ -989,6 +1018,12 @@ else
|
|||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleCancelCP"),$langs->trans("ConfirmCancelCP"),"confirm_cancel", '', 1, 1);
|
||||
}
|
||||
|
||||
// Si back to draft
|
||||
if ($action == 'backtodraft')
|
||||
{
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1);
|
||||
}
|
||||
|
||||
$head=holiday_prepare_head($object);
|
||||
|
||||
|
||||
|
|
@ -1208,18 +1243,31 @@ else
|
|||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete" class="butActionDelete">'.$langs->trans("DeleteCP").'</a>';
|
||||
}
|
||||
|
||||
if ($user->id == $object->fk_validator && $object->statut == 2)
|
||||
if ($object->statut == 2)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
|
||||
if ($user->id == $object->fk_validator)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid" class="butAction">'.$langs->trans("Approve").'</a>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse" class="butAction">'.$langs->trans("ActionRefuseCP").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("Approve").'</a>';
|
||||
print '<a href="#" class="butActionRefused" title="'.$langs->trans("NotTheAssignedApprover").'">'.$langs->trans("ActionRefuseCP").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (($user->id == $object->fk_validator || $user->id == $object->fk_user) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved
|
||||
if (($user->id == $object->fk_validator || $user->id == $object->fk_user || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved
|
||||
{
|
||||
if (($object->date_debut > dol_now()) || $user->admin) print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel" class="butAction">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
else print '<a href="#" class="butActionRefused" title="'.$langs->trans("HolidayStarted").'">'.$langs->trans("ActionCancelCP").'</a>';
|
||||
}
|
||||
|
||||
if ($canedit && $object->statut == 4)
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ CancelCP=Canceled
|
|||
RefuseCP=Refused
|
||||
ValidatorCP=Approbator
|
||||
ListeCP=List of leaves
|
||||
ReviewedByCP=Will be reviewed by
|
||||
ReviewedByCP=Will be approved by
|
||||
DescCP=Description
|
||||
SendRequestCP=Create leave request
|
||||
DelayToRequestCP=Leave requests must be made at least <b>%s day(s)</b> before them.
|
||||
|
|
|
|||
|
|
@ -757,6 +757,8 @@ SomeTranslationAreUncomplete=Some languages may be partially translated or may c
|
|||
DirectDownloadLink=Direct download link
|
||||
Download=Download
|
||||
ActualizeCurrency=Update currency rate
|
||||
TitleSetToDraft=Go back to draft
|
||||
ConfirmSetToDraft=Are you sure you want to go back to Draft status ?
|
||||
# Week day
|
||||
Monday=Monday
|
||||
Tuesday=Tuesday
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user