- 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.
218 lines
4.7 KiB
PHP
218 lines
4.7 KiB
PHP
<?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>
|