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; }