diff options
Diffstat (limited to 'includes/view')
-rw-r--r-- | includes/view/AngelTypes_view.php | 111 | ||||
-rw-r--r-- | includes/view/Rooms_view.php | 5 | ||||
-rw-r--r-- | includes/view/ShiftCalendarRenderer.php | 2 | ||||
-rw-r--r-- | includes/view/ShiftsFilterRenderer.php | 10 |
4 files changed, 90 insertions, 38 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index 6e70b3be..e42321af 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -1,5 +1,7 @@ <?php +use Engelsystem\ShiftsFilterRenderer; +use Engelsystem\ShiftCalendarRenderer; /** * AngelTypes */ @@ -320,36 +322,86 @@ function AngelType_view( $admin_angeltypes, $supporter, $user_driver_license, - $user + $user, + ShiftsFilterRenderer $shiftsFilterRenderer, + ShiftCalendarRenderer $shiftCalendarRenderer ) { - $page = [ + return page_with_title(sprintf(_('Team %s'), $angeltype['name']), [ AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user), - msg() - ]; + msg(), + tabs([ + _('Info') => AngelType_view_info( + $angeltype, + $members, + $admin_user_angeltypes, + $admin_angeltypes, + $supporter + ), + _('Shifts') => AngelType_view_shifts( + $angeltype, + $shiftsFilterRenderer, + $shiftCalendarRenderer + ) + ]) + ]); +} +/** + * @param Angeltype $angeltype + * @param ShiftsFilterRenderer $shiftsFilterRenderer + * @param ShiftCalendarRenderer $shiftCalendarRenderer + * @return string HTML + */ +function AngelType_view_shifts($angeltype, $shiftsFilterRenderer, $shiftCalendarRenderer) +{ + $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [ + 'action' => 'view', + 'angeltype_id' => $angeltype['id'] + ])); + $shifts .= $shiftCalendarRenderer->render(); + + return div('first', $shifts); +} + +/** + * @param Angeltype $angeltype + * @param array $members + * @param bool $admin_user_angeltypes + * @param bool $admin_angeltypes + * @param bool $supporter + * @return string HTML + */ +function AngelType_view_info( + $angeltype, + $members, + $admin_user_angeltypes, + $admin_angeltypes, + $supporter +) { + $info = []; if(AngelType_has_contact_info($angeltype)) { - $page[] = AngelTypes_render_contact_info($angeltype); + $info[] = AngelTypes_render_contact_info($angeltype); } - $page[] = '<h3>' . _('Description') . '</h3>'; + $info[] = '<h3>' . _('Description') . '</h3>'; $parsedown = new Parsedown(); if ($angeltype['description'] != '') { - $page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; + $info[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>'; } - + list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members( $angeltype, $members, $admin_user_angeltypes, $admin_angeltypes - ); + ); $table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes); - + if (count($supporters) > 0) { - $page[] = '<h3>' . _('supporters') . '</h3>'; - $page[] = table($table_headers, $supporters); + $info[] = '<h3>' . _('supporters') . '</h3>'; + $info[] = table($table_headers, $supporters); } - + if (count($members_confirmed) > 0) { $members_confirmed[] = [ 'Nick' => _('Sum'), @@ -357,7 +409,7 @@ function AngelType_view( 'actions' => '' ]; } - + if (count($members_unconfirmed) > 0) { $members_unconfirmed[] = [ 'Nick' => _('Sum'), @@ -365,40 +417,40 @@ function AngelType_view( 'actions' => '' ]; } - - $page[] = '<h3>' . _('Members') . '</h3>'; + + $info[] = '<h3>' . _('Members') . '</h3>'; if ($admin_user_angeltypes) { - $page[] = buttons([ + $info[] = buttons([ button( page_link_to( 'user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']] - ), + ), _('Add'), 'add' - ) + ) ]); } - $page[] = table($table_headers, $members_confirmed); - + $info[] = table($table_headers, $members_confirmed); + if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) { - $page[] = '<h3>' . _('Unconfirmed') . '</h3>'; - $page[] = buttons([ + $info[] = '<h3>' . _('Unconfirmed') . '</h3>'; + $info[] = buttons([ button( page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]), _('confirm all'), 'ok' - ), + ), button( page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]), _('deny all'), 'cancel' - ) + ) ]); - $page[] = table($table_headers, $members_unconfirmed); + $info[] = table($table_headers, $members_unconfirmed); } - - return page_with_title(sprintf(_('Team %s'), $angeltype['name']), $page); + + return join($info); } /** @@ -407,7 +459,8 @@ function AngelType_view( * @param Anteltype $angeltype * @return string HTML */ -function AngelTypes_render_contact_info($angeltype) { +function AngelTypes_render_contact_info($angeltype) +{ return heading(_('Contact'), 3) . description([ _('Name') => $angeltype['contact_name'], _('DECT') => $angeltype['contact_dect'], diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php index adb58a9a..bd6138e1 100644 --- a/includes/view/Rooms_view.php +++ b/includes/view/Rooms_view.php @@ -19,7 +19,10 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen } return page_with_title(glyph('map-marker') . $room['Name'], [ - $shiftsFilterRenderer->render($room), + $shiftsFilterRenderer->render(page_link_to('rooms', [ + 'action' => 'view', + 'room_id' => $room['RID'] + ])), $assignNotice, $shiftCalendarRenderer->render() ]); diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php index d2becb58..354d0336 100644 --- a/includes/view/ShiftCalendarRenderer.php +++ b/includes/view/ShiftCalendarRenderer.php @@ -143,7 +143,7 @@ class ShiftCalendarRenderer public function render() { if (count($this->lanes) == 0) { - return ''; + return info(_('No shifts found.'), true); } return div('shift-calendar', [ $this->renderTimeLane(), diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php index c3e0ccf1..27c6240a 100644 --- a/includes/view/ShiftsFilterRenderer.php +++ b/includes/view/ShiftsFilterRenderer.php @@ -39,21 +39,17 @@ class ShiftsFilterRenderer /** * Renders the filter. * - * @param array $room + * @param string $page_link Link pointing to the actual page. * @return string Generated HTML */ - public function render($room) + public function render($page_link) { $toolbar = []; if ($this->daySelectionEnabled && !empty($this->days)) { $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime()); $day_dropdown_items = []; foreach ($this->days as $day) { - $link = page_link_to('rooms', [ - 'action' => 'view', - 'room_id' => $room['RID'], - 'shifts_filter_day' => $day, - ]); + $link = $page_link . '&shifts_filter_day=' . $day; $day_dropdown_items[] = toolbar_item_link($link, '', $day); } $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active'); |