From 6ceec76e7d27798aeaf968afe2b800bffb9b30f1 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 27 Dec 2017 13:36:38 +0100 Subject: feature request: filter angel types based on account settings, closes #362 --- includes/pages/user_shifts.php | 49 +++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'includes/pages/user_shifts.php') diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 2c30c86a..d822054e 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -186,6 +186,7 @@ function view_user_shifts() $session->set('ShiftsFilter', $shiftsFilter); } + /** @var ShiftsFilter $shiftsFilter */ $shiftsFilter = $session->get('ShiftsFilter'); update_ShiftsFilter($shiftsFilter, in_array('user_shifts_admin', $privileges), $days); @@ -214,6 +215,11 @@ function view_user_shifts() info(render_user_arrived_hint()); } + $ownTypes = []; + foreach (UserAngelTypes_by_User($user) as $type) { + $ownTypes[] = (int)$type['angeltype_id']; + } + return page([ div('col-md-12', [ msg(), @@ -238,7 +244,13 @@ function view_user_shifts() $types, $shiftsFilter->getTypes(), 'types', - _('Angeltypes') . '1' + _('Angeltypes') . '1', + [ + button( + 'javascript: checkOwnTypes(\'selection_types\', ' . json_encode($ownTypes) . ')', + _('Own') + ), + ] ), 'filled_select' => make_select($filled, $shiftsFilter->getFilled(), 'filled', _('Occupancy')), 'task_notice' => @@ -269,12 +281,12 @@ function view_user_shifts() /** * Returns a hint for the user how the ical feature works. */ -function ical_hint() { +function ical_hint() +{ global $user; return heading( - _('iCal export'), 2) - . '

' . sprintf( + _('iCal export'), 2) . '

' . sprintf( _('Export of shown shifts. iCal format or JSON format available (please keep secret, otherwise reset the api key).'), page_link_to('ical', ['key' => $user['api_key']]), page_link_to('shifts_json_export', ['key' => $user['api_key']]), @@ -291,15 +303,23 @@ function get_ids_from_array($array) return $array['id']; } -function make_select($items, $selected, $name, $title = null) +/** + * @param array $items + * @param array $selected + * @param string $name + * @param string $title + * @param array $additionalButtons + * @return string + */ +function make_select($items, $selected, $name, $title = null, $additionalButtons = []) { - $html_items = []; + $htmlItems = []; if (isset($title)) { - $html_items[] = '

' . $title . '

' . "\n"; + $htmlItems[] = '

' . $title . '

' . "\n"; } foreach ($items as $i) { - $html_items[] = '
' + $htmlItems[] = '
' . '' @@ -307,11 +327,14 @@ function make_select($items, $selected, $name, $title = null) . '

'; } $html = '
' . "\n"; - $html .= implode("\n", $html_items); - $html .= buttons([ - button('javascript: checkAll(\'selection_' . $name . '\', true)', _('All'), ''), - button('javascript: checkAll(\'selection_' . $name . '\', false)', _('None'), '') - ]); + $html .= implode("\n", $htmlItems); + + $buttons = []; + $buttons[] = button('javascript: checkAll(\'selection_' . $name . '\', true)', _('All')); + $buttons[] = button('javascript: checkAll(\'selection_' . $name . '\', false)', _('None')); + $buttons = array_merge($buttons, $additionalButtons); + $html .= buttons($buttons); + $html .= '
' . "\n"; return $html; } -- cgit v1.2.3-54-g00ecf