summaryrefslogtreecommitdiff
path: root/includes/view/ShiftTypes_view.php
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-12-25 22:32:18 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-12-25 22:32:18 +0100
commite89acc0c1d1188662da7490e3a75a4a5c3950a75 (patch)
treef646260cc23195008f6ca5152426b17641fc4f69 /includes/view/ShiftTypes_view.php
parentbcd33c02c814a8d82c08c078c8fae287d1cd95a5 (diff)
parent544a51612f14c4f3cf7d1c4a6de26a99ea94b788 (diff)
merge feature-shift-types
Diffstat (limited to 'includes/view/ShiftTypes_view.php')
-rw-r--r--includes/view/ShiftTypes_view.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
new file mode 100644
index 00000000..10431440
--- /dev/null
+++ b/includes/view/ShiftTypes_view.php
@@ -0,0 +1,80 @@
+<?php
+
+function ShiftType_name_render($shifttype) {
+ global $privileges;
+ if (in_array('shifttypes', $privileges))
+ return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
+ return $shifttype['name'];
+}
+
+function ShiftType_delete_view($shifttype) {
+ return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), array(
+ info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
+ buttons(array(
+ button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
+ button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
+ ))
+ ));
+}
+
+function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
+ $angeltypes_select = [
+ '' => _('All')
+ ];
+ foreach ($angeltypes as $angeltype)
+ $angeltypes_select[$angeltype['id']] = $angeltype['name'];
+
+ return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes'), shifttypes_title(), 'back')
+ ]),
+ form([
+ form_text('name', _('Name'), $name),
+ form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype_id),
+ form_textarea('description', _('Description'), $description),
+ form_info('', _('Please use markdown for the description.')),
+ form_submit('submit', _('Save'))
+ ])
+ ]);
+}
+
+function ShiftType_view($shifttype, $angeltype) {
+ $parsedown = new Parsedown();
+ $title = $shifttype['name'];
+ if ($angeltype)
+ $title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
+ return page_with_title($title, [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes'), shifttypes_title(), 'back'),
+ $angeltype ? button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], $angeltype['name']) : '',
+ button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'edit'),
+ button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'delete')
+ ]),
+ $parsedown->parse($shifttype['description'])
+ ]);
+}
+
+function ShiftTypes_list_view($shifttypes) {
+ foreach ($shifttypes as &$shifttype) {
+ $shifttype['name'] = '<a href="' . page_link_to('shifttypes') . '&action=view&shifttype_id=' . $shifttype['id'] . '">' . $shifttype['name'] . '</a>';
+ $shifttype['actions'] = table_buttons([
+ button(page_link_to('shifttypes') . '&action=edit&shifttype_id=' . $shifttype['id'], _('edit'), 'btn-xs'),
+ button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'], _('delete'), 'btn-xs')
+ ]);
+ }
+
+ return page_with_title(shifttypes_title(), [
+ msg(),
+ buttons([
+ button(page_link_to('shifttypes') . '&action=edit', _('New shifttype'), 'add')
+ ]),
+ table([
+ 'name' => _('Name'),
+ 'actions' => ''
+ ], $shifttypes)
+ ]);
+}
+
+?> \ No newline at end of file