Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
45 / 45
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportClientDepartment
100.00% covered (success)
100.00%
45 / 45
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
45 / 45
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 ReportClientDepartment extends BaseController
15{
16    protected $totals = [
17        'clientscount',
18        'missed',
19        'withappointment',
20        'missedwithappointment',
21        'noappointment',
22        'missednoappointment',
23        'requestscount'
24    ];
25
26    /**
27     * @SuppressWarnings(Param)
28     * @return ResponseInterface
29     */
30    public function readResponse(
31        RequestInterface $request,
32        ResponseInterface $response,
33        array $args
34    ) {
35        $validator = $request->getAttribute('validator');
36        $clientPeriod = \App::$http
37          ->readGetResult('/warehouse/clientdepartment/' . $this->department->id . '/')
38          ->getEntity();
39
40        $exchangeClient = null;
41        $exchangeNotification = null;
42        if (isset($args['period'])) {
43            $exchangeClient = \App::$http
44                ->readGetResult('/warehouse/clientdepartment/' . $this->department->id . '/' . $args['period'] . '/')
45                ->getEntity()
46                ->withCalculatedTotals($this->totals, 'date')
47                ->toHashed();
48
49            $exchangeNotification = \App::$http
50                ->readGetResult(
51                    '/warehouse/notificationdepartment/' . $this->department->id . '/' . $args['period'] . '/',
52                    ['groupby' => 'month']
53                )
54                ->getEntity()
55                ->toHashed();
56        }
57
58        $type = $validator->getParameter('type')->isString()->getValue();
59        if ($type) {
60            $args['category'] = 'clientdepartment';
61            $args['reports'][] = $exchangeNotification;
62            $args['reports'][] = $exchangeClient;
63            $args['department'] = $this->department;
64            $args['organisation'] = $this->organisation;
65
66            return (new Download\ClientReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
67        }
68
69        return Render::withHtml(
70            $response,
71            'page/reportClientIndex.twig',
72            array(
73                'title' => 'Kundenstatistik Behörde',
74                'activeDepartment' => 'active',
75                'menuActive' => 'client',
76                'department' => $this->department,
77                'organisation' => $this->organisation,
78                'clientperiod' => $clientPeriod,
79                'showAll' => 1,
80                'period' => isset($args['period']) ? $args['period'] : null,
81                'exchangeClient' => $exchangeClient,
82                'exchangeNotification' => $exchangeNotification,
83                'source' => ['entity' => 'ClientDepartment'],
84                'workstation' => $this->workstation->getArrayCopy()
85            )
86        );
87    }
88}