summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-10-05 18:56:50 +0200
committermsquare <msquare@notrademark.de>2016-10-05 18:56:50 +0200
commit6fff6a6c1a5a4ae6c6977c3aeb4ac532ba09a395 (patch)
treeb32209aa2907e34a7e52d41b6754382fa23d6151 /includes/view
parent27c9650dc4064ec5b40c5041d8291a7ce0e5305e (diff)
begin room view and shifts filter renderer
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/Rooms_view.php7
-rw-r--r--includes/view/ShiftsFilterRenderer.php65
2 files changed, 72 insertions, 0 deletions
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index c820e983..4dbf2956 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -1,4 +1,11 @@
<?php
+use Engelsystem\ShiftsFilterRenderer;
+
+function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer) {
+ return page_with_title(glyph('map-marker') . $room['Name'], [
+ $shiftsFilterRenderer->render()
+ ]);
+}
function Room_name_render($room) {
global $privileges;
diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php
new file mode 100644
index 00000000..94d53bb3
--- /dev/null
+++ b/includes/view/ShiftsFilterRenderer.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Engelsystem;
+
+class ShiftsFilterRenderer {
+
+ /**
+ * The shiftFilter to render.
+ *
+ * @var ShiftsFilter
+ */
+ private $shiftsFilter;
+
+ /**
+ * Should the filter display a day selection.
+ *
+ * @var boolean
+ */
+ private $daySelectionEnabled = false;
+
+ private $days = [];
+
+ private $event_config = null;
+
+ public function __construct(ShiftsFilter $shiftsFilter) {
+ $this->shiftsFilter = $shiftsFilter;
+ }
+
+ /**
+ * Renders the filter.
+ *
+ * @return Generated HTML
+ */
+ public function render() {
+ $toolbar = [];
+ if ($this->daySelectionEnabled && ! empty($this->days)) {
+ $today = date("Y-m-d");
+ $selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
+ $day_dropdown_items = [];
+ foreach ($this->days as $day) {
+ $day_dropdown_items[] = toolbar_item_link('', '', $day);
+ }
+ $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ }
+ return toolbar_pills($toolbar);
+ }
+
+ /**
+ * Should the filter display a day selection.
+ */
+ public function enableDaySelection($days, $event_config) {
+ $this->daySelectionEnabled = true;
+ $this->days = $days;
+ $this->event_config = $event_config;
+ }
+
+ /**
+ * Should the filter display a day selection.
+ */
+ public function isDaySelectionEnabled() {
+ return $this->daySelectionEnabled;
+ }
+}
+
+?> \ No newline at end of file