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.php131
1 files changed, 74 insertions, 57 deletions
diff --git a/includes/view/ShiftsFilterRenderer.php b/includes/view/ShiftsFilterRenderer.php
index 301f31a2..c3e0ccf1 100644
--- a/includes/view/ShiftsFilterRenderer.php
+++ b/includes/view/ShiftsFilterRenderer.php
@@ -2,68 +2,85 @@
namespace Engelsystem;
-class ShiftsFilterRenderer {
+class ShiftsFilterRenderer
+{
+ /**
+ * The shiftFilter to render.
+ *
+ * @var ShiftsFilter
+ */
+ private $shiftsFilter;
- /**
- * The shiftFilter to render.
- *
- * @var ShiftsFilter
- */
- private $shiftsFilter;
+ /**
+ * Should the filter display a day selection.
+ *
+ * @var boolean
+ */
+ private $daySelectionEnabled = false;
- /**
- * Should the filter display a day selection.
- *
- * @var boolean
- */
- private $daySelectionEnabled = false;
+ /**
+ * Days that can be selected.
+ * Format Y-m-d
+ *
+ * @var string[]
+ */
+ private $days = [];
- /**
- * Days that can be selected.
- * Format Y-m-d
- *
- * @var string[]
- */
- private $days = [];
-
- public function __construct(ShiftsFilter $shiftsFilter) {
- $this->shiftsFilter = $shiftsFilter;
- }
+ /**
+ * ShiftsFilterRenderer constructor.
+ *
+ * @param ShiftsFilter $shiftsFilter
+ */
+ public function __construct(ShiftsFilter $shiftsFilter)
+ {
+ $this->shiftsFilter = $shiftsFilter;
+ }
- /**
- * Renders the filter.
- *
- * @return Generated HTML
- */
- public function render($link_base) {
- $toolbar = [];
- if ($this->daySelectionEnabled && ! empty($this->days)) {
- $selected_day = date("Y-m-d", $this->shiftsFilter->getStartTime());
- $day_dropdown_items = [];
- foreach ($this->days as $day) {
- $day_dropdown_items[] = toolbar_item_link($link_base . '&shifts_filter_day=' . $day, '', $day);
- }
- $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ /**
+ * Renders the filter.
+ *
+ * @param array $room
+ * @return string Generated HTML
+ */
+ public function render($room)
+ {
+ $toolbar = [];
+ if ($this->daySelectionEnabled && !empty($this->days)) {
+ $selected_day = date('Y-m-d', $this->shiftsFilter->getStartTime());
+ $day_dropdown_items = [];
+ foreach ($this->days as $day) {
+ $link = page_link_to('rooms', [
+ 'action' => 'view',
+ 'room_id' => $room['RID'],
+ 'shifts_filter_day' => $day,
+ ]);
+ $day_dropdown_items[] = toolbar_item_link($link, '', $day);
+ }
+ $toolbar[] = toolbar_dropdown('', $selected_day, $day_dropdown_items, 'active');
+ }
+ return div('form-group', [
+ toolbar_pills($toolbar)
+ ]);
}
- return div('form-group', [
- toolbar_pills($toolbar)
- ]);
- }
- /**
- * Should the filter display a day selection.
- */
- public function enableDaySelection($days) {
- $this->daySelectionEnabled = true;
- $this->days = $days;
- }
+ /**
+ * Should the filter display a day selection.
+ *
+ * @param string[] $days
+ */
+ public function enableDaySelection($days)
+ {
+ $this->daySelectionEnabled = true;
+ $this->days = $days;
+ }
- /**
- * Should the filter display a day selection.
- */
- public function isDaySelectionEnabled() {
- return $this->daySelectionEnabled;
- }
+ /**
+ * Should the filter display a day selection.
+ *
+ * @return bool
+ */
+ public function isDaySelectionEnabled()
+ {
+ return $this->daySelectionEnabled;
+ }
}
-
-?> \ No newline at end of file