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,249 @@
<?php
/**
* app/modules/buildings/list.php
*
* Übersicht aller Gebäude
*/
// =========================
// Filter einlesen
// =========================
$search = trim($_GET['search'] ?? '');
$locationId = (int)($_GET['location_id'] ?? 0);
// =========================
// WHERE-Clause bauen
// =========================
$where = [];
$types = '';
$params = [];
if ($search !== '') {
$where[] = "b.name LIKE ? OR b.comment LIKE ?";
$types .= "ss";
$params[] = "%$search%";
$params[] = "%$search%";
}
if ($locationId > 0) {
$where[] = "b.location_id = ?";
$types .= "i";
$params[] = $locationId;
}
$whereSql = $where ? "WHERE " . implode(" AND ", $where) : "";
$buildings = $sql->get(
"SELECT b.*, l.name AS location_name, COUNT(f.id) AS floor_count
FROM buildings b
LEFT JOIN locations l ON b.location_id = l.id
LEFT JOIN floors f ON f.building_id = b.id
$whereSql
GROUP BY b.id
ORDER BY l.name, b.name",
$types,
$params
);
// =========================
// Filter-Daten
// =========================
$locations = $sql->get("SELECT id, name FROM locations ORDER BY name", "", []);
?>
<div class="buildings-container">
<h1>Gebäude</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="buildings">
<input type="hidden" name="action" value="list">
<input type="text" name="search" placeholder="Suche nach Name…"
value="<?php echo htmlspecialchars($search); ?>" class="search-input">
<select name="location_id">
<option value="">- Alle Standorte -</option>
<?php foreach ($locations as $loc): ?>
<option value="<?php echo $loc['id']; ?>"
<?php echo $loc['id'] === $locationId ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($loc['name']); ?>
</option>
<?php endforeach; ?>
</select>
<button type="submit" class="button">Filter</button>
<a href="?module=buildings&action=list" class="button">Reset</a>
<a href="?module=buildings&action=edit" class="button button-primary" style="margin-left: auto;">+ Neues Gebäude</a>
</form>
</div>
<!-- =========================
Gebäude-Tabelle
========================= -->
<?php if (!empty($buildings)): ?>
<table class="buildings-list">
<thead>
<tr>
<th>Name</th>
<th>Standort</th>
<th>Stockwerke</th>
<th>Beschreibung</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($buildings as $building): ?>
<tr>
<td>
<strong><?php echo htmlspecialchars($building['name']); ?></strong>
</td>
<td>
<?php echo htmlspecialchars($building['location_name'] ?? '—'); ?>
</td>
<td>
<?php echo $building['floor_count']; ?>
</td>
<td>
<small><?php echo htmlspecialchars($building['comment'] ?? ''); ?></small>
</td>
<td class="actions">
<a href="?module=buildings&action=edit&id=<?php echo $building['id']; ?>" class="button button-small">Bearbeiten</a>
<a href="#" class="button button-small button-danger" onclick="confirmDelete(<?php echo $building['id']; ?>)">Löschen</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<div class="empty-state">
<p>Keine Gebäude gefunden.</p>
<p>
<a href="?module=buildings&action=edit" class="button button-primary">
Erstes Gebäude anlegen
</a>
</p>
</div>
<?php endif; ?>
</div>
<style>
.buildings-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,
.filter-form select {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
}
.search-input {
flex: 1;
min-width: 250px;
}
.buildings-list {
width: 100%;
border-collapse: collapse;
margin: 15px 0;
}
.buildings-list th {
background: #f5f5f5;
padding: 12px;
text-align: left;
border-bottom: 2px solid #ddd;
font-weight: bold;
}
.buildings-list td {
padding: 12px;
border-bottom: 1px solid #ddd;
}
.buildings-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('Dieses Gebäude wirklich löschen?')) {
// TODO: AJAX-Delete implementieren
alert('Löschen noch nicht implementiert');
}
}
</script>