Anpassung Ladezeit Impfen + Urlaubsplaner
This commit is contained in:
@@ -550,6 +550,100 @@ if (!function_exists('impfGetWartelistenZeitraeumeLabels')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('impfGetWartelistenZeitraeumeLabelsMap')) {
|
||||
function impfGetWartelistenZeitraeumeLabelsMap(PDO $pdo, array $warteids, bool $onlyActive = false): array
|
||||
{
|
||||
$warteids = array_values(array_unique(array_filter(array_map('intval', $warteids), static function (int $warteid): bool {
|
||||
return $warteid > 0;
|
||||
})));
|
||||
|
||||
if (empty($warteids) || !impfTableExists($pdo, 'warteliste_zeitraum')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($warteids as $warteid) {
|
||||
$result[$warteid] = [];
|
||||
}
|
||||
|
||||
$placeholders = [];
|
||||
$params = [];
|
||||
foreach ($warteids as $index => $warteid) {
|
||||
$key = 'wid' . $index;
|
||||
$placeholders[] = ':' . $key;
|
||||
$params[$key] = $warteid;
|
||||
}
|
||||
$inList = implode(', ', $placeholders);
|
||||
|
||||
$sql = "SELECT wz.warteid, 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 IN (" . $inList . ")";
|
||||
if ($onlyActive) {
|
||||
$sql .= " AND z.aktiv = 1";
|
||||
}
|
||||
$sql .= " ORDER BY wz.warteid, z.wochentag, z.start, z.ende, z.bezeichnung, z.zeitraum_id";
|
||||
|
||||
$st = $pdo->prepare($sql);
|
||||
$st->execute($params);
|
||||
$rows = $st->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$warteid = (int)($row['warteid'] ?? 0);
|
||||
if ($warteid <= 0) {
|
||||
continue;
|
||||
}
|
||||
$row['label'] = impfZeitraumLabel($row);
|
||||
$result[$warteid][] = (string)$row['label'];
|
||||
}
|
||||
|
||||
$missing = array_values(array_filter($warteids, static function (int $warteid) use ($result): bool {
|
||||
return empty($result[$warteid]);
|
||||
}));
|
||||
|
||||
if (empty($missing)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$fallbackPlaceholders = [];
|
||||
$fallbackParams = [];
|
||||
foreach ($missing as $index => $warteid) {
|
||||
$key = 'f_wid' . $index;
|
||||
$fallbackPlaceholders[] = ':' . $key;
|
||||
$fallbackParams[$key] = $warteid;
|
||||
}
|
||||
$fallbackInList = implode(', ', $fallbackPlaceholders);
|
||||
|
||||
$fallbackSql = "SELECT w.warteid, 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 IN (" . $fallbackInList . ")
|
||||
AND w.zeitraum_id IS NOT NULL";
|
||||
if ($onlyActive) {
|
||||
$fallbackSql .= " AND z.aktiv = 1";
|
||||
}
|
||||
|
||||
$stFallback = $pdo->prepare($fallbackSql);
|
||||
$stFallback->execute($fallbackParams);
|
||||
$fallbackRows = $stFallback->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($fallbackRows as $row) {
|
||||
$warteid = (int)($row['warteid'] ?? 0);
|
||||
if ($warteid <= 0) {
|
||||
continue;
|
||||
}
|
||||
$row['label'] = impfZeitraumLabel($row);
|
||||
$result[$warteid] = [(string)$row['label']];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('impfSetWartelistenZeitraeume')) {
|
||||
function impfSetWartelistenZeitraeume(PDO $pdo, int $warteid, $zeitraumIds): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user