Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
45 / 45 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ReportClientOrganisation | |
100.00% |
45 / 45 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
45 / 45 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsstatistic; |
| 9 | |
| 10 | use BO\Slim\Render; |
| 11 | use Psr\Http\Message\RequestInterface; |
| 12 | use Psr\Http\Message\ResponseInterface; |
| 13 | |
| 14 | class ReportClientOrganisation extends BaseController |
| 15 | { |
| 16 | protected $totals = [ |
| 17 | 'notificationscount', |
| 18 | 'notificationscost', |
| 19 | 'clientscount', |
| 20 | 'missed', |
| 21 | 'withappointment', |
| 22 | 'missedwithappointment', |
| 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 | $organisationId = $this->organisation->id; |
| 37 | $clientPeriod = \App::$http |
| 38 | ->readGetResult('/warehouse/clientorganisation/' . $organisationId . '/') |
| 39 | ->getEntity(); |
| 40 | $exchangeClient = null; |
| 41 | $exchangeNotification = null; |
| 42 | if (isset($args['period'])) { |
| 43 | $exchangeClient = \App::$http |
| 44 | ->readGetResult('/warehouse/clientorganisation/' . $organisationId . '/' . $args['period'] . '/') |
| 45 | ->getEntity() |
| 46 | ->withCalculatedTotals($this->totals, 'date') |
| 47 | ->toHashed(); |
| 48 | |
| 49 | $exchangeNotification = \App::$http |
| 50 | ->readGetResult( |
| 51 | '/warehouse/notificationorganisation/' . $organisationId . '/' . $args['period'] . '/', |
| 52 | ['groupby' => 'month'] |
| 53 | ) |
| 54 | ->getEntity() |
| 55 | ->toHashed(); |
| 56 | } |
| 57 | |
| 58 | $type = $validator->getParameter('type')->isString()->getValue(); |
| 59 | if ($type) { |
| 60 | $args['category'] = 'clientorganisation'; |
| 61 | $args['reports'][] = $exchangeNotification; |
| 62 | $args['reports'][] = $exchangeClient; |
| 63 | $args['organisation'] = $this->organisation; |
| 64 | return (new Download\ClientReport(\App::$slim->getContainer()))->readResponse($request, $response, $args); |
| 65 | } |
| 66 | |
| 67 | return Render::withHtml( |
| 68 | $response, |
| 69 | 'page/reportClientIndex.twig', |
| 70 | array( |
| 71 | 'title' => 'Kundenstatistik Bezirk', |
| 72 | 'activeOrganisation' => 'active', |
| 73 | 'menuActive' => 'client', |
| 74 | 'department' => $this->department, |
| 75 | 'organisation' => $this->organisation, |
| 76 | 'clientPeriod' => $clientPeriod, |
| 77 | 'showAll' => 1, |
| 78 | 'period' => isset($args['period']) ? $args['period'] : null, |
| 79 | 'exchangeClient' => $exchangeClient, |
| 80 | 'exchangeNotification' => $exchangeNotification, |
| 81 | 'source' => ['entity' => 'ClientOrganisation'], |
| 82 | 'workstation' => $this->workstation->getArrayCopy() |
| 83 | ) |
| 84 | ); |
| 85 | } |
| 86 | } |