-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from it-at-m/feature-zms-1808-appoinrment-red…
…irect Feature zms 1808 appoinrment redirect
- Loading branch information
Showing
8 changed files
with
370 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* @package Zmsadmin | ||
* @copyright BerlinOnline Stadtportal GmbH & Co. KG | ||
**/ | ||
|
||
namespace BO\Zmsadmin; | ||
|
||
use \Psr\Http\Message\RequestInterface; | ||
|
||
class WorkstationProcessRedirect extends BaseController | ||
{ | ||
/** | ||
* @SuppressWarnings(Param) | ||
* @return String | ||
*/ | ||
public function readResponse( | ||
RequestInterface $request, | ||
\Psr\Http\Message\ResponseInterface $response, | ||
array $args | ||
) { | ||
$workstation = \App::$http->readGetResult('/workstation/', ['resolveReferences' => 2])->getEntity(); | ||
$department = \App::$http | ||
->readGetResult( | ||
'/scope/' . $workstation->scope['id'] . '/department/', | ||
['resolveReferences' => 2] | ||
)->getEntity(); | ||
$input = $request->getParsedBody(); | ||
$process = $workstation->process; | ||
|
||
if ($request->getMethod() === 'POST') { | ||
$validator = $request->getAttribute('validator'); | ||
$selectedLocation = $validator->getParameter('location')->isNumber()->getValue(); | ||
|
||
if (empty($selectedLocation)) { | ||
return \BO\Slim\Render::redirect( | ||
'workstationProcessRedirect', | ||
[], | ||
[ | ||
'errors' => [ | ||
'location' => 'Bitte wählen Sie einen Standort aus.' | ||
] | ||
] | ||
); | ||
} | ||
|
||
$scope = \App::$http | ||
->readGetResult( | ||
'/scope/' . $selectedLocation . '/', | ||
['resolveReferences' => 2] | ||
)->getEntity(); | ||
|
||
$process = \App::$http | ||
->readGetResult( | ||
'/process/'. $process->getId() .'/'. $process->getAuthKey() .'/', | ||
['resolveReferences' => 2] | ||
)->getEntity(); | ||
|
||
$newProcess = clone $process; | ||
$newProcess->scope = $scope; | ||
$newProcess->appointments[0]->scope = $scope; | ||
$newProcess->amendment = $input['amendment']; | ||
|
||
$process = \App::$http->readPostResult('/process/status/redirect/', $newProcess)->getEntity(); | ||
|
||
return \BO\Slim\Render::redirect( | ||
$workstation->getVariantName(), | ||
array(), | ||
array() | ||
); | ||
} | ||
|
||
return \BO\Slim\Render::withHtml( | ||
$response, | ||
'page/workstationProcessRedirect.twig', | ||
array( | ||
'title' => 'Kundendaten', | ||
'workstation' => $workstation, | ||
'department' => $department, | ||
'scope' => $workstation->scope, | ||
'scopes' => $department->getScopeList(), | ||
'menuActive' => 'workstation', | ||
'errors' => $request->getParam('errors') | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{% embed "block/scaffholding/board.twig" with {'class': 'appointment-form'} %} | ||
|
||
{% from 'element/helper/form.twig' import formgroup, formbutton, checkboxfield, selectfield, inputfield %} | ||
|
||
{% block board_title %} | ||
Termin Weiterleiten | ||
{% endblock %} | ||
|
||
{% block board_body %} | ||
{% include "element/helper/messageHandler.twig" %} | ||
{% from 'element/helper/form.twig' import formgroup, formbutton, inputfield, providername %} | ||
|
||
<form data-formData="{{ formData|json_encode }}" data-saved-process="{{ selectedProcess.id }}" method="POST"> | ||
<div class="aural" id="auralmessage" aria-live="polite" data-aural='{"clean":"{{ cleanupRequestAuralMessage|trans }}", "add":"{{ addRequestAuralMessage|trans }}","remove":"{{ removeRequestAuralMessage|trans }}", "chooseRequestFirst":"{{ chooseRequestFirst|trans }}"}'></div> | ||
|
||
{% set scopeOptionsGroup = [{ 'value' : '', 'name' : '-- bitte auswählen --'}] %} | ||
{% set scopeOptionsGroupOptions = [] %} | ||
{% for scopeOption in scopes|filter((s) => s.name != '' and s.id != scope.id) %} | ||
{% set scopeOptionsGroupOptions = scopeOptionsGroupOptions|merge([{ "value": scopeOption.id, "name": providername(scopeOption) }]) %} | ||
{% endfor %} | ||
{% set scopeOptionsGroup = scopeOptionsGroup|merge([{ 'name' : department.name, 'options' : scopeOptionsGroupOptions|msort('name') }]) %} | ||
|
||
{{ formgroup( | ||
{"label": "Weiterleiten zu Standort", "required": true, "errors": [errors.location]}, | ||
[{ | ||
"type": "select", | ||
"required": true, | ||
"parameter": { | ||
"name": "location", | ||
"options": scopeOptionsGroup | ||
} | ||
}] | ||
) }} | ||
|
||
{{ formgroup( | ||
{ | ||
"label": "Anmerkung", | ||
"checked": scope.preferences.client.amendmentActivated, | ||
"class": "form-group--nomaxwidth", | ||
"errors": formData.amendment.messages | ||
}, | ||
[{ | ||
"type":"textarea", | ||
"parameter": { | ||
"name": "amendment", | ||
"rows": "3", | ||
"maxlength": 300, | ||
"value": workstation.process.amendment, | ||
"accesskey":"w" | ||
} | ||
}] | ||
) }} | ||
|
||
<button class="button button--positive button-submit process-reserve" accesskey="h">{{ "%s"|format("Termin buchen")|trans }}</button> | ||
</form> | ||
{% endblock %} | ||
{% endembed %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends "layout/main.twig" %} | ||
{% from 'element/helper/snippets.twig' import headline1 %} | ||
|
||
{% block headline %} | ||
{{ headline1("Sachbearbeiterplatz") }} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="workstation-view" | ||
data-includeurl="{{ includeUrl() }}" | ||
data-selected-date="{{ selectedDate }}" | ||
data-selected-time="{{ selectedTime }}" | ||
data-selected-process="{{ selectedProcess }}" | ||
data-cluster-enabled="{{ workstation.queue.clusterEnabled }}" | ||
data-selected-scope="{% if workstation.queue.clusterEnabled == 0 %}{{ workstation.scope.id }}{% else %}{{ selectedScope }}{% endif %}" | ||
data-called-process="{{ calledProcess }}"> | ||
<div class="grid"> | ||
<div class="grid__item three-twelfths" id="liveregionClientNext" data-client-next> | ||
{% include "block/process/nextContainer.twig" %} | ||
</div> | ||
<div class="grid__item six-twelfths"> | ||
{% include "block/appointment/formRedirect.twig" with { | ||
'scopes': scopes, | ||
'workstation': workstation | ||
} %} | ||
</div> | ||
<div class="grid__item three-twelfths" aria-live="off" id="liveregionCalendarBox" data-calendar-box> | ||
<div data-calendar> | ||
{% include "block/calendar/calendarContainer.twig" with {source: "workstation"} %} | ||
</div> | ||
<div style="margin-top:-2em;"> | ||
{% include "block/calendar/legend.twig" with {"view": "calendar"} %} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="grid"> | ||
<div class="grid__item" aria-live="off" id="liveregionQueueTable" data-queue-table> | ||
{% include "block/queue/queueContainer.twig" %} | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
/** | ||
* @package ZMS API | ||
* @copyright BerlinOnline Stadtportal GmbH & Co. KG | ||
**/ | ||
|
||
namespace BO\Zmsapi; | ||
|
||
use \BO\Slim\Render; | ||
use \BO\Mellon\Validator; | ||
use BO\Zmsdb\Process; | ||
use \BO\Zmsdb\Process as Query; | ||
use \BO\Zmsdb\ProcessStatusQueued; | ||
use BO\Zmsdb\Workstation; | ||
|
||
/** | ||
* @SuppressWarnings(Coupling) | ||
*/ | ||
class ProcessRedirect extends BaseController | ||
{ | ||
/** | ||
* @SuppressWarnings(Param) | ||
* @return String | ||
*/ | ||
public function readResponse( | ||
\Psr\Http\Message\RequestInterface $request, | ||
\Psr\Http\Message\ResponseInterface $response, | ||
array $args | ||
) { | ||
$workstation = (new Helper\User($request))->checkRights(); | ||
$input = Validator::input()->isJson()->assertValid()->getValue(); | ||
$entity = new \BO\Zmsentities\Process($input); | ||
$newProcess = new \BO\Zmsentities\Process($input); | ||
|
||
|
||
|
||
$process = $this->readValidProcess($workstation, $entity, $input); | ||
$process = (new Process())->readEntity($process->id, $process->authKey, 2); | ||
$requests = $process->getRequests(); | ||
$newProcess->requests = $requests; | ||
|
||
$this->testProcessAccess($workstation, $process); | ||
|
||
\BO\Zmsdb\Connection\Select::getWriteConnection(); | ||
$processStatusArchived = new \BO\Zmsdb\ProcessStatusArchived(); | ||
|
||
$process->status = 'finished'; | ||
$process = (new Query)->updateEntity($process, \App::$now, 0, 'processing'); | ||
(new Workstation)->writeRemovedProcess($workstation); | ||
$processStatusArchived->writeEntityFinished($process, \App::$now, true); | ||
|
||
$newProcess = (new \BO\Zmsdb\Process())->redirectToScope($newProcess, $process->scope, $process->id); | ||
|
||
$message = Response\Message::create($request); | ||
$message->data = $newProcess; | ||
$response = Render::withLastModified($response, time(), '0'); | ||
|
||
return Render::withJson($response, $message->setUpdatedMetaData(), $message->getStatuscode()); | ||
} | ||
|
||
protected function testProcessData($entity) | ||
{ | ||
$entity->testValid(); | ||
$authCheck = (new Query())->readAuthKeyByProcessId($entity->id); | ||
if (! $authCheck) { | ||
throw new Exception\Process\ProcessNotFound(); | ||
} elseif ($authCheck['authKey'] != $entity->authKey && $authCheck['authName'] != $entity->authKey) { | ||
throw new Exception\Process\AuthKeyMatchFailed(); | ||
} | ||
} | ||
|
||
protected function testProcessAccess($workstation, $process) | ||
{ | ||
$cluster = (new \BO\Zmsdb\Cluster)->readByScopeId($workstation->scope['id'], 1); | ||
$workstation->testMatchingProcessScope($workstation->getScopeList($cluster), $process); | ||
if ($workstation->process && $workstation->process->hasId() && $workstation->process->id != $process->id) { | ||
$exception = new Exception\Workstation\WorkstationHasAssignedProcess(); | ||
$exception->data = [ | ||
'process' => $workstation->process | ||
]; | ||
throw $exception; | ||
} | ||
} | ||
|
||
protected function readValidProcess($workstation, $entity, $input) | ||
{ | ||
if ($entity->hasProcessCredentials()) { | ||
$this->testProcessData($entity); | ||
$entity->addData($input); | ||
$process = (new Query())->updateEntity($entity, \App::$now); | ||
} elseif ($entity->hasQueueNumber()) { | ||
// Allow waitingnumbers over 1000 with the fourth parameter | ||
$process = ProcessStatusQueued::init() | ||
->readByQueueNumberAndScope($entity['queue']['number'], $workstation->scope['id'], 0, 100000000); | ||
if (! $process->id) { | ||
$workstation = (new \BO\Zmsdb\Workstation)->readResolvedReferences($workstation, 1); | ||
$process = (new Query())->writeNewPickup($workstation->scope, \App::$now, $entity['queue']['number']); | ||
} | ||
$process->testValid(); | ||
} else { | ||
$entity->testValid(); | ||
throw new Exception\Process\ProcessInvalid(); | ||
} | ||
return $process; | ||
} | ||
} |
Oops, something went wrong.