|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Anorgan\Onfleet; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class Worker |
|
7
|
|
|
* @package Anorgan\Onfleet |
|
8
|
|
|
*/ |
|
9
|
|
|
class Worker extends Entity |
|
10
|
|
|
{ |
|
11
|
|
|
const TYPE_CREATOR = 'super'; |
|
12
|
|
|
const TYPE_DISPATCHER = 'standard'; |
|
13
|
|
|
|
|
14
|
|
|
protected $name; |
|
15
|
|
|
protected $phone; |
|
16
|
|
|
protected $activeTask; |
|
17
|
|
|
protected $tasks = []; |
|
18
|
|
|
protected $onDuty; |
|
19
|
|
|
protected $location; |
|
20
|
|
|
protected $timeLastSeen; |
|
21
|
|
|
protected $delayTime; |
|
22
|
|
|
protected $teams = []; |
|
23
|
|
|
protected $organization; |
|
24
|
|
|
protected $metadata = []; |
|
25
|
|
|
protected $analytics; |
|
26
|
|
|
protected $vehicle; |
|
27
|
|
|
protected $timeCreated; |
|
28
|
|
|
protected $timeLastModified; |
|
29
|
|
|
|
|
30
|
|
|
protected $endpoint = 'workers'; |
|
31
|
|
|
|
|
32
|
|
|
protected static $properties = [ |
|
33
|
|
|
'id', |
|
34
|
|
|
'name', |
|
35
|
|
|
'phone', |
|
36
|
|
|
'activeTask', |
|
37
|
|
|
'tasks', |
|
38
|
|
|
'onDuty', |
|
39
|
|
|
'location', |
|
40
|
|
|
'timeLastSeen', |
|
41
|
|
|
'delayTime', |
|
42
|
|
|
'teams', |
|
43
|
|
|
'organization', |
|
44
|
|
|
'vehicle', |
|
45
|
|
|
'metadata', |
|
46
|
|
|
'analytics', |
|
47
|
|
|
'timeCreated', |
|
48
|
|
|
'timeLastModified', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @return mixed |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getName() |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->name; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param mixed $name |
|
61
|
|
|
*/ |
|
62
|
|
|
public function setName($name) |
|
63
|
|
|
{ |
|
64
|
|
|
$this->name = $name; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return mixed |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getPhone() |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->phone; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return mixed |
|
77
|
|
|
*/ |
|
78
|
|
|
public function getActiveTask() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->activeTask; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param mixed $activeTask |
|
85
|
|
|
*/ |
|
86
|
|
|
public function setActiveTask($activeTask) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->activeTask = $activeTask; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @return array |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getTasks(): array |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->tasks; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param array $tasks |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setTasks(array $tasks) |
|
103
|
|
|
{ |
|
104
|
|
|
$this->tasks = $tasks; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @return bool |
|
109
|
|
|
*/ |
|
110
|
|
|
public function isOnDuty() |
|
111
|
|
|
{ |
|
112
|
|
|
return $this->onDuty; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* @return mixed |
|
117
|
|
|
*/ |
|
118
|
|
|
public function getLocation() |
|
119
|
|
|
{ |
|
120
|
|
|
return $this->location; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* @return \DateTime |
|
125
|
|
|
*/ |
|
126
|
|
|
public function getTimeLastSeen() |
|
127
|
|
|
{ |
|
128
|
|
|
return $this->toDateTime($this->timeLastSeen); |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return int Amount of time in seconds that a worker is delayed by. |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getDelayTime() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->delayTime; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return array |
|
141
|
|
|
*/ |
|
142
|
|
|
public function getTeams(): array |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->teams; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @param array $teams |
|
149
|
|
|
*/ |
|
150
|
|
|
public function setTeams(array $teams) |
|
151
|
|
|
{ |
|
152
|
|
|
$this->teams = $teams; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @return mixed |
|
157
|
|
|
*/ |
|
158
|
|
|
public function getOrganization() |
|
159
|
|
|
{ |
|
160
|
|
|
return $this->organization; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @param mixed $organization |
|
165
|
|
|
*/ |
|
166
|
|
|
public function setOrganization($organization) |
|
167
|
|
|
{ |
|
168
|
|
|
$this->organization = $organization; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @return array |
|
173
|
|
|
*/ |
|
174
|
|
|
public function getMetadata(): array |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->metadata; |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @return mixed |
|
181
|
|
|
*/ |
|
182
|
|
|
public function getAnalytics() |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->analytics; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @return mixed |
|
189
|
|
|
*/ |
|
190
|
|
|
public function getVehicle() |
|
191
|
|
|
{ |
|
192
|
|
|
return $this->vehicle; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @param mixed $vehicle |
|
197
|
|
|
*/ |
|
198
|
|
|
public function setVehicle($vehicle) |
|
199
|
|
|
{ |
|
200
|
|
|
$this->vehicle = $vehicle; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* @return \DateTime |
|
205
|
|
|
*/ |
|
206
|
|
|
public function getTimeCreated() |
|
207
|
|
|
{ |
|
208
|
|
|
return $this->toDateTime($this->timeCreated); |
|
209
|
|
|
} |
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* @return \DateTime |
|
213
|
|
|
*/ |
|
214
|
|
|
public function getTimeLastModified() |
|
215
|
|
|
{ |
|
216
|
|
|
return $this->toDateTime($this->timeLastModified); |
|
217
|
|
|
} |
|
218
|
|
|
} |
|
219
|
|
|
|