diff options
Diffstat (limited to 'includes/view/User_view.php')
-rw-r--r-- | includes/view/User_view.php | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/includes/view/User_view.php b/includes/view/User_view.php index fff2952e..b1521ff8 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -408,7 +408,7 @@ function User_view_myshift($shift, $user_source, $its_me) * @param bool $its_me * @return array */ -function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin) +function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin, $user_worklogs, $admin_user_worklog_privilege) { $myshifts_table = []; $timesum = 0; @@ -420,6 +420,13 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi } } + if($its_me || $admin_user_worklog_privilege) { + foreach($user_worklogs as $worklog) { + $myshifts_table[] = User_view_worklog($worklog, $admin_user_worklog_privilege); + $timesum += $worklog['work_hours'] * 3600; + } + } + if (count($myshifts_table) > 0) { $myshifts_table[] = [ 'date' => '<b>' . _('Sum:') . '</b>', @@ -444,6 +451,38 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi } /** + * Renders table entry for user work log + * @param UserWorkLog $worklog + * @param bool $admin_user_worklog_privilege + */ +function User_view_worklog($worklog, $admin_user_worklog_privilege) { + $actions = ''; + if($admin_user_worklog_privilege) { + $actions = table_buttons([ + button( + user_worklog_edit_link($worklog), + glyph('edit') . _('edit'), + 'btn-xs' + ), + button( + user_worklog_delete_link($worklog), + glyph('trash') . _('delete'), + 'btn-xs' + ) + ]); + } + + return [ + 'date' => '', + 'duration' => '<b>' . $worklog['work_hours'] . ' h</b>', + 'room' => '', + 'shift_info' => _('Work log entry'), + 'comment' => $worklog['comment'], + 'actions' => $actions + ]; +} + +/** * Renders view for a single user * * @param array $user_source @@ -466,12 +505,14 @@ function User_view( $shifts, $its_me, $tshirt_score, - $tshirt_admin + $tshirt_admin, + $admin_user_worklog_privilege, + $user_worklogs ) { $user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']); $myshifts_table = ''; if($its_me || $admin_user_privilege) { - $my_shifts = User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin); + $my_shifts = User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin, $user_worklogs, $admin_user_worklog_privilege); if(count($my_shifts) > 0) { $myshifts_table = table([ 'date' => _('Day & time'), @@ -514,6 +555,10 @@ function User_view( ), glyph('cutlery') . _('Edit vouchers') ) : '', + $admin_user_worklog_privilege ? button( + user_worklog_add_link($user_source), + glyph('list') . _('Add work log') + ) : '', $its_me ? button( page_link_to('user_settings'), glyph('list-alt') . _('Settings') |