Hide dect, voucher and t-shirt options shown to users when disabled via config
This commit is contained in:
parent
737066414e
commit
92e0b8be65
|
@ -148,7 +148,7 @@ function angeltype_edit_controller()
|
|||
$angeltype->description = strip_request_item_nl('description', $angeltype->description);
|
||||
|
||||
$angeltype->contact_name = strip_request_item('contact_name', $angeltype->contact_name);
|
||||
$angeltype->contact_dect = strip_request_item('contact_dect', $angeltype->contact_dect);
|
||||
$angeltype->contact_dect = strip_request_item('contact_dect', $angeltype->contact_dect) ?: '';
|
||||
$angeltype->contact_email = strip_request_item('contact_email', $angeltype->contact_email);
|
||||
|
||||
if ($valid) {
|
||||
|
|
|
@ -126,7 +126,7 @@ function AngelType_edit_view(AngelType $angeltype, bool $supporter_mode)
|
|||
__('Primary contact person/desk for user questions.')
|
||||
),
|
||||
form_text('contact_name', __('Name'), $angeltype->contact_name),
|
||||
form_text('contact_dect', __('DECT'), $angeltype->contact_dect),
|
||||
config('enable_dect') ? form_text('contact_dect', __('DECT'), $angeltype->contact_dect) : '',
|
||||
form_text('contact_email', __('E-Mail'), $angeltype->contact_email),
|
||||
form_submit('submit', __('Save'))
|
||||
])
|
||||
|
@ -220,7 +220,9 @@ function AngelType_view_members(AngelType $angeltype, $members, $admin_user_ange
|
|||
$members_unconfirmed = [];
|
||||
foreach ($members as $member) {
|
||||
$member->name = User_Nick_render($member) . User_Pronoun_render($member);
|
||||
if (config('enable_dect')) {
|
||||
$member['dect'] = $member->contact->dect;
|
||||
}
|
||||
if ($angeltype->requires_driver_license) {
|
||||
$member['wants_to_drive'] = icon_bool($member->license->wantsToDrive());
|
||||
$member['has_car'] = icon_bool($member->license->has_car);
|
||||
|
@ -313,8 +315,13 @@ function AngelType_view_members(AngelType $angeltype, $members, $admin_user_ange
|
|||
*/
|
||||
function AngelType_view_table_headers(AngelType $angeltype, $supporter, $admin_angeltypes)
|
||||
{
|
||||
$headers = [
|
||||
'name' => __('Nick'),
|
||||
'dect' => __('DECT'),
|
||||
'actions' => ''
|
||||
];
|
||||
if ($angeltype->requires_driver_license && ($supporter || $admin_angeltypes)) {
|
||||
return [
|
||||
$headers = [
|
||||
'name' => __('Nick'),
|
||||
'dect' => __('DECT'),
|
||||
'wants_to_drive' => __('Driver'),
|
||||
|
@ -327,11 +334,10 @@ function AngelType_view_table_headers(AngelType $angeltype, $supporter, $admin_a
|
|||
'actions' => ''
|
||||
];
|
||||
}
|
||||
return [
|
||||
'name' => __('Nick'),
|
||||
'dect' => __('DECT'),
|
||||
'actions' => ''
|
||||
];
|
||||
if (!config('enable_dect')) {
|
||||
unset($headers['dect']);
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,7 +504,7 @@ function AngelTypes_render_contact_info(AngelType $angeltype)
|
|||
{
|
||||
$info = [
|
||||
__('Name') => [$angeltype->contact_name, $angeltype->contact_name],
|
||||
__('DECT') => [sprintf('<a href="tel:%s">%1$s</a>', $angeltype->contact_dect), $angeltype->contact_dect],
|
||||
__('DECT') => config('enable_dect') ? [sprintf('<a href="tel:%s">%1$s</a>', $angeltype->contact_dect), $angeltype->contact_dect] : null,
|
||||
__('E-Mail') => [sprintf('<a href="mailto:%s">%1$s</a>', $angeltype->contact_email), $angeltype->contact_email],
|
||||
];
|
||||
$contactInfo = [];
|
||||
|
|
|
@ -91,12 +91,16 @@ function Users_view(
|
|||
$u['last_name'] = $user->personalData->last_name;
|
||||
$u['dect'] = sprintf('<a href="tel:%s">%1$s</a>', $user->contact->dect);
|
||||
$u['arrived'] = icon_bool($user->state->arrived);
|
||||
if (config('enable_voucher')) {
|
||||
$u['got_voucher'] = $user->state->got_voucher;
|
||||
}
|
||||
$u['freeloads'] = $user->getAttribute('freeloads');
|
||||
$u['active'] = icon_bool($user->state->active);
|
||||
$u['force_active'] = icon_bool($user->state->force_active);
|
||||
if (config('enable_tshirt_size')) {
|
||||
$u['got_shirt'] = icon_bool($user->state->got_shirt);
|
||||
$u['shirt_size'] = $user->personalData->shirt_size;
|
||||
}
|
||||
$u['arrival_date'] = $user->personalData->planned_arrival_date
|
||||
? $user->personalData->planned_arrival_date->format(__('Y-m-d')) : '';
|
||||
$u['departure_date'] = $user->personalData->planned_departure_date
|
||||
|
@ -129,12 +133,18 @@ function Users_view(
|
|||
$user_table_headers['dect'] = Users_table_header_link('dect', __('DECT'), $order_by);
|
||||
}
|
||||
$user_table_headers['arrived'] = Users_table_header_link('arrived', __('Arrived'), $order_by);
|
||||
if (config('enable_voucher')) {
|
||||
$user_table_headers['got_voucher'] = Users_table_header_link('got_voucher', __('Voucher'), $order_by);
|
||||
}
|
||||
$user_table_headers['freeloads'] = Users_table_header_link('freeloads', __('Freeloads'), $order_by);
|
||||
$user_table_headers['active'] = Users_table_header_link('active', __('Active'), $order_by);
|
||||
$user_table_headers['force_active'] = Users_table_header_link('force_active', __('Forced'), $order_by);
|
||||
if (config('enable_tshirt_size')) {
|
||||
$user_table_headers['got_shirt'] = Users_table_header_link('got_shirt', __('T-Shirt'), $order_by);
|
||||
}
|
||||
if (config('enable_tshirt_size')) {
|
||||
$user_table_headers['shirt_size'] = Users_table_header_link('shirt_size', __('Size'), $order_by);
|
||||
}
|
||||
$user_table_headers['arrival_date'] = Users_table_header_link(
|
||||
'planned_arrival_date',
|
||||
__('Planned arrival'),
|
||||
|
@ -510,7 +520,7 @@ function User_view(
|
|||
div('row', [
|
||||
div('col-md-12', [
|
||||
buttons([
|
||||
$auth->can('user.edit.shirt') ? button(
|
||||
$auth->can('user.edit.shirt') && config('enable_tshirt_size') ? button(
|
||||
url('/admin/user/' . $user_source->id . '/shirt'),
|
||||
icon('person') . __('Shirt')
|
||||
) : '',
|
||||
|
@ -599,7 +609,7 @@ function User_view(
|
|||
]),
|
||||
($its_me || $admin_user_privilege) ? '<h2>' . __('Shifts') . '</h2>' : '',
|
||||
$myshifts_table,
|
||||
($its_me && $nightShiftsConfig['enabled']) ? info(
|
||||
($its_me && $nightShiftsConfig['enabled'] && config('enable_tshirt_size')) ? info(
|
||||
icon('info-circle') . sprintf(
|
||||
__('Your night shifts between %d and %d am count twice.'),
|
||||
$nightShiftsConfig['start'],
|
||||
|
@ -705,6 +715,7 @@ function User_view_state_admin($freeloader, $user_source)
|
|||
. '</span>';
|
||||
}
|
||||
|
||||
if (config('enable_voucher')) {
|
||||
$voucherCount = $user_source->state->got_voucher;
|
||||
$availableCount = $voucherCount + User_get_eligable_voucher_count($user_source);
|
||||
$availableCount = max($voucherCount, $availableCount);
|
||||
|
@ -719,6 +730,7 @@ function User_view_state_admin($freeloader, $user_source)
|
|||
. ($availableCount ? ' (' . __('out of %s', [$availableCount]) . ')' : '')
|
||||
. '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue