Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 49 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| WorkstationProcessRedirect | |
0.00% |
0 / 49 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| readResponse | |
0.00% |
0 / 49 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package Zmsadmin |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | **/ |
| 7 | |
| 8 | namespace BO\Zmsadmin; |
| 9 | |
| 10 | use Psr\Http\Message\RequestInterface; |
| 11 | |
| 12 | class WorkstationProcessRedirect extends BaseController |
| 13 | { |
| 14 | /** |
| 15 | * @SuppressWarnings(Param) |
| 16 | * @return String |
| 17 | */ |
| 18 | public function readResponse( |
| 19 | RequestInterface $request, |
| 20 | \Psr\Http\Message\ResponseInterface $response, |
| 21 | array $args |
| 22 | ) { |
| 23 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
| 24 | $department = \App::$http |
| 25 | ->readGetResult( |
| 26 | '/scope/' . $workstation->scope['id'] . '/department/', |
| 27 | ['resolveReferences' => 2] |
| 28 | )->getEntity(); |
| 29 | $input = $request->getParsedBody(); |
| 30 | $process = $workstation->process; |
| 31 | |
| 32 | if ($request->getMethod() === 'POST') { |
| 33 | $validator = $request->getAttribute('validator'); |
| 34 | $selectedLocation = $validator->getParameter('location')->isNumber()->getValue(); |
| 35 | |
| 36 | if (empty($selectedLocation)) { |
| 37 | return \BO\Slim\Render::redirect( |
| 38 | 'workstationProcessRedirect', |
| 39 | [], |
| 40 | [ |
| 41 | 'errors' => [ |
| 42 | 'location' => 'Bitte wählen Sie einen Standort aus.' |
| 43 | ] |
| 44 | ] |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | $scope = \App::$http |
| 49 | ->readGetResult( |
| 50 | '/scope/' . $selectedLocation . '/', |
| 51 | ['resolveReferences' => 2] |
| 52 | )->getEntity(); |
| 53 | |
| 54 | $newProcess = clone $process; |
| 55 | $newProcess->scope = $scope; |
| 56 | $newProcess->appointments[0]->scope = $scope; |
| 57 | $newProcess->amendment = $input['amendment']; |
| 58 | |
| 59 | $process = \App::$http->readPostResult('/process/status/redirect/', $newProcess)->getEntity(); |
| 60 | |
| 61 | return \BO\Slim\Render::redirect( |
| 62 | $workstation->getVariantName(), |
| 63 | array(), |
| 64 | array() |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | return \BO\Slim\Render::withHtml( |
| 69 | $response, |
| 70 | 'page/workstationProcessRedirect.twig', |
| 71 | array( |
| 72 | 'title' => 'Kundendaten', |
| 73 | 'workstation' => $workstation, |
| 74 | 'department' => $department, |
| 75 | 'scope' => $workstation->scope, |
| 76 | 'scopes' => $department->getScopeList(), |
| 77 | 'menuActive' => 'workstation', |
| 78 | 'errors' => $request->getParam('errors') ?? null |
| 79 | ) |
| 80 | ); |
| 81 | } |
| 82 | } |