Fix: skip approver "not enough days" warning for leave types that don't use the balance counter (#38213)
The validator notification email warned about insufficient balance regardless of whether the leave type has affect=1 in c_holiday_types. For types like overtime compensation or unpaid leave (affect=0), getCPforUser() always returns 0 and the warning fires on every request. Same getTypes(1, 1) filter that the balance display in the form uses.
This commit is contained in:
parent
f4fe44518b
commit
1eba22f29b
2 changed files with 14 additions and 6 deletions
|
|
@ -530,11 +530,15 @@ if (empty($reshook)) {
|
|||
}
|
||||
|
||||
// option to notify the validator if the balance is less than the request
|
||||
// (only for leave types that actually use the balance counter)
|
||||
if (!getDolGlobalString('HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE')) {
|
||||
$nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
|
||||
$affectingtypes = $object->getTypes(1, 1);
|
||||
if (!empty($affectingtypes[$object->fk_type])) {
|
||||
$nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
|
||||
|
||||
if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) {
|
||||
$message .= "<p>".$langs->transnoentities("HolidaysToValidateAlertSolde")."</p>\n";
|
||||
if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) {
|
||||
$message .= "<p>".$langs->transnoentities("HolidaysToValidateAlertSolde")."</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -757,11 +757,15 @@ function sendMail($id, $cancreate, $now, $autoValidation)
|
|||
}
|
||||
|
||||
// option to notify the validator if the balance is less than the request
|
||||
// (only for leave types that actually use the balance counter)
|
||||
if (!getDolGlobalString('HOLIDAY_HIDE_APPROVER_ABOUT_NEGATIVE_BALANCE')) {
|
||||
$nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
|
||||
$affectingtypes = $object->getTypes(1, 1);
|
||||
if (!empty($affectingtypes[$object->fk_type])) {
|
||||
$nbopenedday = num_open_day($object->date_debut_gmt, $object->date_fin_gmt, 0, 1, $object->halfday);
|
||||
|
||||
if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) {
|
||||
$message .= "<p>".$langs->transnoentities("HolidaysToValidateAlertSolde")."</p>\n";
|
||||
if ($nbopenedday > $object->getCPforUser($object->fk_user, $object->fk_type)) {
|
||||
$message .= "<p>".$langs->transnoentities("HolidaysToValidateAlertSolde")."</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue