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,83 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* app/floors/edit.php
|
||||
* app/modules/floors/edit.php
|
||||
*
|
||||
* Floor / Stockwerk anlegen oder bearbeiten
|
||||
* - Name, Beschreibung
|
||||
* - Zugehörige Räume / Netzwerkdosen
|
||||
* - SVG-Grundriss laden / speichern
|
||||
* - Name, Ebene, Beschreibung
|
||||
* - Zugehöriges Gebäude
|
||||
* - SVG-Grundriss (optional)
|
||||
*/
|
||||
|
||||
// TODO: bootstrap laden
|
||||
// require_once __DIR__ . '/../../bootstrap.php';
|
||||
|
||||
// TODO: Auth erzwingen
|
||||
// requireAuth();
|
||||
|
||||
// =========================
|
||||
// Kontext bestimmen
|
||||
// =========================
|
||||
$floorId = (int)($_GET['id'] ?? 0);
|
||||
$floor = null;
|
||||
|
||||
// Floor-ID aus GET
|
||||
// $floorId = (int)($_GET['id'] ?? 0);
|
||||
if ($floorId > 0) {
|
||||
$floor = $sql->single(
|
||||
"SELECT * FROM floors WHERE id = ?",
|
||||
"i",
|
||||
[$floorId]
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Floor aus DB laden, falls ID vorhanden
|
||||
// $floor = null;
|
||||
$isEdit = !empty($floor);
|
||||
$pageTitle = $isEdit ? "Stockwerk bearbeiten: " . htmlspecialchars($floor['name']) : "Neues Stockwerk";
|
||||
|
||||
// TODO: Räume / Dosen laden, falls Floor existiert
|
||||
$rooms = []; // TODO: Räume vorbereiten
|
||||
// =========================
|
||||
// Gebäude laden
|
||||
// =========================
|
||||
$buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []);
|
||||
|
||||
?>
|
||||
|
||||
<h2>Stockwerk bearbeiten</h2>
|
||||
<div class="floor-edit">
|
||||
<h1><?php echo $pageTitle; ?></h1>
|
||||
|
||||
<form method="post" action="/app/floors/save.php" enctype="multipart/form-data">
|
||||
<form method="post" action="?module=floors&action=save" enctype="multipart/form-data" class="edit-form">
|
||||
|
||||
<!-- =========================
|
||||
Basisdaten
|
||||
========================= -->
|
||||
<?php if ($isEdit): ?>
|
||||
<input type="hidden" name="id" value="<?php echo $floorId; ?>">
|
||||
<?php endif; ?>
|
||||
|
||||
<fieldset>
|
||||
<legend>Allgemein</legend>
|
||||
<!-- =========================
|
||||
Basisdaten
|
||||
========================= -->
|
||||
<fieldset>
|
||||
<legend>Allgemein</legend>
|
||||
|
||||
<label>
|
||||
Name<br>
|
||||
<input type="text" name="name" value="">
|
||||
<!-- TODO: Name vorbelegen -->
|
||||
</label>
|
||||
<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>
|
||||
|
||||
<br><br>
|
||||
<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>
|
||||
|
||||
<label>
|
||||
Beschreibung<br>
|
||||
<textarea name="description"></textarea>
|
||||
<!-- TODO: Beschreibung vorbelegen -->
|
||||
</label>
|
||||
</fieldset>
|
||||
<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>
|
||||
|
||||
<!-- =========================
|
||||
Räume / Netzwerkdosen
|
||||
========================= -->
|
||||
<!-- =========================
|
||||
Gebäude & Standort
|
||||
========================= -->
|
||||
<fieldset>
|
||||
<legend>Standort</legend>
|
||||
|
||||
<fieldset>
|
||||
<legend>Räume / Netzwerkdosen</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>
|
||||
|
||||
<p class="hint">
|
||||
Räume hinzufügen / bearbeiten. Netzwerkdosen können einzeln nummeriert / benannt werden.
|
||||
</p>
|
||||
<!-- =========================
|
||||
SVG-Grundriss (optional)
|
||||
========================= -->
|
||||
<fieldset>
|
||||
<legend>Grundriss (SVG)</legend>
|
||||
|
||||
<div class="room-list">
|
||||
<!-- TODO: Räume auflisten -->
|
||||
<!-- TODO: Netzwerkdosen pro Raum anzeigen -->
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<button type="button" id="add-room">
|
||||
+ Raum hinzufügen
|
||||
</button>
|
||||
</fieldset>
|
||||
<?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>
|
||||
|
||||
<!-- =========================
|
||||
SVG Floorplan
|
||||
<!-- =========================
|
||||
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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
115
app/modules/floors/save.php
Normal file
115
app/modules/floors/save.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* app/modules/floors/save.php
|
||||
*
|
||||
* Speichert / aktualisiert ein Stockwerk
|
||||
*/
|
||||
|
||||
// Nur POST
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: ?module=floors&action=list');
|
||||
exit;
|
||||
}
|
||||
|
||||
// =========================
|
||||
// Daten einlesen
|
||||
// =========================
|
||||
$floorId = (int)($_POST['id'] ?? 0);
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$buildingId = (int)($_POST['building_id'] ?? 0);
|
||||
$level = isset($_POST['level']) ? (int)$_POST['level'] : null;
|
||||
$comment = trim($_POST['comment'] ?? '');
|
||||
|
||||
// =========================
|
||||
// Validierung
|
||||
// =========================
|
||||
$errors = [];
|
||||
|
||||
if (empty($name)) {
|
||||
$errors[] = "Name ist erforderlich";
|
||||
}
|
||||
|
||||
if ($buildingId <= 0) {
|
||||
$errors[] = "Gebäude ist erforderlich";
|
||||
}
|
||||
|
||||
// Falls Fehler: zurück zum Edit-Formular
|
||||
if (!empty($errors)) {
|
||||
$_SESSION['error'] = implode(', ', $errors);
|
||||
$redirectUrl = $floorId ? "?module=floors&action=edit&id=$floorId" : "?module=floors&action=edit";
|
||||
header("Location: $redirectUrl");
|
||||
exit;
|
||||
}
|
||||
|
||||
// =========================
|
||||
// SVG-Upload verarbeiten (optional)
|
||||
// =========================
|
||||
$svgPath = null;
|
||||
if (!empty($_FILES['svg_file']['name'])) {
|
||||
$file = $_FILES['svg_file'];
|
||||
$tmpName = $file['tmp_name'];
|
||||
$originalName = basename($file['name']);
|
||||
$fileExt = strtolower(pathinfo($originalName, PATHINFO_EXTENSION));
|
||||
|
||||
// Nur SVG erlaubt
|
||||
if ($fileExt !== 'svg') {
|
||||
$_SESSION['error'] = "Nur SVG-Dateien sind erlaubt";
|
||||
$redirectUrl = $floorId ? "?module=floors&action=edit&id=$floorId" : "?module=floors&action=edit";
|
||||
header("Location: $redirectUrl");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Zielverzeichnis
|
||||
$uploadDir = __DIR__ . '/../../uploads/floorplans/';
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0755, true);
|
||||
}
|
||||
|
||||
// Eindeutiger Dateiname
|
||||
$newFileName = uniqid('floor_') . '.svg';
|
||||
$destPath = $uploadDir . $newFileName;
|
||||
|
||||
if (move_uploaded_file($tmpName, $destPath)) {
|
||||
$svgPath = 'uploads/floorplans/' . $newFileName;
|
||||
} else {
|
||||
$_SESSION['error'] = "Datei-Upload fehlgeschlagen";
|
||||
$redirectUrl = $floorId ? "?module=floors&action=edit&id=$floorId" : "?module=floors&action=edit";
|
||||
header("Location: $redirectUrl");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// =========================
|
||||
// In DB speichern
|
||||
// =========================
|
||||
if ($floorId > 0) {
|
||||
// UPDATE
|
||||
if ($svgPath) {
|
||||
$sql->set(
|
||||
"UPDATE floors SET name = ?, building_id = ?, level = ?, comment = ?, svg_path = ? WHERE id = ?",
|
||||
"siissi",
|
||||
[$name, $buildingId, $level, $comment, $svgPath, $floorId]
|
||||
);
|
||||
} else {
|
||||
$sql->set(
|
||||
"UPDATE floors SET name = ?, building_id = ?, level = ?, comment = ? WHERE id = ?",
|
||||
"siiss",
|
||||
[$name, $buildingId, $level, $comment, $floorId]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// INSERT
|
||||
$sql->set(
|
||||
"INSERT INTO floors (name, building_id, level, comment, svg_path) VALUES (?, ?, ?, ?, ?)",
|
||||
"siiss",
|
||||
[$name, $buildingId, $level, $comment, $svgPath]
|
||||
);
|
||||
}
|
||||
|
||||
$_SESSION['success'] = "Stockwerk gespeichert";
|
||||
|
||||
// =========================
|
||||
// Redirect
|
||||
// =========================
|
||||
header('Location: ?module=floors&action=list');
|
||||
exit;
|
||||
Reference in New Issue
Block a user