From 7c8fb4a5fb3c917a57025f980c7e103fb8fa6238 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 30 Sep 2021 17:48:20 +0200 Subject: [PATCH] FIX: leave request blocking when balance negative: don't check when creating, check only when updating not in draft --- htdocs/holiday/class/holiday.class.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 5c82f0ab4b3..31d850846e2 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -270,17 +270,6 @@ class Holiday extends CommonObject $this->error = "ErrorBadParameterFkType"; return -1; } - $checkBalance = getDictvalue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); - - if ($checkBalance > 0) { - $balance = $this->getCPforUser($this->fk_user, $this->fk_type); - - if ($balance < 0) { - $this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative'; - return -1; - } - } - // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."holiday("; $sql .= "ref,"; @@ -910,7 +899,7 @@ class Holiday extends CommonObject $checkBalance = getDictvalue(MAIN_DB_PREFIX.'c_holiday_types', 'block_if_negative', $this->fk_type); - if ($checkBalance > 0) { + if ($checkBalance > 0 && $this->statut != self::STATUS_DRAFT) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); if ($balance < 0) {