FIX: holiday: also block if balance is negative at request update, validation and approval
This commit is contained in:
parent
30e0471451
commit
084abe4547
@ -703,6 +703,17 @@ class Holiday extends CommonObject
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error = 0;
|
$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
|
// Define new ref
|
||||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) {
|
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref) || $this->ref == $this->id)) {
|
||||||
$num = $this->getNextNumRef(null);
|
$num = $this->getNextNumRef(null);
|
||||||
@ -767,6 +778,17 @@ class Holiday extends CommonObject
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error = 0;
|
$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
|
// Update request
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET";
|
||||||
|
|
||||||
@ -876,6 +898,17 @@ class Holiday extends CommonObject
|
|||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error = 0;
|
$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
|
// Update request
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."holiday SET";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user