feat: implement package 1 session and validation feedback

- add session validation_errors bootstrap initialization

- render global flash + validation messages in header

- remove footer alert-based flash handling

- persist structured validation errors across save handlers

- mark NEXT_STEPS package 1 tasks as done
This commit is contained in:
2026-02-18 09:40:59 +01:00
parent ec20fa2f96
commit f4ce7f360d
17 changed files with 162 additions and 55 deletions

View File

@@ -20,6 +20,24 @@ if ($type === 'patchpanel') {
$height = $fixedPanelHeight;
$portCount = (int)($_POST['port_count'] ?? 0);
$comment = trim($_POST['comment'] ?? '');
$errors = [];
if ($name === '') {
$errors[] = 'Name ist erforderlich';
}
if ($floorId <= 0) {
$errors[] = 'Stockwerk ist erforderlich';
}
if ($portCount < 0) {
$errors[] = 'Port-Anzahl darf nicht negativ sein';
}
if (!empty($errors)) {
$_SESSION['error'] = implode(', ', $errors);
$_SESSION['validation_errors'] = $errors;
$redirectUrl = $id > 0 ? "?module=floor_infrastructure&action=edit&type=patchpanel&id=$id" : "?module=floor_infrastructure&action=edit&type=patchpanel";
header("Location: $redirectUrl");
exit;
}
$panelId = $id;
@@ -55,6 +73,7 @@ if ($type === 'patchpanel') {
}
}
}
$_SESSION['success'] = $id > 0 ? 'Patchpanel gespeichert' : 'Patchpanel erstellt';
} elseif ($type === 'outlet') {
$name = trim($_POST['name'] ?? '');
$roomId = (int)($_POST['room_id'] ?? 0);
@@ -62,6 +81,21 @@ if ($type === 'patchpanel') {
$y = (int)($_POST['y'] ?? 0);
$comment = trim($_POST['comment'] ?? '');
$outletId = $id;
$errors = [];
if ($name === '') {
$errors[] = 'Name ist erforderlich';
}
if ($roomId <= 0) {
$errors[] = 'Raum ist erforderlich';
}
if (!empty($errors)) {
$_SESSION['error'] = implode(', ', $errors);
$_SESSION['validation_errors'] = $errors;
$redirectUrl = $id > 0 ? "?module=floor_infrastructure&action=edit&type=outlet&id=$id" : "?module=floor_infrastructure&action=edit&type=outlet";
header("Location: $redirectUrl");
exit;
}
if ($id > 0) {
$sql->set(
@@ -93,6 +127,10 @@ if ($type === 'patchpanel') {
);
}
}
$_SESSION['success'] = $id > 0 ? 'Wandbuchse gespeichert' : 'Wandbuchse erstellt';
} else {
$_SESSION['error'] = 'Ungueltiger Infrastrukturobjekt-Typ';
$_SESSION['validation_errors'] = ['Ungueltiger Infrastrukturobjekt-Typ'];
}
header('Location: ?module=floor_infrastructure&action=list');