From 803722e323801bbc4e3d5b79651bd666cb0835ad Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 4 Aug 2021 14:48:10 +0200 Subject: [PATCH 1/3] Fix : we only want employee users for holidays --- htdocs/holiday/class/holiday.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 2637f3c0eaa..3cd649e11ac 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1630,6 +1630,7 @@ class Holiday extends CommonObject $sql .= " WHERE u.entity IN (".getEntity('user').")"; } $sql .= " AND u.statut > 0"; + $sql .= " AND u.employee = 1"; // We only want employee users for holidays if ($filters) $sql .= $filters; $resql = $this->db->query($sql); @@ -1720,6 +1721,7 @@ class Holiday extends CommonObject } $sql .= " AND u.statut > 0"; + $sql .= " AND u.employee = 1"; // We only want employee users for holidays if ($filters) $sql .= $filters; $resql = $this->db->query($sql); From ceaaff0186455528c266caf9b1633b0b314d84da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 17 Aug 2021 18:05:34 +0200 Subject: [PATCH 2/3] Sellby always before Eatby #18361 --- htdocs/reception/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 24144365256..40444faacb7 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1827,12 +1827,12 @@ if ($action == 'create') { print '
'; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print $langs->trans('EatByDate').' : '; - print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
'; + print $langs->trans('SellByDate').' : '; + print $form->selectDate($lines[$i]->sellby, 'dlc'.$line_id, '', '', 1, "").'
'; } if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print $langs->trans('SellByDate').' : '; - print $form->selectDate($lines[$i]->sellby, 'dluo'.$line_id, '', '', 1, ""); + print $langs->trans('EatByDate').' : '; + print $form->selectDate($lines[$i]->eatby, 'dluo'.$line_id, '', '', 1, ""); } print ''; } From fe17c13a5f20d16cc3958864c477ad855676343c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Aug 2021 19:22:47 +0200 Subject: [PATCH 3/3] FIX an approved holiday can be canceled by an admin. --- htdocs/holiday/card.php | 58 +++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index ffbd3204459..729b4653f64 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -49,7 +49,7 @@ $ref = GETPOST('ref', 'alpha'); $fuserid = (GETPOST('fuserid', 'int') ?GETPOST('fuserid', 'int') : $user->id); // Load translation files required by the page -$langs->loadLangs(array("other", "holiday", "mails")); +$langs->loadLangs(array("other", "holiday", "mails", "trips")); $now = dol_now(); @@ -255,6 +255,7 @@ if (empty($reshook)) } } + // If update and we are an approver, we can update with another approver if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { $object->fetch($id); @@ -310,6 +311,8 @@ if (empty($reshook)) if ($cancreate) { $valideur = GETPOST('valideur', 'int'); + // TODO Check this user id has the permission for approval + $description = trim(GETPOST('description', 'restricthtml')); // If no start date @@ -760,7 +763,7 @@ if (empty($reshook)) } } - // Si confirmation of cancellation + // If confirmation of cancellation if ($action == 'confirm_cancel' && GETPOST('confirm') == 'yes') { $error = 0; @@ -768,8 +771,8 @@ if (empty($reshook)) $object->fetch($id); // Si statut en attente de validation et valideur = valideur ou utilisateur, ou droits de faire pour les autres - if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && ($user->id == $object->fk_validator || in_array($object->fk_user, $childids) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)))) + if (($object->statut == Holiday::STATUS_VALIDATED || $object->statut == Holiday::STATUS_APPROVED) && + (!empty($user->admin) || $user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance)))) { $db->begin(); @@ -1468,30 +1471,53 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') print '
'; - if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) - { + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { print ''.$langs->trans("EditCP").''; } - if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) // If draft - { + + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { // If draft print ''.$langs->trans("Validate").''; } - if ($object->statut == Holiday::STATUS_VALIDATED) // If validated - { - if ($user->id == $object->fk_validator) - { + + if ($object->statut == Holiday::STATUS_VALIDATED) { // If validated + // Button Approve / Refuse + if ($user->id == $object->fk_validator) { print ''.$langs->trans("Approve").''; print ''.$langs->trans("ActionRefuseCP").''; } else { print ''.$langs->trans("Approve").''; print ''.$langs->trans("ActionRefuseCP").''; + + // Button Cancel + if (in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) { + if (($object->date_debut > dol_now()) || !empty($user->admin)) { + print ''.$langs->trans("ActionCancelCP").''; + } else { + print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").''; + } + } } } - if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved - { - if (($object->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; - else print ''.$langs->trans("ActionCancelCP").''; + + if ($object->statut == Holiday::STATUS_APPROVED) { // If validated or approved + if ($user->id == $object->fk_validator + || in_array($object->fk_user, $childids) + || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->holiday->writeall_advance))) { + if (($object->date_debut > dol_now()) || !empty($user->admin)) { + print ''.$langs->trans("ActionCancelCP").''; + } else { + print 'trans("NotAllowed").'">'.$langs->trans("ActionCancelCP").''; + } + } else { // I have no rights on the user of the holiday. + if (!empty($user->admin)) { // If current validator can't cancel an approved leave, we allow admin user + print ''.$langs->trans("ActionCancelCP").''; + } else { + print ''.$langs->trans("ActionCancelCP").''; + } + } } + + if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) { print ''.$langs->trans("SetToDraft").'';