From 6dd0ac86b26ccf9545f4da488c45efc61b50d27e Mon Sep 17 00:00:00 2001 From: Clemens Creutzburg Date: Tue, 24 Mar 2026 14:57:21 +0100 Subject: [PATCH] Impfworkflow + Patientensuche repariert --- admin/impfworkflow.php | 80 +++++++++++++++++++++++++++++++++++++++++- admin/js/patienten.js | 18 +++++----- intern/js/patienten.js | 18 +++++----- 3 files changed, 97 insertions(+), 19 deletions(-) diff --git a/admin/impfworkflow.php b/admin/impfworkflow.php index 4d2c245..1dd21b9 100644 --- a/admin/impfworkflow.php +++ b/admin/impfworkflow.php @@ -92,6 +92,23 @@ function workflowDeleteWaitlistEntry(PDO $pdo, int $warteid): void $stDelete->execute(['wid' => $warteid]); } +function workflowLoadWaitlistEntry(PDO $pdo, int $warteid): ?array +{ + if ($warteid <= 0) { + return null; + } + + $stWait = $pdo->prepare("SELECT w.warteid, w.userid, w.checked, p.vorname, p.nachname + FROM warteliste w + LEFT JOIN persons p ON p.person_id = w.userid + WHERE w.warteid = :wid + LIMIT 1"); + $stWait->execute(['wid' => $warteid]); + $row = $stWait->fetch(PDO::FETCH_ASSOC); + + return $row ?: null; +} + function workflowCountWaitersForPlan(PDO $pdo, int $impfstoffId, int $planId): int { return impfWorkflowNotificationCountWaitersForPlan($pdo, $impfstoffId, $planId); @@ -583,6 +600,55 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $error = "Wartelisten-Eintrag nicht gefunden."; } } + } elseif ($aktion === 'confirm_waitlist') { + $warteid = (int)($_POST['warteid'] ?? 0); + if ($warteid <= 0) { + $error = "Ungültiger Wartelisten-Eintrag."; + } else { + $waitRow = workflowLoadWaitlistEntry($pdo, $warteid); + if (!$waitRow) { + $error = "Wartelisten-Eintrag nicht gefunden."; + } elseif ((int)$waitRow['checked'] >= 1) { + $error = "Der Wartelisten-Eintrag ist bereits bestätigt."; + } else { + $stUpdate = $pdo->prepare("UPDATE warteliste + SET checked = 1 + WHERE warteid = :wid + AND checked < 1"); + $stUpdate->execute(['wid' => $warteid]); + + if ($stUpdate->rowCount() < 1) { + $error = "Wartelisten-Eintrag konnte nicht bestätigt werden."; + } else { + SendMailMessageVorlage($pdo, '2', $warteid, '9'); + $notificationEvents = impfWorkflowNotificationProcess($pdo); + $personName = trim((string)($waitRow['vorname'] ?? '') . ' ' . (string)($waitRow['nachname'] ?? '')); + $message = "Wartelisten-Eintrag für " . trim($personName) . " wurde bestätigt."; + if (!empty($notificationEvents)) { + $message .= ' ' . count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet."; + } + } + } + } + } elseif ($aktion === 'cancel_waitlist') { + $warteid = (int)($_POST['warteid'] ?? 0); + if ($warteid <= 0) { + $error = "Ungültiger Wartelisten-Eintrag."; + } else { + $waitRow = workflowLoadWaitlistEntry($pdo, $warteid); + if (!$waitRow) { + $error = "Wartelisten-Eintrag nicht gefunden."; + } else { + SendMailMessageVorlage($pdo, '2', $warteid, '10'); + workflowDeleteWaitlistEntry($pdo, $warteid); + $notificationEvents = impfWorkflowNotificationProcess($pdo); + $personName = trim((string)($waitRow['vorname'] ?? '') . ' ' . (string)($waitRow['nachname'] ?? '')); + $message = "Wartelisten-Eintrag für " . trim($personName) . " wurde abgesagt."; + if (!empty($notificationEvents)) { + $message .= ' ' . count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet."; + } + } + } } } @@ -809,7 +875,19 @@ try { -
+ + + + + +
+ +
+ + + +
+
diff --git a/admin/js/patienten.js b/admin/js/patienten.js index 84b932f..0cb4b82 100644 --- a/admin/js/patienten.js +++ b/admin/js/patienten.js @@ -1,12 +1,12 @@ -$(function() { - $("#user_input").autocomplete({ - source: "inc/suchepatient.php", - minLength: 3, - select: function( event, ui ) { - event.preventDefault(); - $("#userid_input").val(ui.item.id); - $("#user_input").val(ui.item.value); +$(function() { + $("#user_input").autocomplete({ + source: "../inc/suchepatient.php", + minLength: 3, + select: function( event, ui ) { + event.preventDefault(); + $("#userid_input").val(ui.item.id); + $("#user_input").val(ui.item.value); $("#formbenutzersuche").submit(); } }); @@ -43,4 +43,4 @@ function submitForm(sub) { }).responseText; //window.location.reload(false); document.body.innerHTML = result; -} \ No newline at end of file +} diff --git a/intern/js/patienten.js b/intern/js/patienten.js index 84b932f..0cb4b82 100644 --- a/intern/js/patienten.js +++ b/intern/js/patienten.js @@ -1,12 +1,12 @@ -$(function() { - $("#user_input").autocomplete({ - source: "inc/suchepatient.php", - minLength: 3, - select: function( event, ui ) { - event.preventDefault(); - $("#userid_input").val(ui.item.id); - $("#user_input").val(ui.item.value); +$(function() { + $("#user_input").autocomplete({ + source: "../inc/suchepatient.php", + minLength: 3, + select: function( event, ui ) { + event.preventDefault(); + $("#userid_input").val(ui.item.id); + $("#user_input").val(ui.item.value); $("#formbenutzersuche").submit(); } }); @@ -43,4 +43,4 @@ function submitForm(sub) { }).responseText; //window.location.reload(false); document.body.innerHTML = result; -} \ No newline at end of file +}