Inital
This commit is contained in:
@@ -0,0 +1,735 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
require_once __DIR__ . "/../inc/config.inc.php";
|
||||
require_once __DIR__ . "/../inc/functions.inc.php";
|
||||
require_once __DIR__ . "/../inc/functions.impfen.inc.php";
|
||||
|
||||
$user = check_admin_user();
|
||||
include __DIR__ . "/templates/header.inc.php";
|
||||
|
||||
if (!$user) {
|
||||
echo "<div class='container main-container'><h3>Erst anmelden: <a href='login.php'>Login</a></h3></div>";
|
||||
include __DIR__ . "/templates/footer.inc.php";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!check_worker()) {
|
||||
echo "<div class='container main-container'>Dieser Bereich ist nur fuer Bearbeiter freigeschaltet.</div>";
|
||||
include __DIR__ . "/templates/footer.inc.php";
|
||||
exit;
|
||||
}
|
||||
|
||||
function esc($v): string
|
||||
{
|
||||
return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function weekdayName(int $d): string
|
||||
{
|
||||
$map = [1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag', 7 => 'Sonntag'];
|
||||
return $map[$d] ?? 'Unbekannt';
|
||||
}
|
||||
|
||||
function ensureWorkflowTables(PDO $pdo): void
|
||||
{
|
||||
impfWorkflowEnsureTables($pdo);
|
||||
}
|
||||
|
||||
function tableHasColumn(PDO $pdo, string $table, string $column): bool
|
||||
{
|
||||
static $cache = [];
|
||||
$cacheKey = $table . '.' . $column;
|
||||
if (array_key_exists($cacheKey, $cache)) {
|
||||
return $cache[$cacheKey];
|
||||
}
|
||||
|
||||
$st = $pdo->prepare("SHOW COLUMNS FROM `" . $table . "` LIKE :column");
|
||||
$st->execute(['column' => $column]);
|
||||
$cache[$cacheKey] = (bool)$st->fetch(PDO::FETCH_ASSOC);
|
||||
return $cache[$cacheKey];
|
||||
}
|
||||
|
||||
function getImpfstoffe(PDO $pdo, bool $onlyActive = true): array
|
||||
{
|
||||
$sql = "SELECT impfid, impfname, sortierung, aktiv, aktivwarteliste, aktivtermin, aktivgrippe
|
||||
FROM impfstoff";
|
||||
if ($onlyActive) {
|
||||
$sql .= " WHERE aktiv = 1 OR aktivwarteliste = 1 OR aktivtermin = 1 OR aktivgrippe = 1";
|
||||
}
|
||||
$sql .= " ORDER BY sortierung, impfname";
|
||||
|
||||
$st = $pdo->prepare($sql);
|
||||
$st->execute();
|
||||
return $st->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function getImpforte(PDO $pdo, bool $onlyActive = true): array
|
||||
{
|
||||
$sql = "SELECT ortid, anzeigename, adresse, aktiv";
|
||||
if (tableHasColumn($pdo, 'impfort', 'art')) {
|
||||
$sql .= ", art";
|
||||
}
|
||||
$sql .= " FROM impfort";
|
||||
if ($onlyActive) {
|
||||
$sql .= " WHERE aktiv = 1";
|
||||
}
|
||||
$sql .= " ORDER BY anzeigename, adresse";
|
||||
|
||||
$st = $pdo->prepare($sql);
|
||||
$st->execute();
|
||||
return $st->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
function setImpfstoffAktiv(PDO $pdo, int $impfstoffId, int $aktiv): void
|
||||
{
|
||||
if ($aktiv === 1) {
|
||||
$st = $pdo->prepare("UPDATE impfstoff
|
||||
SET aktiv = 1,
|
||||
aktivwarteliste = 1,
|
||||
aktivtermin = 1
|
||||
WHERE impfid = :iid");
|
||||
$st->execute(['iid' => $impfstoffId]);
|
||||
return;
|
||||
}
|
||||
|
||||
$st = $pdo->prepare("UPDATE impfstoff
|
||||
SET aktiv = 0,
|
||||
aktivwarteliste = 0,
|
||||
aktivtermin = 0,
|
||||
aktivgrippe = 0
|
||||
WHERE impfid = :iid");
|
||||
$st->execute(['iid' => $impfstoffId]);
|
||||
}
|
||||
|
||||
function setImpfortAktiv(PDO $pdo, int $impfortId, int $aktiv): void
|
||||
{
|
||||
$st = $pdo->prepare("UPDATE impfort
|
||||
SET aktiv = :aktiv
|
||||
WHERE ortid = :oid");
|
||||
$st->execute([
|
||||
'aktiv' => $aktiv,
|
||||
'oid' => $impfortId,
|
||||
]);
|
||||
}
|
||||
|
||||
$message = "";
|
||||
$error = "";
|
||||
|
||||
try {
|
||||
ensureWorkflowTables($pdo);
|
||||
} catch (Throwable $e) {
|
||||
$error = "Workflow-Tabellen konnten nicht erstellt werden: " . $e->getMessage();
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$aktion = (string)($_POST['aktion'] ?? '');
|
||||
|
||||
if ($aktion === 'add_impfstoff') {
|
||||
$impfname = trim((string)($_POST['impfname'] ?? ''));
|
||||
$sortierung = (int)($_POST['sortierung'] ?? 100);
|
||||
|
||||
if ($impfname === '') {
|
||||
$error = "Bitte einen Impfstoffnamen eingeben.";
|
||||
} else {
|
||||
try {
|
||||
$stExisting = $pdo->prepare("SELECT impfid FROM impfstoff WHERE LOWER(TRIM(impfname)) = LOWER(TRIM(:name)) LIMIT 1");
|
||||
$stExisting->execute(['name' => $impfname]);
|
||||
$existingId = (int)($stExisting->fetchColumn() ?: 0);
|
||||
|
||||
if ($existingId > 0) {
|
||||
$stUpdate = $pdo->prepare("UPDATE impfstoff
|
||||
SET impfname = :name,
|
||||
sortierung = :sortierung
|
||||
WHERE impfid = :iid");
|
||||
$stUpdate->execute([
|
||||
'name' => $impfname,
|
||||
'sortierung' => $sortierung,
|
||||
'iid' => $existingId,
|
||||
]);
|
||||
setImpfstoffAktiv($pdo, $existingId, 1);
|
||||
$message = "Impfstoff wurde reaktiviert und aktualisiert.";
|
||||
} else {
|
||||
$stInsert = $pdo->prepare("INSERT INTO impfstoff
|
||||
(impfname, sortierung, aktiv, aktivwarteliste, aktivtermin, aktivgrippe)
|
||||
VALUES
|
||||
(:name, :sortierung, 1, 1, 1, 0)");
|
||||
$stInsert->execute([
|
||||
'name' => $impfname,
|
||||
'sortierung' => $sortierung,
|
||||
]);
|
||||
$message = "Impfstoff wurde hinzugefuegt.";
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$error = "Impfstoff konnte nicht gespeichert werden: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'toggle_impfstoff') {
|
||||
$impfstoffId = (int)($_POST['impfstoff_id'] ?? 0);
|
||||
$aktiv = ((int)($_POST['aktiv'] ?? 0) === 1) ? 1 : 0;
|
||||
|
||||
if ($impfstoffId <= 0) {
|
||||
$error = "Bitte einen gueltigen Impfstoff auswaehlen.";
|
||||
} else {
|
||||
setImpfstoffAktiv($pdo, $impfstoffId, $aktiv);
|
||||
$message = ($aktiv === 1) ? "Impfstoff wurde aktiviert." : "Impfstoff wurde deaktiviert.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'add_impfort') {
|
||||
$anzeigename = trim((string)($_POST['anzeigename'] ?? ''));
|
||||
$adresse = trim((string)($_POST['adresse'] ?? ''));
|
||||
$art = trim((string)($_POST['art'] ?? ''));
|
||||
|
||||
if ($anzeigename === '' || $adresse === '') {
|
||||
$error = "Bitte Standortname und Adresse eingeben.";
|
||||
} else {
|
||||
try {
|
||||
$stExisting = $pdo->prepare("SELECT ortid FROM impfort WHERE LOWER(TRIM(anzeigename)) = LOWER(TRIM(:name)) AND LOWER(TRIM(adresse)) = LOWER(TRIM(:adresse)) LIMIT 1");
|
||||
$stExisting->execute([
|
||||
'name' => $anzeigename,
|
||||
'adresse' => $adresse,
|
||||
]);
|
||||
$existingId = (int)($stExisting->fetchColumn() ?: 0);
|
||||
|
||||
if ($existingId > 0) {
|
||||
if (tableHasColumn($pdo, 'impfort', 'art')) {
|
||||
$stUpdate = $pdo->prepare("UPDATE impfort
|
||||
SET anzeigename = :name,
|
||||
adresse = :adresse,
|
||||
art = :art
|
||||
WHERE ortid = :oid");
|
||||
$stUpdate->execute([
|
||||
'name' => $anzeigename,
|
||||
'adresse' => $adresse,
|
||||
'art' => $art,
|
||||
'oid' => $existingId,
|
||||
]);
|
||||
} else {
|
||||
$stUpdate = $pdo->prepare("UPDATE impfort
|
||||
SET anzeigename = :name,
|
||||
adresse = :adresse
|
||||
WHERE ortid = :oid");
|
||||
$stUpdate->execute([
|
||||
'name' => $anzeigename,
|
||||
'adresse' => $adresse,
|
||||
'oid' => $existingId,
|
||||
]);
|
||||
}
|
||||
setImpfortAktiv($pdo, $existingId, 1);
|
||||
$message = "Standort wurde reaktiviert und aktualisiert.";
|
||||
} else {
|
||||
if (tableHasColumn($pdo, 'impfort', 'art')) {
|
||||
$stInsert = $pdo->prepare("INSERT INTO impfort
|
||||
(anzeigename, adresse, art, aktiv)
|
||||
VALUES
|
||||
(:name, :adresse, :art, 1)");
|
||||
$stInsert->execute([
|
||||
'name' => $anzeigename,
|
||||
'adresse' => $adresse,
|
||||
'art' => $art,
|
||||
]);
|
||||
} else {
|
||||
$stInsert = $pdo->prepare("INSERT INTO impfort
|
||||
(anzeigename, adresse, aktiv)
|
||||
VALUES
|
||||
(:name, :adresse, 1)");
|
||||
$stInsert->execute([
|
||||
'name' => $anzeigename,
|
||||
'adresse' => $adresse,
|
||||
]);
|
||||
}
|
||||
$message = "Standort wurde hinzugefuegt.";
|
||||
}
|
||||
} catch (Throwable $e) {
|
||||
$error = "Standort konnte nicht gespeichert werden: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'toggle_impfort') {
|
||||
$impfortId = (int)($_POST['impfort_id'] ?? 0);
|
||||
$aktiv = ((int)($_POST['aktiv'] ?? 0) === 1) ? 1 : 0;
|
||||
|
||||
if ($impfortId <= 0) {
|
||||
$error = "Bitte einen gueltigen Standort auswaehlen.";
|
||||
} else {
|
||||
setImpfortAktiv($pdo, $impfortId, $aktiv);
|
||||
$message = ($aktiv === 1) ? "Standort wurde aktiviert." : "Standort wurde deaktiviert.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'save_rule') {
|
||||
$impfstoffId = (int)($_POST['impfstoff_id'] ?? 0);
|
||||
$dosen = max(1, (int)($_POST['dosen_pro_flasche'] ?? 0));
|
||||
|
||||
if ($impfstoffId <= 0) {
|
||||
$error = "Bitte einen Impfstoff auswaehlen.";
|
||||
} else {
|
||||
$st = $pdo->prepare("INSERT INTO impfstoff_workflow (impfstoff_id, dosen_pro_flasche) VALUES (:iid, :dosen)
|
||||
ON DUPLICATE KEY UPDATE dosen_pro_flasche = VALUES(dosen_pro_flasche)");
|
||||
$st->execute(['iid' => $impfstoffId, 'dosen' => $dosen]);
|
||||
$message = "Stammdaten gespeichert.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'delete_rule') {
|
||||
$impfstoffId = (int)($_POST['impfstoff_id'] ?? 0);
|
||||
|
||||
if ($impfstoffId <= 0) {
|
||||
$error = "Bitte einen gueltigen Impfstoff auswaehlen.";
|
||||
} else {
|
||||
$st = $pdo->prepare("DELETE FROM impfstoff_workflow WHERE impfstoff_id = :iid");
|
||||
$st->execute(['iid' => $impfstoffId]);
|
||||
$message = "Stammdaten fuer den Impfstoff wurden entfernt.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'add_zeitraum') {
|
||||
$bezeichnung = trim((string)($_POST['bezeichnung'] ?? ''));
|
||||
$wochentag = (int)($_POST['wochentag'] ?? 0);
|
||||
$start = trim((string)($_POST['start'] ?? ''));
|
||||
$ende = trim((string)($_POST['ende'] ?? ''));
|
||||
$impfortId = (int)($_POST['impfortid'] ?? 0);
|
||||
|
||||
if ($wochentag < 1 || $wochentag > 7 || $start === '' || $ende === '' || $impfortId <= 0) {
|
||||
$error = "Bitte Zeitraum vollstaendig ausfuellen.";
|
||||
} else {
|
||||
$startSql = $start . ':00';
|
||||
$endeSql = $ende . ':00';
|
||||
|
||||
$stExisting = $pdo->prepare("SELECT zeitraum_id
|
||||
FROM impf_zeitraum
|
||||
WHERE bezeichnung = :bezeichnung
|
||||
AND wochentag = :wochentag
|
||||
AND start = :start
|
||||
AND ende = :ende
|
||||
AND impfortid = :impfortid
|
||||
LIMIT 1");
|
||||
$stExisting->execute([
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'wochentag' => $wochentag,
|
||||
'start' => $startSql,
|
||||
'ende' => $endeSql,
|
||||
'impfortid' => $impfortId,
|
||||
]);
|
||||
$existingId = (int)($stExisting->fetchColumn() ?: 0);
|
||||
|
||||
if ($existingId > 0) {
|
||||
$stUpdate = $pdo->prepare("UPDATE impf_zeitraum
|
||||
SET aktiv = 1
|
||||
WHERE zeitraum_id = :zid");
|
||||
$stUpdate->execute(['zid' => $existingId]);
|
||||
$message = "Zeitraum wurde reaktiviert.";
|
||||
} else {
|
||||
$st = $pdo->prepare("INSERT INTO impf_zeitraum (bezeichnung, wochentag, start, ende, impfortid, aktiv)
|
||||
VALUES (:bezeichnung, :wd, :start, :ende, :oid, 1)");
|
||||
$st->execute([
|
||||
'bezeichnung' => $bezeichnung,
|
||||
'wd' => $wochentag,
|
||||
'start' => $startSql,
|
||||
'ende' => $endeSql,
|
||||
'oid' => $impfortId,
|
||||
]);
|
||||
$message = "Zeitraum gespeichert.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'save_zeitraum_assignments') {
|
||||
$zeitraumId = (int)($_POST['zeitraum_id'] ?? 0);
|
||||
$impfstoffIds = array_values(array_unique(array_map('intval', $_POST['impfstoff_ids'] ?? [])));
|
||||
|
||||
if ($zeitraumId <= 0) {
|
||||
$error = "Bitte einen gueltigen Zeitraum auswaehlen.";
|
||||
} else {
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$stDelete = $pdo->prepare("DELETE FROM impf_zeitraum_impfstoff WHERE zeitraum_id = :zid");
|
||||
$stDelete->execute(['zid' => $zeitraumId]);
|
||||
|
||||
if (!empty($impfstoffIds)) {
|
||||
$stInsert = $pdo->prepare("INSERT INTO impf_zeitraum_impfstoff (zeitraum_id, impfstoff_id)
|
||||
VALUES (:zid, :iid)");
|
||||
foreach ($impfstoffIds as $impfstoffId) {
|
||||
if ($impfstoffId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$stInsert->execute([
|
||||
'zid' => $zeitraumId,
|
||||
'iid' => $impfstoffId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
$message = "Zuordnung fuer den Zeitraum gespeichert.";
|
||||
} catch (Throwable $e) {
|
||||
if ($pdo->inTransaction()) {
|
||||
$pdo->rollBack();
|
||||
}
|
||||
$error = "Zuordnung konnte nicht gespeichert werden: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($aktion === 'delete_zeitraum') {
|
||||
$zeitraumId = (int)($_POST['zeitraum_id'] ?? 0);
|
||||
if ($zeitraumId > 0) {
|
||||
$pdo->beginTransaction();
|
||||
try {
|
||||
$stDeleteMap = $pdo->prepare("DELETE FROM impf_zeitraum_impfstoff WHERE zeitraum_id = :zid");
|
||||
$stDeleteMap->execute(['zid' => $zeitraumId]);
|
||||
|
||||
$stDelete = $pdo->prepare("DELETE FROM impf_zeitraum WHERE zeitraum_id = :zid");
|
||||
$stDelete->execute(['zid' => $zeitraumId]);
|
||||
|
||||
$pdo->commit();
|
||||
$message = "Zeitraum geloescht.";
|
||||
} catch (Throwable $e) {
|
||||
if ($pdo->inTransaction()) {
|
||||
$pdo->rollBack();
|
||||
}
|
||||
$error = "Zeitraum konnte nicht geloescht werden: " . $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$impfstoffe = getImpfstoffe($pdo, true);
|
||||
$allImpfstoffe = getImpfstoffe($pdo, false);
|
||||
$impforte = getImpforte($pdo, true);
|
||||
$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
|
||||
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);
|
||||
|
||||
?>
|
||||
<div class="container main-container">
|
||||
<h2>Impfverwaltung - Stammdaten</h2>
|
||||
|
||||
<div class="row" style="margin-bottom: 15px;">
|
||||
<div class="col-sm-12">
|
||||
<a class="btn btn-default" href="impfworkflow_warteliste.php">Warteliste</a>
|
||||
<a class="btn btn-default" href="impfworkflow_teilnehmer.php">Teilnehmer pflegen</a>
|
||||
<a class="btn btn-default" href="impfworkflow_event_create.php">Impfevent erstellen</a>
|
||||
<a class="btn btn-default" href="impfworkflow_event_teilnehmer.php">Event-Teilnehmer</a>
|
||||
<a class="btn btn-primary" href="impfworkflow_stammdaten.php">Stammdaten</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($message): ?>
|
||||
<div class="alert alert-success"><?php echo esc($message); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger"><?php echo esc($error); ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<style>
|
||||
.workflow-action-row {
|
||||
margin-top: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><strong>Impfstoffe pflegen (hinzufuegen und entfernen)</strong></div>
|
||||
<div class="panel-body">
|
||||
<form method="post" class="form-inline" style="margin-bottom:12px;">
|
||||
<input type="hidden" name="aktion" value="add_impfstoff">
|
||||
<label>Name</label>
|
||||
<input class="form-control" type="text" name="impfname" required>
|
||||
<label style="margin-left:10px;">Sortierung</label>
|
||||
<input class="form-control" type="number" name="sortierung" value="100" min="0" max="9999">
|
||||
<div class="workflow-action-row">
|
||||
<button class="btn btn-primary" type="submit">Impfstoff speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Impfstoff</th>
|
||||
<th>Sortierung</th>
|
||||
<th>Nutzung</th>
|
||||
<th>Status</th>
|
||||
<th>Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($allImpfstoffe as $s): ?>
|
||||
<?php
|
||||
$nutzung = [];
|
||||
if ((int)($s['aktivwarteliste'] ?? 0) === 1) {
|
||||
$nutzung[] = 'Warteliste';
|
||||
}
|
||||
if ((int)($s['aktivtermin'] ?? 0) === 1) {
|
||||
$nutzung[] = 'Termin';
|
||||
}
|
||||
if ((int)($s['aktivgrippe'] ?? 0) === 1) {
|
||||
$nutzung[] = 'Grippe';
|
||||
}
|
||||
$isAktiv = ((int)($s['aktiv'] ?? 0) === 1 || (int)($s['aktivwarteliste'] ?? 0) === 1 || (int)($s['aktivtermin'] ?? 0) === 1 || (int)($s['aktivgrippe'] ?? 0) === 1);
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo esc((string)$s['impfname']); ?></td>
|
||||
<td><?php echo (int)($s['sortierung'] ?? 0); ?></td>
|
||||
<td><?php echo esc(empty($nutzung) ? '-' : implode(', ', $nutzung)); ?></td>
|
||||
<td><?php echo $isAktiv ? 'Aktiv' : 'Inaktiv'; ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline;">
|
||||
<input type="hidden" name="aktion" value="toggle_impfstoff">
|
||||
<input type="hidden" name="impfstoff_id" value="<?php echo (int)$s['impfid']; ?>">
|
||||
<input type="hidden" name="aktiv" value="<?php echo $isAktiv ? '0' : '1'; ?>">
|
||||
<button class="btn btn-default btn-sm" type="submit"><?php echo $isAktiv ? 'Deaktivieren' : 'Aktivieren'; ?></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><strong>Standorte pflegen (hinzufuegen und entfernen)</strong></div>
|
||||
<div class="panel-body">
|
||||
<form method="post" class="form-inline" style="margin-bottom:12px;">
|
||||
<input type="hidden" name="aktion" value="add_impfort">
|
||||
<label>Name</label>
|
||||
<input class="form-control" type="text" name="anzeigename" required>
|
||||
<label style="margin-left:10px;">Adresse</label>
|
||||
<input class="form-control" type="text" name="adresse" required>
|
||||
<label style="margin-left:10px;">Typ</label>
|
||||
<input class="form-control" type="text" name="art" placeholder="z. B. Praxis">
|
||||
<div class="workflow-action-row">
|
||||
<button class="btn btn-primary" type="submit">Standort speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Standort</th>
|
||||
<th>Adresse</th>
|
||||
<th>Typ</th>
|
||||
<th>Status</th>
|
||||
<th>Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($allImpforte as $o): ?>
|
||||
<?php $isAktiv = ((int)($o['aktiv'] ?? 0) === 1); ?>
|
||||
<tr>
|
||||
<td><?php echo esc((string)$o['anzeigename']); ?></td>
|
||||
<td><?php echo esc((string)$o['adresse']); ?></td>
|
||||
<td><?php echo esc((string)($o['art'] ?? '')); ?></td>
|
||||
<td><?php echo $isAktiv ? 'Aktiv' : 'Inaktiv'; ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline;">
|
||||
<input type="hidden" name="aktion" value="toggle_impfort">
|
||||
<input type="hidden" name="impfort_id" value="<?php echo (int)$o['ortid']; ?>">
|
||||
<input type="hidden" name="aktiv" value="<?php echo $isAktiv ? '0' : '1'; ?>">
|
||||
<button class="btn btn-default btn-sm" type="submit"><?php echo $isAktiv ? 'Deaktivieren' : 'Aktivieren'; ?></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><strong>Stammdaten pro Impfstoff</strong></div>
|
||||
<div class="panel-body">
|
||||
<form method="post" class="form-inline" style="margin-bottom:12px;">
|
||||
<input type="hidden" name="aktion" value="save_rule">
|
||||
<label>Impfstoff</label>
|
||||
<select class="form-control" name="impfstoff_id" required>
|
||||
<option value="">Bitte waehlen</option>
|
||||
<?php foreach ($impfstoffe as $s): ?>
|
||||
<option value="<?php echo (int)$s['impfid']; ?>"><?php echo esc($s['impfname']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<label style="margin-left:10px;">Dosen pro Flasche</label>
|
||||
<input class="form-control" type="number" name="dosen_pro_flasche" min="1" required>
|
||||
<div class="workflow-action-row">
|
||||
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead><tr><th>Impfstoff</th><th>Dosen pro Flasche</th><th>Bestaetigte Warteliste</th><th>Status</th><th>Aktion</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($rules as $r): ?>
|
||||
<?php
|
||||
$dosen = (int)$r['dosen_pro_flasche'];
|
||||
$wartende = (int)$r['wartende'];
|
||||
$status = ($wartende >= $dosen) ? 'bereit' : ('fehlen: ' . ($dosen - $wartende));
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo esc($r['impfname']); ?></td>
|
||||
<td><?php echo $dosen; ?></td>
|
||||
<td><?php echo $wartende; ?></td>
|
||||
<td><?php echo esc($status); ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline;" onsubmit="return confirm('Stammdaten fuer diesen Impfstoff wirklich entfernen?');">
|
||||
<input type="hidden" name="aktion" value="delete_rule">
|
||||
<input type="hidden" name="impfstoff_id" value="<?php echo (int)$r['impfstoff_id']; ?>">
|
||||
<button class="btn btn-default btn-sm" type="submit">Entfernen</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><strong>Zeitraeume pflegen</strong></div>
|
||||
<div class="panel-body">
|
||||
<form method="post" class="form-inline" style="margin-bottom:12px;">
|
||||
<input type="hidden" name="aktion" value="add_zeitraum">
|
||||
<label>Bezeichnung</label>
|
||||
<input class="form-control" type="text" name="bezeichnung" placeholder="z. B. Mittwoch Vormittag">
|
||||
<label style="margin-left:10px;">Wochentag</label>
|
||||
<select class="form-control" name="wochentag" required>
|
||||
<option value="1">Montag</option>
|
||||
<option value="2">Dienstag</option>
|
||||
<option value="3">Mittwoch</option>
|
||||
<option value="4">Donnerstag</option>
|
||||
<option value="5">Freitag</option>
|
||||
<option value="6">Samstag</option>
|
||||
<option value="7">Sonntag</option>
|
||||
</select>
|
||||
<label style="margin-left:10px;">Start</label>
|
||||
<input class="form-control" type="time" name="start" required>
|
||||
<label style="margin-left:10px;">Ende</label>
|
||||
<input class="form-control" type="time" name="ende" required>
|
||||
<label style="margin-left:10px;">Impfort</label>
|
||||
<select class="form-control" name="impfortid" required>
|
||||
<option value="">Bitte waehlen</option>
|
||||
<?php foreach ($impforte as $o): ?>
|
||||
<option value="<?php echo (int)$o['ortid']; ?>"><?php echo esc($o['anzeigename'] . ' - ' . $o['adresse']); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="workflow-action-row">
|
||||
<button class="btn btn-primary" type="submit">Zeitraum speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead><tr><th>Bezeichnung</th><th>Wochentag</th><th>Zeit</th><th>Impfort</th><th>Zugeordnete Impfstoffe</th><th>Aktion</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($zeitraeume as $z): ?>
|
||||
<tr>
|
||||
<td><?php echo esc((string)($z['bezeichnung'] ?: '-')); ?></td>
|
||||
<td><?php echo esc(weekdayName((int)$z['wochentag'])); ?></td>
|
||||
<td><?php echo esc(substr((string)$z['start'], 0, 5) . ' - ' . substr((string)$z['ende'], 0, 5)); ?></td>
|
||||
<td><?php echo esc((string)(($z['anzeigename'] ?? '') . ' - ' . ($z['adresse'] ?? ''))); ?></td>
|
||||
<td><?php echo esc(empty($z['impfstoff_name_list']) ? '-' : implode(', ', $z['impfstoff_name_list'])); ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline;" onsubmit="return confirm('Zeitraum wirklich loeschen?');">
|
||||
<input type="hidden" name="aktion" value="delete_zeitraum">
|
||||
<input type="hidden" name="zeitraum_id" value="<?php echo (int)$z['zeitraum_id']; ?>">
|
||||
<button class="btn btn-default btn-sm" type="submit">Loeschen</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><strong>Impfstoffe den Zeitraeumen zuordnen</strong></div>
|
||||
<div class="panel-body">
|
||||
<?php if (empty($zeitraeume)): ?>
|
||||
<p>Bitte zuerst mindestens einen Zeitraum anlegen.</p>
|
||||
<?php else: ?>
|
||||
<form method="post">
|
||||
<input type="hidden" name="aktion" value="save_zeitraum_assignments">
|
||||
<div class="form-group">
|
||||
<label for="zeitraum_id">Zeitraum</label>
|
||||
<select class="form-control" name="zeitraum_id" id="zuordnung_zeitraum" required>
|
||||
<option value="">Bitte waehlen</option>
|
||||
<?php foreach ($zeitraeume as $z): ?>
|
||||
<option
|
||||
value="<?php echo (int)$z['zeitraum_id']; ?>"
|
||||
data-assigned="<?php echo esc(implode(',', $z['impfstoff_id_list'])); ?>"
|
||||
>
|
||||
<?php echo esc($z['label']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row" style="margin-top:12px;">
|
||||
<?php foreach ($impfstoffe as $s): ?>
|
||||
<div class="col-sm-3">
|
||||
<label style="font-weight: normal;">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="impfstoff_ids[]"
|
||||
value="<?php echo (int)$s['impfid']; ?>"
|
||||
class="zuordnung-impfstoff"
|
||||
>
|
||||
<?php echo esc((string)$s['impfname']); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="workflow-action-row">
|
||||
<button class="btn btn-primary" type="submit">Zuordnung speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var select = document.getElementById('zuordnung_zeitraum');
|
||||
if (!select) {
|
||||
return;
|
||||
}
|
||||
|
||||
function syncAssignments() {
|
||||
var option = select.options[select.selectedIndex];
|
||||
var assigned = option ? (option.getAttribute('data-assigned') || '') : '';
|
||||
var assignedMap = {};
|
||||
if (assigned !== '') {
|
||||
assigned.split(',').forEach(function (value) {
|
||||
if (value !== '') {
|
||||
assignedMap[value] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var checkboxes = document.querySelectorAll('.zuordnung-impfstoff');
|
||||
for (var i = 0; i < checkboxes.length; i++) {
|
||||
checkboxes[i].checked = !!assignedMap[checkboxes[i].value];
|
||||
}
|
||||
}
|
||||
|
||||
select.addEventListener('change', syncAssignments);
|
||||
syncAssignments();
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php include __DIR__ . "/templates/footer.inc.php"; ?>
|
||||
Reference in New Issue
Block a user