summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php17
-rw-r--r--includes/view/PublicDashboard_view.php2
-rw-r--r--includes/view/ShiftEntry_view.php2
-rw-r--r--includes/view/Shifts_view.php7
-rw-r--r--includes/view/UserAngelTypes_view.php12
-rw-r--r--includes/view/UserWorkLog_view.php8
-rw-r--r--includes/view/User_view.php106
7 files changed, 66 insertions, 88 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 3ce063ab..58c9567b 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -203,6 +203,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
$members_unconfirmed = [];
foreach ($members as $member) {
$member->name = User_Nick_render($member);
+ $member['dect'] = $member->contact->dect;
if ($angeltype['requires_driver_license']) {
$member['wants_to_drive'] = glyph_bool($member['wants_to_drive']);
$member['has_car'] = glyph_bool($member['has_car']);
@@ -294,8 +295,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
{
if ($angeltype['requires_driver_license'] && ($supporter || $admin_angeltypes)) {
return [
- 'Nick' => __('Nick'),
- 'DECT' => __('DECT'),
+ 'name' => __('Nick'),
+ 'dect' => __('DECT'),
'wants_to_drive' => __('Driver'),
'has_car' => __('Has car'),
'has_license_car' => __('Car'),
@@ -307,8 +308,8 @@ function AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes)
];
}
return [
- 'Nick' => __('Nick'),
- 'DECT' => __('DECT'),
+ 'name' => __('Nick'),
+ 'dect' => __('DECT'),
'actions' => ''
];
}
@@ -420,16 +421,16 @@ function AngelType_view_info(
if (count($members_confirmed) > 0) {
$members_confirmed[] = [
- 'Nick' => __('Sum'),
- 'DECT' => count($members_confirmed),
+ 'name' => __('Sum'),
+ 'dect' => count($members_confirmed),
'actions' => ''
];
}
if (count($members_unconfirmed) > 0) {
$members_unconfirmed[] = [
- 'Nick' => __('Sum'),
- 'DECT' => count($members_unconfirmed),
+ 'name' => __('Sum'),
+ 'dect' => count($members_unconfirmed),
'actions' => ''
];
}
diff --git a/includes/view/PublicDashboard_view.php b/includes/view/PublicDashboard_view.php
index 2bfca3fa..baab2f8a 100644
--- a/includes/view/PublicDashboard_view.php
+++ b/includes/view/PublicDashboard_view.php
@@ -16,7 +16,7 @@ function public_dashboard_view($stats, $free_shifts)
];
foreach ($free_shifts as $i => $shift) {
$shift_panels[] = public_dashboard_shift_render($shift);
- if($i % 4 == 3) {
+ if ($i % 4 == 3) {
$shift_panels[] = '</div><div class="row">';
}
}
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 9b528256..5d4364f5 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -76,7 +76,7 @@ function ShiftEntry_delete_title()
* @param array $room
* @param array $angeltype
* @param array $angeltypes_select
- * @param User $signup_user
+ * @param User $signup_user
* @param array $users_select
* @return string
*/
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 2485ec67..4c329f1b 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -76,10 +76,8 @@ function Shift_editor_info_render($shift)
*/
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
{
- $user = auth()->user();
-
if (empty($user_angeltype)) {
- $user_angeltype = UserAngelType_by_User_and_AngelType($user->id, $angeltype);
+ $user_angeltype = UserAngelType_by_User_and_AngelType(auth()->user()->id, $angeltype);
}
if ($angeltype['shift_signup_state']->isSignupAllowed()) {
@@ -105,7 +103,6 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupState $shift_signup_state)
{
global $privileges;
- $user = auth()->user();
$shift_admin = in_array('admin_shifts', $privileges);
$user_shift_admin = in_array('user_shifts_admin', $privileges);
@@ -143,7 +140,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt
$admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '',
];
}
- $buttons[] = button(user_link($user->id), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
+ $buttons[] = button(user_link(auth()->user()->id), '<span class="icon-icon_angel"></span> ' . __('My shifts'));
$content[] = buttons($buttons);
$content[] = Shift_view_header($shift, $room);
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index 78bf6fe9..1c583389 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -4,7 +4,7 @@ use Engelsystem\Models\User\User;
/**
* @param array $user_angeltype
- * @param User $user
+ * @param User $user
* @param array $angeltype
* @param bool $supporter
* @return string
@@ -91,7 +91,7 @@ function UserAngelTypes_confirm_all_view($angeltype)
/**
* @param array $user_angeltype
- * @param User $user
+ * @param User $user
* @param array $angeltype
* @return string
*/
@@ -120,7 +120,7 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
/**
* @param array $user_angeltype
- * @param User $user
+ * @param User $user
* @param array $angeltype
* @return string
*/
@@ -146,9 +146,9 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
}
/**
- * @param array $angeltype
+ * @param array $angeltype
* @param User[] $users_source
- * @param int $user_id
+ * @param int $user_id
* @return string
*/
function UserAngelType_add_view($angeltype, $users_source, $user_id)
@@ -176,7 +176,7 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id)
}
/**
- * @param User $user
+ * @param User $user
* @param array $angeltype
* @return string
*/
diff --git a/includes/view/UserWorkLog_view.php b/includes/view/UserWorkLog_view.php
index ee35350b..8b4e7ae3 100644
--- a/includes/view/UserWorkLog_view.php
+++ b/includes/view/UserWorkLog_view.php
@@ -5,7 +5,7 @@ use Engelsystem\Models\User\User;
/**
* Delete work log entry.
*
- * @param User $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
@@ -36,7 +36,7 @@ function UserWorkLog_delete_title()
/**
* Render edit table.
*
- * @param User $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
@@ -54,7 +54,7 @@ function UserWorkLog_edit_form($user_source, $userWorkLog)
/**
* Form for edit a user work log entry.
*
- * @param User $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
@@ -72,7 +72,7 @@ function UserWorkLog_edit_view($user_source, $userWorkLog)
/**
* Form for adding a user work log entry.
*
- * @param User $user_source
+ * @param User $user_source
* @param array $userWorkLog
* @return string
*/
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index c055169e..2b4154b4 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -25,7 +25,6 @@ function User_settings_view(
$tshirt_sizes
) {
$personalData = $user_source->personalData;
- $state = $user_source->state;
return page_with_title(settings_title(), [
msg(),
div('row', [
@@ -34,12 +33,12 @@ function User_settings_view(
form_info('', __('Here you can change your user details.')),
form_info(entry_required() . ' = ' . __('Entry required!')),
form_text('nick', __('Nick'), $user_source->name, true),
- form_text('lastname', __('Last name'), $user_source->personalData->last_name),
- form_text('prename', __('First name'), $user_source->personalData->first_name),
+ form_text('lastname', __('Last name'), $personalData->last_name),
+ form_text('prename', __('First name'), $personalData->first_name),
form_date(
'planned_arrival_date',
__('Planned date of arrival') . ' ' . entry_required(),
- $state->arrival_date ? $state->arrival_date->getTimestamp() : '',
+ $personalData->planned_arrival_date ? $personalData->planned_arrival_date->getTimestamp() : '',
$buildup_start_date,
$teardown_end_date
),
@@ -52,7 +51,7 @@ function User_settings_view(
),
form_text('dect', __('DECT'), $user_source->contact->dect),
form_text('mobile', __('Mobile'), $user_source->contact->mobile),
- form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->contact->email),
+ form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email),
form_checkbox(
'email_shiftinfo',
__(
@@ -70,7 +69,7 @@ function User_settings_view(
'tshirt_size',
__('Shirt size'),
$tshirt_sizes,
- $user_source->personalData->shirt_size,
+ $personalData->shirt_size,
__('Please select...')
) : '',
form_info('', __('Please visit the angeltypes page to manage your angeltypes.')),
@@ -215,31 +214,31 @@ function Users_view(
$usersList = [];
foreach ($users as $user) {
$u = [];
- $u['Nick'] = User_Nick_render($user);
- $u['Vorname'] = $user->personalData->first_name;
- $u['Name'] = $user->personalData->last_name;
- $u['DECT'] = $user->contact->dect;
- $u['Gekommen'] = glyph_bool($user->state->arrived);
- $u['got_voucher'] = glyph_bool($user->state->got_voucher);
+ $u['name'] = User_Nick_render($user);
+ $u['first_name'] = $user->personalData->first_name;
+ $u['last_name'] = $user->personalData->last_name;
+ $u['dect'] = $user->contact->dect;
+ $u['arrived'] = glyph_bool($user->state->arrived);
+ $u['got_voucher'] = $user->state->got_voucher;
$u['freeloads'] = $user->getAttribute('freeloads');
- $u['Aktiv'] = glyph_bool($user->state->active);
+ $u['active'] = glyph_bool($user->state->active);
$u['force_active'] = glyph_bool($user->state->force_active);
- $u['Tshirt'] = glyph_bool($user->state->got_shirt);
- $u['Size'] = $user->personalData->shirt_size;
- $u['lastLogIn'] = $user->last_login_at ? $user->last_login_at->format(__('m/d/Y h:i a')) : '';
+ $u['got_shirt'] = glyph_bool($user->state->got_shirt);
+ $u['shirt_size'] = $user->personalData->shirt_size;
+ $u['last_login_at'] = $user->last_login_at ? $user->last_login_at->format(__('m/d/Y h:i a')) : '';
$u['actions'] = table_buttons([
button_glyph(page_link_to('admin_user', ['id' => $user->id]), 'edit', 'btn-xs')
]);
$usersList[] = $u;
}
$usersList[] = [
- 'Nick' => '<strong>' . __('Sum') . '</strong>',
- 'Gekommen' => $arrived_count,
+ 'name' => '<strong>' . __('Sum') . '</strong>',
+ 'arrived' => $arrived_count,
'got_voucher' => $voucher_count,
- 'Aktiv' => $active_count,
+ 'active' => $active_count,
'force_active' => $force_active_count,
'freeloads' => $freeloads_count,
- 'Tshirt' => $tshirts_count,
+ 'got_shirt' => $tshirts_count,
'actions' => '<strong>' . count($usersList) . '</strong>'
];
@@ -249,19 +248,19 @@ function Users_view(
button(page_link_to('register'), glyph('plus') . __('New user'))
]),
table([
- 'Nick' => Users_table_header_link('Nick', __('Nick'), $order_by),
- 'Vorname' => Users_table_header_link('Vorname', __('Prename'), $order_by),
- 'Name' => Users_table_header_link('Name', __('Name'), $order_by),
- 'DECT' => Users_table_header_link('DECT', __('DECT'), $order_by),
- 'Gekommen' => Users_table_header_link('Gekommen', __('Arrived'), $order_by),
- 'got_voucher' => Users_table_header_link('got_voucher', __('Voucher'), $order_by),
- 'freeloads' => __('Freeloads'),
- 'Aktiv' => Users_table_header_link('Aktiv', __('Active'), $order_by),
- 'force_active' => Users_table_header_link('force_active', __('Forced'), $order_by),
- 'Tshirt' => Users_table_header_link('Tshirt', __('T-Shirt'), $order_by),
- 'Size' => Users_table_header_link('Size', __('Size'), $order_by),
- 'lastLogIn' => Users_table_header_link('lastLogIn', __('Last login'), $order_by),
- 'actions' => ''
+ 'name' => Users_table_header_link('name', __('Nick'), $order_by),
+ 'first_name' => Users_table_header_link('first_name', __('Prename'), $order_by),
+ 'last_name' => Users_table_header_link('last_name', __('Name'), $order_by),
+ 'dect' => Users_table_header_link('dect', __('DECT'), $order_by),
+ 'arrived' => Users_table_header_link('arrived', __('Arrived'), $order_by),
+ 'got_voucher' => Users_table_header_link('got_voucher', __('Voucher'), $order_by),
+ 'freeloads' => __('Freeloads'),
+ 'active' => Users_table_header_link('active', __('Active'), $order_by),
+ 'force_active' => Users_table_header_link('force_active', __('Forced'), $order_by),
+ 'got_shirt' => Users_table_header_link('got_shirt', __('T-Shirt'), $order_by),
+ 'shirt_size' => Users_table_header_link('shirt_size', __('Size'), $order_by),
+ 'last_login_at' => Users_table_header_link('last_login_at', __('Last login'), $order_by),
+ 'actions' => ''
], $usersList)
]);
}
@@ -282,24 +281,16 @@ function Users_table_header_link($column, $label, $order_by)
}
/**
- * @param User|array $user
+ * @param User $user
* @return string|false
*/
function User_shift_state_render($user)
{
- if ($user instanceof User) {
- $id = $user->id;
- $arrived = $user->state->arrived;
- } else {
- $arrived = $user['Gekommen'];
- $id = $user['UID'];
- }
-
- if (!$arrived) {
+ if (!$user->state->arrived) {
return '';
}
- $upcoming_shifts = ShiftEntries_upcoming_for_user($id);
+ $upcoming_shifts = ShiftEntries_upcoming_for_user($user->id);
if (empty($upcoming_shifts)) {
return '<span class="text-success">' . __('Free') . '</span>';
}
@@ -735,7 +726,7 @@ function User_view_state_admin($freeloader, $user_source)
} elseif ($user_source->state->active) {
$state[] = '<span class="text-success">' . __('Active') . '</span>';
}
- if ($user_source->personalData->shirt_size) {
+ if ($user_source->state->got_shirt) {
$state[] = '<span class="text-success">' . __('T-Shirt') . '</span>';
}
} else {
@@ -844,20 +835,14 @@ function User_groups_render($user_groups)
*/
function User_Nick_render($user)
{
- if ($user instanceof User) {
- $id = $user->id;
- $name = $user->name;
- $arrived = $user->state->arrived;
- } else {
- $id = $user['UID'];
- $name = $user['Nick'];
- $arrived = $user['Gekommen'];
+ if (is_array($user)) {
+ $user = (new User())->forceFill($user);
}
return render_profile_link(
- '<span class="icon-icon_angel"></span> ' . htmlspecialchars($name) . '</a>',
- $id,
- ($arrived ? '' : 'text-muted')
+ '<span class="icon-icon_angel"></span> ' . htmlspecialchars($user->name) . '</a>',
+ $user->id,
+ ($user->state->arrived ? '' : 'text-muted')
);
}
@@ -917,9 +902,7 @@ function render_user_freeloader_hint()
*/
function render_user_arrived_hint()
{
- $user = auth()->user();
-
- if (!$user->state->arrived) {
+ if (!auth()->user()->state->arrived) {
/** @var Carbon $buildup */
$buildup = config('buildup_start');
if (!empty($buildup) && $buildup->lessThan(new Carbon())) {
@@ -935,9 +918,7 @@ function render_user_arrived_hint()
*/
function render_user_tshirt_hint()
{
- $user = auth()->user();
-
- if (config('enable_tshirt_size') && !$user->personalData->shirt_size) {
+ if (config('enable_tshirt_size') && !auth()->user()->personalData->shirt_size) {
$text = __('You need to specify a tshirt size in your settings!');
return render_profile_link($text, null, 'alert-link');
}
@@ -951,7 +932,6 @@ function render_user_tshirt_hint()
function render_user_dect_hint()
{
$user = auth()->user();
-
if ($user->state->arrived && !$user->contact->dect) {
$text = __('You need to specify a DECT phone number in your settings! If you don\'t have a DECT phone, just enter \'-\'.');
return render_profile_link($text, null, 'alert-link');