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:
44
app/modules/locations/save.php
Normal file
44
app/modules/locations/save.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* app/modules/locations/save.php
|
||||
*/
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: ?module=locations&action=list');
|
||||
exit;
|
||||
}
|
||||
|
||||
$locationId = (int)($_POST['id'] ?? 0);
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$comment = trim($_POST['comment'] ?? '');
|
||||
|
||||
$errors = [];
|
||||
|
||||
if (empty($name)) {
|
||||
$errors[] = "Name ist erforderlich";
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$_SESSION['error'] = implode(', ', $errors);
|
||||
$redirectUrl = $locationId ? "?module=locations&action=edit&id=$locationId" : "?module=locations&action=edit";
|
||||
header("Location: $redirectUrl");
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($locationId > 0) {
|
||||
$sql->set(
|
||||
"UPDATE locations SET name = ?, comment = ? WHERE id = ?",
|
||||
"ssi",
|
||||
[$name, $comment, $locationId]
|
||||
);
|
||||
} else {
|
||||
$sql->set(
|
||||
"INSERT INTO locations (name, comment) VALUES (?, ?)",
|
||||
"ss",
|
||||
[$name, $comment]
|
||||
);
|
||||
}
|
||||
|
||||
$_SESSION['success'] = "Standort gespeichert";
|
||||
header('Location: ?module=locations&action=list');
|
||||
exit;
|
||||
Reference in New Issue
Block a user