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