blob: 47ef50d740afedc0882b47c1b331b1b00189d03a (
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
<?php
namespace Engelsystem;
/**
* BO Class that stores all parameters used to filter shifts for users.
*
* @author msquare
*/
class ShiftsFilter
{
/**
* How long can the time interval be?
* 86400 = one day
*/
const MAX_DURATION = 86400;
/**
* Shift is completely full.
*/
const FILLED_FILLED = 1;
/**
* Shift has some free slots.
*/
const FILLED_FREE = 0;
/**
* Has the user "user shifts admin" privilege?
*
* @var boolean
*/
private $userShiftsAdmin;
/** @var int[] */
private $filled = [];
/** @var int[] */
private $rooms = [];
/** @var int[] */
private $types = [];
/** @var int unix timestamp */
private $startTime = null;
/** @var int unix timestamp */
private $endTime = null;
/**
* ShiftsFilter constructor.
*
* @param bool $user_shifts_admin
* @param int[] $rooms
* @param int[] $types
*/
public function __construct($user_shifts_admin, $rooms, $types)
{
$this->user_shifts_admin = $user_shifts_admin;
$this->rooms = $rooms;
$this->types = $types;
$this->filled = [
ShiftsFilter::FILLED_FREE
];
if ($user_shifts_admin) {
$this->filled[] = ShiftsFilter::FILLED_FILLED;
}
}
/**
* @return int unix timestamp
*/
public function getStartTime()
{
return $this->startTime;
}
/**
* @param int $startTime unix timestamp
*/
public function setStartTime($startTime)
{
$this->startTime = $startTime;
}
/**
* @return int unix timestamp
*/
public function getEndTime()
{
return $this->endTime;
}
/**
* @param int $endTime unix timestamp
*/
public function setEndTime($endTime)
{
if ($endTime - $this->startTime > ShiftsFilter::MAX_DURATION) {
$endTime = $this->startTime + ShiftsFilter::MAX_DURATION;
}
$this->endTime = $endTime;
}
/**
* @return int[]
*/
public function getTypes()
{
if (count($this->types) == 0) {
return [0];
}
return $this->types;
}
/**
* @param int[] $types
*/
public function setTypes($types)
{
$this->types = $types;
}
/**
* @return int[]
*/
public function getRooms()
{
if (count($this->rooms) == 0) {
return [0];
}
return $this->rooms;
}
/**
* @param int[] $rooms
*/
public function setRooms($rooms)
{
$this->rooms = $rooms;
}
/**
* @return bool
*/
public function isUserShiftsAdmin()
{
return $this->userShiftsAdmin;
}
/**
* @param bool $userShiftsAdmin
*/
public function setUserShiftsAdmin($userShiftsAdmin)
{
$this->userShiftsAdmin = $userShiftsAdmin;
}
/**
* @return int[]
*/
public function getFilled()
{
return $this->filled;
}
/**
* @param int[] $filled
*/
public function setFilled($filled)
{
$this->filled = $filled;
}
}
|