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
ReportClientOrganisation
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 ReportClientOrganisation extends BaseController
15{
16    protected $totals = [
17        'clientscount',
18        'missed',
19        'withappointment',
20        'missedwithappointment',
21        'requestscount'
22    ];
23
24    /**
25     * @SuppressWarnings(Param)
26     * @return ResponseInterface
27     */
28    public function readResponse(
29        RequestInterface $request,
30        ResponseInterface $response,
31        array $args
32    ) {
33        $validator = $request->getAttribute('validator');
34        $organisationId = $this->organisation->id;
35        $clientPeriod = \App::$http
36          ->readGetResult('/warehouse/clientorganisation/' . $organisationId . '/')
37          ->getEntity();
38        $exchangeClient = null;
39        if (isset($args['period'])) {
40            $exchangeClient = \App::$http
41            ->readGetResult('/warehouse/clientorganisation/' . $organisationId . '/' . $args['period'] . '/')
42            ->getEntity()
43            ->withCalculatedTotals($this->totals, 'date')
44            ->toHashed();
45        }
46
47        $type = $validator->getParameter('type')->isString()->getValue();
48        if ($type) {
49            $args['category'] = 'clientorganisation';
50            $args['reports'][] = $exchangeClient;
51            $args['organisation'] = $this->organisation;
52            return (new Download\ClientReport(\App::$slim->getContainer()))->readResponse($request, $response, $args);
53        }
54
55        return Render::withHtml(
56            $response,
57            'page/reportClientIndex.twig',
58            array(
59                'title' => 'Kundenstatistik Bezirk',
60                'activeOrganisation' => 'active',
61                'menuActive' => 'client',
62                'department' => $this->department,
63                'organisation' => $this->organisation,
64                'clientPeriod' => $clientPeriod,
65                'showAll' => 1,
66                'period' => isset($args['period']) ? $args['period'] : null,
67                'exchangeClient' => $exchangeClient,
68                'source' => ['entity' => 'ClientOrganisation'],
69                'workstation' => $this->workstation->getArrayCopy()
70            )
71        );
72    }
73}