Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
39 / 39
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportRequestDepartment
100.00% covered (success)
100.00%
39 / 39
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
39 / 39
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3/**
4 * @package Zmsadmin
5 * @copyright BerlinOnline Stadtportal GmbH & Co. KG
6 **/
7
8namespace BO\Zmsstatistic;
9
10use BO\Slim\Render;
11use Psr\Http\Message\RequestInterface;
12use Psr\Http\Message\ResponseInterface;
13
14class ReportRequestDepartment 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    #[\Override]
30    public function readResponse(
31        RequestInterface $request,
32        ResponseInterface $response,
33        array $args
34    ) {
35        $validator = $request->getAttribute('validator');
36        $requestPeriod = \App::$http
37          ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/')
38          ->getEntity();
39        $exchangeRequest = null;
40        if (isset($args['period'])) {
41            $exchangeRequest = \App::$http
42            ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/' . $args['period'] . '/')
43            ->getEntity()
44            ->toGrouped($this->groupfields, $this->hashset)
45            ->withRequestsSum()
46            ->withAverage('processingtime')
47            ->withUncapturedRequestRowSortedLast();
48        }
49
50        $type = $validator->getParameter('type')->isString()->getValue();
51        if ($type) {
52            $args['category'] = 'requestdepartment';
53            $args['reports'][] = $exchangeRequest;
54            $args['scope'] = $this->workstation->scope;
55            $args['department'] = $this->department;
56            $args['organisation'] = $this->organisation;
57            return (new Download\RequestReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
58        }
59
60        return Render::withHtml(
61            $response,
62            'page/reportRequestIndex.twig',
63            array(
64              'title' => 'Dienstleistungsstatistik Behörde',
65              'activeDepartment' => 'active',
66              'menuActive' => 'request',
67              'department' => $this->department,
68              'organisation' => $this->organisation,
69              'owner' => $this->owner,
70              'requestPeriod' => $requestPeriod,
71              'showAll' => 1,
72              'period' => (isset($args['period'])) ? $args['period'] : null,
73              'exchangeRequest' => $exchangeRequest,
74              'source' => ['entity' => 'RequestDepartment'],
75              'workstation' => $this->workstation->getArrayCopy()
76            )
77        );
78    }
79}