Impfverwaltung anpassen

This commit is contained in:
2026-03-30 21:52:10 +02:00
parent 091702c2a2
commit 6360af272a
3 changed files with 117 additions and 77 deletions
+47 -27
View File
@@ -120,22 +120,12 @@ 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 (
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)
)
)
ORDER BY w.date_created ASC, w.warteid ASC");
$stW->execute([
'iid' => $impfstoffId,
@@ -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 {
<?php if (!empty($w['zeitraum_labels'])): ?>
<?php echo implode('<br>', array_map('esc', $w['zeitraum_labels'])); ?>
<?php else: ?>
<?php echo esc((string)$w['impfenzeitraum']); ?>
<?php echo esc(impfLimitLabelLength((string)$w['impfenzeitraum'], 50)); ?>
<?php endif; ?>
</td>
<td>
@@ -953,10 +965,11 @@ try {
<?php endif; ?>
<?php endif; ?>
<form method="post" class="form-inline">
<form method="post">
<input type="hidden" name="aktion" value="add_waitlist_existing">
<input type="hidden" name="person_search" value="<?php echo esc($personSearch); ?>">
<div class="form-group" style="display:block; margin-bottom:10px;">
<label>Patient</label>
<select class="form-control" name="wl_person_id" required <?php echo empty($personResults) ? 'disabled' : ''; ?>>
<option value="">Bitte wählen</option>
@@ -969,8 +982,10 @@ try {
<option value="<?php echo $pid; ?>" <?php echo $selected; ?>><?php echo esc($personLabel); ?></option>
<?php endforeach; ?>
</select>
</div>
<label style="margin-left:10px;">Impfstoff</label>
<div class="form-group" style="display:block; margin-bottom:10px;">
<label>Impfstoff</label>
<select class="form-control" name="wl_impfstoff_id" id="existing_impfstoff">
<option value="0" <?php echo ((int)($_POST['wl_impfstoff_id'] ?? 0) === 0) ? 'selected' : ''; ?>>Keine Vorgabe</option>
<?php foreach ($configuredImpfstoffe as $r): ?>
@@ -983,8 +998,10 @@ try {
</option>
<?php endforeach; ?>
</select>
</div>
<label style="margin-left:10px;">Zeitfenster</label>
<div class="form-group" style="display:block;">
<label>Zeitfenster</label>
<?php $selectedExistingPlanIds = impfNormalizeZeitraumIds($_POST['wl_plan_ids'] ?? ($_POST['wl_plan_id'] ?? [])); ?>
<select class="form-control" name="wl_plan_ids[]" id="existing_plan" multiple size="6">
<?php foreach ($plans as $p): ?>
@@ -992,13 +1009,14 @@ try {
$planId = (int)$p['zeitraum_id'];
$selected = in_array($planId, $selectedExistingPlanIds, true) ? 'selected' : '';
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
$optionLabel = workflowPlanLabel($p);
?>
<option value="<?php echo $planId; ?>" data-impfstoffe="<?php echo esc($impfstoffeCsv); ?>" <?php echo $selected; ?>>
<?php echo esc(workflowPlanLabel($p) . ' | Impfstoffe: ' . $impfstoffeText); ?>
<?php echo esc($optionLabel); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="workflow-action-row">
<button class="btn btn-primary" type="submit" <?php echo empty($personResults) ? 'disabled' : ''; ?>>
Zur Warteliste hinzufügen
@@ -1083,10 +1101,10 @@ try {
$planId = (int)$p['zeitraum_id'];
$selected = in_array($planId, $selectedNewPlanIds, true) ? 'selected' : '';
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
$optionLabel = workflowPlanLabel($p);
?>
<option value="<?php echo $planId; ?>" data-impfstoffe="<?php echo esc($impfstoffeCsv); ?>" <?php echo $selected; ?>>
<?php echo esc(workflowPlanLabel($p) . ' | Impfstoffe: ' . $impfstoffeText); ?>
<?php echo esc($optionLabel); ?>
</option>
<?php endforeach; ?>
</select>
@@ -1114,7 +1132,7 @@ try {
<div class="panel panel-default">
<div class="panel-heading"><strong>Konkretes Impfevent erstellen</strong></div>
<div class="panel-body">
<p>Es werden nur Impfstoffe angeboten, bei denen die bestätigte Warteliste mindestens eine Flasche füllt.</p>
<p>Es werden nur Impfstoffe und Zeiträume angeboten, bei denen die bestätigte Warteliste mindestens eine Flasche füllt und die Wartenden diesen Zeitraum auch ausdrücklich gewählt haben.</p>
<form method="post" class="form-inline" style="margin-bottom:14px;">
<input type="hidden" name="aktion" value="create_event">
@@ -1130,14 +1148,18 @@ try {
<select class="form-control" name="plan_id" id="event_plan" required>
<option value="">Bitte wählen</option>
<?php foreach ($plans as $p): ?>
<?php foreach (($p['impfstoff_id_list'] ?? []) as $planImpfstoffId): ?>
<?php
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
$waiterCount = (int)($planWaitCounts[(int)$planImpfstoffId][(int)$p['zeitraum_id']] ?? 0);
if ($waiterCount <= 0) {
continue;
}
?>
<option value="<?php echo (int)$p['zeitraum_id']; ?>" data-impfstoffe="<?php echo esc($impfstoffeCsv); ?>">
<?php echo esc(workflowPlanLabel($p) . ' | Impfstoffe: ' . $impfstoffeText); ?>
<option value="<?php echo (int)$p['zeitraum_id']; ?>" data-impfstoffe="<?php echo esc((string)$planImpfstoffId); ?>">
<?php echo esc(workflowPlanLabel($p) . ' | Impfstoff: ' . ($configuredImpfstoffNames[(int)$planImpfstoffId] ?? 'Unbekannt') . ' | Wartende: ' . $waiterCount); ?>
</option>
<?php endforeach; ?>
<?php endforeach; ?>
</select>
<label style="margin-left:10px;">Konkretes Datum</label>
@@ -1287,5 +1309,3 @@ try {
</div>
<?php include __DIR__ . "/templates/footer.inc.php"; ?>
+6 -1
View File
@@ -289,6 +289,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($aktion === 'add_zeitraum') {
$bezeichnung = trim((string)($_POST['bezeichnung'] ?? ''));
if (function_exists('mb_substr')) {
$bezeichnung = mb_substr($bezeichnung, 0, 50, 'UTF-8');
} else {
$bezeichnung = substr($bezeichnung, 0, 50);
}
$wochentag = (int)($_POST['wochentag'] ?? 0);
$start = trim((string)($_POST['start'] ?? ''));
$ende = trim((string)($_POST['ende'] ?? ''));
@@ -608,7 +613,7 @@ $rules = $stRules->fetchAll(PDO::FETCH_ASSOC);
<form method="post" class="form-inline" style="margin-bottom:12px;">
<input type="hidden" name="aktion" value="add_zeitraum">
<label>Bezeichnung</label>
<input class="form-control" type="text" name="bezeichnung" placeholder="z. B. Mittwoch Vormittag">
<input class="form-control" type="text" name="bezeichnung" maxlength="50" placeholder="z. B. Mittwoch Vormittag">
<label style="margin-left:10px;">Wochentag</label>
<select class="form-control" name="wochentag" required>
<option value="1">Montag</option>
+21 -6
View File
@@ -87,6 +87,26 @@ if (!function_exists('impfWeekdayName')) {
}
}
if (!function_exists('impfLimitLabelLength')) {
function impfLimitLabelLength(string $text, int $maxLength = 50): string
{
$text = trim($text);
if ($text === '') {
return $text;
}
if (function_exists('mb_strimwidth')) {
return rtrim(mb_strimwidth($text, 0, $maxLength, '...', 'UTF-8'));
}
if (strlen($text) <= $maxLength) {
return $text;
}
return rtrim(substr($text, 0, max(0, $maxLength - 3))) . '...';
}
}
if (!function_exists('impfWorkflowEnsureTables')) {
function impfWorkflowEnsureTables(PDO $pdo): void
{
@@ -336,12 +356,7 @@ if (!function_exists('impfZeitraumLabel')) {
$zeitText .= ' (' . $ortText . ')';
}
$bezeichnung = trim((string)($zeitraum['bezeichnung'] ?? ''));
if ($includeName && $bezeichnung !== '') {
return $bezeichnung . ': ' . $zeitText;
}
return $zeitText;
return impfLimitLabelLength($zeitText, 50);
}
}