summaryrefslogtreecommitdiff
path: root/includes/view/Shifts_view.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-12-20 00:42:58 +0100
committermsquare <msquare@notrademark.de>2017-12-20 00:42:58 +0100
commit1289101f6e4b729018dba64e92b4c9397db67f2d (patch)
tree9b63d1174807af762050275062a20dbaf7d761d7 /includes/view/Shifts_view.php
parentafd7c59d1d1e07c61099e3cf6a4c66af883c3302 (diff)
rewrite controller for creating shift entries
Diffstat (limited to 'includes/view/Shifts_view.php')
-rw-r--r--includes/view/Shifts_view.php71
1 files changed, 40 insertions, 31 deletions
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
@@ -3,6 +3,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', [
+ '<h4>' . _('Title') . '</h4>',
+ '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Start') . '</h4>',
+ '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
+ glyph('calendar') . date(_('Y-m-d'), $shift['start']),
+ '<br />',
+ glyph('time') . date('H:i', $shift['start']),
+ '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('End') . '</h4>',
+ '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
+ glyph('calendar') . date(_('Y-m-d'), $shift['end']),
+ '<br />',
+ glyph('time') . date('H:i', $shift['end']),
+ '</p>'
+ ]),
+ div('col-sm-3 col-xs-6', [
+ '<h4>' . _('Location') . '</h4>',
+ '<p class="lead">' . Room_name_render($room) . '</p>'
+ ])
+ ]);
+}
+
+/**
* @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', [
- '<h4>' . _('Title') . '</h4>',
- '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Start') . '</h4>',
- '<p class="lead' . (time() >= $shift['start'] ? ' text-success' : '') . '">',
- glyph('calendar') . date(_('Y-m-d'), $shift['start']),
- '<br />',
- glyph('time') . date('H:i', $shift['start']),
- '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('End') . '</h4>',
- '<p class="lead' . (time() >= $shift['end'] ? ' text-success' : '') . '">',
- glyph('calendar') . date(_('Y-m-d'), $shift['end']),
- '<br />',
- glyph('time') . date('H:i', $shift['end']),
- '</p>'
- ]),
- div('col-sm-3 col-xs-6', [
- '<h4>' . _('Location') . '</h4>',
- '<p class="lead">' . Room_name_render($room) . '</p>'
- ])
- ]),
+ Shift_view_header($shift, $room),
div('row', [
div('col-sm-6', [
'<h2>' . _('Needed angels') . '</h2>',
@@ -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 .= '</div>';
}
return $entry;