|
|
@ -121,6 +121,41 @@ function UserWorkLog_create($userWorkLog)
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param array|int $shift
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function UserWorkLog_from_shift($shift)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$shift = is_array($shift) ? $shift : Shift($shift);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($shift['start'] > time()) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$room = Room($shift['RID']);
|
|
|
|
|
|
|
|
foreach ($shift['ShiftEntry'] as $entry) {
|
|
|
|
|
|
|
|
if ($entry['freeloaded']) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$type = AngelType($entry['TID']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserWorkLog_create([
|
|
|
|
|
|
|
|
'user_id' => $entry['UID'],
|
|
|
|
|
|
|
|
'work_timestamp' => $shift['start'],
|
|
|
|
|
|
|
|
'work_hours' => ($shift['end'] - $shift['start']) / 60 / 60,
|
|
|
|
|
|
|
|
'comment' => sprintf(
|
|
|
|
|
|
|
|
'%s (%s as %s) in %s, %s-%s',
|
|
|
|
|
|
|
|
$shift['name'],
|
|
|
|
|
|
|
|
$shift['title'],
|
|
|
|
|
|
|
|
$type['name'],
|
|
|
|
|
|
|
|
$room['Name'],
|
|
|
|
|
|
|
|
Carbon::createFromTimestamp($shift['start'])->format(__('m/d/Y h:i a')),
|
|
|
|
|
|
|
|
Carbon::createFromTimestamp($shift['end'])->format(__('m/d/Y h:i a'))
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* New user work log entry
|
|
|
|
* New user work log entry
|
|
|
|
*
|
|
|
|
*
|
|
|
|