From 6360af272ade97f694b6aaddee3dadc0e872db37 Mon Sep 17 00:00:00 2001 From: Clemens Creutzburg Date: Mon, 30 Mar 2026 21:52:10 +0200 Subject: [PATCH] Impfverwaltung anpassen --- admin/impfworkflow.php | 160 +++++++++++++++++------------- admin/impfworkflow_stammdaten.php | 7 +- inc/functions.impfen.inc.php | 27 +++-- 3 files changed, 117 insertions(+), 77 deletions(-) diff --git a/admin/impfworkflow.php b/admin/impfworkflow.php index d8db8d8..2a05bcd 100644 --- a/admin/impfworkflow.php +++ b/admin/impfworkflow.php @@ -120,21 +120,11 @@ function workflowLoadWaitRowsForPlan(PDO $pdo, int $impfstoffId, int $planId): a FROM warteliste w WHERE w.checked = 1 AND (w.impfstoff = :iid OR w.impfstoff = 0) - AND ( - EXISTS ( - SELECT 1 - FROM warteliste_zeitraum wz - WHERE wz.warteid = w.warteid - AND wz.zeitraum_id = :zid - ) - OR ( - NOT EXISTS ( - SELECT 1 - FROM warteliste_zeitraum wz_none - WHERE wz_none.warteid = w.warteid - ) - AND (w.zeitraum_id = :zid OR w.zeitraum_id IS NULL) - ) + AND EXISTS ( + SELECT 1 + FROM warteliste_zeitraum wz + WHERE wz.warteid = w.warteid + AND wz.zeitraum_id = :zid ) ORDER BY w.date_created ASC, w.warteid ASC"); $stW->execute([ @@ -145,6 +135,26 @@ function workflowLoadWaitRowsForPlan(PDO $pdo, int $impfstoffId, int $planId): a return $stW->fetchAll(PDO::FETCH_ASSOC); } +function workflowCountStrictWaitersForPlan(PDO $pdo, int $impfstoffId, int $planId): int +{ + $stW = $pdo->prepare("SELECT COUNT(DISTINCT w.userid) + FROM warteliste w + WHERE w.checked = 1 + AND (w.impfstoff = :iid OR w.impfstoff = 0) + AND EXISTS ( + SELECT 1 + FROM warteliste_zeitraum wz + WHERE wz.warteid = w.warteid + AND wz.zeitraum_id = :zid + )"); + $stW->execute([ + 'iid' => $impfstoffId, + 'zid' => $planId, + ]); + + return (int)$stW->fetchColumn(); +} + function workflowAddWartelisteEntry( PDO $pdo, int $personId, @@ -665,6 +675,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $rules = []; $plans = []; $configuredImpfstoffe = []; +$configuredImpfstoffNames = []; $eligible = []; $personResults = []; $waitRows = []; @@ -700,6 +711,7 @@ try { foreach ($rules as $r) { $iid = (int)$r['impfstoff_id']; + $configuredImpfstoffNames[$iid] = (string)$r['impfname']; if (!isset($planExistsForImpfstoff[$iid])) { continue; } @@ -721,7 +733,7 @@ try { } $planId = (int)$plan['zeitraum_id']; - $planWaitCounts[$iid][$planId] = workflowCountWaitersForPlan($pdo, $iid, $planId); + $planWaitCounts[$iid][$planId] = workflowCountStrictWaitersForPlan($pdo, $iid, $planId); if ($planWaitCounts[$iid][$planId] >= $dosen) { $hasEligiblePlan = true; } @@ -893,7 +905,7 @@ try { ', array_map('esc', $w['zeitraum_labels'])); ?> - + @@ -953,52 +965,58 @@ try { -
+ - - +
+ + +
- - +
+ + +
- - - +
+ + + +