Code Coverage  | 
      ||||||||||
Lines  | 
       Functions and Methods  | 
       Classes and Traits  | 
      ||||||||
| Total |         | 
       97.32%  | 
       291 / 299  | 
               | 
       92.00%  | 
       23 / 25  | 
       CRAP |         | 
       0.00%  | 
       0 / 1  | 
      
| Scope |         | 
       97.32%  | 
       291 / 299  | 
               | 
       92.00%  | 
       23 / 25  | 
       36 |         | 
       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 | |||
| addConditionScopeIds |         | 
       0.00%  | 
       0 / 6  | 
               | 
       0.00%  | 
       0 / 1  | 
       6 | |||
| 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 addConditionScopeIds(array $scopeIds) | 
| 245 | { | 
| 246 | $scopeIds = array_values(array_unique(array_map('intval', $scopeIds))); | 
| 247 | if (!$scopeIds) { | 
| 248 | $this->query->where(self::expression('1'), '=', 0); | 
| 249 | return $this; | 
| 250 | } | 
| 251 | |
| 252 | $this->query->whereIn('scope.StandortID', $scopeIds); | 
| 253 | return $this; | 
| 254 | } | 
| 255 | |
| 256 | public function addConditionWithAdminEmail() | 
| 257 | { | 
| 258 | $this->query->where('scope.emailstandortadmin', '!=', ''); | 
| 259 | return $this; | 
| 260 | } | 
| 261 | |
| 262 | public function addSelectWorkstationCount($dateTime) | 
| 263 | { | 
| 264 | $this->query->select( | 
| 265 | ['status__queue__workstationCount' => self::expression(' | 
| 266 | IF( | 
| 267 | `scope`.`virtuellesachbearbeiterzahl` > -1, | 
| 268 | `scope`.`virtuellesachbearbeiterzahl`, | 
| 269 | ( | 
| 270 | SELECT COUNT(*) | 
| 271 | FROM nutzer | 
| 272 | WHERE nutzer.StandortID = scope.StandortID | 
| 273 | AND nutzer.Datum = "' . $dateTime->format('Y-m-d') . '" | 
| 274 | AND nutzer.Arbeitsplatznr <> 0 | 
| 275 | ) | 
| 276 | ) | 
| 277 | ') | 
| 278 | ] | 
| 279 | ); | 
| 280 | } | 
| 281 | |
| 282 | public function addConditionProviderId($providerId) | 
| 283 | { | 
| 284 | $this->query->where('scope.InfoDienstleisterID', '=', $providerId); | 
| 285 | return $this; | 
| 286 | } | 
| 287 | |
| 288 | public function addConditionDepartmentId($departmentId) | 
| 289 | { | 
| 290 | $this->query->where('scope.BehoerdenID', '=', $departmentId); | 
| 291 | return $this; | 
| 292 | } | 
| 293 | |
| 294 | public function addConditionClusterId($clusterId) | 
| 295 | { | 
| 296 | $this->leftJoin( | 
| 297 | new Alias('clusterzuordnung', 'cluster_scope'), | 
| 298 | 'scope.StandortID', | 
| 299 | '=', | 
| 300 | 'cluster_scope.standortID' | 
| 301 | ); | 
| 302 | $this->query->where('cluster_scope.clusterID', '=', $clusterId); | 
| 303 | return $this; | 
| 304 | } | 
| 305 | |
| 306 | public function reverseEntityMapping(\BO\Zmsentities\Scope $entity, $parentId = null) | 
| 307 | { | 
| 308 | $data = array(); | 
| 309 | if ($parentId) { | 
| 310 | $data['BehoerdenID'] = $parentId; | 
| 311 | } | 
| 312 | $data['InfoDienstleisterID'] = $entity->getProviderId(); | 
| 313 | $data['emailstandortadmin'] = $entity->getContactEMail(); | 
| 314 | $data['standortinfozeile'] = $entity->getScopeInfo(); | 
| 315 | $data['Hinweis'] = $entity->getScopeHint(); | 
| 316 | $data['Bezeichnung'] = $entity->getName(); | 
| 317 | $data['standortkuerzel'] = $entity->shortName; | 
| 318 | $data['Adresse'] = (isset($entity->contact['street'])) ? $entity->contact['street'] : ''; | 
| 319 | $data['loeschdauer'] = $entity->getPreference('appointment', 'deallocationDuration'); | 
| 320 | $data['info_for_appointment'] = $entity->getPreference('appointment', 'infoForAppointment'); | 
| 321 | $data['info_for_all_appointments'] = $entity->getPreference('appointment', 'infoForAllAppointments'); | 
| 322 | $data['Termine_bis'] = $entity->getPreference('appointment', 'endInDaysDefault'); | 
| 323 | $data['Termine_ab'] = $entity->getPreference('appointment', 'startInDaysDefault'); | 
| 324 | $data['mehrfachtermine'] = $entity->getPreference('appointment', 'multipleSlotsEnabled', true); | 
| 325 | // notificationConfirmationEnabled and notificationHeadsUpEnabled are saved in department! | 
| 326 | $data['reservierungsdauer'] = $entity->getPreference('appointment', 'reservationDuration'); | 
| 327 | $data['aktivierungsdauer'] = $entity->getPreference('appointment', 'activationDuration'); | 
| 328 | $data['qtv_url'] = $entity->getPreference('client', 'alternateAppointmentUrl'); | 
| 329 | $data['anmerkungPflichtfeld'] = $entity->getPreference('client', 'amendmentActivated', true); | 
| 330 | $data['anmerkungLabel'] = $entity->getPreference('client', 'amendmentLabel'); | 
| 331 | $data['emailPflichtfeld'] = $entity->getPreference('client', 'emailRequired', true); | 
| 332 | $data['email_confirmation_activated'] = $entity->getPreference('client', 'emailConfirmationActivated', true); | 
| 333 | $data['telefonaktiviert'] = $entity->getPreference('client', 'telephoneActivated', true); | 
| 334 | $data['telefonPflichtfeld'] = $entity->getPreference('client', 'telephoneRequired', true); | 
| 335 | $data['custom_text_field_active'] = $entity->getPreference('client', 'customTextfieldActivated', true); | 
| 336 | $data['custom_text_field_required'] = $entity->getPreference('client', 'customTextfieldRequired', true); | 
| 337 | $data['custom_text_field_label'] = $entity->getPreference('client', 'customTextfieldLabel'); | 
| 338 | $data['custom_text_field2_active'] = $entity->getPreference('client', 'customTextfield2Activated', true); | 
| 339 | $data['custom_text_field2_required'] = $entity->getPreference('client', 'customTextfield2Required', true); | 
| 340 | $data['custom_text_field2_label'] = $entity->getPreference('client', 'customTextfield2Label'); | 
| 341 | $data['captcha_activated_required'] = $entity->getPreference('client', 'captchaActivatedRequired'); | 
| 342 | $data['appointments_per_mail'] = (int) $entity->getPreference('client', 'appointmentsPerMail'); | 
| 343 | $data['slots_per_appointment'] = (int) $entity->getPreference('client', 'slotsPerAppointment'); | 
| 344 | $data['info_for_appointment'] = $entity->getPreference('appointment', 'infoForAppointment'); | 
| 345 | $data['whitelisted_mails'] = $entity->getPreference('client', 'whitelistedMails'); | 
| 346 | $data['admin_mail_on_appointment'] = $entity->getPreference('client', 'adminMailOnAppointment', true); | 
| 347 | $data['admin_mail_on_deleted'] = $entity->getPreference('client', 'adminMailOnDeleted'); | 
| 348 | $data['admin_mail_on_updated'] = $entity->getPreference('client', 'adminMailOnUpdated', true); | 
| 349 | $data['admin_mail_on_mail_sent'] = $entity->getPreference('client', 'adminMailOnMailSent', true); | 
| 350 | $data['smsbestaetigungstext'] = $entity->getPreference('notifications', 'confirmationContent'); | 
| 351 | $data['smsbenachrichtigungstext'] = $entity->getPreference('notifications', 'headsUpContent'); | 
| 352 | $data['smsbenachrichtigungsfrist'] = $entity->getPreference('notifications', 'headsUpTime'); | 
| 353 | $data['ausgabeschaltername'] = $entity->getPreference('pickup', 'alternateName'); | 
| 354 | $data['defaultabholerstandort'] = $entity->getPreference('pickup', 'isDefault', true); | 
| 355 | $data['anzahlwiederaufruf'] = $entity->getPreference('queue', 'callCountMax'); | 
| 356 | $data['aufrufanzeigetext'] = $entity->getPreference('queue', 'callDisplayText', false, ''); | 
| 357 | $data['startwartenr'] = $entity->getPreference('queue', 'firstNumber'); | 
| 358 | $data['endwartenr'] = $entity->getPreference('queue', 'lastNumber'); | 
| 359 | $data['wartenummernkontingent'] = $entity->getPreference('queue', 'maxNumberContingent'); | 
| 360 | $data['display_number_prefix'] = $entity->getPreference('queue', 'displayNumberPrefix') | 
| 361 | ? strtoupper($entity->getPreference('queue', 'displayNumberPrefix')) | 
| 362 | : ''; | 
| 363 | $data['Bearbeitungszeit'] = gmdate("H:i", $entity->getPreference('queue', 'processingTimeAverage') * 60); | 
| 364 | $data['wartezeitveroeffentlichen'] = $entity->getPreference('queue', 'publishWaitingTimeEnabled', true); | 
| 365 | $data['ohnestatistik'] = (0 == $entity->getPreference('queue', 'statisticsEnabled', true)) ? 1 : 0; | 
| 366 | $data['kundenbef_emailtext'] = $entity->getPreference('survey', 'emailContent'); | 
| 367 | $data['kundenbefragung'] = $entity->getPreference('survey', 'enabled', true); | 
| 368 | $data['kundenbef_label'] = $entity->getPreference('survey', 'label'); | 
| 369 | $data['smswmsbestaetigung'] = $entity->getPreference('ticketprinter', 'confirmationEnabled', true); | 
| 370 | $data['wartenrhinweis'] = $entity->getPreference('ticketprinter', 'deactivatedText', false, ''); | 
| 371 | $data['smsnachtrag'] = $entity->getPreference('ticketprinter', 'notificationsAmendmentEnabled', true); | 
| 372 | $data['smswarteschlange'] = $entity->getPreference('ticketprinter', 'notificationsEnabled', true); | 
| 373 | $data['smskioskangebotsfrist'] = $entity->getPreference('ticketprinter', 'notificationsDelay'); | 
| 374 | $data['notruffunktion'] = $entity->getPreference('workstation', 'emergencyEnabled', true); | 
| 375 | $data['notrufantwort'] = $entity->getStatus('emergency', 'acceptedByWorkstation'); | 
| 376 | $data['notrufausgeloest'] = $entity->getStatus('emergency', 'activated'); | 
| 377 | $data['notrufinitiierung'] = $entity->getStatus('emergency', 'calledByWorkstation'); | 
| 378 | $data['virtuellesachbearbeiterzahl'] = $entity->getStatus('queue', 'ghostWorkstationCount'); | 
| 379 | $data['vergebenewartenummern'] = $entity->getStatus('queue', 'givenNumberCount'); | 
| 380 | $data['letztewartenr'] = $entity->getStatus('queue', 'lastGivenNumber'); | 
| 381 | $data['last_display_number'] = $entity->getStatus('queue', 'lastDisplayNumber'); | 
| 382 | $data['max_display_number'] = $entity->getStatus('queue', 'maxDisplayNumber'); | 
| 383 | $lastGivenTimestamp = $entity->getStatus('queue', 'lastGivenNumberTimestamp'); | 
| 384 | $data['wartenrdatum'] = ($lastGivenTimestamp) ? date('Y-m-d', $lastGivenTimestamp) : null; | 
| 385 | $data['wartenrsperre'] = $entity->getStatus('ticketprinter', 'deactivated'); | 
| 386 | $data['source'] = $entity->getProvider()->source; | 
| 387 | |
| 388 | $data = array_filter($data, function ($value) { | 
| 389 | return ($value !== null && $value !== false); | 
| 390 | }); | 
| 391 | return $data; | 
| 392 | } | 
| 393 | |
| 394 | public function setEmergencyEntityMapping(\BO\Zmsentities\Scope $entity) | 
| 395 | { | 
| 396 | $data['notrufantwort'] = ($entity->toProperty()->status->emergency->acceptedByWorkstation->get(-1)); | 
| 397 | $data['notrufausgeloest'] = intval($entity->toProperty()->status->emergency->activated->get(0)); | 
| 398 | $data['notrufinitiierung'] = ($entity->toProperty()->status->emergency->calledByWorkstation->get(-1)); | 
| 399 | return $data; | 
| 400 | } | 
| 401 | |
| 402 | public function setGhostWorkstationCountEntityMapping(\BO\Zmsentities\Scope $entity, \DateTimeInterface $dateTime) | 
| 403 | { | 
| 404 | $data['virtuellesachbearbeiterzahl'] = $entity->getStatus('queue', 'ghostWorkstationCount'); | 
| 405 | $data['datumvirtuellesachbearbeiterzahl'] = $dateTime->format('Y-m-d'); | 
| 406 | return $data; | 
| 407 | } | 
| 408 | |
| 409 | public function postProcess($data) | 
| 410 | { | 
| 411 | $data = $this->convertTimestamps($data); | 
| 412 | $data = $this->setDefaultValues($data); | 
| 413 | return $data; | 
| 414 | } | 
| 415 | |
| 416 | |
| 417 | private function convertTimestamps($data) | 
| 418 | { | 
| 419 | $lastGivenNumberTimestampKey = $this->getPrefixed("status__queue__lastGivenNumberTimestamp"); | 
| 420 | $lastGivenNumberTimestamp = $data[$lastGivenNumberTimestampKey] ?? null; | 
| 421 | $data[$lastGivenNumberTimestampKey] = $lastGivenNumberTimestamp !== null ? strtotime($lastGivenNumberTimestamp) : null; | 
| 422 | |
| 423 | $lastChangeKey = $this->getPrefixed("lastChange"); | 
| 424 | $lastChange = $data[$lastChangeKey] ?? null; | 
| 425 | if ($lastChange !== null) { | 
| 426 | $data[$lastChangeKey] = (new \DateTime($lastChange . \BO\Zmsdb\Connection\Select::$connectionTimezone)) | 
| 427 | ->getTimestamp(); | 
| 428 | } else { | 
| 429 | $data[$lastChangeKey] = null; | 
| 430 | } | 
| 431 | |
| 432 | return $data; | 
| 433 | } | 
| 434 | |
| 435 | private function setDefaultValues($data) | 
| 436 | { | 
| 437 | $this->setIfEmpty($data, 'preferences__client__emailFrom', [ | 
| 438 | 'preferences__client__emailRequired' => 0 | 
| 439 | ]); | 
| 440 | |
| 441 | $this->setIfEmpty($data, 'preferences__client__telephoneActivated', [ | 
| 442 | 'preferences__client__telephoneRequired' => 0 | 
| 443 | ]); | 
| 444 | |
| 445 | $this->setIfEmpty($data, 'preferences__client__emailConfirmationActivated', [ | 
| 446 | 'preferences__client__emailConfirmationActivated' => 0 | 
| 447 | ]); | 
| 448 | |
| 449 | $this->setIfEmpty($data, 'contact__email', [ | 
| 450 | 'preferences__client__adminMailOnAppointment' => 0, | 
| 451 | 'preferences__client__adminMailOnDeleted' => 0, | 
| 452 | 'preferences__client__adminMailOnUpdated' => 0, | 
| 453 | 'preferences__client__adminMailOnMailSent' => 0, | 
| 454 | ]); | 
| 455 | |
| 456 | $this->setIfEmpty($data, 'preferences__client__customTextfieldActivated', [ | 
| 457 | 'preferences__client__customTextfieldRequired' => 0 | 
| 458 | ]); | 
| 459 | |
| 460 | $this->setIfEmpty($data, 'preferences__client__customTextfield2Activated', [ | 
| 461 | 'preferences__client__customTextfield2Required' => 0 | 
| 462 | ]); | 
| 463 | |
| 464 | $this->setIfEmpty($data, 'preferences__client__appointmentsPerMail', [ | 
| 465 | 'preferences__client__appointmentsPerMail' => null | 
| 466 | ]); | 
| 467 | |
| 468 | $this->setIfEmpty($data, 'preferences__client__slotsPerAppointment', [ | 
| 469 | 'preferences__client__slotsPerAppointment' => null | 
| 470 | ]); | 
| 471 | |
| 472 | $this->setIfEmpty($data, 'preferences__client__whitelistedMails', [ | 
| 473 | 'preferences__client__whitelistedMails' => null | 
| 474 | ]); | 
| 475 | |
| 476 | return $data; | 
| 477 | } | 
| 478 | |
| 479 | private function setIfEmpty(&$data, $checkKey, array $setKeys) | 
| 480 | { | 
| 481 | if (!$data[$this->getPrefixed($checkKey)]) { | 
| 482 | foreach ($setKeys as $key => $value) { | 
| 483 | $data[$this->getPrefixed($key)] = $value; | 
| 484 | } | 
| 485 | } | 
| 486 | } | 
| 487 | } |