|
|
@ -127,6 +127,7 @@ function UserWorkLog_create($userWorkLog)
|
|
|
|
function UserWorkLog_from_shift($shift)
|
|
|
|
function UserWorkLog_from_shift($shift)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$shift = is_array($shift) ? $shift : Shift($shift);
|
|
|
|
$shift = is_array($shift) ? $shift : Shift($shift);
|
|
|
|
|
|
|
|
$nightShifts = config('night_shifts');
|
|
|
|
|
|
|
|
|
|
|
|
if ($shift['start'] > time()) {
|
|
|
|
if ($shift['start'] > time()) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -137,12 +138,26 @@ function UserWorkLog_from_shift($shift)
|
|
|
|
if ($entry['freeloaded']) {
|
|
|
|
if ($entry['freeloaded']) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$type = AngelType($entry['TID']);
|
|
|
|
$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([
|
|
|
|
UserWorkLog_create([
|
|
|
|
'user_id' => $entry['UID'],
|
|
|
|
'user_id' => $entry['UID'],
|
|
|
|
'work_timestamp' => $shift['start'],
|
|
|
|
'work_timestamp' => $shift['start'],
|
|
|
|
'work_hours' => ($shift['end'] - $shift['start']) / 60 / 60,
|
|
|
|
'work_hours' => (($shift['end'] - $shift['start']) / 60 / 60) * $nightShiftMultiplier,
|
|
|
|
'comment' => sprintf(
|
|
|
|
'comment' => sprintf(
|
|
|
|
'%s (%s as %s) in %s, %s-%s',
|
|
|
|
'%s (%s as %s) in %s, %s-%s',
|
|
|
|
$shift['name'],
|
|
|
|
$shift['name'],
|
|
|
|