mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
FIX: holiday: also block if balance is negative at request update, validation and approval
This commit is contained in:
@@ -703,6 +703,17 @@ class Holiday extends CommonObject
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
// Define new ref
|
||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) {
|
||||
$num = $this->getNextNumRef(null);
|
||||
@@ -767,6 +778,17 @@ class Holiday extends CommonObject
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET";
|
||||
|
||||
@@ -876,6 +898,17 @@ class Holiday extends CommonObject
|
||||
global $conf, $langs;
|
||||
$error = 0;
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user