Skip to content

Commit

Permalink
merged dev into mix
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasAFink committed Nov 27, 2023
2 parents db82aaf + 4dff7ec commit abe36e5
Show file tree
Hide file tree
Showing 10 changed files with 556 additions and 14 deletions.
5 changes: 5 additions & 0 deletions zmsadmin/src/Zmsadmin/Helper/GraphDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,11 @@ public static function getProcess()
waitingTime,
callCount
}
processingTime
waitingTime
services
name
withAppointment
requests{
id
link
Expand Down
42 changes: 39 additions & 3 deletions zmsadmin/src/Zmsadmin/ProcessSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function readResponse(
$dateTime = ($process->isWithAppointment()) ?
(new \DateTime())->setTimestamp($process->getFirstAppointment()->date) :
\App::$now;
$shouldNotify = $this->shouldSendNotifications($input, $process);
$process->withUpdatedData($input, $dateTime, $scope);

$validatedForm = ($process->isWithAppointment()) ?
Expand All @@ -51,7 +52,12 @@ public function readResponse(
);
}

$process = $this->writeUpdatedProcess($input, $process, $validator);
$process = $this->writeUpdatedProcess(
$input,
$process,
$validator,
$shouldNotify
);
$appointment = $process->getFirstAppointment();
$conflictList = ($process->isWithAppointment()) ?
static::getConflictList($scope->getId(), $appointment) :
Expand Down Expand Up @@ -84,7 +90,7 @@ public static function getConflictList($scopeId, $appointment)
return (isset($conflictList)) ? $conflictList[$appointment->getStartTime()->format('Y-m-d')] : null;
}

protected function writeUpdatedProcess($input, Entity $process, $validator)
protected function writeUpdatedProcess($input, Entity $process, $validator, $notify = true)
{
$initiator = $validator->getParameter('initiator')->isString()->getValue();
$process = \App::$http->readPostResult(
Expand All @@ -96,7 +102,37 @@ protected function writeUpdatedProcess($input, Entity $process, $validator)
'slotsRequired' => (isset($input['slotCount']) && 1 < $input['slotCount']) ? $input['slotCount'] : 0
]
)->getEntity();
AppointmentFormHelper::updateMailAndNotification($input, $process);

if ($notify) {
AppointmentFormHelper::updateMailAndNotification($input, $process);
}

return $process;
}

