mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 17:48:25 +01:00
NEW: holiday: handle monthly updates with cronjob
This commit is contained in:
@@ -135,6 +135,28 @@ class modHoliday extends DolibarrModules
|
|||||||
//$r++;
|
//$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
|
// Permissions
|
||||||
$this->rights = array(); // Permission array used by this module
|
$this->rights = array(); // Permission array used by this module
|
||||||
$r = 0;
|
$r = 0;
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class Holiday extends CommonObject
|
|||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 0; // for cronjob use (0 is OK, any other value is an error code)
|
||||||
} else {
|
} else {
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -193,10 +193,6 @@ llxHeader('', $langs->trans('CPTitreMenu'));
|
|||||||
|
|
||||||
|
|
||||||
$typeleaves = $holiday->getTypes(1, 1);
|
$typeleaves = $holiday->getTypes(1, 1);
|
||||||
$result = $holiday->updateBalance(); // Create users into table holiday if they don't exists. TODO Remove this whif we use field into table user.
|
|
||||||
if ($result < 0) {
|
|
||||||
setEventMessages($holiday->error, $holiday->errors, 'errors');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
|||||||
@@ -231,9 +231,6 @@ $formfile = new FormFile($db);
|
|||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
$holidaystatic = new Holiday($db);
|
$holidaystatic = new Holiday($db);
|
||||||
|
|
||||||
// Update sold
|
|
||||||
$result = $object->updateBalance();
|
|
||||||
|
|
||||||
$title = $langs->trans('CPTitreMenu');
|
$title = $langs->trans('CPTitreMenu');
|
||||||
llxHeader('', $title);
|
llxHeader('', $title);
|
||||||
|
|
||||||
|
|||||||
@@ -68,16 +68,6 @@ if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INF
|
|||||||
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Actions
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Update sold
|
|
||||||
if (!empty($conf->holiday->enabled) && !empty($setupcompanynotcomplete)) {
|
|
||||||
$holidaystatic = new Holiday($db);
|
|
||||||
$result = $holidaystatic->updateBalance();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
|
|||||||
@@ -132,3 +132,4 @@ FreeLegalTextOnHolidays=Free text on PDF
|
|||||||
WatermarkOnDraftHolidayCards=Watermarks on draft leave requests
|
WatermarkOnDraftHolidayCards=Watermarks on draft leave requests
|
||||||
HolidaysToApprove=Holidays to approve
|
HolidaysToApprove=Holidays to approve
|
||||||
NobodyHasPermissionToValidateHolidays=Nobody has permission to validate holidays
|
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');
|
$localobjecta->updateConfCP('lastUpdate', '20100101120000');
|
||||||
$result = $localobjecta->updateBalance();
|
$result = $localobjecta->updateBalance();
|
||||||
$this->assertEquals($result, 1);
|
$this->assertEquals($result, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user