diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index dbc86724..1d3dae68 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -269,6 +269,10 @@ function Users_table_header_link($column, $label, $order_by)
*/
function User_shift_state_render($user)
{
+ if(!$user['Gekommen']) {
+ return '';
+ }
+
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
if (empty($upcoming_shifts)) {
@@ -473,43 +477,7 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$user_source['DECT'],
''
]),
- div('col-md-3', [
- '
' . _('User state') . '
',
- ($admin_user_privilege && $freeloader)
- ? ' ' . _('Freeloader') . '
'
- : '',
- $user_source['Gekommen']
- ? User_shift_state_render($user_source) . '
'
- : '',
- $admin_user_privilege || $its_me
- ? (
- $user_source['Gekommen']
- ? ' '
- . sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
- . ''
- : ''
- . sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date']))
- . ''
- )
- : (
- $user_source['Gekommen']
- ? ' ' . _('Arrived') . ''
- : '' . _('Not arrived') . ''),
- $admin_user_privilege
- ? (
- $user_source['got_voucher'] > 0
- ? '
'
- . glyph('cutlery')
- . sprintf(
- ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']),
- $user_source['got_voucher']
- )
- . '
'
- : '
' . _('Got no vouchers') . '
')
- : '',
- ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' ' . _('Active') . '' : '',
- ($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' ' . _('T-Shirt') . '' : ''
- ]),
+ User_view_state($admin_user_privilege, $freeloader, $its_me, $user_source),
div('col-md-3', [
'' . _('Angeltypes') . '
',
User_angeltypes_render($user_angeltypes)
@@ -539,6 +507,63 @@ 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') . '';
+ }
+ }
+ 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') . '';
+ }
+ }
+ }
+
+ return div('col-md-3',[
+ heading(_('User state'), 4),
+ join('
', $state)
+ ]);
+}
+
/**
* View for password recovery step 1: E-Mail
*