Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.33% |
28 / 30 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WorkstationSelect | |
93.33% |
28 / 30 |
|
0.00% |
0 / 1 |
7.01 | |
0.00% |
0 / 1 |
| readResponse | |
93.33% |
28 / 30 |
|
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\Zmsclient\ModuleAccess; |
| 11 | use BO\Slim\Render; |
| 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 $resolveLevel = 2; |
| 20 | /** |
| 21 | * @SuppressWarnings(Parameter) |
| 22 | * @return ResponseInterface |
| 23 | */ |
| 24 | public function readResponse( |
| 25 | RequestInterface $request, |
| 26 | ResponseInterface $response, |
| 27 | array $args |
| 28 | ) { |
| 29 | /** @var \BO\Zmsentities\Workstation $workstation */ |
| 30 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 31 | if (!$workstation->hasId()) { |
| 32 | return \BO\Slim\Render::redirect('index', array('error' => 'login_failed')); |
| 33 | } |
| 34 | if ($wrongModuleResponse = ModuleAccess::rejectWrongModuleAccess(ModuleAccess::MODULE_STATISTIC, $workstation, $response)) { |
| 35 | return $wrongModuleResponse; |
| 36 | } |
| 37 | $input = $request->getParsedBody(); |
| 38 | $formData = []; |
| 39 | if (is_array($input) && (array_key_exists('scope', $input))) { |
| 40 | $form = LoginForm::fromAdditionalParameters(); |
| 41 | $formData = $form->getStatus(); |
| 42 | $selectedDate = Validator::param('selectedDate')->isString()->getValue(); |
| 43 | $queryParams = ($selectedDate) ? array('date' => $selectedDate) : array(); |
| 44 | if (! $form->hasFailed()) { |
| 45 | LoginForm::writeWorkstationUpdate($form, $this->workstation); |
| 46 | return Render::redirect( |
| 47 | 'Overview', |
| 48 | array(), |
| 49 | $queryParams |
| 50 | ); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return Render::withHtml( |
| 55 | $response, |
| 56 | 'page/workstationSelect.twig', |
| 57 | array( |
| 58 | 'title' => 'Standort auswählen', |
| 59 | 'advancedData' => $formData, |
| 60 | 'workstation' => $this->workstation, |
| 61 | 'menuActive' => 'select', |
| 62 | 'today' => \App::$now->format('Y-m-d') |
| 63 | ) |
| 64 | ); |
| 65 | } |
| 66 | } |