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    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            ->withUncapturedRequestRowSortedLast();
47        }
48
49        $type = $validator->getParameter('type')->isString()->getValue();
50        if ($type) {
51            $args['category'] = 'requestorganisation';
52            $args['reports'][] = $exchangeRequest;
53            $args['organisation'] = $this->organisation;
54            return (new Download\RequestReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
55        }
56
57        return Render::withHtml(
58            $response,
59            'page/reportRequestIndex.twig',
60            array(
61              'title' => 'Dienstleistungsstatistik Bezirk',
62              'activeOrganisation' => 'active',
63              'menuActive' => 'request',
64              'department' => $this->department,
65              'organisation' => $this->organisation,
66              'requestPeriod' => $requestPeriod,
67              'showAll' => 1,
68              'period' => (isset($args['period'])) ? $args['period'] : null,
69              'exchangeRequest' => $exchangeRequest,
70              'source' => ['entity' => 'RequestOrganisation'],
71              'workstation' => $this->workstation->getArrayCopy()
72            )
73        );
74    }
75}