diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php index 818557a4..ea5e319e 100644 --- a/includes/controller/shift_entries_controller.php +++ b/includes/controller/shift_entries_controller.php @@ -10,8 +10,8 @@ use Engelsystem\ShiftSignupState; function shift_entries_controller() { global $user; - - if(!isset($user)) { + + if (!isset($user)) { redirect(page_link_to('login')); } diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php index 7b22e347..71901b97 100644 --- a/includes/model/UserAngelTypes_model.php +++ b/includes/model/UserAngelTypes_model.php @@ -226,3 +226,20 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype) ] ); } + +/** + * Get an UserAngelTypes by user + * + * @param array $user + * @return array[]|null + */ +function UserAngelTypes_by_User($user) +{ + return DB::select(' + SELECT * + FROM `UserAngelTypes` + WHERE `user_id`=? + ', + [$user['UID']] + ); +} 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[] = '
' . round(-($shift['end'] - $shift['start']) / 3600 * 2, 2) . ' h' . '
'; + $myshift['duration'] = '' + . round(-($shift['end'] - $shift['start']) / 3600 * 2, 2) . ' h' + . '
'; if (in_array('user_shifts_admin', $privileges)) { $myshift['comment'] .= '' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '
'; @@ -424,7 +429,7 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi 'comment' => '', 'actions' => '' ]; - if($its_me || $tshirt_admin) { + if ($its_me || $tshirt_admin) { $myshifts_table[] = [ 'date' => '' . _('Your t-shirt score') . '™:', 'duration' => '' . round($tshirt_score, 2) . ' h', @@ -452,8 +457,17 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi * @param bool $tshirt_admin * @return string */ -function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me, $tshirt_score, $tshirt_admin) -{ +function User_view( + $user_source, + $admin_user_privilege, + $freeloader, + $user_angeltypes, + $user_groups, + $shifts, + $its_me, + $tshirt_score, + $tshirt_admin +) { $user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']); $myshifts_table = User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin); diff --git a/locale/de_DE.UTF-8/LC_MESSAGES/default.mo b/locale/de_DE.UTF-8/LC_MESSAGES/default.mo index a58c3a05..b7f8e941 100644 Binary files a/locale/de_DE.UTF-8/LC_MESSAGES/default.mo and b/locale/de_DE.UTF-8/LC_MESSAGES/default.mo differ diff --git a/locale/de_DE.UTF-8/LC_MESSAGES/default.po b/locale/de_DE.UTF-8/LC_MESSAGES/default.po index a093149f..4d6a5807 100644 --- a/locale/de_DE.UTF-8/LC_MESSAGES/default.po +++ b/locale/de_DE.UTF-8/LC_MESSAGES/default.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Engelsystem 2.0\n" -"POT-Creation-Date: 2017-12-27 12:17+0100\n" -"PO-Revision-Date: 2017-12-27 12:17+0100\n" +"POT-Creation-Date: 2017-12-27 13:38+0100\n" +"PO-Revision-Date: 2017-12-27 13:38+0100\n" "Last-Translator: msquare