Merge pull request #17883 from marc-dll/develop_NEW_holiday_cron

NEW: holiday: handle monthly balance updates with cronjob
This commit is contained in:
Laurent Destailleur 2021-07-16 12:48:12 +02:00 committed by GitHub
commit 2fc8a80070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View File

@ -135,6 +135,28 @@ class modHoliday extends DolibarrModules
//$r++;
// Cronjobs
$arraydate = dol_getdate(dol_now());
$datestart = dol_mktime(4, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array(
0 => array(
'label' => 'HolidayBalanceMonthlyUpdate',
'jobtype' => 'method',
'class' => 'holiday/class/holiday.class.php',
'objectname' => 'Holiday',
'method' => 'updateBalance',
'parameters' => '',
'comment' => 'Update holiday balance every month',
'frequency' => 1,
'unitfrequency' => 3600 * 24,
'priority' => 50,
'status' => 1,
'test' => '$conf->holiday->enabled',
'datestart' => $datestart
)
);
// Permissions
$this->rights = array(); // Permission array used by this module
$r = 0;

View File

@ -227,7 +227,7 @@ class Holiday extends CommonObject
if ($result >= 0) {
$this->db->commit();
return 1;
return 0; // for cronjob use (0 is OK, any other value is an error code)
} else {
$this->db->rollback();
return -1;

View File

@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF
WatermarkOnDraftHolidayCards=Watermarks on draft leave requests
HolidaysToApprove=Holidays to approve
NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays
HolidayBalanceMonthlyUpdate=Monthly update of holiday balance

View File

@ -366,6 +366,6 @@ class HolidayTest extends PHPUnit\Framework\TestCase
$localobjecta->updateConfCP('lastUpdate', '20100101120000');
$result = $localobjecta->updateBalance();
$this->assertEquals($result, 1);
$this->assertEquals($result, 0);
}
}