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    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/requestdepartment/' . $this->department->id . '/')
37          ->getEntity();
38        $exchangeRequest = null;
39        if (isset($args['period'])) {
40            $exchangeRequest = \App::$http
41            ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/' . $args['period'] . '/')
42            ->getEntity()
43            ->toGrouped($this->groupfields, $this->hashset)
44            ->withRequestsSum()
45            ->withAverage('processingtime')
46            ->withUncapturedRequestRowSortedLast();
47        }
48
49        $type = $validator->getParameter('type')->isString()->getValue();
50        if ($type) {
51            $args['category'] = 'requestdepartment';
52            $args['reports'][] = $exchangeRequest;
53            $args['scope'] = $this->workstation->scope;
54            $args['department'] = $this->department;
55            $args['organisation'] = $this->organisation;
56            return (new Download\RequestReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
57        }
58
59        return Render::withHtml(
60            $response,
61            'page/reportRequestIndex.twig',
62            array(
63              'title' => 'Dienstleistungsstatistik Behörde',
64              'activeDepartment' => 'active',
65              'menuActive' => 'request',
66              'department' => $this->department,
67              'organisation' => $this->organisation,
68              'owner' => $this->owner,
69              'requestPeriod' => $requestPeriod,
70              'showAll' => 1,
71              'period' => (isset($args['period'])) ? $args['period'] : null,
72              'exchangeRequest' => $exchangeRequest,
73              'source' => ['entity' => 'RequestDepartment'],
74              'workstation' => $this->workstation->getArrayCopy()
75            )
76        );
77    }
78}