Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
35 / 35 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ReportRequestOrganisation | |
100.00% |
35 / 35 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
35 / 35 |
|
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 | |
14 | class ReportRequestOrganisation extends BaseController |
15 | { |
16 | protected $hashset = [ |
17 | 'requestscount' |
18 | ]; |
19 | |
20 | protected $groupfields = [ |
21 | 'name', |
22 | 'date' |
23 | ]; |
24 | |
25 | /** |
26 | * @SuppressWarnings(Param) |
27 | * @return ResponseInterface |
28 | */ |
29 | public function readResponse( |
30 | RequestInterface $request, |
31 | ResponseInterface $response, |
32 | array $args |
33 | ) { |
34 | $validator = $request->getAttribute('validator'); |
35 | $requestPeriod = \App::$http |
36 | ->readGetResult('/warehouse/requestorganisation/' . $this->organisation->id . '/') |
37 | ->getEntity(); |
38 | $exchangeRequest = null; |
39 | if (isset($args['period'])) { |
40 | $exchangeRequest = \App::$http |
41 | ->readGetResult('/warehouse/requestorganisation/' . $this->organisation->id . '/' . $args['period'] . '/') |
42 | ->getEntity() |
43 | ->toGrouped($this->groupfields, $this->hashset) |
44 | ->withRequestsSum() |
45 | ->withAverage('processingtime'); |
46 | } |
47 | |
48 | $type = $validator->getParameter('type')->isString()->getValue(); |
49 | if ($type) { |
50 | $args['category'] = 'requestorganisation'; |
51 | $args['reports'][] = $exchangeRequest; |
52 | $args['organisation'] = $this->organisation; |
53 | return (new Download\RequestReport(\App::$slim->getContainer()))->readResponse($request, $response, $args); |
54 | } |
55 | |
56 | return Render::withHtml( |
57 | $response, |
58 | 'page/reportRequestIndex.twig', |
59 | array( |
60 | 'title' => 'Dienstleistungsstatistik Bezirk', |
61 | 'activeOrganisation' => 'active', |
62 | 'menuActive' => 'request', |
63 | 'department' => $this->department, |
64 | 'organisation' => $this->organisation, |
65 | 'requestPeriod' => $requestPeriod, |
66 | 'showAll' => 1, |
67 | 'period' => (isset($args['period'])) ? $args['period'] : null, |
68 | 'exchangeRequest' => $exchangeRequest, |
69 | 'source' => ['entity' => 'RequestOrganisation'], |
70 | 'workstation' => $this->workstation->getArrayCopy() |
71 | ) |
72 | ); |
73 | } |
74 | } |