blob: 301f31a2418cf8911d5cdf42aaf701f7e80a4ae4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?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;
/**
* Days that can be selected.
* Format Y-m-d
*
* @var string[]
*/
private $days = [];
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');
}
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.
*/
public function isDaySelectionEnabled() {
return $this->daySelectionEnabled;
}
}
?>
|