-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New: add configuration to choose if holiday are updated at the end of month #29438
New: add configuration to choose if holiday are updated at the end of month #29438
Conversation
…or every request + update translations
…y array + delete duplicate code
…ay-update-at-the-end-of-month
…or every request + update translations
…y array + delete duplicate code
…ustRaosha/dolibarr into new-holiday-update-at-the-end-of-month
…ustRaosha/dolibarr into new-holiday-update-at-the-end-of-month
…d var in sql request
// Get month of last update | ||
$lastUpdate = $this->getConfCP('lastUpdate', $newdateforlastupdate); | ||
$monthLastUpdate = $lastUpdate[4].$lastUpdate[5]; | ||
$lastUpdate = strtotime($this->getConfCP('lastUpdate', dol_print_date($now, '%Y%m%d%H%M%S'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of strtotime is forbidden because it does not deal correctly the timezone.
You can use dol_stringtotime()
|
||
// If month date is not same than the one of last update (the one we saved in database), then we update the timestamp and balance of each open user, | ||
// catching up to the current month if a gap is detected | ||
while (date('Ym', $lastUpdate) < date('Ym', $now)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of date() function is forbidden because it does not deal correctly the timezone.
You can use dol_print_date
PS: to avoid call to a function inside the while (function()). You should set 2 variables, for example $yearmonth = ... and $yearmonthnow = ... and then do
while (yearmonth < $yearmonthnow)
return 1; | ||
} else { | ||
//updating the date of the last monthly balance update | ||
$lastUpdate = strtotime('+1 month', strtotime(date('Ym01His', $lastUpdate))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strtotime is forbidden as it does not deal correctly the timezone and daylight times.
// We add a log for each user | ||
$this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']); | ||
// We add a log for each user when its balance gets increased | ||
$this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidayMonthlyCredit'), $newSolde, $userCounter['type']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the goal of adding the translation key HolidayMonthlyCredit compared to HolidayMonthlyUpdate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to be more understandable when reading the logs of the update because update could mean increasing or decreasing. Now, the user would know if his balance is credited or debited.
…holiday-update-at-the-end-of-month
Hello @eldy, I have updated this branch to the latest commits and it is working, could you please take a look at this new feature and give any feedback if I have to improve anything. |
…annisHoareau/dolibarr into new-holiday-update-at-the-end-of-month
…annisHoareau/dolibarr into new-holiday-update-at-the-end-of-month
…rework casting to int
…rework casting to int (2)
Hey @eldy, any news about this new feature ? |
If the configuration is selected, the holiday balance is not updated when clicked on approve, it is now updated at the end of the month, when the balance get increased.
If a leave period gets cancelled, only the already consummated days are credited again in balance.