summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-10-13 20:28:34 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2019-10-13 20:28:34 +0200
commit4154e97f3ffa6ecbbf8f6228599742cd23001f95 (patch)
tree2c32992852f3e2d5d03bc527f2bc29962619604a /includes
parentc5dd21cbd6d0d8f3fe8e003e6b75b3b46a54fa00 (diff)
Deleted shift: Multiply with night shifts multiplier for worklog entry
Diffstat (limited to 'includes')
-rw-r--r--includes/model/UserWorkLog_model.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/includes/model/UserWorkLog_model.php b/includes/model/UserWorkLog_model.php
index c450d901..cc7686cf 100644
--- a/includes/model/UserWorkLog_model.php
+++ b/includes/model/UserWorkLog_model.php
@@ -127,6 +127,7 @@ function UserWorkLog_create($userWorkLog)
function UserWorkLog_from_shift($shift)
{
$shift = is_array($shift) ? $shift : Shift($shift);
+ $nightShifts = config('night_shifts');
if ($shift['start'] > time()) {
return;
@@ -137,12 +138,26 @@ function UserWorkLog_from_shift($shift)
if ($entry['freeloaded']) {
continue;
}
+
$type = AngelType($entry['TID']);
+ $nightShiftMultiplier = 1;
+ $shiftStart = Carbon::createFromTimestamp($shift['start']);
+ $shiftEnd = Carbon::createFromTimestamp($shift['end']);
+ if (
+ $nightShifts['enabled']
+ && (
+ $shiftStart->hour >= $nightShifts['start'] && $shiftStart->hour < $nightShifts['end']
+ || $shiftEnd->hour >= $nightShifts['start'] && $shiftEnd->hour < $nightShifts['end']
+ )
+ ) {
+ $nightShiftMultiplier = $nightShifts['multiplier'];
+ }
+
UserWorkLog_create([
'user_id' => $entry['UID'],
'work_timestamp' => $shift['start'],
- 'work_hours' => ($shift['end'] - $shift['start']) / 60 / 60,
+ 'work_hours' => (($shift['end'] - $shift['start']) / 60 / 60) * $nightShiftMultiplier,
'comment' => sprintf(
'%s (%s as %s) in %s, %s-%s',
$shift['name'],