Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
41 / 41 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ReportWaitingIndex | |
100.00% |
41 / 41 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
41 / 41 |
|
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 ReportWaitingIndex extends BaseController |
16 | { |
17 | protected $hashset = [ |
18 | 'waitingcount', |
19 | 'waitingtime', |
20 | 'waitingcalculated', |
21 | 'waitingcount_termin', |
22 | 'waitingtime_termin', |
23 | 'waitingcalculated_termin', |
24 | 'waytime', |
25 | 'waytime_termin', |
26 | ]; |
27 | |
28 | protected $groupfields = [ |
29 | 'date', |
30 | 'hour' |
31 | ]; |
32 | |
33 | /** |
34 | * @SuppressWarnings(Param) |
35 | * @return ResponseInterface |
36 | */ |
37 | public function readResponse( |
38 | RequestInterface $request, |
39 | ResponseInterface $response, |
40 | array $args |
41 | ) { |
42 | $validator = $request->getAttribute('validator'); |
43 | $waitingPeriod = \App::$http |
44 | ->readGetResult('/warehouse/waitingscope/' . $this->workstation->scope['id'] . '/') |
45 | ->getEntity(); |
46 | $exchangeWaiting = null; |
47 | if (isset($args['period'])) { |
48 | $exchangeWaiting = \App::$http |
49 | ->readGetResult('/warehouse/waitingscope/' . $this->workstation->scope['id'] . '/' . $args['period'] . '/') |
50 | ->getEntity() |
51 | ->toGrouped($this->groupfields, $this->hashset) |
52 | ->withMaxByHour($this->hashset) |
53 | ->withMaxAndAverageFromWaitingTime(); |
54 | |
55 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waitingtime'); |
56 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waitingtime_termin'); |
57 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waytime'); |
58 | $exchangeWaiting = ReportHelper::withMaxAndAverage($exchangeWaiting, 'waytime_termin'); |
59 | } |
60 | |
61 | $type = $validator->getParameter('type')->isString()->getValue(); |
62 | if ($type) { |
63 | $args['category'] = 'waitingscope'; |
64 | $args['reports'][] = $exchangeWaiting; |
65 | $args['scope'] = $this->workstation->scope; |
66 | $args['department'] = $this->department; |
67 | $args['organisation'] = $this->organisation; |
68 | return (new Download\WaitingReport(\App::$slim->getContainer()))->readResponse($request, $response, $args); |
69 | } |
70 | |
71 | return Render::withHtml( |
72 | $response, |
73 | 'page/reportWaitingIndex.twig', |
74 | array( |
75 | 'title' => 'Wartestatistik Standort', |
76 | 'activeScope' => 'active', |
77 | 'menuActive' => 'waiting', |
78 | 'department' => $this->department, |
79 | 'organisation' => $this->organisation, |
80 | 'waitingPeriod' => $waitingPeriod, |
81 | 'showAll' => 1, |
82 | 'period' => (isset($args['period'])) ? $args['period'] : null, |
83 | 'exchangeWaiting' => $exchangeWaiting, |
84 | 'source' => ['entity' => 'WaitingIndex'], |
85 | 'workstation' => $this->workstation->getArrayCopy() |
86 | ) |
87 | ); |
88 | } |
89 | } |