summaryrefslogtreecommitdiff
path: root/includes/view/ShiftsFilterRenderer.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view/ShiftsFilterRenderer.php')
-rw-r--r--includes/view/ShiftsFilterRenderer.php65
1 files changed, 65 insertions, 0 deletions
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