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
ReportClientDepartment
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 ReportClientDepartment extends BaseController
15{
16    protected array $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    #[\Override]
31    public function readResponse(
32        RequestInterface $request,
33        ResponseInterface $response,
34        array $args
35    ): mixed {
36        /** @var \Psr\Http\Message\ServerRequestInterface $request */
37        $validator = $request->getAttribute('validator');
38        $clientPeriod = \App::http()
39          ->readGetResult('/warehouse/clientdepartment/' . $this->department->id . '/')
40          ->getEntity();
41
42        $exchangeClient = null;
43        if (isset($args['period'])) {
44            /** @var mixed $entity */
45            $entity = \App::http()
46                ->readGetResult('/warehouse/clientdepartment/' . $this->department->id . '/' . $args['period'] . '/')
47                ->getEntity();
48            $exchangeClient = $entity
49                ->withCalculatedTotals($this->totals, 'date')
50                ->toHashed();
51        }
52
53        $type = $validator->getParameter('type')->isString()->getValue();
54        if ($type) {
55            $args['category'] = 'clientdepartment';
56            $args['reports'][] = $exchangeClient;
57            $args['department'] = $this->department;
58            $args['organisation'] = $this->organisation;
59
60            /** @var mixed $container */
61            $container = \App::$slim->getContainer();
62            return (new Download\ClientReport($container))->readResponse($request, $response, $args);
63        }
64
65        return Render::withHtml(
66            $response,
67            'page/reportClientIndex.twig',
68            array(
69                'title' => 'Kundenstatistik Behörde',
70                'activeDepartment' => 'active',
71                'menuActive' => 'client',
72                'department' => $this->department,
73                'organisation' => $this->organisation,
74                'clientPeriod' => $clientPeriod,
75                'showAll' => 1,
76                'period' => isset($args['period']) ? $args['period'] : null,
77                'exchangeClient' => $exchangeClient,
78                'source' => ['entity' => 'ClientDepartment'],
79                'workstation' => $this->workstation->getArrayCopy()
80            )
81        );
82    }
83}