impfwarteliste angepasst
This commit is contained in:
+145
-69
@@ -4,6 +4,7 @@ session_start();
|
|||||||
require_once __DIR__ . "/../inc/config.inc.php";
|
require_once __DIR__ . "/../inc/config.inc.php";
|
||||||
require_once __DIR__ . "/../inc/functions.inc.php";
|
require_once __DIR__ . "/../inc/functions.inc.php";
|
||||||
require_once __DIR__ . "/../inc/functions.impfen.inc.php";
|
require_once __DIR__ . "/../inc/functions.impfen.inc.php";
|
||||||
|
require_once __DIR__ . "/../inc/impfworkflow_notifications.inc.php";
|
||||||
|
|
||||||
$user = check_admin_user();
|
$user = check_admin_user();
|
||||||
include __DIR__ . "/templates/header.inc.php";
|
include __DIR__ . "/templates/header.inc.php";
|
||||||
@@ -78,11 +79,60 @@ function ensureWorkflowTables(PDO $pdo): void
|
|||||||
impfWorkflowEnsureTables($pdo);
|
impfWorkflowEnsureTables($pdo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function workflowDeleteWaitlistEntry(PDO $pdo, int $warteid): void
|
||||||
|
{
|
||||||
|
if ($warteid <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stDeleteMap = $pdo->prepare("DELETE FROM warteliste_zeitraum WHERE warteid = :wid");
|
||||||
|
$stDeleteMap->execute(['wid' => $warteid]);
|
||||||
|
|
||||||
|
$stDelete = $pdo->prepare("DELETE FROM warteliste WHERE warteid = :wid");
|
||||||
|
$stDelete->execute(['wid' => $warteid]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function workflowCountWaitersForPlan(PDO $pdo, int $impfstoffId, int $planId): int
|
||||||
|
{
|
||||||
|
return impfWorkflowNotificationCountWaitersForPlan($pdo, $impfstoffId, $planId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function workflowLoadWaitRowsForPlan(PDO $pdo, int $impfstoffId, int $planId): array
|
||||||
|
{
|
||||||
|
$stW = $pdo->prepare("SELECT w.warteid, w.userid, w.hash, w.impfart, w.Impfaufklaerung, w.WeitereFragen, w.letzteimpfung, w.date_created
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ORDER BY w.date_created ASC, w.warteid ASC");
|
||||||
|
$stW->execute([
|
||||||
|
'iid' => $impfstoffId,
|
||||||
|
'zid' => $planId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $stW->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
function workflowAddWartelisteEntry(
|
function workflowAddWartelisteEntry(
|
||||||
PDO $pdo,
|
PDO $pdo,
|
||||||
int $personId,
|
int $personId,
|
||||||
int $impfstoffId,
|
int $impfstoffId,
|
||||||
int $planId,
|
$planIds,
|
||||||
int $impfart,
|
int $impfart,
|
||||||
?string $letzteImpfung,
|
?string $letzteImpfung,
|
||||||
int $checked
|
int $checked
|
||||||
@@ -92,7 +142,7 @@ function workflowAddWartelisteEntry(
|
|||||||
}
|
}
|
||||||
|
|
||||||
$impfstoffId = max(0, $impfstoffId);
|
$impfstoffId = max(0, $impfstoffId);
|
||||||
$planId = max(0, $planId);
|
$planIds = impfNormalizeZeitraumIds($planIds);
|
||||||
$impfart = ($impfart >= 1 && $impfart <= 4) ? $impfart : 1;
|
$impfart = ($impfart >= 1 && $impfart <= 4) ? $impfart : 1;
|
||||||
if ($impfart > 1 && !$letzteImpfung) {
|
if ($impfart > 1 && !$letzteImpfung) {
|
||||||
$impfart = 1;
|
$impfart = 1;
|
||||||
@@ -112,10 +162,12 @@ function workflowAddWartelisteEntry(
|
|||||||
$impfstoffName = 'ohne Vorgabe';
|
$impfstoffName = 'ohne Vorgabe';
|
||||||
$zeitraum = 'Flexibel';
|
$zeitraum = 'Flexibel';
|
||||||
|
|
||||||
if ($planId > 0) {
|
if (!empty($planIds)) {
|
||||||
|
$zeitraumLabels = [];
|
||||||
|
foreach ($planIds as $planId) {
|
||||||
$plan = impfLoadZeitraumById($pdo, $planId, true);
|
$plan = impfLoadZeitraumById($pdo, $planId, true);
|
||||||
if (!$plan) {
|
if (!$plan) {
|
||||||
return [false, "Das ausgewaehlte Zeitfenster ist nicht mehr verfuegbar."];
|
return [false, "Mindestens ein ausgewaehltes Zeitfenster ist nicht mehr verfuegbar."];
|
||||||
}
|
}
|
||||||
|
|
||||||
$zugeordneteImpfstoffe = $plan['impfstoff_id_list'] ?? [];
|
$zugeordneteImpfstoffe = $plan['impfstoff_id_list'] ?? [];
|
||||||
@@ -125,25 +177,24 @@ function workflowAddWartelisteEntry(
|
|||||||
|
|
||||||
if ($impfstoffId <= 0) {
|
if ($impfstoffId <= 0) {
|
||||||
if (count($zugeordneteImpfstoffe) !== 1) {
|
if (count($zugeordneteImpfstoffe) !== 1) {
|
||||||
return [false, "Bitte einen Impfstoff auswaehlen, der dem Zeitfenster zugeordnet ist."];
|
return [false, "Bitte einen Impfstoff auswaehlen, der allen Zeitfenstern eindeutig zugeordnet ist."];
|
||||||
}
|
}
|
||||||
$impfstoffId = (int)$zugeordneteImpfstoffe[0];
|
$currentImpfstoffId = (int)$zugeordneteImpfstoffe[0];
|
||||||
|
if ($impfstoffValue > 0 && $impfstoffValue !== $currentImpfstoffId) {
|
||||||
|
return [false, "Die ausgewaehlten Zeitfenster gehoeren zu unterschiedlichen Impfstoffen."];
|
||||||
|
}
|
||||||
|
$impfstoffValue = $currentImpfstoffId;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stImpfstoff = $pdo->prepare("SELECT impfid, impfname
|
$zeitraumLabels[] = workflowPlanLabel($plan);
|
||||||
FROM impfstoff
|
|
||||||
WHERE impfid = :iid
|
|
||||||
LIMIT 1");
|
|
||||||
$stImpfstoff->execute(['iid' => $impfstoffId]);
|
|
||||||
$impfstoff = $stImpfstoff->fetch(PDO::FETCH_ASSOC);
|
|
||||||
if (!$impfstoff) {
|
|
||||||
return [false, "Der ausgewaehlte Impfstoff wurde nicht gefunden."];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$impfstoffValue = $impfstoffId;
|
if ($impfstoffId <= 0) {
|
||||||
$impfstoffName = (string)$impfstoff['impfname'];
|
$impfstoffId = $impfstoffValue;
|
||||||
$zeitraum = workflowPlanLabel($plan);
|
}
|
||||||
} elseif ($impfstoffId > 0) {
|
}
|
||||||
|
|
||||||
|
if ($impfstoffId > 0) {
|
||||||
$stImpfstoff = $pdo->prepare("SELECT impfid, impfname
|
$stImpfstoff = $pdo->prepare("SELECT impfid, impfname
|
||||||
FROM impfstoff
|
FROM impfstoff
|
||||||
WHERE impfid = :iid
|
WHERE impfid = :iid
|
||||||
@@ -158,6 +209,10 @@ function workflowAddWartelisteEntry(
|
|||||||
$impfstoffValue = 0;
|
$impfstoffValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($planIds)) {
|
||||||
|
$zeitraum = implode(' | ', $zeitraumLabels);
|
||||||
|
}
|
||||||
|
|
||||||
$stDup = $pdo->prepare("SELECT warteid
|
$stDup = $pdo->prepare("SELECT warteid
|
||||||
FROM warteliste
|
FROM warteliste
|
||||||
WHERE userid = :uid
|
WHERE userid = :uid
|
||||||
@@ -172,7 +227,7 @@ function workflowAddWartelisteEntry(
|
|||||||
$hash = md5('admin-warte-' . $personId . '-' . microtime(true) . '-' . random_int(1000, 9999));
|
$hash = md5('admin-warte-' . $personId . '-' . microtime(true) . '-' . random_int(1000, 9999));
|
||||||
$checkedValue = ($checked === 0) ? 0 : 1;
|
$checkedValue = ($checked === 0) ? 0 : 1;
|
||||||
$letzteValue = ($impfart === 1) ? null : ($letzteImpfung ?: null);
|
$letzteValue = ($impfart === 1) ? null : ($letzteImpfung ?: null);
|
||||||
$zeitraumIdValue = ($planId > 0) ? $planId : null;
|
$zeitraumIdValue = !empty($planIds) ? (int)$planIds[0] : null;
|
||||||
|
|
||||||
$stInsert = $pdo->prepare("INSERT INTO warteliste
|
$stInsert = $pdo->prepare("INSERT INTO warteliste
|
||||||
(userid, checked, hash, impfenangebot, impfstoff, Patientenart, Impfaufklaerung, WeitereFragen, impfart, impfenmit, letzteimpfung, impfenzeitraum, zeitraum_id, date_created)
|
(userid, checked, hash, impfenangebot, impfstoff, Patientenart, Impfaufklaerung, WeitereFragen, impfart, impfenmit, letzteimpfung, impfenzeitraum, zeitraum_id, date_created)
|
||||||
@@ -190,6 +245,11 @@ function workflowAddWartelisteEntry(
|
|||||||
'zeitraum_id' => $zeitraumIdValue,
|
'zeitraum_id' => $zeitraumIdValue,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$warteid = (int)$pdo->lastInsertId();
|
||||||
|
if (!empty($planIds)) {
|
||||||
|
impfSetWartelistenZeitraeume($pdo, $warteid, $planIds);
|
||||||
|
}
|
||||||
|
|
||||||
$personName = trim((string)$person['vorname'] . ' ' . (string)$person['nachname']);
|
$personName = trim((string)$person['vorname'] . ' ' . (string)$person['nachname']);
|
||||||
return [true, "Wartelistenplatz fuer {$personName} ({$impfstoffName}) gespeichert."];
|
return [true, "Wartelistenplatz fuer {$personName} ({$impfstoffName}) gespeichert."];
|
||||||
}
|
}
|
||||||
@@ -235,16 +295,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
} else {
|
} else {
|
||||||
$dosen = (int)$rule['dosen_pro_flasche'];
|
$dosen = (int)$rule['dosen_pro_flasche'];
|
||||||
|
|
||||||
$stCount = $pdo->prepare("SELECT COUNT(DISTINCT userid)
|
$wartende = workflowCountWaitersForPlan($pdo, $impfstoffId, $planId);
|
||||||
FROM warteliste
|
|
||||||
WHERE checked = 1
|
|
||||||
AND (impfstoff = :iid OR impfstoff = 0)
|
|
||||||
AND (zeitraum_id = :zid OR zeitraum_id IS NULL)");
|
|
||||||
$stCount->execute([
|
|
||||||
'iid' => $impfstoffId,
|
|
||||||
'zid' => $planId,
|
|
||||||
]);
|
|
||||||
$wartende = (int)$stCount->fetchColumn();
|
|
||||||
|
|
||||||
if ($wartende < $dosen) {
|
if ($wartende < $dosen) {
|
||||||
$error = "Nicht genug bestätigte Warteteilnehmer: {$wartende} von {$dosen}.";
|
$error = "Nicht genug bestätigte Warteteilnehmer: {$wartende} von {$dosen}.";
|
||||||
@@ -286,16 +337,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
]);
|
]);
|
||||||
$timeid = (int)$pdo->lastInsertId();
|
$timeid = (int)$pdo->lastInsertId();
|
||||||
|
|
||||||
$stW = $pdo->prepare("SELECT warteid, userid, hash, impfart, Impfaufklaerung, WeitereFragen, letzteimpfung
|
$warteRowsRaw = workflowLoadWaitRowsForPlan($pdo, $impfstoffId, $planId);
|
||||||
FROM warteliste
|
|
||||||
WHERE checked = 1
|
|
||||||
AND (impfstoff = :iid OR impfstoff = 0)
|
|
||||||
AND (zeitraum_id = :zid OR zeitraum_id IS NULL)
|
|
||||||
ORDER BY date_created ASC, warteid ASC");
|
|
||||||
$stW->bindValue(':iid', $impfstoffId, PDO::PARAM_INT);
|
|
||||||
$stW->bindValue(':zid', $planId, PDO::PARAM_INT);
|
|
||||||
$stW->execute();
|
|
||||||
$warteRowsRaw = $stW->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$warteRows = [];
|
$warteRows = [];
|
||||||
$seenUserIds = [];
|
$seenUserIds = [];
|
||||||
foreach ($warteRowsRaw as $warteRow) {
|
foreach ($warteRowsRaw as $warteRow) {
|
||||||
@@ -333,6 +375,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
]);
|
]);
|
||||||
$terminIds[] = (int)$pdo->lastInsertId();
|
$terminIds[] = (int)$pdo->lastInsertId();
|
||||||
$stDelW->execute(['wid' => (int)$w['warteid']]);
|
$stDelW->execute(['wid' => (int)$w['warteid']]);
|
||||||
|
$pdo->prepare("DELETE FROM warteliste_zeitraum WHERE warteid = :wid")
|
||||||
|
->execute(['wid' => (int)$w['warteid']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stReduce = $pdo->prepare("UPDATE timeslots SET impfdosen = GREATEST(impfdosen - :cnt, 0) WHERE timeid = :timeid");
|
$stReduce = $pdo->prepare("UPDATE timeslots SET impfdosen = GREATEST(impfdosen - :cnt, 0) WHERE timeid = :timeid");
|
||||||
@@ -363,13 +407,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
} elseif ($aktion === 'add_waitlist_existing') {
|
} elseif ($aktion === 'add_waitlist_existing') {
|
||||||
$personId = (int)($_POST['wl_person_id'] ?? 0);
|
$personId = (int)($_POST['wl_person_id'] ?? 0);
|
||||||
$impfstoffId = (int)($_POST['wl_impfstoff_id'] ?? 0);
|
$impfstoffId = (int)($_POST['wl_impfstoff_id'] ?? 0);
|
||||||
$planId = (int)($_POST['wl_plan_id'] ?? 0);
|
$planIds = impfNormalizeZeitraumIds($_POST['wl_plan_ids'] ?? ($_POST['wl_plan_id'] ?? []));
|
||||||
|
|
||||||
[$ok, $msg] = workflowAddWartelisteEntry(
|
[$ok, $msg] = workflowAddWartelisteEntry(
|
||||||
$pdo,
|
$pdo,
|
||||||
$personId,
|
$personId,
|
||||||
$impfstoffId,
|
$impfstoffId,
|
||||||
$planId,
|
$planIds,
|
||||||
1,
|
1,
|
||||||
null,
|
null,
|
||||||
1
|
1
|
||||||
@@ -391,7 +435,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$patientenart = ((int)($_POST['new_patientenart'] ?? 0) === 1) ? 1 : 0;
|
$patientenart = ((int)($_POST['new_patientenart'] ?? 0) === 1) ? 1 : 0;
|
||||||
|
|
||||||
$impfstoffId = (int)($_POST['new_impfstoff_id'] ?? 0);
|
$impfstoffId = (int)($_POST['new_impfstoff_id'] ?? 0);
|
||||||
$planId = (int)($_POST['new_plan_id'] ?? 0);
|
$planIds = impfNormalizeZeitraumIds($_POST['new_plan_ids'] ?? ($_POST['new_plan_id'] ?? []));
|
||||||
|
|
||||||
if ($vorname === '' || $nachname === '' || $geburtstag === '') {
|
if ($vorname === '' || $nachname === '' || $geburtstag === '') {
|
||||||
$error = "Für neue Patienten sind Vorname, Nachname und Geburtstag erforderlich.";
|
$error = "Für neue Patienten sind Vorname, Nachname und Geburtstag erforderlich.";
|
||||||
@@ -414,7 +458,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$pdo,
|
$pdo,
|
||||||
$personId,
|
$personId,
|
||||||
$impfstoffId,
|
$impfstoffId,
|
||||||
$planId,
|
$planIds,
|
||||||
1,
|
1,
|
||||||
null,
|
null,
|
||||||
1
|
1
|
||||||
@@ -529,9 +573,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
if ($warteid <= 0) {
|
if ($warteid <= 0) {
|
||||||
$error = "Ungültiger Wartelisten-Eintrag.";
|
$error = "Ungültiger Wartelisten-Eintrag.";
|
||||||
} else {
|
} else {
|
||||||
$stDelete = $pdo->prepare("DELETE FROM warteliste WHERE warteid = :wid");
|
$stDelete = $pdo->prepare("SELECT warteid FROM warteliste WHERE warteid = :wid");
|
||||||
$stDelete->execute(['wid' => $warteid]);
|
$stDelete->execute(['wid' => $warteid]);
|
||||||
if ($stDelete->rowCount() > 0) {
|
$exists = (bool)$stDelete->fetch(PDO::FETCH_ASSOC);
|
||||||
|
workflowDeleteWaitlistEntry($pdo, $warteid);
|
||||||
|
if ($exists) {
|
||||||
$message = "Wartelisten-Eintrag wurde gelöscht.";
|
$message = "Wartelisten-Eintrag wurde gelöscht.";
|
||||||
} else {
|
} else {
|
||||||
$error = "Wartelisten-Eintrag nicht gefunden.";
|
$error = "Wartelisten-Eintrag nicht gefunden.";
|
||||||
@@ -548,6 +594,7 @@ $personResults = [];
|
|||||||
$waitRows = [];
|
$waitRows = [];
|
||||||
$upcomingRows = [];
|
$upcomingRows = [];
|
||||||
$eventOverview = [];
|
$eventOverview = [];
|
||||||
|
$planWaitCounts = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stRules = $pdo->prepare("SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname,
|
$stRules = $pdo->prepare("SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname,
|
||||||
@@ -571,11 +618,26 @@ try {
|
|||||||
foreach ($rules as $r) {
|
foreach ($rules as $r) {
|
||||||
$iid = (int)$r['impfstoff_id'];
|
$iid = (int)$r['impfstoff_id'];
|
||||||
$dosen = (int)$r['dosen_pro_flasche'];
|
$dosen = (int)$r['dosen_pro_flasche'];
|
||||||
if ($dosen > 0 && isset($planExistsForImpfstoff[$iid])) {
|
if ($dosen <= 0 || !isset($planExistsForImpfstoff[$iid])) {
|
||||||
$configuredImpfstoffe[] = $r;
|
continue;
|
||||||
if ((int)$r['wartende'] >= $dosen) {
|
|
||||||
$eligible[] = $r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$configuredImpfstoffe[] = $r;
|
||||||
|
$hasEligiblePlan = false;
|
||||||
|
foreach ($plans as $plan) {
|
||||||
|
if (!in_array($iid, $plan['impfstoff_id_list'] ?? [], true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$planId = (int)$plan['zeitraum_id'];
|
||||||
|
$planWaitCounts[$iid][$planId] = workflowCountWaitersForPlan($pdo, $iid, $planId);
|
||||||
|
if ($planWaitCounts[$iid][$planId] >= $dosen) {
|
||||||
|
$hasEligiblePlan = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($hasEligiblePlan) {
|
||||||
|
$eligible[] = $r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,16 +673,19 @@ try {
|
|||||||
$waitRows = $stWait->fetchAll(PDO::FETCH_ASSOC);
|
$waitRows = $stWait->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
foreach ($waitRows as &$waitRow) {
|
foreach ($waitRows as &$waitRow) {
|
||||||
$zeitraumId = (int)($waitRow['zeitraum_id'] ?? 0);
|
$waitRow['zeitraum_labels'] = impfGetWartelistenZeitraeumeLabels($pdo, (int)$waitRow['warteid'], false);
|
||||||
if ($zeitraumId > 0) {
|
if (!empty($waitRow['zeitraum_labels'])) {
|
||||||
$zeitraum = impfLoadZeitraumById($pdo, $zeitraumId, true);
|
$waitRow['impfenzeitraum'] = implode(' | ', $waitRow['zeitraum_labels']);
|
||||||
if ($zeitraum) {
|
|
||||||
$waitRow['impfenzeitraum'] = $zeitraum['label'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($waitRow);
|
unset($waitRow);
|
||||||
|
|
||||||
|
$notificationEvents = impfWorkflowNotificationProcess($pdo);
|
||||||
|
if (!empty($notificationEvents)) {
|
||||||
|
$notificationText = count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet.";
|
||||||
|
$message = ($message === '') ? $notificationText : ($message . ' ' . $notificationText);
|
||||||
|
}
|
||||||
|
|
||||||
$stUpcoming = $pdo->prepare("SELECT ts.timeid, ts.date, ts.start, ts.ende, ts.impfdosen,
|
$stUpcoming = $pdo->prepare("SELECT ts.timeid, ts.date, ts.start, ts.ende, ts.impfdosen,
|
||||||
i.impfname, o.anzeigename, o.adresse,
|
i.impfname, o.anzeigename, o.adresse,
|
||||||
it.terminid, it.checked, it.behandelt, it.impfart,
|
it.terminid, it.checked, it.behandelt, it.impfart,
|
||||||
@@ -728,7 +793,13 @@ try {
|
|||||||
<?php echo esc((string)$w['tele']); ?>
|
<?php echo esc((string)$w['tele']); ?>
|
||||||
</td>
|
</td>
|
||||||
<td><?php echo esc((string)($w['impfname'] ?: 'Unbekannt')); ?></td>
|
<td><?php echo esc((string)($w['impfname'] ?: 'Unbekannt')); ?></td>
|
||||||
<td><?php echo esc((string)$w['impfenzeitraum']); ?></td>
|
<td>
|
||||||
|
<?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 endif; ?>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php echo esc(workflowImpfartName((int)$w['impfart'])); ?>
|
<?php echo esc(workflowImpfartName((int)$w['impfart'])); ?>
|
||||||
<?php if (!empty($w['letzteimpfung'])): ?>
|
<?php if (!empty($w['letzteimpfung'])): ?>
|
||||||
@@ -806,12 +877,12 @@ try {
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<label style="margin-left:10px;">Zeitfenster</label>
|
<label style="margin-left:10px;">Zeitfenster</label>
|
||||||
<select class="form-control" name="wl_plan_id" id="existing_plan">
|
<?php $selectedExistingPlanIds = impfNormalizeZeitraumIds($_POST['wl_plan_ids'] ?? ($_POST['wl_plan_id'] ?? [])); ?>
|
||||||
<option value="0" <?php echo ((int)($_POST['wl_plan_id'] ?? 0) === 0) ? 'selected' : ''; ?>>Ohne Zeitfenster</option>
|
<select class="form-control" name="wl_plan_ids[]" id="existing_plan" multiple size="6">
|
||||||
<?php foreach ($plans as $p): ?>
|
<?php foreach ($plans as $p): ?>
|
||||||
<?php
|
<?php
|
||||||
$planId = (int)$p['zeitraum_id'];
|
$planId = (int)$p['zeitraum_id'];
|
||||||
$selected = ((int)($_POST['wl_plan_id'] ?? 0) === $planId) ? 'selected' : '';
|
$selected = in_array($planId, $selectedExistingPlanIds, true) ? 'selected' : '';
|
||||||
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
|
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
|
||||||
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
|
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
|
||||||
?>
|
?>
|
||||||
@@ -897,12 +968,12 @@ try {
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<label>Zeitfenster</label>
|
<label>Zeitfenster</label>
|
||||||
<select class="form-control" name="new_plan_id" id="new_plan">
|
<?php $selectedNewPlanIds = impfNormalizeZeitraumIds($_POST['new_plan_ids'] ?? ($_POST['new_plan_id'] ?? [])); ?>
|
||||||
<option value="0" <?php echo ((int)($_POST['new_plan_id'] ?? 0) === 0) ? 'selected' : ''; ?>>Ohne Zeitfenster</option>
|
<select class="form-control" name="new_plan_ids[]" id="new_plan" multiple size="6">
|
||||||
<?php foreach ($plans as $p): ?>
|
<?php foreach ($plans as $p): ?>
|
||||||
<?php
|
<?php
|
||||||
$planId = (int)$p['zeitraum_id'];
|
$planId = (int)$p['zeitraum_id'];
|
||||||
$selected = ((int)($_POST['new_plan_id'] ?? 0) === $planId) ? 'selected' : '';
|
$selected = in_array($planId, $selectedNewPlanIds, true) ? 'selected' : '';
|
||||||
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
|
$impfstoffeCsv = implode(',', $p['impfstoff_id_list']);
|
||||||
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
|
$impfstoffeText = empty($p['impfstoff_name_list']) ? 'ohne Impfstoff' : implode(', ', $p['impfstoff_name_list']);
|
||||||
?>
|
?>
|
||||||
@@ -1061,15 +1132,18 @@ try {
|
|||||||
function filterPlans() {
|
function filterPlans() {
|
||||||
var val = impfstoff.value;
|
var val = impfstoff.value;
|
||||||
var needsFilter = (val !== "" && val !== "0");
|
var needsFilter = (val !== "" && val !== "0");
|
||||||
var selectedValid = false;
|
var selectedValues = [];
|
||||||
|
for (var s = 0; s < plan.options.length; s++) {
|
||||||
|
if (plan.options[s].selected && plan.options[s].value !== '') {
|
||||||
|
selectedValues.push(plan.options[s].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var selectedValid = 0;
|
||||||
for (var i = 0; i < plan.options.length; i++) {
|
for (var i = 0; i < plan.options.length; i++) {
|
||||||
var opt = plan.options[i];
|
var opt = plan.options[i];
|
||||||
var optionImpfstoffe = opt.getAttribute('data-impfstoffe');
|
var optionImpfstoffe = opt.getAttribute('data-impfstoffe');
|
||||||
if (!optionImpfstoffe) {
|
if (!optionImpfstoffe) {
|
||||||
opt.hidden = false;
|
opt.hidden = false;
|
||||||
if (opt.value === plan.value) {
|
|
||||||
selectedValid = true;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var ids = optionImpfstoffe.split(',');
|
var ids = optionImpfstoffe.split(',');
|
||||||
@@ -1083,11 +1157,13 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
opt.hidden = !visible;
|
opt.hidden = !visible;
|
||||||
if (visible && opt.value === plan.value) {
|
if (!visible) {
|
||||||
selectedValid = true;
|
opt.selected = false;
|
||||||
|
} else if (selectedValues.indexOf(opt.value) !== -1) {
|
||||||
|
selectedValid++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!selectedValid) {
|
if (selectedValues.length > 0 && selectedValid === 0) {
|
||||||
plan.value = '';
|
plan.value = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-17
@@ -1,17 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// WICHTIG: Pfade aus /admin heraus korrekt auflösen
|
// WICHTIG: Pfade aus /admin heraus korrekt auflösen
|
||||||
require_once __DIR__ . "/../inc/config.inc.php";
|
require_once __DIR__ . "/../inc/config.inc.php";
|
||||||
require_once __DIR__ . "/../inc/functions.inc.php";
|
require_once __DIR__ . "/../inc/functions.inc.php";
|
||||||
|
require_once __DIR__ . "/../inc/impfworkflow_notifications.inc.php";
|
||||||
|
|
||||||
// Login prüfen
|
// Login prüfen
|
||||||
$user = check_admin_user();
|
$user = check_admin_user();
|
||||||
|
|
||||||
include __DIR__ . "/templates/header.inc.php";
|
include __DIR__ . "/templates/header.inc.php";
|
||||||
|
|
||||||
$user = check_admin_user();
|
$user = check_admin_user();
|
||||||
$internUserId = (int)$_SESSION['auth']['id'];
|
$internUserId = (int)$_SESSION['auth']['id'];
|
||||||
|
$activeTab = 'data';
|
||||||
|
|
||||||
if (!$user) { echo "<div class='container main-container'><h3>Erst anmelden: <a href=login.php>Login</a></h3><br>";
|
if (!$user) { echo "<div class='container main-container'><h3>Erst anmelden: <a href=login.php>Login</a></h3><br>";
|
||||||
|
|
||||||
@@ -22,11 +24,12 @@ if(isset($_GET['save'])) {
|
|||||||
$save = $_GET['save'];
|
$save = $_GET['save'];
|
||||||
|
|
||||||
if($save == 'personal_data') {
|
if($save == 'personal_data') {
|
||||||
|
$activeTab = 'data';
|
||||||
$vorname = trim($_POST['vorname']);
|
$vorname = trim($_POST['vorname']);
|
||||||
$nachname = trim($_POST['nachname']);
|
$nachname = trim($_POST['nachname']);
|
||||||
|
|
||||||
if($vorname == "" || $nachname == "") {
|
if($vorname == "" || $nachname == "") {
|
||||||
$error_msg = "Bitte Vor- und Nachname ausfüllen.";
|
$error_msg = "Bitte Vor- und Nachname ausfüllen.";
|
||||||
} else {
|
} else {
|
||||||
$statement = $pdo->prepare("UPDATE users SET vorname = :vorname, nachname = :nachname, updated_at=NOW() WHERE id = :userid");
|
$statement = $pdo->prepare("UPDATE users SET vorname = :vorname, nachname = :nachname, updated_at=NOW() WHERE id = :userid");
|
||||||
$result = $statement->execute(array('vorname' => $vorname, 'nachname'=> $nachname, 'userid' => $user['id'] ));
|
$result = $statement->execute(array('vorname' => $vorname, 'nachname'=> $nachname, 'userid' => $user['id'] ));
|
||||||
@@ -34,14 +37,15 @@ if(isset($_GET['save'])) {
|
|||||||
$success_msg = "Daten erfolgreich gespeichert.";
|
$success_msg = "Daten erfolgreich gespeichert.";
|
||||||
}
|
}
|
||||||
} else if($save == 'email') {
|
} else if($save == 'email') {
|
||||||
|
$activeTab = 'email';
|
||||||
$passwort = $_POST['passwort'];
|
$passwort = $_POST['passwort'];
|
||||||
$email = trim($_POST['email']);
|
$email = trim($_POST['email']);
|
||||||
$email2 = trim($_POST['email2']);
|
$email2 = trim($_POST['email2']);
|
||||||
|
|
||||||
if($email != $email2) {
|
if($email != $email2) {
|
||||||
$error_msg = "Die eingegebenen E-Mail-Adressen stimmten nicht überein.";
|
$error_msg = "Die eingegebenen E-Mail-Adressen stimmten nicht überein.";
|
||||||
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
$error_msg = "Bitte eine gültige E-Mail-Adresse eingeben.";
|
$error_msg = "Bitte eine gültige E-Mail-Adresse eingeben.";
|
||||||
} else if(!password_verify($passwort, $user['passwort'])) {
|
} else if(!password_verify($passwort, $user['passwort'])) {
|
||||||
$error_msg = "Bitte korrektes Passwort eingeben.";
|
$error_msg = "Bitte korrektes Passwort eingeben.";
|
||||||
} else {
|
} else {
|
||||||
@@ -51,13 +55,31 @@ if(isset($_GET['save'])) {
|
|||||||
$success_msg = "E-Mail-Adresse erfolgreich gespeichert.";
|
$success_msg = "E-Mail-Adresse erfolgreich gespeichert.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if($save == 'impfworkflow_notification') {
|
||||||
|
$activeTab = 'impfworkflow';
|
||||||
|
$benachrichtigungEmail = trim((string)($_POST['benachrichtigung_email'] ?? ''));
|
||||||
|
|
||||||
|
if ($benachrichtigungEmail !== '' && !filter_var($benachrichtigungEmail, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$error_msg = "Bitte eine gueltige E-Mail-Adresse fuer die Impfworkflow-Benachrichtigung eingeben.";
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
impfWorkflowNotificationSetEmail($pdo, $benachrichtigungEmail);
|
||||||
|
$success_msg = ($benachrichtigungEmail !== '')
|
||||||
|
? "Impfworkflow-Benachrichtigungsadresse gespeichert."
|
||||||
|
: "Impfworkflow-Benachrichtigungsadresse geloescht.";
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$error_msg = "Die Impfworkflow-Benachrichtigungsadresse konnte nicht gespeichert werden: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else if($save == 'passwort') {
|
} else if($save == 'passwort') {
|
||||||
|
$activeTab = 'passwort';
|
||||||
$passwortAlt = $_POST['passwortAlt'];
|
$passwortAlt = $_POST['passwortAlt'];
|
||||||
$passwortNeu = trim($_POST['passwortNeu']);
|
$passwortNeu = trim($_POST['passwortNeu']);
|
||||||
$passwortNeu2 = trim($_POST['passwortNeu2']);
|
$passwortNeu2 = trim($_POST['passwortNeu2']);
|
||||||
|
|
||||||
if($passwortNeu != $passwortNeu2) {
|
if($passwortNeu != $passwortNeu2) {
|
||||||
$error_msg = "Die eingegebenen Passwörter stimmten nicht überein.";
|
$error_msg = "Die eingegebenen Passwörter stimmten nicht überein.";
|
||||||
} else if($passwortNeu == "") {
|
} else if($passwortNeu == "") {
|
||||||
$error_msg = "Das Passwort darf nicht leer sein.";
|
$error_msg = "Das Passwort darf nicht leer sein.";
|
||||||
} else if(!password_verify($passwortAlt, $user['passwort'])) {
|
} else if(!password_verify($passwortAlt, $user['passwort'])) {
|
||||||
@@ -107,14 +129,15 @@ endif;
|
|||||||
|
|
||||||
<!-- Nav tabs -->
|
<!-- Nav tabs -->
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
<ul class="nav nav-tabs" role="tablist">
|
||||||
<li role="presentation" class="active"><a href="#data" aria-controls="home" role="tab" data-toggle="tab">Persönliche Daten</a></li>
|
<li role="presentation" class="<?php echo ($activeTab === 'data') ? 'active' : ''; ?>"><a href="#data" aria-controls="home" role="tab" data-toggle="tab">Persönliche Daten</a></li>
|
||||||
<li role="presentation"><a href="#email" aria-controls="profile" role="tab" data-toggle="tab">E-Mail</a></li>
|
<li role="presentation" class="<?php echo ($activeTab === 'email') ? 'active' : ''; ?>"><a href="#email" aria-controls="profile" role="tab" data-toggle="tab">E-Mail</a></li>
|
||||||
<li role="presentation"><a href="#passwort" aria-controls="messages" role="tab" data-toggle="tab">Passwort</a></li>
|
<li role="presentation" class="<?php echo ($activeTab === 'impfworkflow') ? 'active' : ''; ?>"><a href="#impfworkflow" aria-controls="impfworkflow" role="tab" data-toggle="tab">Impfworkflow</a></li>
|
||||||
|
<li role="presentation" class="<?php echo ($activeTab === 'passwort') ? 'active' : ''; ?>"><a href="#passwort" aria-controls="messages" role="tab" data-toggle="tab">Passwort</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- Persönliche Daten-->
|
<!-- Persönliche Daten-->
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div role="tabpanel" class="tab-pane active" id="data">
|
<div role="tabpanel" class="tab-pane <?php echo ($activeTab === 'data') ? 'active' : ''; ?>" id="data">
|
||||||
<br>
|
<br>
|
||||||
<form action="?save=personal_data" method="post" class="form-horizontal">
|
<form action="?save=personal_data" method="post" class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -139,10 +162,10 @@ endif;
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Änderung der E-Mail-Adresse -->
|
<!-- Änderung der E-Mail-Adresse -->
|
||||||
<div role="tabpanel" class="tab-pane" id="email">
|
<div role="tabpanel" class="tab-pane <?php echo ($activeTab === 'email') ? 'active' : ''; ?>" id="email">
|
||||||
<br>
|
<br>
|
||||||
<p>Zum Änderen deiner E-Mail-Adresse gib bitte dein aktuelles Passwort sowie die neue E-Mail-Adresse ein.</p>
|
<p>Zum Änderen deiner E-Mail-Adresse gib bitte dein aktuelles Passwort sowie die neue E-Mail-Adresse ein.</p>
|
||||||
<form action="?save=email" method="post" class="form-horizontal">
|
<form action="?save=email" method="post" class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputPasswort" class="col-sm-2 control-label">Passwort</label>
|
<label for="inputPasswort" class="col-sm-2 control-label">Passwort</label>
|
||||||
@@ -174,10 +197,31 @@ endif;
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Änderung des Passworts -->
|
<div role="tabpanel" class="tab-pane <?php echo ($activeTab === 'impfworkflow') ? 'active' : ''; ?>" id="impfworkflow">
|
||||||
<div role="tabpanel" class="tab-pane" id="passwort">
|
|
||||||
<br>
|
<br>
|
||||||
<p>Zum Änderen deines Passworts gib bitte dein aktuelles Passwort sowie das neue Passwort ein.</p>
|
<p>Hier hinterlegst du die E-Mail-Adresse, an die spaeter Impfworkflow-Benachrichtigungen gesendet werden sollen.</p>
|
||||||
|
<?php $currentNotificationEmail = impfWorkflowNotificationGetEmail($pdo); ?>
|
||||||
|
<form action="?save=impfworkflow_notification" method="post" class="form-horizontal">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="inputImpfworkflowMail" class="col-sm-2 control-label">Benachrichtigungs-E-Mail</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input class="form-control" id="inputImpfworkflowMail" name="benachrichtigung_email" type="email" value="<?php echo htmlentities($currentNotificationEmail); ?>" placeholder="benachrichtigung@praxis.de">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<p class="help-block">Leer lassen, um Benachrichtigungen zu deaktivieren.</p>
|
||||||
|
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Änderung des Passworts -->
|
||||||
|
<div role="tabpanel" class="tab-pane <?php echo ($activeTab === 'passwort') ? 'active' : ''; ?>" id="passwort">
|
||||||
|
<br>
|
||||||
|
<p>Zum Änderen deines Passworts gib bitte dein aktuelles Passwort sowie das neue Passwort ein.</p>
|
||||||
<form action="?save=passwort" method="post" class="form-horizontal">
|
<form action="?save=passwort" method="post" class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputPasswort" class="col-sm-2 control-label">Altes Passwort</label>
|
<label for="inputPasswort" class="col-sm-2 control-label">Altes Passwort</label>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ FROM (
|
|||||||
UNION ALL SELECT 'impfstoff_wochenplan'
|
UNION ALL SELECT 'impfstoff_wochenplan'
|
||||||
UNION ALL SELECT 'impf_zeitraum'
|
UNION ALL SELECT 'impf_zeitraum'
|
||||||
UNION ALL SELECT 'impf_zeitraum_impfstoff'
|
UNION ALL SELECT 'impf_zeitraum_impfstoff'
|
||||||
|
UNION ALL SELECT 'warteliste_zeitraum'
|
||||||
UNION ALL SELECT 'warteliste'
|
UNION ALL SELECT 'warteliste'
|
||||||
) t
|
) t
|
||||||
LEFT JOIN information_schema.tables it
|
LEFT JOIN information_schema.tables it
|
||||||
@@ -51,6 +52,9 @@ FROM (
|
|||||||
UNION ALL SELECT 'impf_zeitraum', 'impfortid'
|
UNION ALL SELECT 'impf_zeitraum', 'impfortid'
|
||||||
UNION ALL SELECT 'impf_zeitraum_impfstoff', 'zeitraum_id'
|
UNION ALL SELECT 'impf_zeitraum_impfstoff', 'zeitraum_id'
|
||||||
UNION ALL SELECT 'impf_zeitraum_impfstoff', 'impfstoff_id'
|
UNION ALL SELECT 'impf_zeitraum_impfstoff', 'impfstoff_id'
|
||||||
|
UNION ALL SELECT 'warteliste_zeitraum', 'warteid'
|
||||||
|
UNION ALL SELECT 'warteliste_zeitraum', 'zeitraum_id'
|
||||||
|
UNION ALL SELECT 'warteliste_zeitraum', 'created_at'
|
||||||
UNION ALL SELECT 'warteliste', 'warteid'
|
UNION ALL SELECT 'warteliste', 'warteid'
|
||||||
UNION ALL SELECT 'warteliste', 'userid'
|
UNION ALL SELECT 'warteliste', 'userid'
|
||||||
UNION ALL SELECT 'warteliste', 'impfenzeitraum'
|
UNION ALL SELECT 'warteliste', 'impfenzeitraum'
|
||||||
@@ -71,6 +75,7 @@ SELECT
|
|||||||
END AS status
|
END AS status
|
||||||
FROM (
|
FROM (
|
||||||
SELECT 'warteliste' AS table_name, 'idx_warteliste_zeitraum' AS index_name
|
SELECT 'warteliste' AS table_name, 'idx_warteliste_zeitraum' AS index_name
|
||||||
|
UNION ALL SELECT 'warteliste_zeitraum', 'idx_warteliste_zeitraum_zeitraum'
|
||||||
UNION ALL SELECT 'impfstoff_wochenplan', 'idx_impfstoff_wochenplan_impfstoff'
|
UNION ALL SELECT 'impfstoff_wochenplan', 'idx_impfstoff_wochenplan_impfstoff'
|
||||||
UNION ALL SELECT 'impfstoff_wochenplan', 'idx_impfstoff_wochenplan_wochentag'
|
UNION ALL SELECT 'impfstoff_wochenplan', 'idx_impfstoff_wochenplan_wochentag'
|
||||||
UNION ALL SELECT 'impf_zeitraum', 'idx_impf_zeitraum_wochentag'
|
UNION ALL SELECT 'impf_zeitraum', 'idx_impf_zeitraum_wochentag'
|
||||||
@@ -102,6 +107,24 @@ SELECT
|
|||||||
ELSE 'TABLE_MISSING'
|
ELSE 'TABLE_MISSING'
|
||||||
END AS status;
|
END AS status;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'meta' AS check_type,
|
||||||
|
'impf_workflow_meta.legacy_warteliste_zeitraeume_migrated' AS object_name,
|
||||||
|
CASE
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'impf_workflow_meta'
|
||||||
|
) THEN COALESCE((
|
||||||
|
SELECT CONCAT('VALUE=', meta_value)
|
||||||
|
FROM impf_workflow_meta
|
||||||
|
WHERE meta_key = 'legacy_warteliste_zeitraeume_migrated'
|
||||||
|
LIMIT 1
|
||||||
|
), 'MISSING')
|
||||||
|
ELSE 'TABLE_MISSING'
|
||||||
|
END AS status;
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'data' AS check_type,
|
'data' AS check_type,
|
||||||
'impfstoff_wochenplan rows' AS object_name,
|
'impfstoff_wochenplan rows' AS object_name,
|
||||||
@@ -154,3 +177,16 @@ SELECT
|
|||||||
) THEN CAST((SELECT COUNT(*) FROM warteliste WHERE zeitraum_id IS NOT NULL) AS CHAR)
|
) THEN CAST((SELECT COUNT(*) FROM warteliste WHERE zeitraum_id IS NOT NULL) AS CHAR)
|
||||||
ELSE 'COLUMN_MISSING'
|
ELSE 'COLUMN_MISSING'
|
||||||
END AS status;
|
END AS status;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'data' AS check_type,
|
||||||
|
'warteliste_zeitraum rows' AS object_name,
|
||||||
|
CASE
|
||||||
|
WHEN EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste_zeitraum'
|
||||||
|
) THEN CAST((SELECT COUNT(*) FROM warteliste_zeitraum) AS CHAR)
|
||||||
|
ELSE 'TABLE_MISSING'
|
||||||
|
END AS status;
|
||||||
|
|||||||
@@ -51,6 +51,14 @@ CREATE TABLE IF NOT EXISTS `impf_zeitraum_impfstoff` (
|
|||||||
INDEX `idx_impf_zeitraum_impfstoff_impfstoff` (`impfstoff_id`)
|
INDEX `idx_impf_zeitraum_impfstoff_impfstoff` (`impfstoff_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `warteliste_zeitraum` (
|
||||||
|
`warteid` INT NOT NULL,
|
||||||
|
`zeitraum_id` INT NOT NULL,
|
||||||
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`warteid`, `zeitraum_id`),
|
||||||
|
INDEX `idx_warteliste_zeitraum_zeitraum` (`zeitraum_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
DROP PROCEDURE IF EXISTS `migrate_praxis_schema_20260320`;
|
DROP PROCEDURE IF EXISTS `migrate_praxis_schema_20260320`;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE `migrate_praxis_schema_20260320`()
|
CREATE PROCEDURE `migrate_praxis_schema_20260320`()
|
||||||
@@ -60,6 +68,8 @@ BEGIN
|
|||||||
DECLARE v_warteliste_exists INT DEFAULT 0;
|
DECLARE v_warteliste_exists INT DEFAULT 0;
|
||||||
DECLARE v_zeitraum_id_exists INT DEFAULT 0;
|
DECLARE v_zeitraum_id_exists INT DEFAULT 0;
|
||||||
DECLARE v_warteliste_index_exists INT DEFAULT 0;
|
DECLARE v_warteliste_index_exists INT DEFAULT 0;
|
||||||
|
DECLARE v_warteliste_zeitraum_exists INT DEFAULT 0;
|
||||||
|
DECLARE v_warteliste_zeitraum_index_exists INT DEFAULT 0;
|
||||||
DECLARE v_legacy_plan_exists INT DEFAULT 0;
|
DECLARE v_legacy_plan_exists INT DEFAULT 0;
|
||||||
|
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
@@ -114,6 +124,35 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_warteliste_zeitraum_exists
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste_zeitraum';
|
||||||
|
|
||||||
|
IF v_warteliste_zeitraum_exists = 0 THEN
|
||||||
|
CREATE TABLE `warteliste_zeitraum` (
|
||||||
|
`warteid` INT NOT NULL,
|
||||||
|
`zeitraum_id` INT NOT NULL,
|
||||||
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`warteid`, `zeitraum_id`),
|
||||||
|
INDEX `idx_warteliste_zeitraum_zeitraum` (`zeitraum_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
SET v_warteliste_zeitraum_exists = 1;
|
||||||
|
ELSE
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_warteliste_zeitraum_index_exists
|
||||||
|
FROM information_schema.statistics
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste_zeitraum'
|
||||||
|
AND index_name = 'idx_warteliste_zeitraum_zeitraum';
|
||||||
|
|
||||||
|
IF v_warteliste_zeitraum_index_exists = 0 THEN
|
||||||
|
ALTER TABLE `warteliste_zeitraum`
|
||||||
|
ADD INDEX `idx_warteliste_zeitraum_zeitraum` (`zeitraum_id`);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
INTO v_legacy_plan_exists
|
INTO v_legacy_plan_exists
|
||||||
FROM information_schema.tables
|
FROM information_schema.tables
|
||||||
@@ -159,6 +198,18 @@ BEGIN
|
|||||||
VALUES ('legacy_wochenplan_migrated', '1') AS `incoming`
|
VALUES ('legacy_wochenplan_migrated', '1') AS `incoming`
|
||||||
ON DUPLICATE KEY UPDATE `meta_value` = `incoming`.`meta_value`;
|
ON DUPLICATE KEY UPDATE `meta_value` = `incoming`.`meta_value`;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF v_warteliste_exists > 0 AND v_warteliste_zeitraum_exists > 0 THEN
|
||||||
|
INSERT IGNORE INTO `warteliste_zeitraum` (`warteid`, `zeitraum_id`)
|
||||||
|
SELECT `warteid`, `zeitraum_id`
|
||||||
|
FROM `warteliste`
|
||||||
|
WHERE `zeitraum_id` IS NOT NULL
|
||||||
|
AND `zeitraum_id` > 0;
|
||||||
|
|
||||||
|
INSERT INTO `impf_workflow_meta` (`meta_key`, `meta_value`)
|
||||||
|
VALUES ('legacy_warteliste_zeitraeume_migrated', '1') AS `incoming`
|
||||||
|
ON DUPLICATE KEY UPDATE `meta_value` = `incoming`.`meta_value`;
|
||||||
|
END IF;
|
||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
-- Migration fuer Mehrfach-Zeitfenster in der Impfwarteliste.
|
||||||
|
-- Idempotent: kann mehrfach ausgefuehrt werden.
|
||||||
|
-- Bestehende Tabellen werden nicht neu aufgebaut, sondern nur erweitert.
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `impf_workflow_meta` (
|
||||||
|
`meta_key` VARCHAR(100) NOT NULL,
|
||||||
|
`meta_value` VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
|
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`meta_key`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
|
DROP PROCEDURE IF EXISTS `migrate_warteliste_multi_zeitfenster_20260322`;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE `migrate_warteliste_multi_zeitfenster_20260322`()
|
||||||
|
BEGIN
|
||||||
|
DECLARE v_warteliste_exists INT DEFAULT 0;
|
||||||
|
DECLARE v_zeitraum_id_exists INT DEFAULT 0;
|
||||||
|
DECLARE v_warteliste_index_exists INT DEFAULT 0;
|
||||||
|
DECLARE v_warteliste_zeitraum_exists INT DEFAULT 0;
|
||||||
|
DECLARE v_warteliste_zeitraum_index_exists INT DEFAULT 0;
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_warteliste_exists
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste';
|
||||||
|
|
||||||
|
IF v_warteliste_exists = 0 THEN
|
||||||
|
SIGNAL SQLSTATE '45000'
|
||||||
|
SET MESSAGE_TEXT = 'Tabelle warteliste wurde nicht gefunden.';
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_zeitraum_id_exists
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste'
|
||||||
|
AND column_name = 'zeitraum_id';
|
||||||
|
|
||||||
|
IF v_zeitraum_id_exists = 0 THEN
|
||||||
|
ALTER TABLE `warteliste`
|
||||||
|
ADD COLUMN `zeitraum_id` INT NULL AFTER `impfenzeitraum`;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_warteliste_index_exists
|
||||||
|
FROM information_schema.statistics
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste'
|
||||||
|
AND index_name = 'idx_warteliste_zeitraum';
|
||||||
|
|
||||||
|
IF v_warteliste_index_exists = 0 THEN
|
||||||
|
ALTER TABLE `warteliste`
|
||||||
|
ADD INDEX `idx_warteliste_zeitraum` (`zeitraum_id`);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_warteliste_zeitraum_exists
|
||||||
|
FROM information_schema.tables
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste_zeitraum';
|
||||||
|
|
||||||
|
IF v_warteliste_zeitraum_exists = 0 THEN
|
||||||
|
CREATE TABLE `warteliste_zeitraum` (
|
||||||
|
`warteid` INT NOT NULL,
|
||||||
|
`zeitraum_id` INT NOT NULL,
|
||||||
|
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (`warteid`, `zeitraum_id`),
|
||||||
|
INDEX `idx_warteliste_zeitraum_zeitraum` (`zeitraum_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
SET v_warteliste_zeitraum_exists = 1;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
INTO v_warteliste_zeitraum_index_exists
|
||||||
|
FROM information_schema.statistics
|
||||||
|
WHERE table_schema = DATABASE()
|
||||||
|
AND table_name = 'warteliste_zeitraum'
|
||||||
|
AND index_name = 'idx_warteliste_zeitraum_zeitraum';
|
||||||
|
|
||||||
|
IF v_warteliste_zeitraum_index_exists = 0 THEN
|
||||||
|
ALTER TABLE `warteliste_zeitraum`
|
||||||
|
ADD INDEX `idx_warteliste_zeitraum_zeitraum` (`zeitraum_id`);
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `warteliste_zeitraum` (`warteid`, `zeitraum_id`)
|
||||||
|
SELECT `warteid`, `zeitraum_id`
|
||||||
|
FROM `warteliste`
|
||||||
|
WHERE `zeitraum_id` IS NOT NULL
|
||||||
|
AND `zeitraum_id` > 0;
|
||||||
|
|
||||||
|
INSERT INTO `impf_workflow_meta` (`meta_key`, `meta_value`)
|
||||||
|
VALUES ('legacy_warteliste_zeitraeume_migrated', '1') AS `incoming`
|
||||||
|
ON DUPLICATE KEY UPDATE `meta_value` = `incoming`.`meta_value`;
|
||||||
|
END $$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
CALL `migrate_warteliste_multi_zeitfenster_20260322`();
|
||||||
|
DROP PROCEDURE IF EXISTS `migrate_warteliste_multi_zeitfenster_20260322`;
|
||||||
+170
-23
@@ -8,6 +8,32 @@
|
|||||||
<head>
|
<head>
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', '1');
|
||||||
|
register_shutdown_function(static function (): void {
|
||||||
|
$error = error_get_last();
|
||||||
|
if ($error === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fatalTypes = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
|
||||||
|
if (!in_array((int)$error['type'], $fatalTypes, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!headers_sent()) {
|
||||||
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<div style="max-width:900px;margin:20px auto;padding:16px;border:3px solid #b30000;background:#fff7f7;color:#111;font-family:Arial,sans-serif;">'
|
||||||
|
. '<h3 style="margin-top:0;">Fehler in impfwarteliste.php</h3>'
|
||||||
|
. '<p>Die Seite ist wegen eines PHP-Fehlers abgebrochen.</p>'
|
||||||
|
. '<p><strong>Meldung:</strong> ' . htmlspecialchars((string)$error['message'], ENT_QUOTES, 'UTF-8') . '<br>'
|
||||||
|
. '<strong>Datei:</strong> ' . htmlspecialchars((string)$error['file'], ENT_QUOTES, 'UTF-8') . '<br>'
|
||||||
|
. '<strong>Zeile:</strong> ' . (int)$error['line'] . '</p>'
|
||||||
|
. '</div>';
|
||||||
|
});
|
||||||
|
|
||||||
include('header.php');
|
include('header.php');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -26,11 +52,17 @@
|
|||||||
include_once("inc/config.inc.php");
|
include_once("inc/config.inc.php");
|
||||||
include_once("inc/functions.inc.php");
|
include_once("inc/functions.inc.php");
|
||||||
include_once('inc/functions.impfen.inc.php');
|
include_once('inc/functions.impfen.inc.php');
|
||||||
|
include_once('inc/impfworkflow_notifications.inc.php');
|
||||||
|
$workflowSetupError = '';
|
||||||
if ($con instanceof mysqli) {
|
if ($con instanceof mysqli) {
|
||||||
mysqli_set_charset($con, "utf8mb4");
|
mysqli_set_charset($con, "utf8mb4");
|
||||||
}
|
}
|
||||||
if (isset($pdo) && $pdo instanceof PDO) {
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
try {
|
||||||
impfWorkflowEnsureTables($pdo);
|
impfWorkflowEnsureTables($pdo);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$workflowSetupError = $e->getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$zeitOptionenJson = "{}";
|
$zeitOptionenJson = "{}";
|
||||||
?>
|
?>
|
||||||
@@ -57,11 +89,20 @@ $mailbetreff = "Ihr Wartelistenplatz für eine Impfung bei Praxis Creutzburg";
|
|||||||
|
|
||||||
<section class="box special">
|
<section class="box special">
|
||||||
<h2>Impfwarteliste</h2>
|
<h2>Impfwarteliste</h2>
|
||||||
|
<?php if ($workflowSetupError !== ''): ?>
|
||||||
|
<div style="border:3px solid red; margin: 10px 0; padding: 10px; text-align:left;">
|
||||||
|
Die Impfworkflow-Tabellen konnten nicht automatisch geprueft werden: <?php echo htmlspecialchars($workflowSetupError, ENT_QUOTES, 'UTF-8'); ?><br>
|
||||||
|
Bitte fuehren Sie zuerst das Migrationsskript aus.
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
if(isset($_POST["id"]) || isset($_GET["id"])){
|
if($workflowSetupError !== ''){
|
||||||
|
// Hinweis wurde bereits oberhalb ausgegeben.
|
||||||
|
|
||||||
|
}else if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||||
|
|
||||||
if(isset($_POST["id"])){
|
if(isset($_POST["id"])){
|
||||||
$id = mysqli_real_escape_string($con, $_POST["id"]);
|
$id = mysqli_real_escape_string($con, $_POST["id"]);
|
||||||
@@ -83,6 +124,17 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
$impfenzeitraum = $zeitraumAktuell['label'];
|
$impfenzeitraum = $zeitraumAktuell['label'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$ausgewaehlteZeitraeume = [];
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
$ausgewaehlteZeitraeume = impfGetWartelistenZeitraeumeLabels($pdo, (int)$warteid, false);
|
||||||
|
}
|
||||||
|
if (!empty($ausgewaehlteZeitraeume)) {
|
||||||
|
$impfenzeitraum = implode('<br>', array_map(static function ($label) {
|
||||||
|
return e((string)$label);
|
||||||
|
}, $ausgewaehlteZeitraeume));
|
||||||
|
} else {
|
||||||
|
$impfenzeitraum = htmlspecialchars((string)$impfenzeitraum, ENT_QUOTES, 'UTF-8');
|
||||||
|
}
|
||||||
//echo $userid;
|
//echo $userid;
|
||||||
$queryuser = mysqli_query($con, "SELECT * FROM persons WHERE person_id='" . $userid . "'");
|
$queryuser = mysqli_query($con, "SELECT * FROM persons WHERE person_id='" . $userid . "'");
|
||||||
$rowuser = $queryuser->fetch_assoc();
|
$rowuser = $queryuser->fetch_assoc();
|
||||||
@@ -133,7 +185,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
echo "<h4>Art: $Patientenart</h4>";
|
echo "<h4>Art: $Patientenart</h4>";
|
||||||
echo "<h4>Telefon: $tel</h4>";
|
echo "<h4>Telefon: $tel</h4>";
|
||||||
echo "<h4>Impfstoff: $impfstofftext</h4>";
|
echo "<h4>Impfstoff: $impfstofftext</h4>";
|
||||||
echo "<h4>Zeitraum: $impfenzeitraum </h4><br>";
|
echo "<h4>Zeitraum:<br>$impfenzeitraum</h4><br>";
|
||||||
|
|
||||||
echo "<form action='". $_SERVER['PHP_SELF'] . "' method=POST>";
|
echo "<form action='". $_SERVER['PHP_SELF'] . "' method=POST>";
|
||||||
echo '<input type="hidden" name="warteid" id="warteid" value="'. $warteid .'" />';
|
echo '<input type="hidden" name="warteid" id="warteid" value="'. $warteid .'" />';
|
||||||
@@ -151,6 +203,13 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
echo "Sie haben die folgenden Angaben:<br><br>";
|
echo "Sie haben die folgenden Angaben:<br><br>";
|
||||||
echo "<h4>Name: $userausgabe</h4>";
|
echo "<h4>Name: $userausgabe</h4>";
|
||||||
echo "<h4>Impfstoff: $impfstofftext</h4><br>";
|
echo "<h4>Impfstoff: $impfstofftext</h4><br>";
|
||||||
|
if (!empty($ausgewaehlteZeitraeume)) {
|
||||||
|
echo "<h4>Ausgewählte Zeitfenster:<br>" . implode('<br>', array_map(static function ($label) {
|
||||||
|
return e((string)$label);
|
||||||
|
}, $ausgewaehlteZeitraeume)) . "</h4>";
|
||||||
|
} else {
|
||||||
|
echo "<h4>Zeitraum: $impfenzeitraum</h4>";
|
||||||
|
}
|
||||||
echo "<h4>Wir informieren Sie, sobald ein konkreter Impftermin für Ihren Impfstoff festgelegt wurde.</h4>";
|
echo "<h4>Wir informieren Sie, sobald ein konkreter Impftermin für Ihren Impfstoff festgelegt wurde.</h4>";
|
||||||
echo "Die Terminvergabe erfolgt durch das Praxisteam, sobald eine komplette Impfflasche mit passenden Wartelistenplätzen gefüllt ist.<br><br>";
|
echo "Die Terminvergabe erfolgt durch das Praxisteam, sobald eine komplette Impfflasche mit passenden Wartelistenplätzen gefüllt ist.<br><br>";
|
||||||
echo "Können Sie Ihren Warteplatz nicht wahrnehmen oder benötigen diesen nicht mehr, dann tragen Sie sich bitte aus:<br>";
|
echo "Können Sie Ihren Warteplatz nicht wahrnehmen oder benötigen diesen nicht mehr, dann tragen Sie sich bitte aus:<br>";
|
||||||
@@ -198,6 +257,24 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
echo "<input type=hidden name='".$key."' value='".$value. "'>\n";
|
echo "<input type=hidden name='".$key."' value='".$value. "'>\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if($key === "impfenzeitraeume" && is_array($value)){
|
||||||
|
$zeitraumIds = impfNormalizeZeitraumIds($value);
|
||||||
|
$zeitraumLabels = [];
|
||||||
|
foreach ($zeitraumIds as $zeitraumId) {
|
||||||
|
$zeitraumRow = null;
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
$zeitraumRow = impfLoadZeitraumById($pdo, (int)$zeitraumId, true);
|
||||||
|
}
|
||||||
|
if ($zeitraumRow) {
|
||||||
|
$zeitraumLabels[] = (string)$zeitraumRow['label'];
|
||||||
|
echo '<input type="hidden" name="impfenzeitraeume[]" value="'.(int)$zeitraumId.'">' . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "<tr><td width=100 valign=top class=fett>$key:</td><td>" . implode("<br>", array_map(static function ($label) {
|
||||||
|
return e((string)$label);
|
||||||
|
}, $zeitraumLabels)) . "</td></tr>\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if($value !== ""){
|
if($value !== ""){
|
||||||
if($key == "Impfstoff"){
|
if($key == "Impfstoff"){
|
||||||
$sqlimpfstoffstring = "SELECT * FROM impfstoff WHERE impfid ='" . $value . "' order by sortierung";
|
$sqlimpfstoffstring = "SELECT * FROM impfstoff WHERE impfid ='" . $value . "' order by sortierung";
|
||||||
@@ -215,6 +292,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
}
|
}
|
||||||
$zeitraumText = $zeitraumRow ? $zeitraumRow['label'] : 'Unbekannter Zeitraum';
|
$zeitraumText = $zeitraumRow ? $zeitraumRow['label'] : 'Unbekannter Zeitraum';
|
||||||
echo "<tr><td width=100 valign=top class=fett>$key:</td><td>$zeitraumText</td></tr>\n";
|
echo "<tr><td width=100 valign=top class=fett>$key:</td><td>$zeitraumText</td></tr>\n";
|
||||||
|
echo"<input type=hidden name='impfenzeitraeume[]' value='".(int)$value."'>\n";
|
||||||
echo"<input type=hidden name='".$key."' value='".$value. "'>\n";
|
echo"<input type=hidden name='".$key."' value='".$value. "'>\n";
|
||||||
}else{
|
}else{
|
||||||
echo "<tr><td width=100 valign=top class=fett>$key:</td><td>$value</td></tr>\n";
|
echo "<tr><td width=100 valign=top class=fett>$key:</td><td>$value</td></tr>\n";
|
||||||
@@ -249,12 +327,12 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
$Impfaufklaerung = mysqli_real_escape_string($con, $_POST["Impfaufklaerung"] ?? "Nein");
|
$Impfaufklaerung = mysqli_real_escape_string($con, $_POST["Impfaufklaerung"] ?? "Nein");
|
||||||
$WeitereFragen = mysqli_real_escape_string($con, $_POST["WeitereFragen"] ?? "Nein");
|
$WeitereFragen = mysqli_real_escape_string($con, $_POST["WeitereFragen"] ?? "Nein");
|
||||||
$impfenmit = mysqli_real_escape_string($con, $_POST["zusammenmit"] ?? "");
|
$impfenmit = mysqli_real_escape_string($con, $_POST["zusammenmit"] ?? "");
|
||||||
$impfenzeitraumId = (int)($_POST["impfenzeitraum"] ?? 0);
|
$impfenzeitraumIds = impfNormalizeZeitraumIds($_POST["impfenzeitraeume"] ?? ($_POST["impfenzeitraum"] ?? []));
|
||||||
$impfart = (int)($_POST["impfart"] ?? 0);
|
$impfart = (int)($_POST["impfart"] ?? 0);
|
||||||
$letzteimpfung = trim($_POST["letzteimpfung"] ?? "");
|
$letzteimpfung = trim($_POST["letzteimpfung"] ?? "");
|
||||||
|
|
||||||
if ($impfstoff <= 0 || $impfart <= 0 || $impfenzeitraumId <= 0) {
|
if ($impfstoff <= 0 || $impfart <= 0 || empty($impfenzeitraumIds)) {
|
||||||
echo "<h3>Pflichtfelder fehlen</h3><br>Bitte wählen Sie Impfstoff, Zeitraum und Impfungsart aus.<br><br>";
|
echo "<h3>Pflichtfelder fehlen</h3><br>Bitte wählen Sie Impfstoff, mindestens einen Zeitraum und die Impfungsart aus.<br><br>";
|
||||||
goto end_aktion_1;
|
goto end_aktion_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,12 +345,19 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
$letzteimpfung = "";
|
$letzteimpfung = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
$zeitraumRow = (isset($pdo) && $pdo instanceof PDO) ? impfLoadZeitraumById($pdo, $impfenzeitraumId, true) : null;
|
$zeitraumLabels = [];
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
foreach ($impfenzeitraumIds as $impfenzeitraumId) {
|
||||||
|
$zeitraumRow = impfLoadZeitraumById($pdo, (int)$impfenzeitraumId, true);
|
||||||
if (!$zeitraumRow || !in_array($impfstoff, $zeitraumRow['impfstoff_id_list'] ?? [], true)) {
|
if (!$zeitraumRow || !in_array($impfstoff, $zeitraumRow['impfstoff_id_list'] ?? [], true)) {
|
||||||
echo "<h3>Ungültiger Zeitraum</h3><br>Bitte wählen Sie einen gültigen Zeitraum für den ausgewählten Impfstoff.<br><br>";
|
echo "<h3>Ungültiger Zeitraum</h3><br>Bitte wählen Sie einen gültigen Zeitraum für den ausgewählten Impfstoff aus.<br><br>";
|
||||||
goto end_aktion_1;
|
goto end_aktion_1;
|
||||||
}
|
}
|
||||||
$impfenzeitraum = mysqli_real_escape_string($con, $zeitraumRow['label']);
|
$zeitraumLabels[] = (string)$zeitraumRow['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$impfenzeitraum = mysqli_real_escape_string($con, implode(' | ', $zeitraumLabels));
|
||||||
|
$impfenzeitraumId = (int)($impfenzeitraumIds[0] ?? 0);
|
||||||
|
|
||||||
|
|
||||||
//echo $impfenmit;
|
//echo $impfenmit;
|
||||||
@@ -333,12 +418,43 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
$letzteimpfungSql = ($letzteimpfung !== "") ? ("'" . mysqli_real_escape_string($con, $letzteimpfung) . "'") : "NULL";
|
$letzteimpfungSql = ($letzteimpfung !== "") ? ("'" . mysqli_real_escape_string($con, $letzteimpfung) . "'") : "NULL";
|
||||||
$query = mysqli_query($con, "SELECT * FROM warteliste WHERE userid='" . (int)$userid . "'");
|
$query = mysqli_query($con, "SELECT * FROM warteliste WHERE userid='" . (int)$userid . "'");
|
||||||
if($query && $query->num_rows == 0){
|
if($query && $query->num_rows == 0){
|
||||||
$query = mysqli_query($con, "INSERT INTO warteliste (userid, hash, impfenangebot, impfstoff, Patientenart,Impfaufklaerung, WeitereFragen, date_created, impfenmit, impfenzeitraum, zeitraum_id, impfart, letzteimpfung, checked) VALUES ('". (int)$userid ."', '".$hash."', '".$impfenangebot."', '".$impfstoff."', '".$Patientenart."', '".$Impfaufklaerung."', '".$WeitereFragen."', now(), '".$impfenmit."', '".$impfenzeitraum."', '". (int)$impfenzeitraumId ."', '".$impfart."', ".$letzteimpfungSql.", '0')");
|
$warteid = 0;
|
||||||
if($query){
|
$saveOk = false;
|
||||||
$warteid = mysqli_insert_id($con);
|
$saveErrorShown = false;
|
||||||
SendMailMessageVorlage($pdo, "2", $warteid , "8" );
|
try {
|
||||||
echo "<h3>Nachricht abgeschickt!</h3><br>Sie müssen die Eintragung in der Warteliste noch bestätigen!<br>Überprüfen Sie auch Ihren Spam-Filter!<br><br>";
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
[$ok, $msg, $newWarteid] = impfCreateWaitlistEntryForPerson(
|
||||||
|
$pdo,
|
||||||
|
(int)$userid,
|
||||||
|
$impfstoff,
|
||||||
|
$impfenzeitraumIds,
|
||||||
|
$impfart,
|
||||||
|
($letzteimpfung !== "") ? $letzteimpfung : null,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
if (!$ok) {
|
||||||
|
throw new RuntimeException($msg);
|
||||||
|
}
|
||||||
|
$warteid = (int)$newWarteid;
|
||||||
|
$pdo->prepare("UPDATE warteliste SET impfenangebot = :impfenangebot, impfenmit = :impfenmit, Impfaufklaerung = :aufklaerung, WeitereFragen = :fragen WHERE warteid = :warteid")
|
||||||
|
->execute([
|
||||||
|
'impfenangebot' => $impfenangebot,
|
||||||
|
'impfenmit' => $impfenmit,
|
||||||
|
'aufklaerung' => $Impfaufklaerung,
|
||||||
|
'fragen' => $WeitereFragen,
|
||||||
|
'warteid' => $warteid,
|
||||||
|
]);
|
||||||
|
$saveOk = true;
|
||||||
} else {
|
} else {
|
||||||
|
throw new RuntimeException("PDO Verbindungsobjekt fehlt.");
|
||||||
|
}
|
||||||
|
SendMailMessageVorlage($pdo, "2", (int)$warteid, "8" );
|
||||||
|
echo "<h3>Nachricht abgeschickt!</h3><br>Sie müssen die Eintragung in der Warteliste noch bestätigen!<br>Überprüfen Sie auch Ihren Spam-Filter!<br><br>";
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
echo "<h3>Speicherung nicht erfolgreich</h3><br>" . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8') . "<br><br>";
|
||||||
|
$saveErrorShown = true;
|
||||||
|
}
|
||||||
|
if(!$saveOk && !$saveErrorShown){
|
||||||
echo "<h3>Speicherung nicht erfolgreich</h3><br>Ihre Anfrage konnte nicht gespeichert werden.<br>Nutzen Sie das Formular erneut<br><br>";
|
echo "<h3>Speicherung nicht erfolgreich</h3><br>Ihre Anfrage konnte nicht gespeichert werden.<br>Nutzen Sie das Formular erneut<br><br>";
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -381,6 +497,13 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
$userausgabe = $vorname . " " . $nachname;
|
$userausgabe = $vorname . " " . $nachname;
|
||||||
|
|
||||||
SendMailMessageVorlage($pdo, "2", $warteid , "9" );
|
SendMailMessageVorlage($pdo, "2", $warteid , "9" );
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
try {
|
||||||
|
impfWorkflowNotificationProcess($pdo);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
error_log('impfWorkflowNotificationProcess failed in impfwarteliste confirm: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -398,11 +521,22 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
$queryimpf = mysqli_query($con, "SELECT * FROM warteliste WHERE warteid='" . $_POST["warteid"] . "'");
|
$queryimpf = mysqli_query($con, "SELECT * FROM warteliste WHERE warteid='" . $_POST["warteid"] . "'");
|
||||||
$rowimpf = $queryimpf->fetch_assoc() ;
|
$rowimpf = $queryimpf->fetch_assoc() ;
|
||||||
SendMailMessageVorlage($pdo, "2", $_POST["warteid"], "10" );
|
SendMailMessageVorlage($pdo, "2", $_POST["warteid"], "10" );
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
$pdo->prepare("DELETE FROM warteliste_zeitraum WHERE warteid = :warteid")->execute([
|
||||||
|
'warteid' => (int)$_POST["warteid"],
|
||||||
|
]);
|
||||||
|
}
|
||||||
$query = mysqli_query($con, "DELETE FROM warteliste WHERE warteid ='".$_POST["warteid"]."'");
|
$query = mysqli_query($con, "DELETE FROM warteliste WHERE warteid ='".$_POST["warteid"]."'");
|
||||||
if($query){
|
if($query){
|
||||||
echo "<h4>Ihr Warteplatz wurde erfolgreich gelöscht!<h4><br>";
|
echo "<h4>Ihr Warteplatz wurde erfolgreich gelöscht!<h4><br>";
|
||||||
echo "Sie erhalten gleiche eine schriftliche Bestätigung per E-Mail<br>";
|
echo "Sie erhalten gleiche eine schriftliche Bestätigung per E-Mail<br>";
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
try {
|
||||||
|
impfWorkflowNotificationProcess($pdo);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
error_log('impfWorkflowNotificationProcess failed in impfwarteliste delete: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -443,8 +577,11 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
echo "<h4>Mail wird gleich versendet!</h4>";
|
echo "<h4>Mail wird gleich versendet!</h4>";
|
||||||
echo "<br>Überprüfen Sie auch Ihren SPAM Ordner!<br>";
|
echo "<br>Überprüfen Sie auch Ihren SPAM Ordner!<br>";
|
||||||
SendMailMessageVorlage($pdo, "1", (int)$terminid, "1" );
|
SendMailMessageVorlage($pdo, "1", (int)$terminid, "1" );
|
||||||
|
if (isset($pdo) && $pdo instanceof PDO) {
|
||||||
|
$pdo->prepare("DELETE FROM warteliste_zeitraum WHERE warteid = :warteid")->execute([
|
||||||
|
'warteid' => (int)$warteid,
|
||||||
|
]);
|
||||||
|
}
|
||||||
$query = mysqli_query($con, "DELETE FROM warteliste WHERE warteid ='".$warteid."'");
|
$query = mysqli_query($con, "DELETE FROM warteliste WHERE warteid ='".$warteid."'");
|
||||||
}else{
|
}else{
|
||||||
echo "<h4>Fehler bei Speichern der Anfragen!</h4>";
|
echo "<h4>Fehler bei Speichern der Anfragen!</h4>";
|
||||||
@@ -512,7 +649,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
}
|
}
|
||||||
$zeitOptionenByImpfstoff[$iid][] = [
|
$zeitOptionenByImpfstoff[$iid][] = [
|
||||||
'id' => (int)$zeitraum['zeitraum_id'],
|
'id' => (int)$zeitraum['zeitraum_id'],
|
||||||
'label' => (string)$zeitraum['label'],
|
'label' => impfZeitraumLabel($zeitraum, false),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,9 +739,9 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<div class="12u">
|
<div class="12u">
|
||||||
<label for="impfenzeitraum">Wählen Sie den möglichen Zeitbereich für den gewählten Impfstoff:</label>
|
<label for="impfenzeitraeume">Wählen Sie die möglichen Zeitbereiche für den gewählten Impfstoff:</label>
|
||||||
<div class="select-wrapper">
|
<div class="select-wrapper">
|
||||||
<select name="impfenzeitraum" id="impfenzeitraum" required disabled onchange="checkZeitraum()">
|
<select name="impfenzeitraeume[]" id="impfenzeitraeume" multiple size="6" required disabled onchange="checkZeitraum()">
|
||||||
<option value="">- Bitte zuerst Impfstoff auswählen -</option>
|
<option value="">- Bitte zuerst Impfstoff auswählen -</option>
|
||||||
</select>
|
</select>
|
||||||
<div id="Zeitrauminfo"></div>
|
<div id="Zeitrauminfo"></div>
|
||||||
@@ -680,6 +817,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const zeitfensterByImpfstoff = <?php echo $zeitOptionenJson ?: '{}'; ?>;
|
const zeitfensterByImpfstoff = <?php echo $zeitOptionenJson ?: '{}'; ?>;
|
||||||
|
const initialZeitraumIds = <?php echo json_encode(impfNormalizeZeitraumIds($_POST["impfenzeitraeume"] ?? ($_POST["impfenzeitraum"] ?? [])), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||||
|
|
||||||
function isIE() {
|
function isIE() {
|
||||||
return /Trident\/|MSIE/.test(window.navigator.userAgent);
|
return /Trident\/|MSIE/.test(window.navigator.userAgent);
|
||||||
@@ -687,7 +825,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
|
|
||||||
function updateZeitfenster() {
|
function updateZeitfenster() {
|
||||||
const impfstoff = document.getElementById('AstraImpfung');
|
const impfstoff = document.getElementById('AstraImpfung');
|
||||||
const zeitraum = document.getElementById('impfenzeitraum');
|
const zeitraum = document.getElementById('impfenzeitraeume');
|
||||||
const zeitraumInfo = document.getElementById('Zeitrauminfo');
|
const zeitraumInfo = document.getElementById('Zeitrauminfo');
|
||||||
const submit = document.getElementById('submitbox');
|
const submit = document.getElementById('submitbox');
|
||||||
const impfstoffId = impfstoff.value;
|
const impfstoffId = impfstoff.value;
|
||||||
@@ -697,7 +835,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
if (!impfstoffId || optionen.length === 0) {
|
if (!impfstoffId || optionen.length === 0) {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = '';
|
opt.value = '';
|
||||||
opt.textContent = '- Kein Zeitbereich verfügbar -';
|
opt.textContent = '- Keine Zeitbereiche verfügbar -';
|
||||||
zeitraum.appendChild(opt);
|
zeitraum.appendChild(opt);
|
||||||
zeitraum.disabled = true;
|
zeitraum.disabled = true;
|
||||||
submit.disabled = true;
|
submit.disabled = true;
|
||||||
@@ -713,11 +851,15 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = String(eintrag.id || '');
|
opt.value = String(eintrag.id || '');
|
||||||
opt.textContent = eintrag.label || '';
|
opt.textContent = eintrag.label || '';
|
||||||
|
if (initialZeitraumIds.includes(Number(eintrag.id))) {
|
||||||
|
opt.selected = true;
|
||||||
|
}
|
||||||
zeitraum.appendChild(opt);
|
zeitraum.appendChild(opt);
|
||||||
});
|
});
|
||||||
zeitraum.disabled = false;
|
zeitraum.disabled = false;
|
||||||
submit.disabled = false;
|
submit.disabled = false;
|
||||||
zeitraumInfo.innerHTML = '';
|
zeitraumInfo.innerHTML = '';
|
||||||
|
checkZeitraum();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checklastImpf() {
|
function checklastImpf() {
|
||||||
@@ -736,10 +878,14 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
|
|
||||||
function checkZeitraum() {
|
function checkZeitraum() {
|
||||||
const info = document.getElementById('Zeitrauminfo');
|
const info = document.getElementById('Zeitrauminfo');
|
||||||
if (document.getElementById('impfenzeitraum').value === "") {
|
const submit = document.getElementById('submitbox');
|
||||||
|
const selected = Array.from(document.getElementById('impfenzeitraeume').selectedOptions || []).filter((opt) => opt.value !== '');
|
||||||
|
if (selected.length === 0) {
|
||||||
info.innerHTML = "";
|
info.innerHTML = "";
|
||||||
|
submit.disabled = true;
|
||||||
} else {
|
} else {
|
||||||
info.innerHTML = '<div style="border:5px solid red; margin: 5px; padding: 5px;">Bitte halten Sie sich den gewählten Zeitraum frei. Die konkrete Terminanfrage erhalten Sie später per E-Mail.</div>';
|
info.innerHTML = '<div style="border:5px solid red; margin: 5px; padding: 5px;">Bitte halten Sie sich die gewählten Zeitbereiche frei. Die konkrete Terminanfrage erhalten Sie später per E-Mail.</div>';
|
||||||
|
submit.disabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,6 +896,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
|||||||
}
|
}
|
||||||
checklastImpf();
|
checklastImpf();
|
||||||
updateZeitfenster();
|
updateZeitfenster();
|
||||||
|
checkZeitraum();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+238
-27
@@ -35,6 +35,41 @@ if (!function_exists('impfTableHasIndex')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfEnsureTable')) {
|
||||||
|
function impfEnsureTable(PDO $pdo, string $table, string $createSql): void
|
||||||
|
{
|
||||||
|
if (impfTableExists($pdo, $table)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdo->exec($createSql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfNormalizeZeitraumIds')) {
|
||||||
|
function impfNormalizeZeitraumIds($zeitraumIds): array
|
||||||
|
{
|
||||||
|
if ($zeitraumIds === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_array($zeitraumIds)) {
|
||||||
|
$zeitraumIds = [$zeitraumIds];
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = [];
|
||||||
|
foreach ($zeitraumIds as $zeitraumId) {
|
||||||
|
$zeitraumId = (int)$zeitraumId;
|
||||||
|
if ($zeitraumId <= 0 || isset($result[$zeitraumId])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$result[$zeitraumId] = $zeitraumId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values($result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('impfWeekdayName')) {
|
if (!function_exists('impfWeekdayName')) {
|
||||||
function impfWeekdayName(int $day): string
|
function impfWeekdayName(int $day): string
|
||||||
{
|
{
|
||||||
@@ -55,21 +90,21 @@ if (!function_exists('impfWeekdayName')) {
|
|||||||
if (!function_exists('impfWorkflowEnsureTables')) {
|
if (!function_exists('impfWorkflowEnsureTables')) {
|
||||||
function impfWorkflowEnsureTables(PDO $pdo): void
|
function impfWorkflowEnsureTables(PDO $pdo): void
|
||||||
{
|
{
|
||||||
$pdo->exec("CREATE TABLE IF NOT EXISTS impf_workflow_meta (
|
impfEnsureTable($pdo, 'impf_workflow_meta', "CREATE TABLE impf_workflow_meta (
|
||||||
meta_key VARCHAR(100) NOT NULL,
|
meta_key VARCHAR(100) NOT NULL,
|
||||||
meta_value VARCHAR(255) NOT NULL DEFAULT '',
|
meta_value VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (meta_key)
|
PRIMARY KEY (meta_key)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
||||||
|
|
||||||
$pdo->exec("CREATE TABLE IF NOT EXISTS impfstoff_workflow (
|
impfEnsureTable($pdo, 'impfstoff_workflow', "CREATE TABLE impfstoff_workflow (
|
||||||
impfstoff_id INT NOT NULL,
|
impfstoff_id INT NOT NULL,
|
||||||
dosen_pro_flasche INT NOT NULL,
|
dosen_pro_flasche INT NOT NULL,
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
PRIMARY KEY (impfstoff_id)
|
PRIMARY KEY (impfstoff_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
||||||
|
|
||||||
$pdo->exec("CREATE TABLE IF NOT EXISTS impfstoff_wochenplan (
|
impfEnsureTable($pdo, 'impfstoff_wochenplan', "CREATE TABLE impfstoff_wochenplan (
|
||||||
plan_id INT NOT NULL AUTO_INCREMENT,
|
plan_id INT NOT NULL AUTO_INCREMENT,
|
||||||
impfstoff_id INT NOT NULL,
|
impfstoff_id INT NOT NULL,
|
||||||
wochentag TINYINT NOT NULL,
|
wochentag TINYINT NOT NULL,
|
||||||
@@ -83,7 +118,7 @@ if (!function_exists('impfWorkflowEnsureTables')) {
|
|||||||
INDEX idx_impfstoff_wochenplan_wochentag (wochentag)
|
INDEX idx_impfstoff_wochenplan_wochentag (wochentag)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
||||||
|
|
||||||
$pdo->exec("CREATE TABLE IF NOT EXISTS impf_zeitraum (
|
impfEnsureTable($pdo, 'impf_zeitraum', "CREATE TABLE impf_zeitraum (
|
||||||
zeitraum_id INT NOT NULL AUTO_INCREMENT,
|
zeitraum_id INT NOT NULL AUTO_INCREMENT,
|
||||||
bezeichnung VARCHAR(120) NOT NULL DEFAULT '',
|
bezeichnung VARCHAR(120) NOT NULL DEFAULT '',
|
||||||
wochentag TINYINT NOT NULL,
|
wochentag TINYINT NOT NULL,
|
||||||
@@ -101,7 +136,7 @@ if (!function_exists('impfWorkflowEnsureTables')) {
|
|||||||
$pdo->exec("ALTER TABLE impf_zeitraum ADD COLUMN bezeichnung VARCHAR(120) NOT NULL DEFAULT '' AFTER zeitraum_id");
|
$pdo->exec("ALTER TABLE impf_zeitraum ADD COLUMN bezeichnung VARCHAR(120) NOT NULL DEFAULT '' AFTER zeitraum_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdo->exec("CREATE TABLE IF NOT EXISTS impf_zeitraum_impfstoff (
|
impfEnsureTable($pdo, 'impf_zeitraum_impfstoff', "CREATE TABLE impf_zeitraum_impfstoff (
|
||||||
zeitraum_id INT NOT NULL,
|
zeitraum_id INT NOT NULL,
|
||||||
impfstoff_id INT NOT NULL,
|
impfstoff_id INT NOT NULL,
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
@@ -109,6 +144,18 @@ if (!function_exists('impfWorkflowEnsureTables')) {
|
|||||||
INDEX idx_impf_zeitraum_impfstoff_impfstoff (impfstoff_id)
|
INDEX idx_impf_zeitraum_impfstoff_impfstoff (impfstoff_id)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
||||||
|
|
||||||
|
impfEnsureTable($pdo, 'warteliste_zeitraum', "CREATE TABLE warteliste_zeitraum (
|
||||||
|
warteid INT NOT NULL,
|
||||||
|
zeitraum_id INT NOT NULL,
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (warteid, zeitraum_id),
|
||||||
|
INDEX idx_warteliste_zeitraum_zeitraum (zeitraum_id)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3");
|
||||||
|
|
||||||
|
if (impfTableExists($pdo, 'warteliste_zeitraum') && !impfTableHasIndex($pdo, 'warteliste_zeitraum', 'idx_warteliste_zeitraum_zeitraum')) {
|
||||||
|
$pdo->exec("ALTER TABLE warteliste_zeitraum ADD INDEX idx_warteliste_zeitraum_zeitraum (zeitraum_id)");
|
||||||
|
}
|
||||||
|
|
||||||
if (impfTableExists($pdo, 'warteliste') && !impfTableHasColumn($pdo, 'warteliste', 'zeitraum_id')) {
|
if (impfTableExists($pdo, 'warteliste') && !impfTableHasColumn($pdo, 'warteliste', 'zeitraum_id')) {
|
||||||
$pdo->exec("ALTER TABLE warteliste ADD COLUMN zeitraum_id INT NULL AFTER impfenzeitraum");
|
$pdo->exec("ALTER TABLE warteliste ADD COLUMN zeitraum_id INT NULL AFTER impfenzeitraum");
|
||||||
}
|
}
|
||||||
@@ -117,6 +164,7 @@ if (!function_exists('impfWorkflowEnsureTables')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impfWorkflowMigrateLegacyPlans($pdo);
|
impfWorkflowMigrateLegacyPlans($pdo);
|
||||||
|
impfWorkflowMigrateLegacyWartelisteZeitraeume($pdo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,6 +275,42 @@ if (!function_exists('impfWorkflowMigrateLegacyPlans')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowMigrateLegacyWartelisteZeitraeume')) {
|
||||||
|
function impfWorkflowMigrateLegacyWartelisteZeitraeume(PDO $pdo): void
|
||||||
|
{
|
||||||
|
if (!impfTableExists($pdo, 'warteliste') || !impfTableExists($pdo, 'warteliste_zeitraum')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (impfWorkflowGetMeta($pdo, 'legacy_warteliste_zeitraeume_migrated') === '1') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$manageTransaction = !$pdo->inTransaction();
|
||||||
|
if ($manageTransaction) {
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo->exec("INSERT IGNORE INTO warteliste_zeitraum (warteid, zeitraum_id)
|
||||||
|
SELECT warteid, zeitraum_id
|
||||||
|
FROM warteliste
|
||||||
|
WHERE zeitraum_id IS NOT NULL
|
||||||
|
AND zeitraum_id > 0");
|
||||||
|
impfWorkflowSetMeta($pdo, 'legacy_warteliste_zeitraeume_migrated', '1');
|
||||||
|
|
||||||
|
if ($manageTransaction) {
|
||||||
|
$pdo->commit();
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
if ($manageTransaction && $pdo->inTransaction()) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('impfCsvToIntList')) {
|
if (!function_exists('impfCsvToIntList')) {
|
||||||
function impfCsvToIntList(?string $csv): array
|
function impfCsvToIntList(?string $csv): array
|
||||||
{
|
{
|
||||||
@@ -243,7 +327,7 @@ if (!function_exists('impfCsvToIntList')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('impfZeitraumLabel')) {
|
if (!function_exists('impfZeitraumLabel')) {
|
||||||
function impfZeitraumLabel(array $zeitraum): string
|
function impfZeitraumLabel(array $zeitraum, bool $includeName = true): string
|
||||||
{
|
{
|
||||||
$zeitText = impfWeekdayName((int)$zeitraum['wochentag']) . ' ' . substr((string)$zeitraum['start'], 0, 5) . '-' . substr((string)$zeitraum['ende'], 0, 5);
|
$zeitText = impfWeekdayName((int)$zeitraum['wochentag']) . ' ' . substr((string)$zeitraum['start'], 0, 5) . '-' . substr((string)$zeitraum['ende'], 0, 5);
|
||||||
$ort = trim((string)($zeitraum['anzeigename'] ?? '') . ' - ' . (string)($zeitraum['adresse'] ?? ''));
|
$ort = trim((string)($zeitraum['anzeigename'] ?? '') . ' - ' . (string)($zeitraum['adresse'] ?? ''));
|
||||||
@@ -253,7 +337,7 @@ if (!function_exists('impfZeitraumLabel')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$bezeichnung = trim((string)($zeitraum['bezeichnung'] ?? ''));
|
$bezeichnung = trim((string)($zeitraum['bezeichnung'] ?? ''));
|
||||||
if ($bezeichnung !== '') {
|
if ($includeName && $bezeichnung !== '') {
|
||||||
return $bezeichnung . ': ' . $zeitText;
|
return $bezeichnung . ': ' . $zeitText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +472,7 @@ if (!function_exists('impfGetWartelistenFormOptions')) {
|
|||||||
}
|
}
|
||||||
$zeitfenster[$impfstoffId][] = [
|
$zeitfenster[$impfstoffId][] = [
|
||||||
'id' => (int)$zeitraum['zeitraum_id'],
|
'id' => (int)$zeitraum['zeitraum_id'],
|
||||||
'label' => (string)$zeitraum['label'],
|
'label' => impfZeitraumLabel($zeitraum, false),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -406,12 +490,112 @@ if (!function_exists('impfGetWartelistenFormOptions')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfGetWartelistenZeitraeume')) {
|
||||||
|
function impfGetWartelistenZeitraeume(PDO $pdo, int $warteid, bool $onlyActive = false): array
|
||||||
|
{
|
||||||
|
if ($warteid <= 0 || !impfTableExists($pdo, 'warteliste_zeitraum')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT z.zeitraum_id, z.bezeichnung, z.wochentag, z.start, z.ende, z.impfortid, z.aktiv, z.created_at,
|
||||||
|
o.anzeigename, o.adresse
|
||||||
|
FROM warteliste_zeitraum wz
|
||||||
|
INNER JOIN impf_zeitraum z ON z.zeitraum_id = wz.zeitraum_id
|
||||||
|
LEFT JOIN impfort o ON o.ortid = z.impfortid
|
||||||
|
WHERE wz.warteid = :warteid";
|
||||||
|
if ($onlyActive) {
|
||||||
|
$sql .= " AND z.aktiv = 1";
|
||||||
|
}
|
||||||
|
$sql .= " ORDER BY z.wochentag, z.start, z.ende, z.bezeichnung, z.zeitraum_id";
|
||||||
|
|
||||||
|
$st = $pdo->prepare($sql);
|
||||||
|
$st->execute(['warteid' => $warteid]);
|
||||||
|
$rows = $st->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
foreach ($rows as &$row) {
|
||||||
|
$row['label'] = impfZeitraumLabel($row);
|
||||||
|
}
|
||||||
|
unset($row);
|
||||||
|
|
||||||
|
if (!empty($rows)) {
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stFallback = $pdo->prepare("SELECT w.zeitraum_id, z.bezeichnung, z.wochentag, z.start, z.ende, z.impfortid, z.aktiv, z.created_at,
|
||||||
|
o.anzeigename, o.adresse
|
||||||
|
FROM warteliste w
|
||||||
|
LEFT JOIN impf_zeitraum z ON z.zeitraum_id = w.zeitraum_id
|
||||||
|
LEFT JOIN impfort o ON o.ortid = z.impfortid
|
||||||
|
WHERE w.warteid = :warteid
|
||||||
|
AND w.zeitraum_id IS NOT NULL
|
||||||
|
LIMIT 1");
|
||||||
|
$stFallback->execute(['warteid' => $warteid]);
|
||||||
|
$row = $stFallback->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if (!$row) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['label'] = impfZeitraumLabel($row);
|
||||||
|
return [$row];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfGetWartelistenZeitraeumeLabels')) {
|
||||||
|
function impfGetWartelistenZeitraeumeLabels(PDO $pdo, int $warteid, bool $onlyActive = false): array
|
||||||
|
{
|
||||||
|
$rows = impfGetWartelistenZeitraeume($pdo, $warteid, $onlyActive);
|
||||||
|
return array_values(array_map(static function (array $row): string {
|
||||||
|
return (string)($row['label'] ?? '');
|
||||||
|
}, $rows));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfSetWartelistenZeitraeume')) {
|
||||||
|
function impfSetWartelistenZeitraeume(PDO $pdo, int $warteid, $zeitraumIds): void
|
||||||
|
{
|
||||||
|
$zeitraumIds = impfNormalizeZeitraumIds($zeitraumIds);
|
||||||
|
if ($warteid <= 0) {
|
||||||
|
throw new InvalidArgumentException('Unguelige Wartelisten-ID.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$manageTransaction = !$pdo->inTransaction();
|
||||||
|
if ($manageTransaction) {
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$stDelete = $pdo->prepare("DELETE FROM warteliste_zeitraum WHERE warteid = :warteid");
|
||||||
|
$stDelete->execute(['warteid' => $warteid]);
|
||||||
|
|
||||||
|
if (!empty($zeitraumIds)) {
|
||||||
|
$stInsert = $pdo->prepare("INSERT INTO warteliste_zeitraum (warteid, zeitraum_id)
|
||||||
|
VALUES (:warteid, :zeitraum_id)");
|
||||||
|
foreach ($zeitraumIds as $zeitraumId) {
|
||||||
|
$stInsert->execute([
|
||||||
|
'warteid' => $warteid,
|
||||||
|
'zeitraum_id' => $zeitraumId,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($manageTransaction) {
|
||||||
|
$pdo->commit();
|
||||||
|
}
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
if ($manageTransaction && $pdo->inTransaction()) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!function_exists('impfCreateWaitlistEntryForPerson')) {
|
if (!function_exists('impfCreateWaitlistEntryForPerson')) {
|
||||||
function impfCreateWaitlistEntryForPerson(
|
function impfCreateWaitlistEntryForPerson(
|
||||||
PDO $pdo,
|
PDO $pdo,
|
||||||
int $personId,
|
int $personId,
|
||||||
int $impfstoffId,
|
int $impfstoffId,
|
||||||
int $zeitraumId,
|
$zeitraumIds,
|
||||||
int $impfart,
|
int $impfart,
|
||||||
?string $letzteImpfung = null,
|
?string $letzteImpfung = null,
|
||||||
int $checked = 1
|
int $checked = 1
|
||||||
@@ -422,13 +606,15 @@ if (!function_exists('impfCreateWaitlistEntryForPerson')) {
|
|||||||
if ($impfstoffId <= 0) {
|
if ($impfstoffId <= 0) {
|
||||||
return [false, 'Bitte einen Impfstoff auswaehlen.', null];
|
return [false, 'Bitte einen Impfstoff auswaehlen.', null];
|
||||||
}
|
}
|
||||||
if ($zeitraumId <= 0) {
|
|
||||||
return [false, 'Bitte ein Zeitfenster auswaehlen.', null];
|
|
||||||
}
|
|
||||||
if ($impfart < 1 || $impfart > 4) {
|
if ($impfart < 1 || $impfart > 4) {
|
||||||
return [false, 'Bitte eine gueltige Impfungsart auswaehlen.', null];
|
return [false, 'Bitte eine gueltige Impfungsart auswaehlen.', null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$zeitraumIds = impfNormalizeZeitraumIds($zeitraumIds);
|
||||||
|
if (empty($zeitraumIds)) {
|
||||||
|
return [false, 'Bitte mindestens ein Zeitfenster auswaehlen.', null];
|
||||||
|
}
|
||||||
|
|
||||||
$letzteImpfung = $letzteImpfung !== null ? trim($letzteImpfung) : null;
|
$letzteImpfung = $letzteImpfung !== null ? trim($letzteImpfung) : null;
|
||||||
if ($impfart === 1) {
|
if ($impfart === 1) {
|
||||||
$letzteImpfung = null;
|
$letzteImpfung = null;
|
||||||
@@ -448,26 +634,32 @@ if (!function_exists('impfCreateWaitlistEntryForPerson')) {
|
|||||||
return [false, 'Die Person wurde nicht gefunden.', null];
|
return [false, 'Die Person wurde nicht gefunden.', null];
|
||||||
}
|
}
|
||||||
|
|
||||||
$zeitraum = impfLoadZeitraumById($pdo, $zeitraumId, true);
|
$zeitraumRows = [];
|
||||||
if (!$zeitraum) {
|
$zeitraumLabels = [];
|
||||||
return [false, 'Das ausgewaehlte Zeitfenster ist nicht mehr verfuegbar.', null];
|
foreach ($zeitraumIds as $zeitraumId) {
|
||||||
|
$row = impfLoadZeitraumById($pdo, $zeitraumId, true);
|
||||||
|
if (!$row) {
|
||||||
|
return [false, 'Mindestens ein ausgewaehltes Zeitfenster ist nicht mehr verfuegbar.', null];
|
||||||
}
|
}
|
||||||
if (!in_array($impfstoffId, $zeitraum['impfstoff_id_list'] ?? [], true)) {
|
if (!in_array($impfstoffId, $row['impfstoff_id_list'] ?? [], true)) {
|
||||||
return [false, 'Impfstoff und Zeitfenster passen nicht zusammen.', null];
|
return [false, 'Impfstoff und Zeitfenster passen nicht zusammen.', null];
|
||||||
}
|
}
|
||||||
|
$zeitraumRows[$zeitraumId] = $row;
|
||||||
|
$zeitraumLabels[] = (string)$row['label'];
|
||||||
|
}
|
||||||
|
|
||||||
$stDup = $pdo->prepare("SELECT warteid
|
$stDup = $pdo->prepare("SELECT w.warteid
|
||||||
FROM warteliste
|
FROM warteliste w
|
||||||
WHERE userid = :uid
|
LEFT JOIN warteliste_zeitraum wz ON wz.warteid = w.warteid
|
||||||
AND checked IN (0, 1)
|
WHERE w.userid = :uid
|
||||||
AND impfstoff = :impfstoff
|
AND w.checked IN (0, 1)
|
||||||
AND COALESCE(zeitraum_id, 0) = :zeitraum_id
|
AND w.impfstoff = :impfstoff
|
||||||
AND impfart = :impfart
|
AND w.impfart = :impfart
|
||||||
|
GROUP BY w.warteid
|
||||||
LIMIT 1");
|
LIMIT 1");
|
||||||
$stDup->execute([
|
$stDup->execute([
|
||||||
'uid' => $personId,
|
'uid' => $personId,
|
||||||
'impfstoff' => $impfstoffId,
|
'impfstoff' => $impfstoffId,
|
||||||
'zeitraum_id' => $zeitraumId,
|
|
||||||
'impfart' => $impfart,
|
'impfart' => $impfart,
|
||||||
]);
|
]);
|
||||||
if ($stDup->fetchColumn()) {
|
if ($stDup->fetchColumn()) {
|
||||||
@@ -477,7 +669,15 @@ if (!function_exists('impfCreateWaitlistEntryForPerson')) {
|
|||||||
$patientenart = ((int)($person['patientenart'] ?? 0) === 1) ? 1 : 0;
|
$patientenart = ((int)($person['patientenart'] ?? 0) === 1) ? 1 : 0;
|
||||||
$hash = bin2hex(random_bytes(16));
|
$hash = bin2hex(random_bytes(16));
|
||||||
$checkedValue = ($checked === 0) ? 0 : 1;
|
$checkedValue = ($checked === 0) ? 0 : 1;
|
||||||
|
$primaerZeitraumId = (int)$zeitraumIds[0];
|
||||||
|
$impfenzeitraum = implode(' | ', $zeitraumLabels);
|
||||||
|
|
||||||
|
$manageTransaction = !$pdo->inTransaction();
|
||||||
|
if ($manageTransaction) {
|
||||||
|
$pdo->beginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
$stInsert = $pdo->prepare("INSERT INTO warteliste
|
$stInsert = $pdo->prepare("INSERT INTO warteliste
|
||||||
(userid, checked, hash, impfenangebot, impfstoff, Patientenart, Impfaufklaerung, WeitereFragen, impfart, impfenmit, letzteimpfung, impfenzeitraum, zeitraum_id, date_created)
|
(userid, checked, hash, impfenangebot, impfstoff, Patientenart, Impfaufklaerung, WeitereFragen, impfart, impfenmit, letzteimpfung, impfenzeitraum, zeitraum_id, date_created)
|
||||||
VALUES
|
VALUES
|
||||||
@@ -490,13 +690,24 @@ if (!function_exists('impfCreateWaitlistEntryForPerson')) {
|
|||||||
'patientenart' => $patientenart,
|
'patientenart' => $patientenart,
|
||||||
'impfart' => $impfart,
|
'impfart' => $impfart,
|
||||||
'letzteimpfung' => $letzteImpfung,
|
'letzteimpfung' => $letzteImpfung,
|
||||||
'impfenzeitraum' => (string)$zeitraum['label'],
|
'impfenzeitraum' => $impfenzeitraum,
|
||||||
'zeitraum_id' => $zeitraumId,
|
'zeitraum_id' => $primaerZeitraumId,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$warteid = (int)$pdo->lastInsertId();
|
$warteid = (int)$pdo->lastInsertId();
|
||||||
$personName = trim((string)$person['vorname'] . ' ' . (string)$person['nachname']);
|
impfSetWartelistenZeitraeume($pdo, $warteid, $zeitraumIds);
|
||||||
|
|
||||||
|
if ($manageTransaction) {
|
||||||
|
$pdo->commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$personName = trim((string)$person['vorname'] . ' ' . (string)$person['nachname']);
|
||||||
return [true, 'Wartelistenplatz fuer ' . $personName . ' wurde gespeichert.', $warteid];
|
return [true, 'Wartelistenplatz fuer ' . $personName . ' wurde gespeichert.', $warteid];
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
if ($manageTransaction && $pdo->inTransaction()) {
|
||||||
|
$pdo->rollBack();
|
||||||
|
}
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1262,6 +1262,8 @@ function Userspeichern($vorname, $nachname, $geburtstag, $mail, $tele, $ort, $pl
|
|||||||
UPDATE persons
|
UPDATE persons
|
||||||
SET vorname=:vorname,
|
SET vorname=:vorname,
|
||||||
nachname=:nachname,
|
nachname=:nachname,
|
||||||
|
geburtstag=:geburtstag,
|
||||||
|
email=:email,
|
||||||
tele=:tele,
|
tele=:tele,
|
||||||
ort=:ort,
|
ort=:ort,
|
||||||
plz=:plz,
|
plz=:plz,
|
||||||
|
|||||||
@@ -0,0 +1,256 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationEnsureMetaTable')) {
|
||||||
|
function impfWorkflowNotificationEnsureMetaTable(PDO $pdo): void
|
||||||
|
{
|
||||||
|
$pdo->exec("CREATE TABLE IF NOT EXISTS impf_workflow_meta (
|
||||||
|
meta_key VARCHAR(100) NOT NULL,
|
||||||
|
meta_value VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (meta_key)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationGetMeta')) {
|
||||||
|
function impfWorkflowNotificationGetMeta(PDO $pdo, string $key): ?string
|
||||||
|
{
|
||||||
|
impfWorkflowNotificationEnsureMetaTable($pdo);
|
||||||
|
|
||||||
|
$st = $pdo->prepare("SELECT meta_value
|
||||||
|
FROM impf_workflow_meta
|
||||||
|
WHERE meta_key = :meta_key
|
||||||
|
LIMIT 1");
|
||||||
|
$st->execute(['meta_key' => $key]);
|
||||||
|
$value = $st->fetchColumn();
|
||||||
|
|
||||||
|
return ($value === false) ? null : (string)$value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationSetMeta')) {
|
||||||
|
function impfWorkflowNotificationSetMeta(PDO $pdo, string $key, string $value): void
|
||||||
|
{
|
||||||
|
impfWorkflowNotificationEnsureMetaTable($pdo);
|
||||||
|
|
||||||
|
$st = $pdo->prepare("INSERT INTO impf_workflow_meta (meta_key, meta_value)
|
||||||
|
VALUES (:meta_key, :meta_value)
|
||||||
|
ON DUPLICATE KEY UPDATE meta_value = VALUES(meta_value)");
|
||||||
|
$st->execute([
|
||||||
|
'meta_key' => $key,
|
||||||
|
'meta_value' => $value,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationGetEmail')) {
|
||||||
|
function impfWorkflowNotificationGetEmail(PDO $pdo): string
|
||||||
|
{
|
||||||
|
return trim((string)(impfWorkflowNotificationGetMeta($pdo, 'benachrichtigung_email') ?? ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationSetEmail')) {
|
||||||
|
function impfWorkflowNotificationSetEmail(PDO $pdo, string $email): void
|
||||||
|
{
|
||||||
|
$email = trim($email);
|
||||||
|
impfWorkflowNotificationSetMeta($pdo, 'benachrichtigung_email', $email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationIsReady')) {
|
||||||
|
function impfWorkflowNotificationIsReady(PDO $pdo): bool
|
||||||
|
{
|
||||||
|
return impfWorkflowNotificationGetEmail($pdo) !== '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationShouldTrigger')) {
|
||||||
|
function impfWorkflowNotificationShouldTrigger(int $wartende, int $dosen): bool
|
||||||
|
{
|
||||||
|
if ($wartende < 5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($dosen > 5) {
|
||||||
|
return $wartende >= $dosen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationStateKey')) {
|
||||||
|
function impfWorkflowNotificationStateKey(int $impfstoffId, int $zeitraumId): string
|
||||||
|
{
|
||||||
|
return 'notification_sent_' . $impfstoffId . '_' . $zeitraumId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationCountWaitersForPlan')) {
|
||||||
|
function impfWorkflowNotificationCountWaitersForPlan(PDO $pdo, int $impfstoffId, int $zeitraumId): int
|
||||||
|
{
|
||||||
|
if ($impfstoffId <= 0 || $zeitraumId <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$st = $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
|
||||||
|
)
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
)");
|
||||||
|
$st->execute([
|
||||||
|
'iid' => $impfstoffId,
|
||||||
|
'zid' => $zeitraumId,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (int)$st->fetchColumn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationSendForPlan')) {
|
||||||
|
function impfWorkflowNotificationSendForPlan(
|
||||||
|
PDO $pdo,
|
||||||
|
int $impfstoffId,
|
||||||
|
string $impfstoffName,
|
||||||
|
int $zeitraumId,
|
||||||
|
string $zeitraumLabel,
|
||||||
|
int $wartende,
|
||||||
|
int $dosen
|
||||||
|
): array {
|
||||||
|
if ($impfstoffId <= 0 || $zeitraumId <= 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stateKey = impfWorkflowNotificationStateKey($impfstoffId, $zeitraumId);
|
||||||
|
$alreadySent = impfWorkflowNotificationGetMeta($pdo, $stateKey) === '1';
|
||||||
|
$shouldTrigger = impfWorkflowNotificationShouldTrigger($wartende, $dosen);
|
||||||
|
|
||||||
|
if (!$shouldTrigger) {
|
||||||
|
if ($alreadySent) {
|
||||||
|
impfWorkflowNotificationSetMeta($pdo, $stateKey, '0');
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($alreadySent) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$email = impfWorkflowNotificationGetEmail($pdo);
|
||||||
|
if ($email === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$thresholdText = ($dosen > 5)
|
||||||
|
? 'Die Flasche hat mehr als 5 Dosen, daher wird erst bei einer vollen Flasche benachrichtigt.'
|
||||||
|
: 'Es sind mindestens 5 Interessenten fuer dieses Zeitfenster vorhanden.';
|
||||||
|
|
||||||
|
$subject = 'Impfworkflow: Warteliste ist bereit fuer ' . $impfstoffName;
|
||||||
|
$body = '<p>Fuer den Impfworkflow ist ein Zeitfenster benachrichtigungsreif.</p>'
|
||||||
|
. '<p><strong>Impfstoff:</strong> ' . htmlspecialchars($impfstoffName, ENT_QUOTES, 'UTF-8') . '<br>'
|
||||||
|
. '<strong>Zeitfenster:</strong> ' . htmlspecialchars($zeitraumLabel, ENT_QUOTES, 'UTF-8') . '<br>'
|
||||||
|
. '<strong>Interessenten:</strong> ' . $wartende . '<br>'
|
||||||
|
. '<strong>Dosen pro Flasche:</strong> ' . $dosen . '</p>'
|
||||||
|
. '<p>' . htmlspecialchars($thresholdText, ENT_QUOTES, 'UTF-8') . '</p>';
|
||||||
|
|
||||||
|
if (!SendMailMessage($pdo, $email, $subject, $body)) {
|
||||||
|
throw new RuntimeException('Benachrichtigungs-E-Mail konnte nicht versendet werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
impfWorkflowNotificationSetMeta($pdo, $stateKey, '1');
|
||||||
|
|
||||||
|
return [[
|
||||||
|
'impfstoff_id' => $impfstoffId,
|
||||||
|
'zeitraum_id' => $zeitraumId,
|
||||||
|
'email' => $email,
|
||||||
|
'impfstoff' => $impfstoffName,
|
||||||
|
'zeitraum' => $zeitraumLabel,
|
||||||
|
'wartende' => $wartende,
|
||||||
|
'dosen' => $dosen,
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!function_exists('impfWorkflowNotificationProcess')) {
|
||||||
|
function impfWorkflowNotificationProcess(PDO $pdo, int $impfstoffId = 0, array $zeitraumIds = []): array
|
||||||
|
{
|
||||||
|
if (!function_exists('impfGetZeitraeumeByImpfstoff') || !function_exists('impfLoadZeitraumById')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$zeitraumIds = array_values(array_unique(array_filter(array_map('intval', $zeitraumIds), static function (int $zeitraumId): bool {
|
||||||
|
return $zeitraumId > 0;
|
||||||
|
})));
|
||||||
|
|
||||||
|
$sql = "SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname
|
||||||
|
FROM impfstoff_workflow r
|
||||||
|
INNER JOIN impfstoff i ON i.impfid = r.impfstoff_id
|
||||||
|
WHERE (i.aktiv = 1 OR i.aktivwarteliste = 1 OR i.aktivtermin = 1 OR i.aktivgrippe = 1)";
|
||||||
|
$params = [];
|
||||||
|
if ($impfstoffId > 0) {
|
||||||
|
$sql .= " AND r.impfstoff_id = :iid";
|
||||||
|
$params['iid'] = $impfstoffId;
|
||||||
|
}
|
||||||
|
$sql .= " ORDER BY i.impfname";
|
||||||
|
|
||||||
|
$stRules = $pdo->prepare($sql);
|
||||||
|
$stRules->execute($params);
|
||||||
|
$rules = $stRules->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
if (empty($rules)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$zeitraeumeByImpfstoff = impfGetZeitraeumeByImpfstoff($pdo, true);
|
||||||
|
$sent = [];
|
||||||
|
|
||||||
|
foreach ($rules as $rule) {
|
||||||
|
$currentImpfstoffId = (int)$rule['impfstoff_id'];
|
||||||
|
$dosen = (int)$rule['dosen_pro_flasche'];
|
||||||
|
if ($currentImpfstoffId <= 0 || $dosen <= 0 || empty($zeitraeumeByImpfstoff[$currentImpfstoffId])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($zeitraeumeByImpfstoff[$currentImpfstoffId] as $zeitraum) {
|
||||||
|
$currentZeitraumId = (int)($zeitraum['zeitraum_id'] ?? 0);
|
||||||
|
if ($currentZeitraumId <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!empty($zeitraumIds) && !in_array($currentZeitraumId, $zeitraumIds, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wartende = impfWorkflowNotificationCountWaitersForPlan($pdo, $currentImpfstoffId, $currentZeitraumId);
|
||||||
|
$sent = array_merge(
|
||||||
|
$sent,
|
||||||
|
impfWorkflowNotificationSendForPlan(
|
||||||
|
$pdo,
|
||||||
|
$currentImpfstoffId,
|
||||||
|
(string)$rule['impfname'],
|
||||||
|
$currentZeitraumId,
|
||||||
|
(string)($zeitraum['label'] ?? ''),
|
||||||
|
$wartende,
|
||||||
|
$dosen
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sent;
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
-10
@@ -3,6 +3,7 @@
|
|||||||
require_once(__DIR__ . "/../inc/config.inc.php");
|
require_once(__DIR__ . "/../inc/config.inc.php");
|
||||||
require_once(__DIR__ . "/../inc/functions.inc.php");
|
require_once(__DIR__ . "/../inc/functions.inc.php");
|
||||||
require_once(__DIR__ . "/../inc/functions.impfen.inc.php");
|
require_once(__DIR__ . "/../inc/functions.impfen.inc.php");
|
||||||
|
require_once(__DIR__ . "/../inc/impfworkflow_notifications.inc.php");
|
||||||
|
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
@@ -66,7 +67,7 @@ $zeitOptionenJson = json_encode($zeitOptionenByImpfstoff, JSON_UNESCAPED_UNICODE
|
|||||||
|
|
||||||
$form = [
|
$form = [
|
||||||
'impfstoff_id' => (int)($_POST['impfstoff_id'] ?? 0),
|
'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),
|
'impfart' => (int)($_POST['impfart'] ?? 0),
|
||||||
'letzteimpfung' => trim((string)($_POST['letzteimpfung'] ?? '')),
|
'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");
|
ORDER BY w.date_created DESC, w.warteid DESC");
|
||||||
$stActive->execute(['pid' => $personId]);
|
$stActive->execute(['pid' => $personId]);
|
||||||
$activeWaitRows = $stActive->fetchAll(PDO::FETCH_ASSOC);
|
$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') {
|
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST' && (string)($_POST['aktion'] ?? '') === 'create_waitlist') {
|
||||||
try {
|
try {
|
||||||
@@ -89,7 +94,7 @@ if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST' && (string)($_POST['aktion'
|
|||||||
$pdo,
|
$pdo,
|
||||||
$personId,
|
$personId,
|
||||||
(int)$form['impfstoff_id'],
|
(int)$form['impfstoff_id'],
|
||||||
(int)$form['zeitraum_id'],
|
$form['zeitraum_ids'],
|
||||||
(int)$form['impfart'],
|
(int)$form['impfart'],
|
||||||
$form['letzteimpfung'] !== '' ? $form['letzteimpfung'] : null,
|
$form['letzteimpfung'] !== '' ? $form['letzteimpfung'] : null,
|
||||||
1
|
1
|
||||||
@@ -106,6 +111,13 @@ if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST' && (string)($_POST['aktion'
|
|||||||
|
|
||||||
$stActive->execute(['pid' => $personId]);
|
$stActive->execute(['pid' => $personId]);
|
||||||
$activeWaitRows = $stActive->fetchAll(PDO::FETCH_ASSOC);
|
$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 {
|
} else {
|
||||||
$errorMessage = (string)$message;
|
$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 "Sie koennen im internen Bereich mehrere verschiedene Wartelistenanfragen anlegen. Exakte Duplikate werden weiterhin geblockt.";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo "<table class='table table-bordered table-striped'>";
|
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) {
|
foreach ($activeWaitRows as $activeWaitRow) {
|
||||||
$statusText = ((int)$activeWaitRow['checked'] === 1) ? 'Bestaetigt' : 'Unbestaetigt';
|
$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 "<tr>";
|
||||||
echo "<td>" . e((string)($activeWaitRow['impfname'] ?? 'Unbekannt')) . "</td>";
|
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((string)($impfartLabels[(int)$activeWaitRow['impfart']] ?? ('Status ' . (int)$activeWaitRow['impfart']))) . "</td>";
|
||||||
echo "<td>" . e($statusText) . "</td>";
|
echo "<td>" . e($statusText) . "</td>";
|
||||||
echo "<td>" . e((string)($activeWaitRow['letzteimpfung'] ?? '')) . "</td>";
|
echo "<td>" . e((string)($activeWaitRow['letzteimpfung'] ?? '')) . "</td>";
|
||||||
@@ -178,8 +195,8 @@ if (empty($verfuegbareImpfstoffe)) {
|
|||||||
|
|
||||||
<div class="row" style="margin-top:12px;">
|
<div class="row" style="margin-top:12px;">
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<label for="zeitraum_id">Welcher Zeitbereich passt fuer Sie?</label>
|
<label for="zeitraum_ids">Welche Zeitbereiche passen fuer Sie?</label>
|
||||||
<select class="form-control" name="zeitraum_id" id="zeitraum_id" required disabled>
|
<select class="form-control" name="zeitraum_ids[]" id="zeitraum_ids" required multiple size="6" disabled onchange="checkLetzteImpfung()">
|
||||||
<option value="">- Bitte zuerst Impfstoff auswaehlen -</option>
|
<option value="">- Bitte zuerst Impfstoff auswaehlen -</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -215,11 +232,11 @@ if (empty($verfuegbareImpfstoffe)) {
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
const zeitfensterByImpfstoff = <?php echo $zeitOptionenJson ?: '{}'; ?>;
|
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() {
|
function updateZeitfenster() {
|
||||||
const impfstoff = document.getElementById('impfstoff_id');
|
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 submit = document.getElementById('submit_waitlist');
|
||||||
const impfstoffId = impfstoff.value;
|
const impfstoffId = impfstoff.value;
|
||||||
const optionen = zeitfensterByImpfstoff[impfstoffId] || [];
|
const optionen = zeitfensterByImpfstoff[impfstoffId] || [];
|
||||||
@@ -228,7 +245,7 @@ if (empty($verfuegbareImpfstoffe)) {
|
|||||||
if (!impfstoffId || optionen.length === 0) {
|
if (!impfstoffId || optionen.length === 0) {
|
||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = '';
|
opt.value = '';
|
||||||
opt.textContent = '- Kein Zeitfenster verfuegbar -';
|
opt.textContent = '- Keine Zeitfenster verfuegbar -';
|
||||||
zeitraum.appendChild(opt);
|
zeitraum.appendChild(opt);
|
||||||
zeitraum.disabled = true;
|
zeitraum.disabled = true;
|
||||||
submit.disabled = true;
|
submit.disabled = true;
|
||||||
@@ -244,7 +261,7 @@ if (empty($verfuegbareImpfstoffe)) {
|
|||||||
const opt = document.createElement('option');
|
const opt = document.createElement('option');
|
||||||
opt.value = String(eintrag.id || '');
|
opt.value = String(eintrag.id || '');
|
||||||
opt.textContent = eintrag.label || '';
|
opt.textContent = eintrag.label || '';
|
||||||
if (initialZeitraumId > 0 && Number(eintrag.id) === initialZeitraumId) {
|
if (initialZeitraumIds.includes(Number(eintrag.id))) {
|
||||||
opt.selected = true;
|
opt.selected = true;
|
||||||
}
|
}
|
||||||
zeitraum.appendChild(opt);
|
zeitraum.appendChild(opt);
|
||||||
@@ -252,12 +269,24 @@ if (empty($verfuegbareImpfstoffe)) {
|
|||||||
|
|
||||||
zeitraum.disabled = false;
|
zeitraum.disabled = false;
|
||||||
submit.disabled = false;
|
submit.disabled = false;
|
||||||
|
checkLetzteImpfung();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkLetzteImpfung() {
|
function checkLetzteImpfung() {
|
||||||
const impfart = document.getElementById('impfart');
|
const impfart = document.getElementById('impfart');
|
||||||
const box = document.getElementById('letzteimpfung_box');
|
const box = document.getElementById('letzteimpfung_box');
|
||||||
const input = document.getElementById('letzteimpfung');
|
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') {
|
if (impfart.value === '' || impfart.value === '1') {
|
||||||
box.style.display = 'none';
|
box.style.display = 'none';
|
||||||
|
|||||||
Reference in New Issue
Block a user