Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
42 / 42
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportRequestDepartment
100.00% covered (success)
100.00%
42 / 42
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
42 / 42
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 array $hashset = [
17        'requestscount'
18    ];
19
20    protected array $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    ): mixed {
35        /** @var \Psr\Http\Message\ServerRequestInterface $request */
36        $validator = $request->getAttribute('validator');
37        $requestPeriod = \App::http()
38          ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/')
39          ->getEntity();
40        $exchangeRequest = null;
41        if (isset($args['period'])) {
42            /** @var mixed $entity */
43            $entity = \App::http()
44            ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/' . $args['period'] . '/')
45            ->getEntity();
46            $exchangeRequest = $entity
47            ->toGrouped($this->groupfields, $this->hashset)
48            ->withRequestsSum()
49            ->withAverage('processingtime')
50            ->withWeightedAverageProcessingTime()
51            ->withUncapturedRequestRowSortedLast();
52        }
53
54        $type = $validator->getParameter('type')->isString()->getValue();
55        if ($type) {
56            $args['category'] = 'requestdepartment';
57            $args['reports'][] = $exchangeRequest;
58            $args['scope'] = $this->workstation->scope;
59            $args['department'] = $this->department;
60            $args['organisation'] = $this->organisation;
61            /** @var mixed $container */
62            $container = \App::$slim->getContainer();
63            return (new Download\RequestReport($container))->readResponse($request, $response, $args);
64        }
65
66        return Render::withHtml(
67            $response,
68            'page/reportRequestIndex.twig',
69            array(
70              'title' => 'Dienstleistungsstatistik Behörde',
71              'activeDepartment' => 'active',
72              'menuActive' => 'request',
73              'department' => $this->department,
74              'organisation' => $this->organisation,
75              'owner' => $this->owner,
76              'requestPeriod' => $requestPeriod,
77              'showAll' => 1,
78              'period' => (isset($args['period'])) ? $args['period'] : null,
79              'exchangeRequest' => $exchangeRequest,
80              'source' => ['entity' => 'RequestDepartment'],
81              'workstation' => $this->workstation->getArrayCopy()
82            )
83        );
84    }
85}