From 8b58de50d52a22a397cab3ecbcd622b90992228a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Sep 2021 03:21:41 +0200 Subject: [PATCH] Clean code --- htdocs/holiday/card.php | 26 +++++++++++--------------- htdocs/holiday/class/holiday.class.php | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index fd0fb2eb91e..ac38a130bfa 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -467,22 +467,24 @@ if (empty($reshook)) { $message .= $langs->transnoentities("HolidaysToValidateBody")."\n"; - $delayForRequest = $object->getConfCP('delayForRequest'); - //$delayForRequest = $delayForRequest * (60*60*24); - - $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); // option to warn the validator in case of too short delay - if ($object->getConfCP('AlertValidatorDelay')) { - if ($object->date_debut < $nextMonth) { - $message .= "\n"; - $message .= $langs->transnoentities("HolidaysToValidateDelay", $object->getConfCP('delayForRequest'))."\n"; + if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_TOO_LOW_DELAY)) { + $delayForRequest = 0; // TODO Set delay depending of holiday leave type + if ($delayForRequest) { + $nowplusdelay = dol_time_plus_duree($now, $delayForRequest, 'd'); + + if ($object->date_debut < $nowplusdelay) { + $message .= "\n"; + $message .= $langs->transnoentities("HolidaysToValidateDelay", $delayForRequest)."\n"; + } } } // option to notify the validator if the balance is less than the request - if ($object->getConfCP('AlertValidatorSolde')) { + if (empty($conf->global->HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE)) { $nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday); + if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) { $message .= "\n"; $message .= $langs->transnoentities("HolidaysToValidateAlertSolde")."\n"; @@ -925,12 +927,6 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { } - $delayForRequest = $object->getConfCP('delayForRequest', 1); - //$delayForRequest = $delayForRequest * (60*60*24); - - $nextMonth = dol_time_plus_duree($now, $delayForRequest, 'd'); - - print '