From 2dbc4c5e01eeb2321788133f8cc250a41753bb2f Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Wed, 7 Jan 2026 11:08:40 +0100 Subject: [PATCH] fix: if holiday type have bock if negative, it is ignored when balance is 0 (#36817) * fix: backport of holiday approval if block_if_negative * fix: backport of holiday approval if block_if_negative --- htdocs/holiday/card.php | 6 +++--- htdocs/holiday/class/holiday.class.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 7bd30263504..fab3b802ae7 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -687,13 +687,13 @@ if (empty($reshook)) { if (!$error) { $db->commit(); - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; } else { $db->rollback(); $action = ''; } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 1102ed53dc7..8d817661d9b 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -882,8 +882,9 @@ class Holiday extends CommonObject if ($checkBalance > 0) { $balance = $this->getCPforUser($this->fk_user, $this->fk_type); + $daysAsked = num_open_day($this->date_debut, $this->date_fin, 0, 1); - if ($balance < 0) { + if (($balance - $daysAsked) < 0) { $this->error = 'LeaveRequestCreationBlockedBecauseBalanceIsNegative'; return -1; }