Lines
95.23%
40 / 42
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| TicketprinterConfig | 95.23% | 40 / 42 | 0.00% | 0 / 1 | 7 | 0.00% | 0 / 1 | |||
| readResponse | 95.23% | 40 / 42 | 0.00% | 0 / 1 | 7 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsadmin | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsadmin; | |
| 9 | ||
| 10 | use BO\Mellon\Validator; | |
| 11 | use BO\Slim\Render; | |
| 12 | use BO\Zmsentities\Collection\RequestList; | |
| 13 | use BO\Zmsentities\Collection\DepartmentList; | |
| 14 | use BO\Zmsentities\Department; | |
| 15 | use BO\Zmsentities\Exception\UserAccountMissingRights; | |
| 16 | ||
| 17 | class TicketprinterConfig extends BaseController | |
| 18 | { | |
| 19 | /** | |
| 20 | * @SuppressWarnings(Param) | |
| 21 | * @return \Psr\Http\Message\ResponseInterface | |
| 22 | */ | |
| 23 | #[\Override] | |
| 24 | public function readResponse( | |
| 25 | \Psr\Http\Message\RequestInterface $request, | |
| 26 | \Psr\Http\Message\ResponseInterface $response, | |
| 27 | array $args | |
| 28 | ): \Psr\Http\Message\ResponseInterface { | |
| 29 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 1])->getEntity(); | |
| 30 | if (!$workstation->getUseraccount()->hasPermissions(['ticketprinter'])) { | |
| 31 | throw new UserAccountMissingRights(); | |
| 32 | } | |
| 33 | $scopeId = Validator::value($workstation['scope']['id'])->isNumber()->getValue(); | |
| 34 | $config = \App::$http->readGetResult('/config/')->getEntity(); | |
| 35 | $organisation = \App::$http->readGetResult( | |
| 36 | '/scope/' . $scopeId . '/organisation/', | |
| 37 | ['resolveReferences' => 5] | |
| 38 | )->getEntity(); | |
| 39 | ||
| 40 | $source = \App::$http->readGetResult( | |
| 41 | '/source/', | |
| 42 | ['resolveReferences' => 2] | |
| 43 | )->getEntity(); | |
| 44 | $requestList = (new RequestList())->addData($source->requests); | |
| 45 | ||
| 46 | $departments = new DepartmentList(); | |
| 47 | ||
| 48 | foreach ($organisation->departments as $departmentData) { | |
| 49 | $department = (new Department($departmentData))->withCompleteScopeList(); | |
| 50 | foreach ($department->scopes as $scope) { | |
| 51 | $scope->services = []; | |
| 52 | ||
| 53 | if (! isset($scope->provider->data)) { | |
| 54 | continue; | |
| 55 | } | |
| 56 | ||
| 57 | foreach ($scope->provider->data['services'] as $serviceArray) { | |
| 58 | $service = $requestList->getEntity($serviceArray['service']); | |
| 59 | ||
| 60 | if (! $service) { | |
| 61 | continue; | |
| 62 | } | |
| 63 | ||
| 64 | $scope->services[] = [ | |
| 65 | 'id' => $scope->id . '-' . $service->id, | |
| 66 | 'name' => $service->name | |
| 67 | ]; | |
| 68 | } | |
| 69 | } | |
| 70 | $departments->addEntity($department); | |
| 71 | } | |
| 72 | return Render::withHtml( | |
| 73 | $response, | |
| 74 | 'page/ticketprinterConfig.twig', | |
| 75 | array( | |
| 76 | 'title' => 'Anmeldung an Warteschlange', | |
| 77 | 'config' => $config->getArrayCopy(), | |
| 78 | 'organisation' => $organisation->getArrayCopy(), | |
| 79 | 'departments' => $departments->getArrayCopy(), | |
| 80 | 'workstation' => $workstation, | |
| 81 | 'menuActive' => 'ticketprinter' | |
| 82 | ) | |
| 83 | ); | |
| 84 | } | |
| 85 | } |