Anpassung Ladezeit Impfen + Urlaubsplaner
This commit is contained in:
+127
-97
@@ -405,6 +405,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
SendMailMessageVorlage($pdo, '1', $tid, $mailTemplateId);
|
||||
}
|
||||
|
||||
impfWorkflowNotificationProcess($pdo);
|
||||
$message = count($terminIds) . " Terminanfragen wurden erstellt und versendet.";
|
||||
} catch (Throwable $e) {
|
||||
if ($pdo->inTransaction()) {
|
||||
@@ -436,7 +437,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
1
|
||||
);
|
||||
if ($ok) {
|
||||
$notificationEvents = impfWorkflowNotificationProcess($pdo);
|
||||
$message = $msg;
|
||||
if (!empty($notificationEvents)) {
|
||||
$message .= ' ' . count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet.";
|
||||
}
|
||||
} else {
|
||||
$error = $msg;
|
||||
}
|
||||
@@ -481,7 +486,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
1
|
||||
);
|
||||
if ($ok) {
|
||||
$notificationEvents = impfWorkflowNotificationProcess($pdo);
|
||||
$message = $msg;
|
||||
if (!empty($notificationEvents)) {
|
||||
$message .= ' ' . count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet.";
|
||||
}
|
||||
} else {
|
||||
$error = $msg;
|
||||
}
|
||||
@@ -595,6 +604,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$exists = (bool)$stDelete->fetch(PDO::FETCH_ASSOC);
|
||||
workflowDeleteWaitlistEntry($pdo, $warteid);
|
||||
if ($exists) {
|
||||
impfWorkflowNotificationProcess($pdo);
|
||||
$message = "Wartelisten-Eintrag wurde gelöscht.";
|
||||
} else {
|
||||
$error = "Wartelisten-Eintrag nicht gefunden.";
|
||||
@@ -663,51 +673,67 @@ $eventOverview = [];
|
||||
$planWaitCounts = [];
|
||||
|
||||
try {
|
||||
$stRules = $pdo->prepare("SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname,
|
||||
COALESCE((SELECT COUNT(DISTINCT w.userid) FROM warteliste w WHERE w.checked = 1 AND (w.impfstoff = r.impfstoff_id OR w.impfstoff = 0)),0) AS wartende
|
||||
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)
|
||||
ORDER BY i.impfname");
|
||||
$stRules->execute();
|
||||
$rules = $stRules->fetchAll(PDO::FETCH_ASSOC);
|
||||
$needsPlanData = in_array($view, ['teilnehmer', 'event-create'], true);
|
||||
$needsEligibilityData = ($view === 'event-create');
|
||||
$needsPersonSearch = ($view === 'teilnehmer' && $personSearch !== '');
|
||||
$needsWaitRows = ($view === 'warteliste');
|
||||
$needsUpcomingRows = ($view === 'event-teilnehmer');
|
||||
|
||||
$plans = impfGetZeitraumRows($pdo, true);
|
||||
if ($needsPlanData) {
|
||||
$stRules = $pdo->prepare("SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname,
|
||||
COALESCE((SELECT COUNT(DISTINCT w.userid) FROM warteliste w WHERE w.checked = 1 AND (w.impfstoff = r.impfstoff_id OR w.impfstoff = 0)),0) AS wartende
|
||||
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)
|
||||
ORDER BY i.impfname");
|
||||
$stRules->execute();
|
||||
$rules = $stRules->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$planExistsForImpfstoff = [];
|
||||
foreach ($plans as $p) {
|
||||
foreach ($p['impfstoff_id_list'] as $impfstoffId) {
|
||||
$planExistsForImpfstoff[(int)$impfstoffId] = true;
|
||||
}
|
||||
}
|
||||
$plans = impfGetZeitraumRows($pdo, true);
|
||||
|
||||
foreach ($rules as $r) {
|
||||
$iid = (int)$r['impfstoff_id'];
|
||||
$dosen = (int)$r['dosen_pro_flasche'];
|
||||
if ($dosen <= 0 || !isset($planExistsForImpfstoff[$iid])) {
|
||||
continue;
|
||||
$planExistsForImpfstoff = [];
|
||||
foreach ($plans as $p) {
|
||||
foreach ($p['impfstoff_id_list'] as $impfstoffId) {
|
||||
$planExistsForImpfstoff[(int)$impfstoffId] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$configuredImpfstoffe[] = $r;
|
||||
$hasEligiblePlan = false;
|
||||
foreach ($plans as $plan) {
|
||||
if (!in_array($iid, $plan['impfstoff_id_list'] ?? [], true)) {
|
||||
foreach ($rules as $r) {
|
||||
$iid = (int)$r['impfstoff_id'];
|
||||
if (!isset($planExistsForImpfstoff[$iid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$planId = (int)$plan['zeitraum_id'];
|
||||
$planWaitCounts[$iid][$planId] = workflowCountWaitersForPlan($pdo, $iid, $planId);
|
||||
if ($planWaitCounts[$iid][$planId] >= $dosen) {
|
||||
$hasEligiblePlan = true;
|
||||
$configuredImpfstoffe[] = $r;
|
||||
if (!$needsEligibilityData) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hasEligiblePlan) {
|
||||
$eligible[] = $r;
|
||||
$dosen = (int)$r['dosen_pro_flasche'];
|
||||
if ($dosen <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($personSearch !== '') {
|
||||
if ($needsPersonSearch) {
|
||||
$searchLike = '%' . $personSearch . '%';
|
||||
$searchExactId = ctype_digit($personSearch) ? (int)$personSearch : -1;
|
||||
$stPersons = $pdo->prepare("SELECT person_id, vorname, nachname, geburtstag, email, tele, ort, plz, strasse
|
||||
@@ -726,74 +752,78 @@ try {
|
||||
$personResults = $stPersons->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
$stWait = $pdo->prepare("SELECT w.warteid, w.userid, w.checked, w.impfstoff, w.impfart, w.impfenzeitraum, w.zeitraum_id, w.letzteimpfung, w.date_created,
|
||||
p.vorname, p.nachname, p.geburtstag, p.email, p.tele,
|
||||
i.impfname
|
||||
FROM warteliste w
|
||||
INNER JOIN persons p ON p.person_id = w.userid
|
||||
LEFT JOIN impfstoff i ON i.impfid = w.impfstoff
|
||||
WHERE w.checked IN (0, 1)
|
||||
ORDER BY w.checked DESC, w.date_created ASC
|
||||
LIMIT 500");
|
||||
$stWait->execute();
|
||||
$waitRows = $stWait->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($needsWaitRows) {
|
||||
$stWait = $pdo->prepare("SELECT w.warteid, w.userid, w.checked, w.impfstoff, w.impfart, w.impfenzeitraum, w.zeitraum_id, w.letzteimpfung, w.date_created,
|
||||
p.vorname, p.nachname, p.geburtstag, p.email, p.tele,
|
||||
i.impfname
|
||||
FROM warteliste w
|
||||
INNER JOIN persons p ON p.person_id = w.userid
|
||||
LEFT JOIN impfstoff i ON i.impfid = w.impfstoff
|
||||
WHERE w.checked IN (0, 1)
|
||||
ORDER BY w.checked DESC, w.date_created ASC
|
||||
LIMIT 500");
|
||||
$stWait->execute();
|
||||
$waitRows = $stWait->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($waitRows as &$waitRow) {
|
||||
$waitRow['zeitraum_labels'] = impfGetWartelistenZeitraeumeLabels($pdo, (int)$waitRow['warteid'], false);
|
||||
if (!empty($waitRow['zeitraum_labels'])) {
|
||||
$waitRow['impfenzeitraum'] = implode(' | ', $waitRow['zeitraum_labels']);
|
||||
$waitIds = array_map(static function (array $waitRow): int {
|
||||
return (int)($waitRow['warteid'] ?? 0);
|
||||
}, $waitRows);
|
||||
$waitLabelsById = impfGetWartelistenZeitraeumeLabelsMap($pdo, $waitIds, false);
|
||||
|
||||
foreach ($waitRows as &$waitRow) {
|
||||
$warteid = (int)($waitRow['warteid'] ?? 0);
|
||||
$waitRow['zeitraum_labels'] = $waitLabelsById[$warteid] ?? [];
|
||||
if (!empty($waitRow['zeitraum_labels'])) {
|
||||
$waitRow['impfenzeitraum'] = implode(' | ', $waitRow['zeitraum_labels']);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($waitRow);
|
||||
|
||||
$notificationEvents = impfWorkflowNotificationProcess($pdo);
|
||||
if (!empty($notificationEvents)) {
|
||||
$notificationText = count($notificationEvents) . " Impfworkflow-Benachrichtigung(en) wurden versendet.";
|
||||
$message = ($message === '') ? $notificationText : ($message . ' ' . $notificationText);
|
||||
unset($waitRow);
|
||||
}
|
||||
|
||||
$stUpcoming = $pdo->prepare("SELECT ts.timeid, ts.date, ts.start, ts.ende, ts.impfdosen,
|
||||
i.impfname, o.anzeigename, o.adresse,
|
||||
it.terminid, it.checked, it.behandelt, it.impfart,
|
||||
p.vorname, p.nachname, p.geburtstag, p.email, p.tele
|
||||
FROM timeslots ts
|
||||
INNER JOIN impfstoff i ON i.impfid = ts.impfstoff
|
||||
LEFT JOIN impfort o ON o.ortid = ts.impfortid
|
||||
LEFT JOIN impftermin it ON it.timeid = ts.timeid
|
||||
LEFT JOIN persons p ON p.person_id = it.userid
|
||||
WHERE ts.date >= :today
|
||||
AND ts.aktiv = 1
|
||||
ORDER BY ts.date, ts.start, ts.ende, i.impfname, p.nachname, p.vorname");
|
||||
$stUpcoming->execute(['today' => date('Y-m-d')]);
|
||||
$upcomingRows = $stUpcoming->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($needsUpcomingRows) {
|
||||
$stUpcoming = $pdo->prepare("SELECT ts.timeid, ts.date, ts.start, ts.ende, ts.impfdosen,
|
||||
i.impfname, o.anzeigename, o.adresse,
|
||||
it.terminid, it.checked, it.behandelt, it.impfart,
|
||||
p.vorname, p.nachname, p.geburtstag, p.email, p.tele
|
||||
FROM timeslots ts
|
||||
INNER JOIN impfstoff i ON i.impfid = ts.impfstoff
|
||||
LEFT JOIN impfort o ON o.ortid = ts.impfortid
|
||||
LEFT JOIN impftermin it ON it.timeid = ts.timeid
|
||||
LEFT JOIN persons p ON p.person_id = it.userid
|
||||
WHERE ts.date >= :today
|
||||
AND ts.aktiv = 1
|
||||
ORDER BY ts.date, ts.start, ts.ende, i.impfname, p.nachname, p.vorname");
|
||||
$stUpcoming->execute(['today' => date('Y-m-d')]);
|
||||
$upcomingRows = $stUpcoming->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($upcomingRows as $row) {
|
||||
$timeid = (int)$row['timeid'];
|
||||
if (!isset($eventOverview[$timeid])) {
|
||||
$eventOverview[$timeid] = [
|
||||
'timeid' => $timeid,
|
||||
'date' => $row['date'],
|
||||
'start' => $row['start'],
|
||||
'ende' => $row['ende'],
|
||||
'impfdosen' => (int)$row['impfdosen'],
|
||||
'impfname' => $row['impfname'],
|
||||
'anzeigename' => $row['anzeigename'],
|
||||
'adresse' => $row['adresse'],
|
||||
'teilnehmer' => [],
|
||||
];
|
||||
}
|
||||
if (!empty($row['terminid'])) {
|
||||
$eventOverview[$timeid]['teilnehmer'][] = [
|
||||
'terminid' => (int)$row['terminid'],
|
||||
'checked' => (int)($row['checked'] ?? 0),
|
||||
'behandelt' => (int)($row['behandelt'] ?? 0),
|
||||
'impfart' => (int)($row['impfart'] ?? 1),
|
||||
'vorname' => (string)($row['vorname'] ?? ''),
|
||||
'nachname' => (string)($row['nachname'] ?? ''),
|
||||
'geburtstag' => (string)($row['geburtstag'] ?? ''),
|
||||
'email' => (string)($row['email'] ?? ''),
|
||||
'tele' => (string)($row['tele'] ?? ''),
|
||||
];
|
||||
foreach ($upcomingRows as $row) {
|
||||
$timeid = (int)$row['timeid'];
|
||||
if (!isset($eventOverview[$timeid])) {
|
||||
$eventOverview[$timeid] = [
|
||||
'timeid' => $timeid,
|
||||
'date' => $row['date'],
|
||||
'start' => $row['start'],
|
||||
'ende' => $row['ende'],
|
||||
'impfdosen' => (int)$row['impfdosen'],
|
||||
'impfname' => $row['impfname'],
|
||||
'anzeigename' => $row['anzeigename'],
|
||||
'adresse' => $row['adresse'],
|
||||
'teilnehmer' => [],
|
||||
];
|
||||
}
|
||||
if (!empty($row['terminid'])) {
|
||||
$eventOverview[$timeid]['teilnehmer'][] = [
|
||||
'terminid' => (int)$row['terminid'],
|
||||
'checked' => (int)($row['checked'] ?? 0),
|
||||
'behandelt' => (int)($row['behandelt'] ?? 0),
|
||||
'impfart' => (int)($row['impfart'] ?? 1),
|
||||
'vorname' => (string)($row['vorname'] ?? ''),
|
||||
'nachname' => (string)($row['nachname'] ?? ''),
|
||||
'geburtstag' => (string)($row['geburtstag'] ?? ''),
|
||||
'email' => (string)($row['email'] ?? ''),
|
||||
'tele' => (string)($row['tele'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
@@ -1257,5 +1287,5 @@ try {
|
||||
</div>
|
||||
|
||||
<?php include __DIR__ . "/templates/footer.inc.php"; ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user