Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
38 / 38 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ReportRequestDepartment | |
100.00% |
38 / 38 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
38 / 38 |
|
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 ReportRequestDepartment extends BaseController |
| 15 | { |
| 16 | protected $hashset = [ |
| 17 | 'requestscount' |
| 18 | ]; |
| 19 | |
| 20 | protected $groupfields = [ |
| 21 | 'name', |
| 22 | 'date' |
| 23 | ]; |
| 24 | |
| 25 | /** |
| 26 | * @SuppressWarnings(Param) |
| 27 | * @return ResponseInterface |
| 28 | */ |
| 29 | public function readResponse( |
| 30 | RequestInterface $request, |
| 31 | ResponseInterface $response, |
| 32 | array $args |
| 33 | ) { |
| 34 | $validator = $request->getAttribute('validator'); |
| 35 | $requestPeriod = \App::$http |
| 36 | ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/') |
| 37 | ->getEntity(); |
| 38 | $exchangeRequest = null; |
| 39 | if (isset($args['period'])) { |
| 40 | $exchangeRequest = \App::$http |
| 41 | ->readGetResult('/warehouse/requestdepartment/' . $this->department->id . '/' . $args['period'] . '/') |
| 42 | ->getEntity() |
| 43 | ->toGrouped($this->groupfields, $this->hashset) |
| 44 | ->withRequestsSum() |
| 45 | ->withAverage('processingtime'); |
| 46 | } |
| 47 | |
| 48 | $type = $validator->getParameter('type')->isString()->getValue(); |
| 49 | if ($type) { |
| 50 | $args['category'] = 'requestdepartment'; |
| 51 | $args['reports'][] = $exchangeRequest; |
| 52 | $args['scope'] = $this->workstation->scope; |
| 53 | $args['department'] = $this->department; |
| 54 | $args['organisation'] = $this->organisation; |
| 55 | return (new Download\RequestReport(\App::$slim->getContainer()))->readResponse($request, $response, $args); |
| 56 | } |
| 57 | |
| 58 | return Render::withHtml( |
| 59 | $response, |
| 60 | 'page/reportRequestIndex.twig', |
| 61 | array( |
| 62 | 'title' => 'Dienstleistungsstatistik Behörde', |
| 63 | 'activeDepartment' => 'active', |
| 64 | 'menuActive' => 'request', |
| 65 | 'department' => $this->department, |
| 66 | 'organisation' => $this->organisation, |
| 67 | 'owner' => $this->owner, |
| 68 | 'requestPeriod' => $requestPeriod, |
| 69 | 'showAll' => 1, |
| 70 | 'period' => (isset($args['period'])) ? $args['period'] : null, |
| 71 | 'exchangeRequest' => $exchangeRequest, |
| 72 | 'source' => ['entity' => 'RequestDepartment'], |
| 73 | 'workstation' => $this->workstation->getArrayCopy() |
| 74 | ) |
| 75 | ); |
| 76 | } |
| 77 | } |