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:
2026-02-11 14:34:07 +01:00
parent 2f341bff9f
commit 0d3c6e1ae7
26 changed files with 3753 additions and 1045 deletions

View File

@@ -0,0 +1,161 @@
<?php
/**
* app/modules/locations/edit.php
*
* Standort anlegen/bearbeiten
*/
// =========================
// Kontext bestimmen
// =========================
$locationId = (int)($_GET['id'] ?? 0);
$location = null;
if ($locationId > 0) {
$location = $sql->single(
"SELECT * FROM locations WHERE id = ?",
"i",
[$locationId]
);
}
$isEdit = !empty($location);
$pageTitle = $isEdit ? "Standort bearbeiten: " . htmlspecialchars($location['name']) : "Neuer Standort";
?>
<div class="location-edit">
<h1><?php echo $pageTitle; ?></h1>
<form method="post" action="?module=locations&action=save" class="edit-form">
<?php if ($isEdit): ?>
<input type="hidden" name="id" value="<?php echo $locationId; ?>">
<?php endif; ?>
<!-- =========================
Basisdaten
========================= -->
<fieldset>
<legend>Allgemein</legend>
<div class="form-group">
<label for="name">Name <span class="required">*</span></label>
<input type="text" id="name" name="name" required
value="<?php echo htmlspecialchars($location['name'] ?? ''); ?>"
placeholder="z.B. Hauptgebäude, Campus A, Außenstelle Berlin">
</div>
<div class="form-group">
<label for="comment">Beschreibung</label>
<textarea id="comment" name="comment" rows="3"
placeholder="Adresse, Kontaktinformationen, Besonderheiten"><?php echo htmlspecialchars($location['comment'] ?? ''); ?></textarea>
</div>
</fieldset>
<!-- =========================
Aktionen
========================= -->
<fieldset class="form-actions">
<button type="submit" class="button button-primary">Speichern</button>
<a href="?module=locations&action=list" class="button">Abbrechen</a>
<?php if ($isEdit): ?>
<a href="#" class="button button-danger" onclick="confirmDelete(<?php echo $locationId; ?>)">Löschen</a>
<?php endif; ?>
</fieldset>
</form>
</div>
<style>
.location-edit {
max-width: 800px;
margin: 20px auto;
padding: 20px;
}
.edit-form {
background: white;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
}
.edit-form fieldset {
margin: 20px 0;
padding: 15px;
border: 1px solid #e0e0e0;
border-radius: 4px;
}
.edit-form legend {
padding: 0 10px;
font-weight: bold;
font-size: 1.1em;
}
.form-group {
margin: 15px 0;
}
.form-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
.form-group input[type="text"],
.form-group textarea {
width: 100%;
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
font-family: inherit;
}
.form-group textarea {
resize: vertical;
}
.required {
color: red;
}
.form-actions {
display: flex;
gap: 10px;
margin-top: 30px;
}
.button {
padding: 10px 15px;
background: #007bff;
color: white;
text-decoration: none;
border-radius: 4px;
border: none;
cursor: pointer;
font-size: 0.95em;
}
.button-primary {
background: #28a745;
}
.button-danger {
background: #dc3545;
}
.button:hover {
opacity: 0.8;
}
</style>
<script>
function confirmDelete(id) {
if (confirm('Diesen Standort wirklich löschen? Alle Gebäude werden gelöscht.')) {
// TODO: AJAX-Delete implementieren
alert('Löschen noch nicht implementiert');
}
}
</script>

View File

@@ -0,0 +1,217 @@
<?php
/**
* app/modules/locations/list.php
*
* Übersicht aller Standorte
*/
// =========================
// Filter einlesen
// =========================
$search = trim($_GET['search'] ?? '');
// =========================
// Standorte laden
// =========================
$where = '';
$types = '';
$params = [];
if ($search !== '') {
$where = "WHERE name LIKE ? OR comment LIKE ?";
$types = "ss";
$params = ["%$search%", "%$search%"];
}
$locations = $sql->get(
"SELECT l.*, COUNT(b.id) AS building_count
FROM locations l
LEFT JOIN buildings b ON b.location_id = l.id
$where
GROUP BY l.id
ORDER BY l.name",
$types,
$params
);
?>
<div class="locations-container">
<h1>Standorte</h1>
<!-- =========================
Toolbar
========================= -->
<div class="filter-form">
<form method="GET" style="display: flex; gap: 10px; flex-wrap: wrap; align-items: center;">
<input type="hidden" name="module" value="locations">
<input type="hidden" name="action" value="list">
<input type="text" name="search" placeholder="Suche nach Name…"
value="<?php echo htmlspecialchars($search); ?>" class="search-input">
<button type="submit" class="button">Filter</button>
<a href="?module=locations&action=list" class="button">Reset</a>
<a href="?module=locations&action=edit" class="button button-primary" style="margin-left: auto;">+ Neuer Standort</a>
</form>
</div>
<!-- =========================
Standorte-Tabelle
========================= -->
<?php if (!empty($locations)): ?>
<table class="locations-list">
<thead>
<tr>
<th>Name</th>
<th>Gebäude</th>
<th>Beschreibung</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($locations as $location): ?>
<tr>
<td>
<strong><?php echo htmlspecialchars($location['name']); ?></strong>
</td>
<td>
<?php echo $location['building_count']; ?>
</td>
<td>
<small><?php echo htmlspecialchars($location['comment'] ?? ''); ?></small>
</td>
<td class="actions">
<a href="?module=locations&action=edit&id=<?php echo $location['id']; ?>" class="button button-small">Bearbeiten</a>
<a href="#" class="button button-small button-danger" onclick="confirmDelete(<?php echo $location['id']; ?>)">Löschen</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="empty-state">
<p>Keine Standorte gefunden.</p>
<p>
<a href="?module=locations&action=edit" class="button button-primary">
Ersten Standort anlegen
</a>
</p>
</div>
<?php endif; ?>
</div>
<style>
.locations-container {
padding: 20px;
max-width: 1000px;
margin: 0 auto;
}
.filter-form {
margin: 20px 0;
}
.filter-form form {
display: flex;
gap: 10px;
flex-wrap: wrap;
align-items: center;
}
.filter-form input {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
}
.search-input {
flex: 1;
min-width: 250px;
}
.locations-list {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
}
.locations-list th {
background: #f5f5f5;
padding: 12px;
text-align: left;
border-bottom: 2px solid #ddd;
font-weight: bold;
}
.locations-list td {
padding: 12px;
border-bottom: 1px solid #ddd;
}
.locations-list tr:hover {
background: #f9f9f9;
}
.actions {
white-space: nowrap;
}
.button {
display: inline-block;
padding: 8px 12px;
background: #007bff;
color: white;
text-decoration: none;
border-radius: 4px;
border: none;
cursor: pointer;
font-size: 0.9em;
}
.button:hover {
background: #0056b3;
}
.button-primary {
background: #28a745;
}
.button-primary:hover {
background: #218838;
}
.button-small {
padding: 4px 8px;
font-size: 0.85em;
}
.button-danger {
background: #dc3545;
}
.button-danger:hover {
background: #c82333;
}
.empty-state {
text-align: center;
padding: 40px 20px;
background: #f9f9f9;
border: 1px solid #eee;
border-radius: 8px;
}
</style>
<script>
function confirmDelete(id) {
if (confirm('Diesen Standort wirklich löschen?')) {
// TODO: AJAX-Delete implementieren
alert('Löschen noch nicht implementiert');
}
}
</script>

View 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;