diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 1f597f2ddc2..6518258b508 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -44,10 +44,6 @@ $id=GETPOST('id', 'int'); $ref=GETPOST('ref', 'alpha'); $fuserid = (GETPOST('fuserid', 'int')?GETPOST('fuserid', 'int'):$user->id); -// Protection if external user -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'holiday', $id, 'holiday'); - $now=dol_now(); // Load translation files required by the page @@ -61,9 +57,9 @@ if (! empty($conf->global->HOLIDAY_FOR_NON_SALARIES_TOO)) $morefilter = ''; $error = 0; $object = new Holiday($db); -if ($id > 0) +if (($id > 0) || $ref) { - $object->fetch($id); + $object->fetch($id, $ref); // Check current user can read this leave request $canread = 0; @@ -83,6 +79,12 @@ $candelete = 0; if (! empty($user->rights->holiday->delete)) $candelete=1; if ($object->statut == Holiday::STATUS_DRAFT && $user->rights->holiday->write && in_array($object->fk_user, $childids)) $candelete=1; +// Protection if external user +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'holiday', $object->id, 'holiday'); + + + /* * Actions */