From 1289101f6e4b729018dba64e92b4c9397db67f2d Mon Sep 17 00:00:00 2001 From: msquare Date: Wed, 20 Dec 2017 00:42:58 +0100 Subject: rewrite controller for creating shift entries --- includes/view/Shifts_view.php | 71 ++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 31 deletions(-) (limited to 'includes/view/Shifts_view.php') diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index bc905f39..083477e6 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -2,6 +2,43 @@ use Engelsystem\ShiftSignupState; +/** + * Renders the basic shift view header. + * + * @param array $shift + * @param array $room + * + * @return string HTML + */ +function Shift_view_header($shift, $room) { + return div('row', [ + div('col-sm-3 col-xs-6', [ + '

' . _('Title') . '

', + '

' . ($shift['URL'] != '' ? '' . $shift['title'] . '' : $shift['title']) . '

' + ]), + div('col-sm-3 col-xs-6', [ + '

' . _('Start') . '

', + '

', + glyph('calendar') . date(_('Y-m-d'), $shift['start']), + '
', + glyph('time') . date('H:i', $shift['start']), + '

' + ]), + div('col-sm-3 col-xs-6', [ + '

' . _('End') . '

', + '

', + glyph('calendar') . date(_('Y-m-d'), $shift['end']), + '
', + glyph('time') . date('H:i', $shift['end']), + '

' + ]), + div('col-sm-3 col-xs-6', [ + '

' . _('Location') . '

', + '

' . Room_name_render($room) . '

' + ]) + ]); +} + /** * @param array $shift * @return string @@ -41,10 +78,7 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) } if ($angeltype['shift_signup_state']->isSignupAllowed()) { - return button( - page_link_to('user_shifts', ['shift_id' => $shift['SID'], 'type_id' => $angeltype['id']]), - _('Sign up') - ); + return button(shift_entry_create_link($shift, $angeltype), _('Sign up')); } elseif ($user_angeltype == null) { return button( page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), @@ -100,32 +134,7 @@ function Shift_view($shift, $shifttype, $room, $angeltypes_source, ShiftSignupSt $admin_shifttypes ? button(shifttype_link($shifttype), $shifttype['name']) : '', $admin_rooms ? button(room_link($room), glyph('map-marker') . $room['Name']) : '' ]) : '', - div('row', [ - div('col-sm-3 col-xs-6', [ - '

' . _('Title') . '

', - '

' . ($shift['URL'] != '' ? '' . $shift['title'] . '' : $shift['title']) . '

' - ]), - div('col-sm-3 col-xs-6', [ - '

' . _('Start') . '

', - '

', - glyph('calendar') . date(_('Y-m-d'), $shift['start']), - '
', - glyph('time') . date('H:i', $shift['start']), - '

' - ]), - div('col-sm-3 col-xs-6', [ - '

' . _('End') . '

', - '

', - glyph('calendar') . date(_('Y-m-d'), $shift['end']), - '
', - glyph('time') . date('H:i', $shift['end']), - '

' - ]), - div('col-sm-3 col-xs-6', [ - '

' . _('Location') . '

', - '

' . Room_name_render($room) . '

' - ]) - ]), + Shift_view_header($shift, $room), div('row', [ div('col-sm-6', [ '

' . _('Needed angels') . '

', @@ -213,7 +222,7 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty 'btn-xs' ); } - $entry .= button_glyph(page_link_to('user_shifts', ['entry_id' => $shift_entry['id']]), 'trash', 'btn-xs'); + $entry .= button_glyph(shift_entry_delete_link($shift_entry), 'trash', 'btn-xs'); $entry .= ''; } return $entry; -- cgit v1.2.3-54-g00ecf