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