feat: Implement floors, locations, and racks management
- Added list, edit, and save functionalities for floors, locations, and racks. - Enhanced UI with search and filter options for better usability. - Implemented SVG upload for floor plans in the floors module. - Added validation for required fields in the save processes. - Improved navigation in the header to reflect new modules. - Styled forms and tables for a consistent look and feel across modules.
This commit is contained in:
49
app/modules/buildings/save.php
Normal file
49
app/modules/buildings/save.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* app/modules/buildings/save.php
|
||||
*/
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: ?module=buildings&action=list');
|
||||
exit;
|
||||
}
|
||||
|
||||
$buildingId = (int)($_POST['id'] ?? 0);
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$locationId = (int)($_POST['location_id'] ?? 0);
|
||||
$comment = trim($_POST['comment'] ?? '');
|
||||
|
||||
$errors = [];
|
||||
|
||||
if (empty($name)) {
|
||||
$errors[] = "Name ist erforderlich";
|
||||
}
|
||||
|
||||
if ($locationId <= 0) {
|
||||
$errors[] = "Standort ist erforderlich";
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$_SESSION['error'] = implode(', ', $errors);
|
||||
$redirectUrl = $buildingId ? "?module=buildings&action=edit&id=$buildingId" : "?module=buildings&action=edit";
|
||||
header("Location: $redirectUrl");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($buildingId > 0) {
|
||||
$sql->set(
|
||||
"UPDATE buildings SET name = ?, location_id = ?, comment = ? WHERE id = ?",
|
||||
"sisi",
|
||||
[$name, $locationId, $comment, $buildingId]
|
||||
);
|
||||
} else {
|
||||
$sql->set(
|
||||
"INSERT INTO buildings (name, location_id, comment) VALUES (?, ?, ?)",
|
||||
"sis",
|
||||
[$name, $locationId, $comment]
|
||||
);
|
||||
}
|
||||
|
||||
$_SESSION['success'] = "Gebäude gespeichert";
|
||||
header('Location: ?module=buildings&action=list');
|
||||
exit;
|
||||
Reference in New Issue
Block a user