Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
WorkstationProcessCalled | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
9 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
32 / 32 |
|
100.00% |
1 / 1 |
9 |
1 | <?php |
2 | |
3 | /** |
4 | * @package Zmsadmin |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsadmin; |
9 | |
10 | use BO\Mellon\Validator; |
11 | |
12 | class WorkstationProcessCalled extends BaseController |
13 | { |
14 | /** |
15 | * @return String |
16 | */ |
17 | public function readResponse( |
18 | \Psr\Http\Message\RequestInterface $request, |
19 | \Psr\Http\Message\ResponseInterface $response, |
20 | array $args |
21 | ) { |
22 | $validator = $request->getAttribute('validator'); |
23 | $workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); |
24 | $processId = Validator::value($args['id'])->isNumber()->getValue(); |
25 | if (! $workstation->process->hasId() && ! $workstation->process->queue->callTime) { |
26 | $process = \App::$http->readGetResult('/process/' . $args['id'] . '/')->getEntity(); |
27 | $workstation = \App::$http->readPostResult('/workstation/process/called/', $process, [ |
28 | 'allowClusterWideCall' => \App::$allowClusterWideCall |
29 | ])->getEntity(); |
30 | } |
31 | |
32 | $excludedIds = $validator->getParameter('exclude')->isString()->setDefault('')->getValue(); |
33 | if ($excludedIds) { |
34 | $exclude = explode(',', $excludedIds); |
35 | } |
36 | $exclude[] = $workstation->process->toQueue(\App::$now)->number; |
37 | |
38 | $error = $validator->getParameter('error')->isString()->getValue(); |
39 | if (isset($processId) && $workstation->process->getId() != $processId) { |
40 | $error = ('pickup' == $workstation->process->getStatus()) ? |
41 | 'has_called_pickup' : |
42 | 'has_called_process'; |
43 | } |
44 | |
45 | if ($workstation->process->getStatus() == 'processing') { |
46 | return \BO\Slim\Render::redirect('workstationProcessProcessing', [], ['error' => $error]); |
47 | } |
48 | |
49 | // Check if $process is set or assign a default value (like null) |
50 | $process = isset($process) ? $process : null; |
51 | |
52 | return \BO\Slim\Render::withHtml( |
53 | $response, |
54 | 'block/process/called.twig', |
55 | array( |
56 | 'title' => 'Sachbearbeiter', |
57 | 'workstation' => $workstation, |
58 | 'menuActive' => 'workstation', |
59 | 'process' => $process, |
60 | 'exclude' => join(',', $exclude), |
61 | 'error' => $error |
62 | ) |
63 | ); |
64 | } |
65 | } |