private function shouldSendNotifications($requestData, \BO\Zmsentities\Schema\Entity $process)
{
$requestIds = $requestData['requests'] ?? [];
$currentRequestIds = [];
foreach ($process->getRequests() as $request) {
$currentRequestIds[] = $request['id'];
}

if (array_merge(array_diff($requestIds, $currentRequestIds), array_diff($currentRequestIds, $requestIds))) {
return true;
}

if ($process->getFirstClient()['familyName'] !== $requestData['familyName']) {
return true;
}

$newDate = $requestData['selecteddate'] . ' '
. str_replace('-', ':', $requestData['selectedtime']);

if ($process->getFirstAppointment()->toDateTime()->format('Y-m-d H:i') !== $newDate) {
return true;
}

return false;
}
}
2 changes: 2 additions & 0 deletions zmsadmin/src/Zmsadmin/QueueTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function readResponse(
$queueList = $processList->toQueueList(\App::$now);
$queueListVisible = $queueList->withStatus(['preconfirmed', 'confirmed', 'queued', 'reserved', 'deleted']);
$queueListMissed = $queueList->withStatus(['missed']);
$queueListFinished = $queueList->withStatus(['finished']);

// rendering
return \BO\Slim\Render::withHtml(
Expand All @@ -65,6 +66,7 @@ public function readResponse(
'clusterEnabled' => $workstation->isClusterEnabled(),
'processList' => $queueListVisible->toProcessList(),
'processListMissed' => $queueListMissed->toProcessList(),
'processListFinished' => $queueListFinished->toProcessList(),
'changedProcess' => $changedProcess,
'success' => $success,
'debug' => \App::DEBUG,
Expand Down
106 changes: 98 additions & 8 deletions zmsadmin/templates/block/queue/table.twig
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,12 @@
</tbody>
</table>
</div>
<h2>Verpasste Termine</h2>
{% if processListMissed|length %}
<div class="table-responsive-wrapper">
<table class="table--base queue-missed">

<div class="table-responsive-wrapper">
<h2>Verpasste Termine</h2>
{% if processListMissed|length %}
<div class="table-responsive-wrapper">
<table class="table--base queue-missed">
<thead>
<tr>
<th>Lfdnr.</th>
Expand Down Expand Up @@ -280,10 +282,98 @@
</tr>
{% endfor %}
</table>
</div>
{% else %}
Keine Einträge gefunden.
{% endif %}
</div>
{% else %}
Keine Einträge gefunden.
{% endif %}
<br>
<br>
</div>

<div class="table-responsive-wrapper">
<h2 id="finished-appointments-control">Abgeschlossene Termine
<i class="fas fa-angle-down" aria-hidden="true"></i>
<i class="fas fa-angle-up hidden" aria-hidden="true"></i>
</h2>
{% if processListFinished|length %}
<div id="finished-appointments-content" class="hidden table-responsive-wrapper">
<table class="table--base queue-missed">
<thead>
<tr>
<th>Lfdnr.</th>
<th>Uhrzeit</th>
<th>Name</th>
<th>Dienstleistung</th>
<th>Art</th>
<th>Wartezeit</th>
<th>Bearbeitungszeit</th>
</tr>
</thead>
{% set lfdnr = 0 %}
{% for item in processListFinished %}
{% set lfdnr = lfdnr + 1 %}
<tr class="missed">
<td>
{{ lfdnr }}.
</td>
<td>
{% if item.queue.withAppointment %}
{{ item.appointments|first.date|date("H:i") }}
{% else %}
{{ item.queue.arrivalTime|date("H:i") }}
{% endif %}
</td>
<td>{{ item.name }}</td>
<td>{{ item.services }}</td>
<td>
{% if item.withAppointment %}
Termin
{% else %}
Spontankunde
{% endif %}
</td>
<td>{{ item.waitingTime }}</td>
<td>{{ item.processingTime }}</td>
</tr>
{% endfor %}
</table>
</div>
{% else %}
Keine Einträge gefunden.
{% endif %}

<script>
(function() {
let control = $('#finished-appointments-control');
let content = $('#finished-appointments-content');
let upButton = $('#finished-appointments-control .fa-angle-up')
let downButton = $('#finished-appointments-control .fa-angle-down')
$(control).click(function(){
if (upButton.hasClass('hidden')) {
upButton.removeClass('hidden')
downButton.addClass('hidden')
content.removeClass('hidden')
} else {
upButton.addClass('hidden')
downButton.removeClass('hidden')
content.addClass('hidden')
}
});
})();
</script>

<style>
.hidden {
display: none;
}
#finished-appointments-control:hover {
cursor: pointer;
}
</style>
</div>

<div class="form-actions">
<div class="right">
<button title="{% trans %}Warteschlange neu laden{% endtrans %}" class="button button-reload reload"><i class="fas fa-sync"></i> Warteschlange aktualisieren</button>
Expand Down
5 changes: 5 additions & 0 deletions zmsapi/src/Zmsapi/ProcessListByScopeAndDate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use \BO\Slim\Render;
use \BO\Mellon\Validator;
use \BO\Zmsdb\Scope as Query;
use \BO\Zmsdb\ProcessStatusArchived;

class ProcessListByScopeAndDate extends BaseController
{
Expand Down Expand Up @@ -37,8 +38,12 @@ public function readResponse(
$resolveReferences? $resolveReferences + 1 : 1 // resolveReferences is for process, for queue we have to +1
);

$archivedProcesses =
(new ProcessStatusArchived())->readListByScopeAndDate($scope->getId(), $dateTime);

$message = Response\Message::create($request);
$message->data = $queueList->toProcessList()->withResolveLevel($resolveReferences);
$message->data->addData($archivedProcesses);

$response = Render::withLastModified($response, time(), '0');
$response = Render::withJson($response, $message, 200);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE `buergerarchiv`
ADD COLUMN `name` varchar (255) DEFAULT NULL;

ALTER TABLE `buergerarchiv`
ADD COLUMN `dienstleistungen` varchar (1000) DEFAULT NULL;
12 changes: 11 additions & 1 deletion zmsdb/src/Zmsdb/ProcessStatusArchived.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace BO\Zmsdb;

use \BO\Zmsentities\Process as Entity;
use \BO\Zmsentities\ProcessArchived as Entity;
use \BO\Zmsentities\Collection\ProcessList as Collection;

/**
Expand Down Expand Up @@ -41,6 +41,16 @@ public function readListByDate($dateTime, $resolveReferences = 0)
return $this->readResolvedList($query, $resolveReferences);
}

public function readListByScopeAndDate($scopeId, $dateTime, $resolveReferences = 0)
{
$query = new Query\ProcessStatusArchived(Query\Base::SELECT);
$query->addEntityMapping()
->addConditionScopeId($scopeId)
->addResolvedReferences($resolveReferences)
->addConditionTime($dateTime);
return $this->readResolvedList($query, $resolveReferences);
}

public function readListForStatistic($dateTime, \BO\Zmsentities\Scope $scope, $limit = 500, $resolveReferences = 0)
{
$query = new Query\ProcessStatusArchived(Query\Base::SELECT);
Expand Down
20 changes: 18 additions & 2 deletions zmsdb/src/Zmsdb/Query/ProcessStatusArchived.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ public function getEntityMapping()
'scope__id' => 'process.StandortID',
'__clientsCount' => 'process.AnzahlPersonen',
'waitingTime' => 'process.wartezeit',
'bearbeitungszeit' => 'process.bearbeitungszeit',
'processingTime' => 'process.bearbeitungszeit',
'name' => 'process.name',
'services' => 'process.dienstleistungen',
'queue__arrivalTime' => self::expression(
'CONCAT(`process`.`Datum`, " 00:00:00")'
),
'queue__callTime' => self::expression(
'CONCAT(`process`.`Datum`, " ", SEC_TO_TIME(`wartezeit`))'
),
'queue__withAppointment' => 'process.mitTermin',
'withAppointment' => 'process.mitTermin',
'queue__status' => self::expression(
'IF(`process`.`nicht_erschienen`,
"missed",
Expand Down Expand Up @@ -118,10 +121,12 @@ public function addValuesNewArchive(\BO\Zmsentities\Process $process, \DateTimeI
{
$this->addValues([
'StandortID' => $process->scope['id'],
'name' => $process->getFirstClient()['familyName'],
'dienstleistungen' => $this->getArchivedServices($process),
'Datum' => $process->getFirstAppointment()->toDateTime()->format('Y-m-d'),
'mitTermin' => ($process->toQueue($now)->withAppointment) ? 1 : 0,
'nicht_erschienen' => ('missed' == $process->queue['status']) ? 1 : 0,
'Timestamp' => $now->format('H:i:s'),
'Timestamp' =>$process->getArrivalTime()->format('H:i:s'),
'wartezeit' => ($process->getWaitedSeconds() > 0) ? $process->getWaitedMinutes() : 0,
'bearbeitungszeit' => $process->finishTime
? floor(
Expand Down Expand Up @@ -151,4 +156,15 @@ public function postProcess($data)
}
return $data;
}

private function getArchivedServices(\BO\Zmsentities\Process $process)
{
$services = $process->getRequests()->getFirst()->name;

if ($process->getRequests()->count() > 1) {
$services .= ' +' . ($process->getRequests()->count() - 1);
}

return $services;
}
}
Loading

0 comments on commit abe36e5

Please sign in to comment.