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:
@@ -1,96 +1,241 @@
|
||||
<?php
|
||||
/**
|
||||
* app/floors/list.php
|
||||
* app/modules/floors/list.php
|
||||
*
|
||||
* Übersicht aller Floors / Stockwerke
|
||||
* - Anzeigen
|
||||
* - Bearbeiten
|
||||
* - Löschen
|
||||
* - SVG-Vorschau optional
|
||||
* - Anzeigen, Bearbeiten, Löschen
|
||||
* - SVG-Floorplan Vorschau (optional)
|
||||
*/
|
||||
|
||||
// TODO: bootstrap laden
|
||||
// require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
// TODO: Auth erzwingen
|
||||
// requireAuth();
|
||||
// =========================
|
||||
// Filter einlesen
|
||||
// =========================
|
||||
$search = trim($_GET['search'] ?? '');
|
||||
|
||||
// =========================
|
||||
// Floors laden
|
||||
// =========================
|
||||
$whereClause = "";
|
||||
$types = "";
|
||||
$params = [];
|
||||
|
||||
// TODO: Floors aus DB laden
|
||||
// $floors = $sql->get("SELECT * FROM floors ORDER BY name", "", []);
|
||||
if ($search !== '') {
|
||||
$whereClause = "WHERE f.name LIKE ? OR f.comment LIKE ?";
|
||||
$types = "ss";
|
||||
$params = ["%$search%", "%$search%"];
|
||||
}
|
||||
|
||||
$floors = $sql->get(
|
||||
"SELECT f.*, b.name AS building_name, COUNT(r.id) AS room_count, COUNT(rk.id) AS rack_count
|
||||
FROM floors f
|
||||
LEFT JOIN buildings b ON f.building_id = b.id
|
||||
LEFT JOIN rooms r ON r.floor_id = f.id
|
||||
LEFT JOIN racks rk ON rk.floor_id = f.id
|
||||
$whereClause
|
||||
GROUP BY f.id
|
||||
ORDER BY b.name, f.level",
|
||||
$types,
|
||||
$params
|
||||
);
|
||||
|
||||
// =========================
|
||||
// Filter-Daten
|
||||
// =========================
|
||||
$buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []);
|
||||
|
||||
?>
|
||||
|
||||
<h2>Stockwerke</h2>
|
||||
<div class="floors-container">
|
||||
<h1>Stockwerke</h1>
|
||||
|
||||
<!-- =========================
|
||||
Toolbar
|
||||
========================= -->
|
||||
<!-- =========================
|
||||
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="floors">
|
||||
<input type="hidden" name="action" value="list">
|
||||
|
||||
<div class="toolbar">
|
||||
<a href="/?page=floors/edit" class="button">
|
||||
+ Neues Stockwerk
|
||||
</a>
|
||||
<input type="text" name="search" placeholder="Suche nach Name…"
|
||||
value="<?php echo htmlspecialchars($search); ?>" class="search-input">
|
||||
|
||||
<!-- TODO: Suchfeld -->
|
||||
<!-- TODO: Filter (Gebäude / Standort) -->
|
||||
<button type="submit" class="button">Filter</button>
|
||||
<a href="?module=floors&action=list" class="button">Reset</a>
|
||||
<a href="?module=floors&action=edit" class="button button-primary" style="margin-left: auto;">+ Neues Stockwerk</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- =========================
|
||||
Floors-Tabelle
|
||||
========================= -->
|
||||
<?php if (!empty($floors)): ?>
|
||||
<table class="floor-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Gebäude</th>
|
||||
<th>Ebene</th>
|
||||
<th>Räume</th>
|
||||
<th>Racks</th>
|
||||
<th>Beschreibung</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($floors as $floor): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?php echo htmlspecialchars($floor['name']); ?></strong>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo htmlspecialchars($floor['building_name'] ?? '—'); ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $floor['level'] ?? '—'; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $floor['room_count']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $floor['rack_count']; ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<small><?php echo htmlspecialchars($floor['comment'] ?? ''); ?></small>
|
||||
</td>
|
||||
|
||||
<td class="actions">
|
||||
<a href="?module=floors&action=edit&id=<?php echo $floor['id']; ?>" class="button button-small">Bearbeiten</a>
|
||||
<a href="#" class="button button-small button-danger" onclick="confirmDelete(<?php echo $floor['id']; ?>)">Löschen</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php else: ?>
|
||||
<div class="empty-state">
|
||||
<p>Keine Stockwerke gefunden.</p>
|
||||
<p>
|
||||
<a href="?module=floors&action=edit" class="button button-primary">
|
||||
Erstes Stockwerk anlegen
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- =========================
|
||||
Floor-Tabelle
|
||||
========================= -->
|
||||
<style>
|
||||
.floors-container {
|
||||
padding: 20px;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
<table class="floor-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Vorschau</th>
|
||||
<th>Name</th>
|
||||
<th>Beschreibung</th>
|
||||
<th>Räume</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
.filter-form {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
<?php /* foreach ($floors as $floor): */ ?>
|
||||
<tr>
|
||||
<td class="preview">
|
||||
<!-- TODO: SVG / JPG Thumbnail Floorplan -->
|
||||
</td>
|
||||
.filter-form form {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
<td>
|
||||
<!-- TODO: Name -->
|
||||
Floor 1
|
||||
</td>
|
||||
.filter-form input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
<td>
|
||||
<!-- TODO: Beschreibung -->
|
||||
</td>
|
||||
.search-input {
|
||||
flex: 1;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
<td>
|
||||
<!-- TODO: Anzahl Räume -->
|
||||
</td>
|
||||
.floor-list {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
<td>
|
||||
<a href="/floors/edit?id=1">Bearbeiten</a>
|
||||
<button>Löschen</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php /* endforeach; */ ?>
|
||||
.floor-list th {
|
||||
background: #f5f5f5;
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
border-bottom: 2px solid #ddd;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
.floor-list td {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
<!-- =========================
|
||||
Leerer Zustand
|
||||
========================= -->
|
||||
.floor-list tr:hover {
|
||||
background: #f9f9f9;
|
||||
}
|
||||
|
||||
<?php /* if (empty($floors)): */ ?>
|
||||
<div class="empty-state">
|
||||
<p>Noch keine Stockwerke angelegt.</p>
|
||||
<p><a href="/floors/edit">Erstes Stockwerk anlegen</a></p>
|
||||
</div>
|
||||
<?php /* endif; */ ?>
|
||||
.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 Stockwerk wirklich löschen? Alle Räume und Racks werden gelöscht.')) {
|
||||
// TODO: AJAX-Delete implementieren
|
||||
alert('Löschen noch nicht implementiert');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user