impfwarteliste angepasst
This commit is contained in:
+174
-27
@@ -8,6 +8,32 @@
|
||||
<head>
|
||||
<?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');
|
||||
|
||||
?>
|
||||
@@ -26,11 +52,17 @@
|
||||
include_once("inc/config.inc.php");
|
||||
include_once("inc/functions.inc.php");
|
||||
include_once('inc/functions.impfen.inc.php');
|
||||
include_once('inc/impfworkflow_notifications.inc.php');
|
||||
$workflowSetupError = '';
|
||||
if ($con instanceof mysqli) {
|
||||
mysqli_set_charset($con, "utf8mb4");
|
||||
}
|
||||
if (isset($pdo) && $pdo instanceof PDO) {
|
||||
impfWorkflowEnsureTables($pdo);
|
||||
try {
|
||||
impfWorkflowEnsureTables($pdo);
|
||||
} catch (Throwable $e) {
|
||||
$workflowSetupError = $e->getMessage();
|
||||
}
|
||||
}
|
||||
$zeitOptionenJson = "{}";
|
||||
?>
|
||||
@@ -57,11 +89,20 @@ $mailbetreff = "Ihr Wartelistenplatz für eine Impfung bei Praxis Creutzburg";
|
||||
|
||||
<section class="box special">
|
||||
<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
|
||||
|
||||
|
||||
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"])){
|
||||
$id = mysqli_real_escape_string($con, $_POST["id"]);
|
||||
@@ -83,6 +124,17 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
$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;
|
||||
$queryuser = mysqli_query($con, "SELECT * FROM persons WHERE person_id='" . $userid . "'");
|
||||
$rowuser = $queryuser->fetch_assoc();
|
||||
@@ -133,7 +185,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
echo "<h4>Art: $Patientenart</h4>";
|
||||
echo "<h4>Telefon: $tel</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 '<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 "<h4>Name: $userausgabe</h4>";
|
||||
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 "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>";
|
||||
@@ -198,6 +257,24 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
echo "<input type=hidden name='".$key."' value='".$value. "'>\n";
|
||||
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($key == "Impfstoff"){
|
||||
$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';
|
||||
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";
|
||||
}else{
|
||||
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");
|
||||
$WeitereFragen = mysqli_real_escape_string($con, $_POST["WeitereFragen"] ?? "Nein");
|
||||
$impfenmit = mysqli_real_escape_string($con, $_POST["zusammenmit"] ?? "");
|
||||
$impfenzeitraumId = (int)($_POST["impfenzeitraum"] ?? 0);
|
||||
$impfenzeitraumIds = impfNormalizeZeitraumIds($_POST["impfenzeitraeume"] ?? ($_POST["impfenzeitraum"] ?? []));
|
||||
$impfart = (int)($_POST["impfart"] ?? 0);
|
||||
$letzteimpfung = trim($_POST["letzteimpfung"] ?? "");
|
||||
|
||||
if ($impfstoff <= 0 || $impfart <= 0 || $impfenzeitraumId <= 0) {
|
||||
echo "<h3>Pflichtfelder fehlen</h3><br>Bitte wählen Sie Impfstoff, Zeitraum und Impfungsart aus.<br><br>";
|
||||
if ($impfstoff <= 0 || $impfart <= 0 || empty($impfenzeitraumIds)) {
|
||||
echo "<h3>Pflichtfelder fehlen</h3><br>Bitte wählen Sie Impfstoff, mindestens einen Zeitraum und die Impfungsart aus.<br><br>";
|
||||
goto end_aktion_1;
|
||||
}
|
||||
|
||||
@@ -267,12 +345,19 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
$letzteimpfung = "";
|
||||
}
|
||||
|
||||
$zeitraumRow = (isset($pdo) && $pdo instanceof PDO) ? impfLoadZeitraumById($pdo, $impfenzeitraumId, true) : null;
|
||||
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>";
|
||||
goto end_aktion_1;
|
||||
$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)) {
|
||||
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;
|
||||
}
|
||||
$zeitraumLabels[] = (string)$zeitraumRow['label'];
|
||||
}
|
||||
}
|
||||
$impfenzeitraum = mysqli_real_escape_string($con, $zeitraumRow['label']);
|
||||
$impfenzeitraum = mysqli_real_escape_string($con, implode(' | ', $zeitraumLabels));
|
||||
$impfenzeitraumId = (int)($impfenzeitraumIds[0] ?? 0);
|
||||
|
||||
|
||||
//echo $impfenmit;
|
||||
@@ -333,12 +418,43 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
$letzteimpfungSql = ($letzteimpfung !== "") ? ("'" . mysqli_real_escape_string($con, $letzteimpfung) . "'") : "NULL";
|
||||
$query = mysqli_query($con, "SELECT * FROM warteliste WHERE userid='" . (int)$userid . "'");
|
||||
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')");
|
||||
if($query){
|
||||
$warteid = mysqli_insert_id($con);
|
||||
SendMailMessageVorlage($pdo, "2", $warteid , "8" );
|
||||
$warteid = 0;
|
||||
$saveOk = false;
|
||||
$saveErrorShown = false;
|
||||
try {
|
||||
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 {
|
||||
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>";
|
||||
}else{
|
||||
} 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>";
|
||||
}
|
||||
}else{
|
||||
@@ -381,6 +497,13 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
$userausgabe = $vorname . " " . $nachname;
|
||||
|
||||
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"] . "'");
|
||||
$rowimpf = $queryimpf->fetch_assoc() ;
|
||||
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"]."'");
|
||||
if($query){
|
||||
echo "<h4>Ihr Warteplatz wurde erfolgreich gelöscht!<h4><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,9 +577,12 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
echo "<h4>Mail wird gleich versendet!</h4>";
|
||||
echo "<br>Überprüfen Sie auch Ihren SPAM Ordner!<br>";
|
||||
SendMailMessageVorlage($pdo, "1", (int)$terminid, "1" );
|
||||
|
||||
|
||||
$query = mysqli_query($con, "DELETE FROM warteliste WHERE warteid ='".$warteid."'");
|
||||
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."'");
|
||||
}else{
|
||||
echo "<h4>Fehler bei Speichern der Anfragen!</h4>";
|
||||
echo "<br>Versuchen Sie es später erneut!<br>";
|
||||
@@ -512,7 +649,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
}
|
||||
$zeitOptionenByImpfstoff[$iid][] = [
|
||||
'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>
|
||||
<br>
|
||||
<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">
|
||||
<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>
|
||||
</select>
|
||||
<div id="Zeitrauminfo"></div>
|
||||
@@ -680,6 +817,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
|
||||
<script>
|
||||
const zeitfensterByImpfstoff = <?php echo $zeitOptionenJson ?: '{}'; ?>;
|
||||
const initialZeitraumIds = <?php echo json_encode(impfNormalizeZeitraumIds($_POST["impfenzeitraeume"] ?? ($_POST["impfenzeitraum"] ?? [])), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
|
||||
function isIE() {
|
||||
return /Trident\/|MSIE/.test(window.navigator.userAgent);
|
||||
@@ -687,7 +825,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
|
||||
function updateZeitfenster() {
|
||||
const impfstoff = document.getElementById('AstraImpfung');
|
||||
const zeitraum = document.getElementById('impfenzeitraum');
|
||||
const zeitraum = document.getElementById('impfenzeitraeume');
|
||||
const zeitraumInfo = document.getElementById('Zeitrauminfo');
|
||||
const submit = document.getElementById('submitbox');
|
||||
const impfstoffId = impfstoff.value;
|
||||
@@ -697,7 +835,7 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
if (!impfstoffId || optionen.length === 0) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = '';
|
||||
opt.textContent = '- Kein Zeitbereich verfügbar -';
|
||||
opt.textContent = '- Keine Zeitbereiche verfügbar -';
|
||||
zeitraum.appendChild(opt);
|
||||
zeitraum.disabled = true;
|
||||
submit.disabled = true;
|
||||
@@ -713,11 +851,15 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
const opt = document.createElement('option');
|
||||
opt.value = String(eintrag.id || '');
|
||||
opt.textContent = eintrag.label || '';
|
||||
if (initialZeitraumIds.includes(Number(eintrag.id))) {
|
||||
opt.selected = true;
|
||||
}
|
||||
zeitraum.appendChild(opt);
|
||||
});
|
||||
zeitraum.disabled = false;
|
||||
submit.disabled = false;
|
||||
zeitraumInfo.innerHTML = '';
|
||||
checkZeitraum();
|
||||
}
|
||||
|
||||
function checklastImpf() {
|
||||
@@ -736,10 +878,14 @@ if(isset($_POST["id"]) || isset($_GET["id"])){
|
||||
|
||||
function checkZeitraum() {
|
||||
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 = "";
|
||||
submit.disabled = true;
|
||||
} 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();
|
||||
updateZeitfenster();
|
||||
checkZeitraum();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user