Lines
93.54%
29 / 31
Functions and Methods
0.00%
0 / 1
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| WorkstationSelect | 93.54% | 29 / 31 | 0.00% | 0 / 1 | 7.01 | 0.00% | 0 / 1 | |||
| readResponse | 93.54% | 29 / 31 | 0.00% | 0 / 1 | 7.01 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | /** | |
| 4 | * @package Zmsstatistic | |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG | |
| 6 | **/ | |
| 7 | ||
| 8 | namespace BO\Zmsstatistic; | |
| 9 | ||
| 10 | use BO\Slim\Render; | |
| 11 | use BO\Zmsclient\ModuleAccess; | |
| 12 | use BO\Zmsstatistic\Helper\LoginForm; | |
| 13 | use BO\Mellon\Validator; | |
| 14 | use Psr\Http\Message\RequestInterface; | |
| 15 | use Psr\Http\Message\ResponseInterface; | |
| 16 | ||
| 17 | class WorkstationSelect extends BaseController | |
| 18 | { | |
| 19 | protected int $resolveLevel = 2; | |
| 20 | /** | |
| 21 | * @SuppressWarnings(Parameter) | |
| 22 | * @return ResponseInterface | |
| 23 | */ | |
| 24 | #[\Override] | |
| 25 | public function readResponse( | |
| 26 | RequestInterface $request, | |
| 27 | ResponseInterface $response, | |
| 28 | array $args | |
| 29 | ): mixed { | |
| 30 | $workstation = \App::http()->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); | |
| 31 | /** @var mixed $workstation */ | |
| 32 | if (!$workstation->hasId()) { | |
| 33 | return \BO\Slim\Render::redirect('index', array('error' => 'login_failed')); | |
| 34 | } | |
| 35 | if ($wrongModuleResponse = ModuleAccess::rejectWrongModuleAccess(ModuleAccess::MODULE_STATISTIC, $workstation, $response)) { | |
| 36 | return $wrongModuleResponse; | |
| 37 | } | |
| 38 | /** @var \Psr\Http\Message\ServerRequestInterface $request */ | |
| 39 | $input = $request->getParsedBody(); | |
| 40 | $formData = []; | |
| 41 | if (is_array($input) && (array_key_exists('scope', $input))) { | |
| 42 | $form = LoginForm::fromAdditionalParameters(); | |
| 43 | $formData = $form->getStatus(); | |
| 44 | $selectedDate = Validator::param('selectedDate')->isString()->getValue(); | |
| 45 | $queryParams = ($selectedDate) ? array('date' => $selectedDate) : array(); | |
| 46 | if (! $form->hasFailed()) { | |
| 47 | LoginForm::writeWorkstationUpdate($form, $this->workstation); | |
| 48 | return Render::redirect( | |
| 49 | 'Overview', | |
| 50 | array(), | |
| 51 | $queryParams | |
| 52 | ); | |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | /** @var \DateTimeInterface $now */ | |
| 57 | $now = \App::$now; | |
| 58 | ||
| 59 | return Render::withHtml( | |
| 60 | $response, | |
| 61 | 'page/workstationSelect.twig', | |
| 62 | array( | |
| 63 | 'title' => 'Standort auswählen', | |
| 64 | 'advancedData' => $formData, | |
| 65 | 'workstation' => $this->workstation, | |
| 66 | 'menuActive' => 'select', | |
| 67 | 'today' => $now->format('Y-m-d') | |
| 68 | ) | |
| 69 | ); | |
| 70 | } | |
| 71 | } |