Merge pull request #17883 from marc-dll/develop_NEW_holiday_cron
NEW: holiday: handle monthly balance updates with cronjob
This commit is contained in:
commit
2fc8a80070
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user