- 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.
275 lines
7.1 KiB
PHP
275 lines
7.1 KiB
PHP
<?php
|
|
/**
|
|
* app/modules/floors/edit.php
|
|
*
|
|
* Floor / Stockwerk anlegen oder bearbeiten
|
|
* - Name, Ebene, Beschreibung
|
|
* - Zugehöriges Gebäude
|
|
* - SVG-Grundriss (optional)
|
|
*/
|
|
|
|
// =========================
|
|
// Kontext bestimmen
|
|
// =========================
|
|
$floorId = (int)($_GET['id'] ?? 0);
|
|
$floor = null;
|
|
|
|
if ($floorId > 0) {
|
|
$floor = $sql->single(
|
|
"SELECT * FROM floors WHERE id = ?",
|
|
"i",
|
|
[$floorId]
|
|
);
|
|
}
|
|
|
|
$isEdit = !empty($floor);
|
|
$pageTitle = $isEdit ? "Stockwerk bearbeiten: " . htmlspecialchars($floor['name']) : "Neues Stockwerk";
|
|
|
|
// =========================
|
|
// Gebäude laden
|
|
// =========================
|
|
$buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []);
|
|
|
|
?>
|
|
|
|
<div class="floor-edit">
|
|
<h1><?php echo $pageTitle; ?></h1>
|
|
|
|
<form method="post" action="?module=floors&action=save" enctype="multipart/form-data" class="edit-form">
|
|
|
|
<?php if ($isEdit): ?>
|
|
<input type="hidden" name="id" value="<?php echo $floorId; ?>">
|
|
<?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($floor['name'] ?? ''); ?>"
|
|
placeholder="z.B. Erdgeschoss">
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="level">Ebene</label>
|
|
<input type="number" id="level" name="level"
|
|
value="<?php echo htmlspecialchars($floor['level'] ?? '0'); ?>"
|
|
placeholder="z.B. 0 für Erdgeschoss, 1 für 1. OG">
|
|
<small>Dient zur Sortierung</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="comment">Beschreibung</label>
|
|
<textarea id="comment" name="comment" rows="3"
|
|
placeholder="Notizen zu diesem Stockwerk"><?php echo htmlspecialchars($floor['comment'] ?? ''); ?></textarea>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<!-- =========================
|
|
Gebäude & Standort
|
|
========================= -->
|
|
<fieldset>
|
|
<legend>Standort</legend>
|
|
|
|
<div class="form-group">
|
|
<label for="building_id">Gebäude <span class="required">*</span></label>
|
|
<select id="building_id" name="building_id" required>
|
|
<option value="">- Wählen -</option>
|
|
<?php foreach ($buildings as $building): ?>
|
|
<option value="<?php echo $building['id']; ?>"
|
|
<?php echo ($floor['building_id'] ?? 0) == $building['id'] ? 'selected' : ''; ?>>
|
|
<?php echo htmlspecialchars($building['name']); ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<!-- =========================
|
|
SVG-Grundriss (optional)
|
|
========================= -->
|
|
<fieldset>
|
|
<legend>Grundriss (SVG)</legend>
|
|
|
|
<div class="form-group">
|
|
<label for="svg_file">SVG-Datei hochladen</label>
|
|
<input type="file" id="svg_file" name="svg_file" accept=".svg">
|
|
<small>Optionales Floorplan-SVG. Kann später im Editor bearbeitet werden.</small>
|
|
</div>
|
|
|
|
<?php if ($isEdit && $floor['svg_path']): ?>
|
|
<div class="form-group">
|
|
<label>Aktueller Grundriss:</label>
|
|
<p><small><?php echo htmlspecialchars($floor['svg_path']); ?></small></p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</fieldset>
|
|
|
|
<!-- =========================
|
|
Aktionen
|
|
========================= -->
|
|
<fieldset class="form-actions">
|
|
<button type="submit" class="button button-primary">Speichern</button>
|
|
<a href="?module=floors&action=list" class="button">Abbrechen</a>
|
|
<?php if ($isEdit): ?>
|
|
<a href="#" class="button button-danger" onclick="confirmDelete(<?php echo $floorId; ?>)">Löschen</a>
|
|
<?php endif; ?>
|
|
</fieldset>
|
|
|
|
</form>
|
|
</div>
|
|
|
|
<style>
|
|
.floor-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 input[type="number"],
|
|
.form-group input[type="file"],
|
|
.form-group select,
|
|
.form-group textarea {
|
|
width: 100%;
|
|
padding: 8px 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-family: inherit;
|
|
}
|
|
|
|
.form-group textarea {
|
|
resize: vertical;
|
|
}
|
|
|
|
.form-group small {
|
|
display: block;
|
|
margin-top: 5px;
|
|
color: #666;
|
|
}
|
|
|
|
.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('Dieses Stockwerk wirklich löschen? Alle Räume und Racks werden gelöscht.')) {
|
|
// TODO: AJAX-Delete implementieren
|
|
alert('Löschen noch nicht implementiert');
|
|
}
|
|
}
|
|
</script>
|
|
========================= -->
|
|
|
|
<fieldset>
|
|
<legend>Grundriss / Floorplan</legend>
|
|
|
|
<div class="svg-editor-container">
|
|
<svg
|
|
id="floor-svg"
|
|
viewBox="0 0 2000 1000"
|
|
width="100%"
|
|
height="600"
|
|
>
|
|
<!-- TODO: Floorplan SVG laden -->
|
|
</svg>
|
|
</div>
|
|
|
|
<p class="hint">
|
|
Räume und Netzwerkdosen per Drag & Drop platzieren. Nummerierung und Bezeichnungen editierbar.
|
|
</p>
|
|
</fieldset>
|
|
|
|
<!-- =========================
|
|
Aktionen
|
|
========================= -->
|
|
|
|
<fieldset>
|
|
<button type="submit">Speichern</button>
|
|
<button type="button" onclick="history.back()">Abbrechen</button>
|
|
<!-- TODO: Löschen, falls edit -->
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
<!-- =========================
|
|
JS-Konfiguration
|
|
========================= -->
|
|
|
|
<script>
|
|
/**
|
|
* Konfiguration für Floorplan SVG-Editor
|
|
*/
|
|
|
|
// TODO: Floor-ID aus PHP setzen
|
|
// window.FLOOR_ID = <?= (int)$floorId ?>;
|
|
|
|
// TODO: Räume / Dosen an JS übergeben
|
|
// window.ROOMS = <?= json_encode($rooms) ?>;
|
|
</script>
|