From 1e8f0c484588882e01bc173f7f60e2cf1376f790 Mon Sep 17 00:00:00 2001 From: msquare Date: Wed, 27 Dec 2017 12:24:55 +0100 Subject: fixes #208, fixes #310: T-Shirt Scoreā„¢ should be shown on the user view page below your shifts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/view/User_view.php | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'includes/view/User_view.php') diff --git a/includes/view/User_view.php b/includes/view/User_view.php index a80eb096..7a36aafe 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -401,16 +401,14 @@ function User_view_myshift($shift, $user_source, $its_me) * @param bool $its_me * @return array */ -function User_view_myshifts($shifts, $user_source, $its_me) +function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin) { $myshifts_table = []; $timesum = 0; foreach ($shifts as $shift) { $myshifts_table[] = User_view_myshift($shift, $user_source, $its_me); - if ($shift['freeloaded']) { - $timesum += (-2 * ($shift['end'] - $shift['start'])); - } else { + if (!$shift['freeloaded']) { $timesum += ($shift['end'] - $shift['start']); } } @@ -418,12 +416,22 @@ function User_view_myshifts($shifts, $user_source, $its_me) if (count($myshifts_table) > 0) { $myshifts_table[] = [ 'date' => '' . _('Sum:') . '', - 'time' => '' . round($timesum / 3600, 1) . ' h', + 'time' => '' . round($timesum / 3600, 2) . ' h', 'room' => '', 'shift_info' => '', 'comment' => '', 'actions' => '' ]; + if($its_me || $tshirt_admin) { + $myshifts_table[] = [ + 'date' => '' . _('Your t-shirt score') . '™:', + 'time' => '' . round($tshirt_score, 2) . ' h', + 'room' => '', + 'shift_info' => '', + 'comment' => '', + 'actions' => '' + ]; + } } return $myshifts_table; } @@ -438,12 +446,14 @@ function User_view_myshifts($shifts, $user_source, $its_me) * @param array[] $user_groups * @param array[] $shifts * @param bool $its_me + * @param int $tshirt_score + * @param bool $tshirt_admin * @return string */ -function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) +function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me, $tshirt_score, $tshirt_admin) { $user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']); - $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me); + $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin); return page_with_title( ' ' -- cgit v1.2.3-54-g00ecf