Lines
100.00%
48 / 48
Functions and Methods
100.00%
1 / 1
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ReportWaitingDepartment | 100.00% | 48 / 48 | 100.00% | 1 / 1 | 4 | 100.00% | 1 / 1 | |||
| readResponse | 100.00% | 48 / 48 | 100.00% | 1 / 1 | 4 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsadmin | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsstatistic; | |
| 9 | ||
| 10 | use BO\Slim\Render; | |
| 11 | use Psr\Http\Message\RequestInterface; | |
| 12 | use Psr\Http\Message\ResponseInterface; | |
| 13 | use BO\Zmsstatistic\Helper\ReportHelper; | |
| 14 | ||
| 15 | class ReportWaitingDepartment extends BaseController | |
| 16 | { | |
| 17 | protected array $hashset = [ | |
| 18 | 'waitingcount', | |
| 19 | 'waitingtime', | |
| 20 | 'waitingcalculated', | |
| 21 | 'waitingcount_termin', | |
| 22 | 'waitingtime_termin', | |
| 23 | 'waitingcalculated_termin', | |
| 24 | 'waytime', | |
| 25 | 'waytime_termin', | |
| 26 | 'waitingcount_total', | |
| 27 | 'waitingtime_total', | |
| 28 | 'waytime_total', | |
| 29 | ]; | |
| 30 | ||
| 31 | protected array $groupfields = [ | |
| 32 | 'date', | |
| 33 | 'hour' | |
| 34 | ]; | |
| 35 | ||
| 36 | /** | |
| 37 | * @SuppressWarnings(Param) | |
| 38 | * @return ResponseInterface | |
| 39 | */ | |
| 40 | #[\Override] | |
| 41 | public function readResponse( | |
| 42 | RequestInterface $request, | |
| 43 | ResponseInterface $response, | |
| 44 | array $args | |
| 45 | ): mixed { | |
| 46 | /** @var \Psr\Http\Message\ServerRequestInterface $request */ | |
| 47 | $validator = $request->getAttribute('validator'); | |
| 48 | $waitingPeriod = \App::http() | |
| 49 | ->readGetResult('/warehouse/waitingdepartment/' . $this->department->id . '/') | |
| 50 | ->getEntity(); | |
| 51 | $exchangeWaiting = null; | |
| 52 | if (isset($args['period'])) { | |
| 53 | /** @var mixed $entity */ | |
| 54 | $entity = \App::http() | |
| 55 | ->readGetResult('/warehouse/waitingdepartment/' . $this->department->id . '/' . $args['period'] . '/') | |
| 56 | ->getEntity(); | |
| 57 | $exchangeWaiting = $entity | |
| 58 | ->toGrouped($this->groupfields, $this->hashset); | |
| 59 | ||
| 60 | $exchangeWaiting = ReportHelper::withTotalCustomers($exchangeWaiting); | |
| 61 | ||
| 62 | $exchangeWaiting = $exchangeWaiting | |
| 63 | ->withMaxByHour($this->hashset) | |
| 64 | ->withMaxAndAverageFromWaitingTime(); | |
| 65 | ||
| 66 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waitingtime'); | |
| 67 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waitingtime_termin'); | |
| 68 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waytime'); | |
| 69 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waytime_termin'); | |
| 70 | ||
| 71 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waitingtime_total'); | |
| 72 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waytime_total'); | |
| 73 | $exchangeWaiting = ReportHelper::withGlobalMaxAndAverage($exchangeWaiting, 'waitingtime_total'); | |
| 74 | $exchangeWaiting = ReportHelper::withGlobalMaxAndAverage($exchangeWaiting, 'waytime_total'); | |
| 75 | } | |
| 76 | ||
| 77 | $type = $validator->getParameter('type')->isString()->getValue(); | |
| 78 | if ($type) { | |
| 79 | $args['category'] = 'waitingscope'; | |
| 80 | $args['reports'][] = $exchangeWaiting; | |
| 81 | $args['department'] = $this->department; | |
| 82 | $args['organisation'] = $this->organisation; | |
| 83 | /** @var mixed $container */ | |
| 84 | $container = \App::$slim->getContainer(); | |
| 85 | return (new Download\WaitingReport($container))->readResponse($request, $response, $args); | |
| 86 | } | |
| 87 | ||
| 88 | return Render::withHtml( | |
| 89 | $response, | |
| 90 | 'page/reportWaitingIndex.twig', | |
| 91 | array( | |
| 92 | 'title' => 'Wartestatistik Behörde', | |
| 93 | 'activeDepartment' => 'active', | |
| 94 | 'menuActive' => 'waiting', | |
| 95 | 'department' => $this->department, | |
| 96 | 'organisation' => $this->organisation, | |
| 97 | 'waitingPeriod' => $waitingPeriod, | |
| 98 | 'showAll' => 1, | |
| 99 | 'period' => (isset($args['period'])) ? $args['period'] : null, | |
| 100 | 'exchangeWaiting' => $exchangeWaiting, | |
| 101 | 'source' => ['entity' => 'WaitingDepartment'], | |
| 102 | 'workstation' => $this->workstation->getArrayCopy() | |
| 103 | ) | |
| 104 | ); | |
| 105 | } | |
| 106 | } |