impfwarteliste angepasst

This commit is contained in:
2026-03-23 17:14:09 +01:00
parent 70a78c9586
commit 4b4c1f74df
10 changed files with 1128 additions and 177 deletions
+39 -10
View File
@@ -3,6 +3,7 @@
require_once(__DIR__ . "/../inc/config.inc.php");
require_once(__DIR__ . "/../inc/functions.inc.php");
require_once(__DIR__ . "/../inc/functions.impfen.inc.php");
require_once(__DIR__ . "/../inc/impfworkflow_notifications.inc.php");
ini_set('display_errors', '1');
error_reporting(E_ALL);
@@ -66,7 +67,7 @@ $zeitOptionenJson = json_encode($zeitOptionenByImpfstoff, JSON_UNESCAPED_UNICODE
$form = [
'impfstoff_id' => (int)($_POST['impfstoff_id'] ?? 0),
'zeitraum_id' => (int)($_POST['zeitraum_id'] ?? 0),
'zeitraum_ids' => impfNormalizeZeitraumIds($_POST['zeitraum_ids'] ?? ($_POST['zeitraum_id'] ?? [])),
'impfart' => (int)($_POST['impfart'] ?? 0),
'letzteimpfung' => trim((string)($_POST['letzteimpfung'] ?? '')),
];
@@ -82,6 +83,10 @@ $stActive = $pdo->prepare("SELECT w.warteid, w.checked, w.impfart, w.letzteimpfu
ORDER BY w.date_created DESC, w.warteid DESC");
$stActive->execute(['pid' => $personId]);
$activeWaitRows = $stActive->fetchAll(PDO::FETCH_ASSOC);
foreach ($activeWaitRows as &$activeWaitRow) {
$activeWaitRow['zeitfenster_labels'] = impfGetWartelistenZeitraeumeLabels($pdo, (int)$activeWaitRow['warteid'], false);
}
unset($activeWaitRow);
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST' && (string)($_POST['aktion'] ?? '') === 'create_waitlist') {
try {
@@ -89,7 +94,7 @@ if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST' && (string)($_POST['aktion'
$pdo,
$personId,
(int)$form['impfstoff_id'],
(int)$form['zeitraum_id'],
$form['zeitraum_ids'],
(int)$form['impfart'],
$form['letzteimpfung'] !== '' ? $form['letzteimpfung'] : null,
1
@@ -106,6 +111,13 @@ if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST' && (string)($_POST['aktion'
$stActive->execute(['pid' => $personId]);
$activeWaitRows = $stActive->fetchAll(PDO::FETCH_ASSOC);
foreach ($activeWaitRows as &$activeWaitRow) {
$activeWaitRow['zeitfenster_labels'] = impfGetWartelistenZeitraeumeLabels($pdo, (int)$activeWaitRow['warteid'], false);
}
unset($activeWaitRow);
if (isset($pdo) && $pdo instanceof PDO) {
impfWorkflowNotificationProcess($pdo);
}
} else {
$errorMessage = (string)$message;
}
@@ -141,12 +153,17 @@ if (!empty($activeWaitRows)) {
echo "Sie koennen im internen Bereich mehrere verschiedene Wartelistenanfragen anlegen. Exakte Duplikate werden weiterhin geblockt.";
echo "</div>";
echo "<table class='table table-bordered table-striped'>";
echo "<thead><tr><th>Impfstoff</th><th>Zeitraum</th><th>Impfungsart</th><th>Status</th><th>Letzte Impfung</th></tr></thead><tbody>";
echo "<thead><tr><th>Impfstoff</th><th>Zeitraeume</th><th>Impfungsart</th><th>Status</th><th>Letzte Impfung</th></tr></thead><tbody>";
foreach ($activeWaitRows as $activeWaitRow) {
$statusText = ((int)$activeWaitRow['checked'] === 1) ? 'Bestaetigt' : 'Unbestaetigt';
$zeitfensterText = !empty($activeWaitRow['zeitfenster_labels'])
? implode('<br>', array_map(static function (string $label): string {
return e($label);
}, $activeWaitRow['zeitfenster_labels']))
: e((string)($activeWaitRow['impfenzeitraum'] ?? ''));
echo "<tr>";
echo "<td>" . e((string)($activeWaitRow['impfname'] ?? 'Unbekannt')) . "</td>";
echo "<td>" . e((string)($activeWaitRow['impfenzeitraum'] ?? '')) . "</td>";
echo "<td>" . $zeitfensterText . "</td>";
echo "<td>" . e((string)($impfartLabels[(int)$activeWaitRow['impfart']] ?? ('Status ' . (int)$activeWaitRow['impfart']))) . "</td>";
echo "<td>" . e($statusText) . "</td>";
echo "<td>" . e((string)($activeWaitRow['letzteimpfung'] ?? '')) . "</td>";
@@ -178,8 +195,8 @@ if (empty($verfuegbareImpfstoffe)) {
<div class="row" style="margin-top:12px;">
<div class="col-sm-10">
<label for="zeitraum_id">Welcher Zeitbereich passt fuer Sie?</label>
<select class="form-control" name="zeitraum_id" id="zeitraum_id" required disabled>
<label for="zeitraum_ids">Welche Zeitbereiche passen fuer Sie?</label>
<select class="form-control" name="zeitraum_ids[]" id="zeitraum_ids" required multiple size="6" disabled onchange="checkLetzteImpfung()">
<option value="">- Bitte zuerst Impfstoff auswaehlen -</option>
</select>
</div>
@@ -215,11 +232,11 @@ if (empty($verfuegbareImpfstoffe)) {
<script>
const zeitfensterByImpfstoff = <?php echo $zeitOptionenJson ?: '{}'; ?>;
const initialZeitraumId = <?php echo (int)$form['zeitraum_id']; ?>;
const initialZeitraumIds = <?php echo json_encode($form['zeitraum_ids'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
function updateZeitfenster() {
const impfstoff = document.getElementById('impfstoff_id');
const zeitraum = document.getElementById('zeitraum_id');
const zeitraum = document.getElementById('zeitraum_ids');
const submit = document.getElementById('submit_waitlist');
const impfstoffId = impfstoff.value;
const optionen = zeitfensterByImpfstoff[impfstoffId] || [];
@@ -228,7 +245,7 @@ if (empty($verfuegbareImpfstoffe)) {
if (!impfstoffId || optionen.length === 0) {
const opt = document.createElement('option');
opt.value = '';
opt.textContent = '- Kein Zeitfenster verfuegbar -';
opt.textContent = '- Keine Zeitfenster verfuegbar -';
zeitraum.appendChild(opt);
zeitraum.disabled = true;
submit.disabled = true;
@@ -244,7 +261,7 @@ if (empty($verfuegbareImpfstoffe)) {
const opt = document.createElement('option');
opt.value = String(eintrag.id || '');
opt.textContent = eintrag.label || '';
if (initialZeitraumId > 0 && Number(eintrag.id) === initialZeitraumId) {
if (initialZeitraumIds.includes(Number(eintrag.id))) {
opt.selected = true;
}
zeitraum.appendChild(opt);
@@ -252,12 +269,24 @@ if (empty($verfuegbareImpfstoffe)) {
zeitraum.disabled = false;
submit.disabled = false;
checkLetzteImpfung();
}
function checkLetzteImpfung() {
const impfart = document.getElementById('impfart');
const box = document.getElementById('letzteimpfung_box');
const input = document.getElementById('letzteimpfung');
const zeitraum = document.getElementById('zeitraum_ids');
const submit = document.getElementById('submit_waitlist');
const selectedCount = zeitraum && zeitraum.selectedOptions
? Array.from(zeitraum.selectedOptions).filter((opt) => opt.value !== '').length
: 0;
if (selectedCount === 0) {
submit.disabled = true;
} else if (zeitraum && !zeitraum.disabled) {
submit.disabled = false;
}
if (impfart.value === '' || impfart.value === '1') {
box.style.display = 'none';