Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
36 / 36
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportRequestOrganisation
100.00% covered (success)
100.00%
36 / 36
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
36 / 36
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 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    #[\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/requestorganisation/' . $this->organisation->id . '/')
38          ->getEntity();
39        $exchangeRequest = null;
40        if (isset($args['period'])) {
41            $exchangeRequest = \App::$http
42            ->readGetResult('/warehouse/requestorganisation/' . $this->organisation->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'] = 'requestorganisation';
53            $args['reports'][] = $exchangeRequest;
54            $args['organisation'] = $this->organisation;
55            return (new Download\RequestReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
56        }
57
58        return Render::withHtml(
59            $response,
60            'page/reportRequestIndex.twig',
61            array(
62              'title' => 'Dienstleistungsstatistik Bezirk',
63              'activeOrganisation' => 'active',
64              'menuActive' => 'request',
65              'department' => $this->department,
66              'organisation' => $this->organisation,
67              'requestPeriod' => $requestPeriod,
68              'showAll' => 1,
69              'period' => (isset($args['period'])) ? $args['period'] : null,
70              'exchangeRequest' => $exchangeRequest,
71              'source' => ['entity' => 'RequestOrganisation'],
72              'workstation' => $this->workstation->getArrayCopy()
73            )
74        );
75    }
76}