From 6f29b6492d0fa85821e155714548ae6aa0786b90 Mon Sep 17 00:00:00 2001 From: msquare Date: Sun, 24 Dec 2017 10:48:04 +0100 Subject: [PATCH] show forced active on user view --- includes/view/User_view.php | 145 +++++++++++++++++++++--------------- 1 file changed, 83 insertions(+), 62 deletions(-) diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 1d3dae68..5aec1962 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -472,20 +472,11 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel ]), div('row', [ div('col-md-3', [ - '

', - '', - $user_source['DECT'], - '

' + heading(glyph('phone') . $user_source['DECT'], 1) ]), - User_view_state($admin_user_privilege, $freeloader, $its_me, $user_source), - div('col-md-3', [ - '

' . _('Angeltypes') . '

', - User_angeltypes_render($user_angeltypes) - ]), - div('col-md-3', [ - '

' . _('Rights') . '

', - User_groups_render($user_groups) - ]) + User_view_state($admin_user_privilege, $freeloader, $user_source), + User_angeltypes_render($user_angeltypes), + User_groups_render($user_groups) ]), ($its_me || $admin_user_privilege) ? '

' . _('Shifts') . '

' : '', ($its_me || $admin_user_privilege) ? table([ @@ -510,60 +501,83 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel /** * Render the state section of user view. */ -function User_view_state($admin_user_privilege, $freeloader, $its_me, $user_source) { - $state = [ - ]; - if($admin_user_privilege && $freeloader) { - $state[] = '' . glyph('exclamation-sign') . _('Freeloader') . ''; - } - $state[] = User_shift_state_render($user_source); - if($admin_user_privilege || $its_me) { - if($user_source['Gekommen']) { - $state[] = '' . glyph('home') - . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date'])) - . ''; - } else { - $state[] = '' - . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date'])) - . ''; - } - } else { - if($user_source['Gekommen']) { - $state[] = '' . glyph('home') . _('Arrived') . ''; - } else { - $state[] = '' . _('Not arrived') . ''; - } - } +function User_view_state($admin_user_privilege, $freeloader, $user_source) { if($admin_user_privilege) { - if($user_source['got_voucher'] > 0) { - $state[] = '' - . glyph('cutlery') - . sprintf( - ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']), - $user_source['got_voucher'] - ) - . ''; - } else { - $state[] = '' . _('Got no vouchers') . ''; - } - if($user_source['Gekommen']) { - if($user_source['force_active']) { - $state[] = '' . _('Active (forced)') . ''; - } elseif($user_source['Aktiv']) { - $state[] = '' . _('Active') . ''; - } - if($user_source['Tshirt']) { - $state[] = '' . _('T-Shirt') . ''; - } - } + $state = User_view_state_admin($freeloader, $user_source); + } else { + $state = User_view_state_user($user_source); } - - return div('col-md-3',[ + + return div('col-md-3', [ heading(_('User state'), 4), join('
', $state) ]); } +/** + * Render the state section of user view for users. + */ +function User_view_state_user($user_source) { + $state = [ + User_shift_state_render($user_source) + ]; + + if($user_source['Gekommen']) { + $state[] = '' . glyph('home') . _('Arrived') . ''; + } else { + $state[] = '' . _('Not arrived') . ''; + } + + return $state; +} + + +/** + * Render the state section of user view for admins. + */ +function User_view_state_admin($freeloader, $user_source) { + $state = []; + + if($freeloader) { + $state[] = '' . glyph('exclamation-sign') . _('Freeloader') . ''; + } + + $state[] = User_shift_state_render($user_source); + + if($user_source['Gekommen']) { + $state[] = '' . glyph('home') + . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date'])) + . ''; + + if($user_source['force_active']) { + $state[] = '' . _('Active (forced)') . ''; + } elseif($user_source['Aktiv']) { + $state[] = '' . _('Active') . ''; + } + if($user_source['Tshirt']) { + $state[] = '' . _('T-Shirt') . ''; + } + } else { + $state[] = '' + . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date'])) + . ''; + } + + if($user_source['got_voucher'] > 0) { + $state[] = '' + . glyph('cutlery') + . sprintf( + ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']), + $user_source['got_voucher'] + ) + . ''; + } else { + $state[] = '' . _('Got no vouchers') . ''; + } + + return $state; +} + /** * View for password recovery step 1: E-Mail * @@ -615,7 +629,10 @@ function User_angeltypes_render($user_angeltypes) . ($angeltype['supporter'] ? glyph('education') : '') . $angeltype['name'] . ''; } - return join('
', $output); + return div('col-md-3', [ + heading(_('Angeltypes'), 4), + join('
', $output) + ]); } /** @@ -628,7 +645,11 @@ function User_groups_render($user_groups) foreach ($user_groups as $group) { $output[] = substr($group['Name'], 2); } - return join('
', $output); + + return div('col-md-3', [ + '

' . _('Rights') . '

', + join('
', $output) + ]); } /**