Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
99.32% |
291 / 293 |
|
95.83% |
23 / 24 |
CRAP | |
0.00% |
0 / 1 |
Scope | |
99.32% |
291 / 293 |
|
95.83% |
23 / 24 |
34 | |
0.00% |
0 / 1 |
getQueryLastWaitingNumber | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQueryLastDisplayNumber | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getQueryGivenNumbersInContingent | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQuerySimpleClusterMatch | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQuerySimpleDepartmentMatch | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQueryReadImageData | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQueryWriteImageData | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getQueryDeleteImage | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addJoin | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
addRequiredJoins | |
100.00% |
22 / 22 |
|
100.00% |
1 / 1 |
1 | |||
getEntityMapping | |
100.00% |
92 / 92 |
|
100.00% |
1 / 1 |
1 | |||
addConditionScopeId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionWithAdminEmail | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addSelectWorkstationCount | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
addConditionProviderId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionDepartmentId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
addConditionClusterId | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
reverseEntityMapping | |
100.00% |
81 / 81 |
|
100.00% |
1 / 1 |
7 | |||
setEmergencyEntityMapping | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
setGhostWorkstationCountEntityMapping | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
postProcess | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
convertTimestamps | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
3 | |||
setDefaultValues | |
100.00% |
31 / 31 |
|
100.00% |
1 / 1 |
1 | |||
setIfEmpty | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | namespace BO\Zmsdb\Query; |
4 | |
5 | class Scope extends Base implements MappingInterface |
6 | { |
7 | /** |
8 | * @var String TABLE mysql table reference |
9 | */ |
10 | const TABLE = 'standort'; |
11 | |
12 | const QUERY_BY_DEPARTMENTID = 'SELECT |
13 | scope.`StandortID` AS id |
14 | FROM `standort` scope |
15 | WHERE |
16 | scope.`BehoerdenID` = :department_id |
17 | '; |
18 | |
19 | public function getQueryLastWaitingNumber() |
20 | { |
21 | return ' |
22 | SELECT letztewartenr |
23 | FROM `standort` scope |
24 | WHERE scope.`StandortID` = :scope_id LIMIT 1 FOR UPDATE'; |
25 | } |
26 | |
27 | public function getQueryLastDisplayNumber() |
28 | { |
29 | return ' |
30 | SELECT last_display_number |
31 | FROM `standort` scope |
32 | WHERE scope.`StandortID` = :scope_id LIMIT 1 FOR UPDATE'; |
33 | } |
34 | |
35 | public function getQueryGivenNumbersInContingent() |
36 | { |
37 | return ' |
38 | SELECT * |
39 | FROM `standort` scope |
40 | WHERE |
41 | scope.`StandortID` = :scope_id AND |
42 | IF( |
43 | scope.`wartenummernkontingent` > 0, |
44 | IF( |
45 | isNull(scope.`vergebenewartenummern`), |
46 | 0, |
47 | scope.`vergebenewartenummern` |
48 | ) < scope.`wartenummernkontingent`, |
49 | scope.`StandortID` |
50 | ) |
51 | '; |
52 | } |
53 | |
54 | public function getQuerySimpleClusterMatch() |
55 | { |
56 | return ' |
57 | SELECT standortID AS id |
58 | FROM `clusterzuordnung` |
59 | WHERE |
60 | clusterID = ? |
61 | '; |
62 | } |
63 | |
64 | public function getQuerySimpleDepartmentMatch() |
65 | { |
66 | return ' |
67 | SELECT s.StandortID AS id, p.name AS contact__name |
68 | FROM `standort` AS s |
69 | LEFT JOIN `provider` AS p ON s.InfoDienstleisterID = p.id |
70 | AND p.source = s.source |
71 | WHERE |
72 | s.BehoerdenID = ? |
73 | '; |
74 | } |
75 | |
76 | public function getQueryReadImageData() |
77 | { |
78 | return ' |
79 | SELECT `imagecontent`, `imagename` |
80 | FROM `imagedata` |
81 | WHERE |
82 | `imagename` LIKE :imagename |
83 | '; |
84 | } |
85 | |
86 | public function getQueryWriteImageData() |
87 | { |
88 | return ' |
89 | REPLACE INTO `imagedata` |
90 | SET |
91 | imagename=:imagename, |
92 | imagecontent=:imagedata |
93 | '; |
94 | } |
95 | |
96 | public function getQueryDeleteImage() |
97 | { |
98 | return ' |
99 | DELETE FROM `imagedata` |
100 | WHERE |
101 | `imagename` LIKE :imagename |
102 | '; |
103 | } |
104 | |
105 | public function addJoin() |
106 | { |
107 | $this->leftJoin( |
108 | new Alias(Provider::getTablename(), 'provider'), |
109 | self::expression('scope.InfoDienstleisterID = provider.id && scope.source = provider.source') |
110 | ); |
111 | $providerQuery = new Provider($this, $this->getPrefixed('provider__')); |
112 | return [$providerQuery]; |
113 | } |
114 | |
115 | protected function addRequiredJoins() |
116 | { |
117 | $this->leftJoin( |
118 | new Alias(Department::TABLE, 'scopedepartment'), |
119 | 'scope.BehoerdenID', |
120 | '=', |
121 | 'scopedepartment.BehoerdenID' |
122 | ); |
123 | $this->leftJoin( |
124 | new Alias('sms', 'scopesms'), |
125 | 'scopedepartment.BehoerdenID', |
126 | '=', |
127 | 'scopesms.BehoerdenID' |
128 | ); |
129 | $this->leftJoin( |
130 | new Alias('email', 'scopemail'), |
131 | 'scopedepartment.BehoerdenID', |
132 | '=', |
133 | 'scopemail.BehoerdenID' |
134 | ); |
135 | $this->leftJoin( |
136 | new Alias(Provider::getTablename(), 'scopeprovider'), |
137 | self::expression('scope.InfoDienstleisterID = scopeprovider.id && scope.source = scopeprovider.source') |
138 | ); |
139 | } |
140 | |
141 | //Todo: now() Parameter to enable query cache |
142 | public function getEntityMapping() |
143 | { |
144 | return [ |
145 | 'hint' => 'scope.Hinweis', |
146 | 'id' => 'scope.StandortID', |
147 | 'contact__name' => 'scopeprovider.name', |
148 | 'contact__street' => 'scope.Adresse', |
149 | 'contact__email' => 'scope.emailstandortadmin', |
150 | 'contact__country' => self::expression('"Germany"'), |
151 | 'lastChange' => 'scope.updateTimestamp', |
152 | 'preferences__appointment__deallocationDuration' => 'scope.loeschdauer', |
153 | 'preferences__appointment__infoForAppointment' => 'scope.info_for_appointment', |
154 | 'preferences__appointment__infoForAllAppointments' => 'scope.info_for_all_appointments', |
155 | 'preferences__appointment__endInDaysDefault' => 'scope.Termine_bis', |
156 | 'preferences__appointment__multipleSlotsEnabled' => 'scope.mehrfachtermine', |
157 | 'preferences__appointment__reservationDuration' => 'scope.reservierungsdauer', |
158 | 'preferences__appointment__activationDuration' => 'scope.aktivierungsdauer', |
159 | 'preferences__appointment__startInDaysDefault' => 'scope.Termine_ab', |
160 | 'preferences__appointment__notificationConfirmationEnabled' => |
161 | self::expression('scopesms.enabled && scopesms.Absender != "" && scopesms.internetbestaetigung'), |
162 | 'preferences__appointment__notificationHeadsUpEnabled' => |
163 | self::expression('scopesms.enabled && scopesms.Absender != "" && scopesms.interneterinnerung'), |
164 | 'preferences__client__alternateAppointmentUrl' => 'scope.qtv_url', |
165 | 'preferences__client__amendmentActivated' => 'scope.anmerkungPflichtfeld', |
166 | 'preferences__client__amendmentLabel' => 'scope.anmerkungLabel', |
167 | 'preferences__client__emailFrom' => 'scopemail.absenderadresse', |
168 | 'preferences__client__emailRequired' => 'scope.emailPflichtfeld', |
169 | 'preferences__client__emailConfirmationActivated' => 'scope.email_confirmation_activated', |
170 | 'preferences__client__telephoneActivated' => 'scope.telefonaktiviert', |
171 | 'preferences__client__telephoneRequired' => 'scope.telefonPflichtfeld', |
172 | 'preferences__client__appointmentsPerMail' => 'scope.appointments_per_mail', |
173 | 'preferences__client__slotsPerAppointment' => 'scope.slots_per_appointment', |
174 | 'preferences__client__whitelistedMails' => 'scope.whitelisted_mails', |
175 | 'preferences__client__customTextfieldActivated' => 'scope.custom_text_field_active', |
176 | 'preferences__client__customTextfieldRequired' => 'scope.custom_text_field_required', |
177 | 'preferences__client__customTextfieldLabel' => 'scope.custom_text_field_label', |
178 | 'preferences__client__customTextfield2Activated' => 'scope.custom_text_field2_active', |
179 | 'preferences__client__customTextfield2Required' => 'scope.custom_text_field2_required', |
180 | 'preferences__client__customTextfield2Label' => 'scope.custom_text_field2_label', |
181 | 'preferences__client__captchaActivatedRequired' => 'scope.captcha_activated_required', |
182 | 'preferences__client__adminMailOnAppointment' => 'scope.admin_mail_on_appointment', |
183 | 'preferences__client__adminMailOnDeleted' => 'scope.admin_mail_on_deleted', |
184 | 'preferences__client__adminMailOnUpdated' => 'scope.admin_mail_on_updated', |
185 | 'preferences__client__adminMailOnMailSent' => 'scope.admin_mail_on_mail_sent', |
186 | 'preferences__notifications__confirmationContent' => 'scope.smsbestaetigungstext', |
187 | 'preferences__notifications__headsUpContent' => 'scope.smsbenachrichtigungstext', |
188 | 'preferences__notifications__headsUpTime' => 'scope.smsbenachrichtigungsfrist', |
189 | 'preferences__pickup__alternateName' => 'scope.ausgabeschaltername', |
190 | 'preferences__pickup__isDefault' => 'scope.defaultabholerstandort', |
191 | 'preferences__queue__callCountMax' => 'scope.anzahlwiederaufruf', |
192 | 'preferences__queue__callDisplayText' => 'scope.aufrufanzeigetext', |
193 | 'preferences__queue__firstNumber' => 'scope.startwartenr', |
194 | 'preferences__queue__lastNumber' => 'scope.endwartenr', |
195 | 'preferences__queue__maxNumberContingent' => 'scope.wartenummernkontingent', |
196 | 'preferences__queue__displayNumberPrefix' => 'scope.display_number_prefix', |
197 | 'preferences__queue__processingTimeAverage' => self::expression( |
198 | 'FLOOR(TIME_TO_SEC(`scope`.`Bearbeitungszeit`) / 60)' |
199 | ), |
200 | 'preferences__queue__publishWaitingTimeEnabled' => 'scope.wartezeitveroeffentlichen', |
201 | 'preferences__queue__statisticsEnabled' => self::expression('NOT `scope`.`ohnestatistik`'), |
202 | 'preferences__survey__emailContent' => 'scope.kundenbef_emailtext', |
203 | 'preferences__survey__enabled' => 'scope.kundenbefragung', |
204 | 'preferences__survey__label' => 'scope.kundenbef_label', |
205 | 'preferences__ticketprinter__buttonName' => self::expression( |
206 | 'IF(`scope`.`standortinfozeile`!="", `scope`.`standortinfozeile`, `scope`.`Bezeichnung`)' |
207 | ), |
208 | 'preferences__ticketprinter__confirmationEnabled' => 'scope.smswmsbestaetigung', |
209 | 'preferences__ticketprinter__deactivatedText' => 'scope.wartenrhinweis', |
210 | 'preferences__ticketprinter__notificationsAmendmentEnabled' => 'scope.smsnachtrag', |
211 | 'preferences__ticketprinter__notificationsEnabled' => 'scope.smswarteschlange', |
212 | 'preferences__ticketprinter__notificationsDelay' => 'scope.smskioskangebotsfrist', |
213 | 'preferences__workstation__emergencyEnabled' => 'scope.notruffunktion', |
214 | 'preferences__workstation__emergencyRefreshInterval' => self::expression( |
215 | '(SELECT `value` FROM config WHERE `name`="emergency__refreshInterval")' |
216 | ), |
217 | 'shortName' => 'scope.standortkuerzel', |
218 | 'status__emergency__acceptedByWorkstation' => 'scope.notrufantwort', |
219 | 'status__emergency__activated' => 'scope.notrufausgeloest', |
220 | 'status__emergency__calledByWorkstation' => 'scope.notrufinitiierung', |
221 | 'status__queue__ghostWorkstationCount' => 'scope.virtuellesachbearbeiterzahl', |
222 | 'status__queue__givenNumberCount' => 'scope.vergebenewartenummern', |
223 | 'status__queue__lastGivenNumber' => 'scope.letztewartenr', |
224 | 'status__queue__lastDisplayNumber' => 'scope.last_display_number', |
225 | 'status__queue__maxDisplayNumber' => 'scope.max_display_number', |
226 | 'status__queue__lastGivenNumberTimestamp' => 'scope.wartenrdatum', |
227 | 'status__ticketprinter__deactivated' => 'scope.wartenrsperre', |
228 | 'provider__id' => self::expression( |
229 | 'IF(`scopeprovider`.`id`!="", `scopeprovider`.`id`, `scope`.`InfoDienstleisterID`)' |
230 | ), |
231 | 'provider__source' => self::expression( |
232 | 'IF(`scopeprovider`.`source`!="", `scopeprovider`.`source`, `scope`.`source`)' |
233 | ), |
234 | 'source' => 'scope.source' |
235 | ]; |
236 | } |
237 | |
238 | public function addConditionScopeId($scopeId) |
239 | { |
240 | $this->query->where('scope.StandortID', '=', $scopeId); |
241 | return $this; |
242 | } |
243 | |
244 | public function addConditionWithAdminEmail() |
245 | { |
246 | $this->query->where('scope.emailstandortadmin', '!=', ''); |
247 | return $this; |
248 | } |
249 | |
250 | public function addSelectWorkstationCount($dateTime) |
251 | { |
252 | $this->query->select( |
253 | ['status__queue__workstationCount' => self::expression(' |
254 | IF( |
255 | `scope`.`virtuellesachbearbeiterzahl` > -1, |
256 | `scope`.`virtuellesachbearbeiterzahl`, |
257 | ( |
258 | SELECT COUNT(*) |
259 | FROM nutzer |
260 | WHERE nutzer.StandortID = scope.StandortID |
261 | AND nutzer.Datum = "' . $dateTime->format('Y-m-d') . '" |
262 | AND nutzer.Arbeitsplatznr <> 0 |
263 | ) |
264 | ) |
265 | ') |
266 | ] |
267 | ); |
268 | } |
269 | |
270 | public function addConditionProviderId($providerId) |
271 | { |
272 | $this->query->where('scope.InfoDienstleisterID', '=', $providerId); |
273 | return $this; |
274 | } |
275 | |
276 | public function addConditionDepartmentId($departmentId) |
277 | { |
278 | $this->query->where('scope.BehoerdenID', '=', $departmentId); |
279 | return $this; |
280 | } |
281 | |
282 | public function addConditionClusterId($clusterId) |
283 | { |
284 | $this->leftJoin( |
285 | new Alias('clusterzuordnung', 'cluster_scope'), |
286 | 'scope.StandortID', |
287 | '=', |
288 | 'cluster_scope.standortID' |
289 | ); |
290 | $this->query->where('cluster_scope.clusterID', '=', $clusterId); |
291 | return $this; |
292 | } |
293 | |
294 | public function reverseEntityMapping(\BO\Zmsentities\Scope $entity, $parentId = null) |
295 | { |
296 | $data = array(); |
297 | if ($parentId) { |
298 | $data['BehoerdenID'] = $parentId; |
299 | } |
300 | $data['InfoDienstleisterID'] = $entity->getProviderId(); |
301 | $data['emailstandortadmin'] = $entity->getContactEMail(); |
302 | $data['standortinfozeile'] = $entity->getScopeInfo(); |
303 | $data['Hinweis'] = $entity->getScopeHint(); |
304 | $data['Bezeichnung'] = $entity->getName(); |
305 | $data['standortkuerzel'] = $entity->shortName; |
306 | $data['Adresse'] = (isset($entity->contact['street'])) ? $entity->contact['street'] : ''; |
307 | $data['loeschdauer'] = $entity->getPreference('appointment', 'deallocationDuration'); |
308 | $data['info_for_appointment'] = $entity->getPreference('appointment', 'infoForAppointment'); |
309 | $data['info_for_all_appointments'] = $entity->getPreference('appointment', 'infoForAllAppointments'); |
310 | $data['Termine_bis'] = $entity->getPreference('appointment', 'endInDaysDefault'); |
311 | $data['Termine_ab'] = $entity->getPreference('appointment', 'startInDaysDefault'); |
312 | $data['mehrfachtermine'] = $entity->getPreference('appointment', 'multipleSlotsEnabled', true); |
313 | // notificationConfirmationEnabled and notificationHeadsUpEnabled are saved in department! |
314 | $data['reservierungsdauer'] = $entity->getPreference('appointment', 'reservationDuration'); |
315 | $data['aktivierungsdauer'] = $entity->getPreference('appointment', 'activationDuration'); |
316 | $data['qtv_url'] = $entity->getPreference('client', 'alternateAppointmentUrl'); |
317 | $data['anmerkungPflichtfeld'] = $entity->getPreference('client', 'amendmentActivated', true); |
318 | $data['anmerkungLabel'] = $entity->getPreference('client', 'amendmentLabel'); |
319 | $data['emailPflichtfeld'] = $entity->getPreference('client', 'emailRequired', true); |
320 | $data['email_confirmation_activated'] = $entity->getPreference('client', 'emailConfirmationActivated', true); |
321 | $data['telefonaktiviert'] = $entity->getPreference('client', 'telephoneActivated', true); |
322 | $data['telefonPflichtfeld'] = $entity->getPreference('client', 'telephoneRequired', true); |
323 | $data['custom_text_field_active'] = $entity->getPreference('client', 'customTextfieldActivated', true); |
324 | $data['custom_text_field_required'] = $entity->getPreference('client', 'customTextfieldRequired', true); |
325 | $data['custom_text_field_label'] = $entity->getPreference('client', 'customTextfieldLabel'); |
326 | $data['custom_text_field2_active'] = $entity->getPreference('client', 'customTextfield2Activated', true); |
327 | $data['custom_text_field2_required'] = $entity->getPreference('client', 'customTextfield2Required', true); |
328 | $data['custom_text_field2_label'] = $entity->getPreference('client', 'customTextfield2Label'); |
329 | $data['captcha_activated_required'] = $entity->getPreference('client', 'captchaActivatedRequired'); |
330 | $data['appointments_per_mail'] = (int) $entity->getPreference('client', 'appointmentsPerMail'); |
331 | $data['slots_per_appointment'] = (int) $entity->getPreference('client', 'slotsPerAppointment'); |
332 | $data['info_for_appointment'] = $entity->getPreference('appointment', 'infoForAppointment'); |
333 | $data['whitelisted_mails'] = $entity->getPreference('client', 'whitelistedMails'); |
334 | $data['admin_mail_on_appointment'] = $entity->getPreference('client', 'adminMailOnAppointment', true); |
335 | $data['admin_mail_on_deleted'] = $entity->getPreference('client', 'adminMailOnDeleted'); |
336 | $data['admin_mail_on_updated'] = $entity->getPreference('client', 'adminMailOnUpdated', true); |
337 | $data['admin_mail_on_mail_sent'] = $entity->getPreference('client', 'adminMailOnMailSent', true); |
338 | $data['smsbestaetigungstext'] = $entity->getPreference('notifications', 'confirmationContent'); |
339 | $data['smsbenachrichtigungstext'] = $entity->getPreference('notifications', 'headsUpContent'); |
340 | $data['smsbenachrichtigungsfrist'] = $entity->getPreference('notifications', 'headsUpTime'); |
341 | $data['ausgabeschaltername'] = $entity->getPreference('pickup', 'alternateName'); |
342 | $data['defaultabholerstandort'] = $entity->getPreference('pickup', 'isDefault', true); |
343 | $data['anzahlwiederaufruf'] = $entity->getPreference('queue', 'callCountMax'); |
344 | $data['aufrufanzeigetext'] = $entity->getPreference('queue', 'callDisplayText', false, ''); |
345 | $data['startwartenr'] = $entity->getPreference('queue', 'firstNumber'); |
346 | $data['endwartenr'] = $entity->getPreference('queue', 'lastNumber'); |
347 | $data['wartenummernkontingent'] = $entity->getPreference('queue', 'maxNumberContingent'); |
348 | $data['display_number_prefix'] = $entity->getPreference('queue', 'displayNumberPrefix') |
349 | ? strtoupper($entity->getPreference('queue', 'displayNumberPrefix')) |
350 | : ''; |
351 | $data['Bearbeitungszeit'] = gmdate("H:i", $entity->getPreference('queue', 'processingTimeAverage') * 60); |
352 | $data['wartezeitveroeffentlichen'] = $entity->getPreference('queue', 'publishWaitingTimeEnabled', true); |
353 | $data['ohnestatistik'] = (0 == $entity->getPreference('queue', 'statisticsEnabled', true)) ? 1 : 0; |
354 | $data['kundenbef_emailtext'] = $entity->getPreference('survey', 'emailContent'); |
355 | $data['kundenbefragung'] = $entity->getPreference('survey', 'enabled', true); |
356 | $data['kundenbef_label'] = $entity->getPreference('survey', 'label'); |
357 | $data['smswmsbestaetigung'] = $entity->getPreference('ticketprinter', 'confirmationEnabled', true); |
358 | $data['wartenrhinweis'] = $entity->getPreference('ticketprinter', 'deactivatedText', false, ''); |
359 | $data['smsnachtrag'] = $entity->getPreference('ticketprinter', 'notificationsAmendmentEnabled', true); |
360 | $data['smswarteschlange'] = $entity->getPreference('ticketprinter', 'notificationsEnabled', true); |
361 | $data['smskioskangebotsfrist'] = $entity->getPreference('ticketprinter', 'notificationsDelay'); |
362 | $data['notruffunktion'] = $entity->getPreference('workstation', 'emergencyEnabled', true); |
363 | $data['notrufantwort'] = $entity->getStatus('emergency', 'acceptedByWorkstation'); |
364 | $data['notrufausgeloest'] = $entity->getStatus('emergency', 'activated'); |
365 | $data['notrufinitiierung'] = $entity->getStatus('emergency', 'calledByWorkstation'); |
366 | $data['virtuellesachbearbeiterzahl'] = $entity->getStatus('queue', 'ghostWorkstationCount'); |
367 | $data['vergebenewartenummern'] = $entity->getStatus('queue', 'givenNumberCount'); |
368 | $data['letztewartenr'] = $entity->getStatus('queue', 'lastGivenNumber'); |
369 | $data['last_display_number'] = $entity->getStatus('queue', 'lastDisplayNumber'); |
370 | $data['max_display_number'] = $entity->getStatus('queue', 'maxDisplayNumber'); |
371 | $lastGivenTimestamp = $entity->getStatus('queue', 'lastGivenNumberTimestamp'); |
372 | $data['wartenrdatum'] = ($lastGivenTimestamp) ? date('Y-m-d', $lastGivenTimestamp) : null; |
373 | $data['wartenrsperre'] = $entity->getStatus('ticketprinter', 'deactivated'); |
374 | $data['source'] = $entity->getProvider()->source; |
375 | |
376 | $data = array_filter($data, function ($value) { |
377 | return ($value !== null && $value !== false); |
378 | }); |
379 | return $data; |
380 | } |
381 | |
382 | public function setEmergencyEntityMapping(\BO\Zmsentities\Scope $entity) |
383 | { |
384 | $data['notrufantwort'] = ($entity->toProperty()->status->emergency->acceptedByWorkstation->get(-1)); |
385 | $data['notrufausgeloest'] = intval($entity->toProperty()->status->emergency->activated->get(0)); |
386 | $data['notrufinitiierung'] = ($entity->toProperty()->status->emergency->calledByWorkstation->get(-1)); |
387 | return $data; |
388 | } |
389 | |
390 | public function setGhostWorkstationCountEntityMapping(\BO\Zmsentities\Scope $entity, \DateTimeInterface $dateTime) |
391 | { |
392 | $data['virtuellesachbearbeiterzahl'] = $entity->getStatus('queue', 'ghostWorkstationCount'); |
393 | $data['datumvirtuellesachbearbeiterzahl'] = $dateTime->format('Y-m-d'); |
394 | return $data; |
395 | } |
396 | |
397 | public function postProcess($data) |
398 | { |
399 | $data = $this->convertTimestamps($data); |
400 | $data = $this->setDefaultValues($data); |
401 | return $data; |
402 | } |
403 | |
404 | |
405 | private function convertTimestamps($data) |
406 | { |
407 | $lastGivenNumberTimestampKey = $this->getPrefixed("status__queue__lastGivenNumberTimestamp"); |
408 | $lastGivenNumberTimestamp = $data[$lastGivenNumberTimestampKey] ?? null; |
409 | $data[$lastGivenNumberTimestampKey] = $lastGivenNumberTimestamp !== null ? strtotime($lastGivenNumberTimestamp) : null; |
410 | |
411 | $lastChangeKey = $this->getPrefixed("lastChange"); |
412 | $lastChange = $data[$lastChangeKey] ?? null; |
413 | if ($lastChange !== null) { |
414 | $data[$lastChangeKey] = (new \DateTime($lastChange . \BO\Zmsdb\Connection\Select::$connectionTimezone)) |
415 | ->getTimestamp(); |
416 | } else { |
417 | $data[$lastChangeKey] = null; |
418 | } |
419 | |
420 | return $data; |
421 | } |
422 | |
423 | private function setDefaultValues($data) |
424 | { |
425 | $this->setIfEmpty($data, 'preferences__client__emailFrom', [ |
426 | 'preferences__client__emailRequired' => 0 |
427 | ]); |
428 | |
429 | $this->setIfEmpty($data, 'preferences__client__telephoneActivated', [ |
430 | 'preferences__client__telephoneRequired' => 0 |
431 | ]); |
432 | |
433 | $this->setIfEmpty($data, 'preferences__client__emailConfirmationActivated', [ |
434 | 'preferences__client__emailConfirmationActivated' => 0 |
435 | ]); |
436 | |
437 | $this->setIfEmpty($data, 'contact__email', [ |
438 | 'preferences__client__adminMailOnAppointment' => 0, |
439 | 'preferences__client__adminMailOnDeleted' => 0, |
440 | 'preferences__client__adminMailOnUpdated' => 0, |
441 | 'preferences__client__adminMailOnMailSent' => 0, |
442 | ]); |
443 | |
444 | $this->setIfEmpty($data, 'preferences__client__customTextfieldActivated', [ |
445 | 'preferences__client__customTextfieldRequired' => 0 |
446 | ]); |
447 | |
448 | $this->setIfEmpty($data, 'preferences__client__customTextfield2Activated', [ |
449 | 'preferences__client__customTextfield2Required' => 0 |
450 | ]); |
451 | |
452 | $this->setIfEmpty($data, 'preferences__client__appointmentsPerMail', [ |
453 | 'preferences__client__appointmentsPerMail' => null |
454 | ]); |
455 | |
456 | $this->setIfEmpty($data, 'preferences__client__slotsPerAppointment', [ |
457 | 'preferences__client__slotsPerAppointment' => null |
458 | ]); |
459 | |
460 | $this->setIfEmpty($data, 'preferences__client__whitelistedMails', [ |
461 | 'preferences__client__whitelistedMails' => null |
462 | ]); |
463 | |
464 | return $data; |
465 | } |
466 | |
467 | private function setIfEmpty(&$data, $checkKey, array $setKeys) |
468 | { |
469 | if (!$data[$this->getPrefixed($checkKey)]) { |
470 | foreach ($setKeys as $key => $value) { |
471 | $data[$this->getPrefixed($key)] = $value; |
472 | } |
473 | } |
474 | } |
475 | } |