Enhance waitlist functionality: update queries to count distinct users, add new impfwarteliste.php page, and improve form handling in functions.impfen.inc.php
This commit is contained in:
+18
-7
@@ -235,7 +235,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
} else {
|
||||
$dosen = (int)$rule['dosen_pro_flasche'];
|
||||
|
||||
$stCount = $pdo->prepare("SELECT COUNT(*)
|
||||
$stCount = $pdo->prepare("SELECT COUNT(DISTINCT userid)
|
||||
FROM warteliste
|
||||
WHERE checked = 1
|
||||
AND (impfstoff = :iid OR impfstoff = 0)
|
||||
@@ -291,16 +291,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
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
|
||||
LIMIT :lim");
|
||||
ORDER BY date_created ASC, warteid ASC");
|
||||
$stW->bindValue(':iid', $impfstoffId, PDO::PARAM_INT);
|
||||
$stW->bindValue(':zid', $planId, PDO::PARAM_INT);
|
||||
$stW->bindValue(':lim', $dosen, PDO::PARAM_INT);
|
||||
$stW->execute();
|
||||
$warteRows = $stW->fetchAll(PDO::FETCH_ASSOC);
|
||||
$warteRowsRaw = $stW->fetchAll(PDO::FETCH_ASSOC);
|
||||
$warteRows = [];
|
||||
$seenUserIds = [];
|
||||
foreach ($warteRowsRaw as $warteRow) {
|
||||
$warteUserId = (int)$warteRow['userid'];
|
||||
if (isset($seenUserIds[$warteUserId])) {
|
||||
continue;
|
||||
}
|
||||
$seenUserIds[$warteUserId] = true;
|
||||
$warteRows[] = $warteRow;
|
||||
if (count($warteRows) >= $dosen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($warteRows) < $dosen) {
|
||||
throw new RuntimeException("Warteliste während Verarbeitung zu klein geworden.");
|
||||
throw new RuntimeException("Warteliste waehrend Verarbeitung zu klein geworden.");
|
||||
}
|
||||
|
||||
$stInsTermin = $pdo->prepare("INSERT INTO impftermin
|
||||
@@ -540,7 +551,7 @@ $eventOverview = [];
|
||||
|
||||
try {
|
||||
$stRules = $pdo->prepare("SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname,
|
||||
COALESCE((SELECT COUNT(*) FROM warteliste w WHERE w.checked = 1 AND (w.impfstoff = r.impfstoff_id OR w.impfstoff = 0)),0) AS wartende
|
||||
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)
|
||||
|
||||
@@ -411,7 +411,7 @@ $allImpforte = getImpforte($pdo, false);
|
||||
$zeitraeume = impfGetZeitraumRows($pdo, true);
|
||||
|
||||
$stRules = $pdo->prepare("SELECT r.impfstoff_id, r.dosen_pro_flasche, i.impfname,
|
||||
COALESCE((SELECT COUNT(*) FROM warteliste w WHERE w.checked = 1 AND (w.impfstoff = r.impfstoff_id OR w.impfstoff = 0)),0) AS wartende
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user