Voucher: Add worklog entries to calculation
This commit is contained in:
parent
ec47d124bb
commit
7fb10ec569
|
@ -22,14 +22,24 @@ function UserWorkLog($user_worklog_id)
|
|||
/**
|
||||
* Returns all work log entries for a user.
|
||||
*
|
||||
* @param int $userId
|
||||
* @param int $userId
|
||||
* @param Carbon|null $sinceTime
|
||||
* @return array[]
|
||||
*/
|
||||
function UserWorkLogsForUser($userId)
|
||||
function UserWorkLogsForUser($userId, Carbon $sinceTime = null)
|
||||
{
|
||||
return Db::select("SELECT * FROM `UserWorkLog` WHERE `user_id`=? ORDER BY `created_timestamp`", [
|
||||
$userId
|
||||
]);
|
||||
return Db::select(
|
||||
'
|
||||
SELECT *
|
||||
FROM `UserWorkLog`
|
||||
WHERE `user_id`=?
|
||||
' . ($sinceTime ? 'AND work_timestamp >= ' . $sinceTime->getTimestamp() : '') . '
|
||||
ORDER BY `created_timestamp`
|
||||
',
|
||||
[
|
||||
$userId
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -236,7 +236,10 @@ function User_get_eligable_voucher_count($user)
|
|||
$start = $voucher_settings['voucher_start']
|
||||
? Carbon::createFromFormat('Y-m-d', $voucher_settings['voucher_start'])->setTime(0, 0)
|
||||
: null;
|
||||
$shifts_done = count(ShiftEntries_finished_by_user($user->id, $start));
|
||||
|
||||
$shifts_done =
|
||||
count(ShiftEntries_finished_by_user($user->id, $start))
|
||||
+ count(UserWorkLogsForUser($user->id, $start));
|
||||
|
||||
$earned_vouchers = $user->state->got_voucher - $voucher_settings['initial_vouchers'];
|
||||
$eligable_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
|
||||
|
|
Loading…
Reference in New Issue