Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReportClientDepartment
100.00% covered (success)
100.00%
35 / 35
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 readResponse
100.00% covered (success)
100.00%
35 / 35
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        if (isset($args['period'])) {
42            $exchangeClient = \App::$http
43                ->readGetResult('/warehouse/clientdepartment/' . $this->department->id . '/' . $args['period'] . '/')
44                ->getEntity()
45                ->withCalculatedTotals($this->totals, 'date')
46                ->toHashed();
47        }
48
49        $type = $validator->getParameter('type')->isString()->getValue();
50        if ($type) {
51            $args['category'] = 'clientdepartment';
52            $args['reports'][] = $exchangeClient;
53            $args['department'] = $this->department;
54            $args['organisation'] = $this->organisation;
55
56            return (new Download\ClientReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
57        }
58
59        return Render::withHtml(
60            $response,
61            'page/reportClientIndex.twig',
62            array(
63                'title' => 'Kundenstatistik Behörde',
64                'activeDepartment' => 'active',
65                'menuActive' => 'client',
66                'department' => $this->department,
67                'organisation' => $this->organisation,
68                'clientPeriod' => $clientPeriod,
69                'showAll' => 1,
70                'period' => isset($args['period']) ? $args['period'] : null,
71                'exchangeClient' => $exchangeClient,
72                'source' => ['entity' => 'ClientDepartment'],
73                'workstation' => $this->workstation->getArrayCopy()
74            )
75        );
76    }
77}