Worklog: log deletion, User page: fix voucher calculation
This commit is contained in:
parent
8833506e04
commit
f3e1192695
|
@ -149,7 +149,10 @@ function User_get_eligable_voucher_count($user)
|
|||
: null;
|
||||
|
||||
$shiftEntries = ShiftEntries_finished_by_user($user, $start);
|
||||
$worklog = UserWorkLogsForUser($user->id, $start);
|
||||
$worklog = $user->worklogs()
|
||||
->whereDate('worked_at', '>=', $start ?: 0)
|
||||
->with(['user', 'creator'])
|
||||
->get();
|
||||
$shifts_done =
|
||||
count($shiftEntries)
|
||||
+ $worklog->count();
|
||||
|
|
|
@ -131,6 +131,16 @@ class UserWorkLogController extends BaseController
|
|||
}
|
||||
$worklog->delete();
|
||||
|
||||
$this->log->info(
|
||||
'Deleted worklog for {name} ({id}) at {time} about {hours}h: {text}',
|
||||
[
|
||||
'name' => $worklog->user->name,
|
||||
'id' => $worklog->user->id,
|
||||
'time' => $worklog->worked_at,
|
||||
'hours' => $worklog->hours,
|
||||
'text' => $worklog->comment,
|
||||
]
|
||||
);
|
||||
$this->addNotification('worklog.delete.success');
|
||||
|
||||
return $this->redirect->to('/users?action=view&user_id=' . $userId);
|
||||
|
|
|
@ -306,6 +306,7 @@ class UserWorkLogControllerTest extends ControllerTest
|
|||
|
||||
$this->controller->deleteWorklog($request);
|
||||
|
||||
$this->log->hasInfoThatContains('Deleted worklog');
|
||||
$this->assertHasNotification('worklog.delete.success');
|
||||
$worklog = Worklog::find($worklog->id);
|
||||
$this->assertNull($worklog);
|
||||
|
|
Loading…
Reference in New Issue