diff --git a/app/index.php b/app/index.php
index 5c56570..c663dee 100644
--- a/app/index.php
+++ b/app/index.php
@@ -44,10 +44,11 @@ if (!in_array($action, $validActions)) {
}
/* =========================
- * Template-Header laden
+ * Template-Header laden (nur für non-save Aktionen)
* ========================= */
-require_once __DIR__ . '/templates/header.php';
-// TODO: ggf. Navigation einbinden
+if ($action !== 'save') {
+ require_once __DIR__ . '/templates/header.php';
+}
/* =========================
* Modul laden
@@ -58,10 +59,14 @@ if (file_exists($modulePath)) {
require_once $modulePath;
} else {
// TODO: Fehlerseite oder 404
- echo "
Die Seite existiert noch nicht.
".$modulePath;
+ if ($action !== 'save') {
+ echo "Die Seite existiert noch nicht.
".$modulePath;
+ }
}
/* =========================
- * Template-Footer laden
+ * Template-Footer laden (nur für non-save Aktionen)
* ========================= */
-require_once __DIR__ . '/templates/footer.php';
+if ($action !== 'save') {
+ require_once __DIR__ . '/templates/footer.php';
+}
diff --git a/app/modules/device_types/edit.php b/app/modules/device_types/edit.php
index 319213b..a89b4d6 100644
--- a/app/modules/device_types/edit.php
+++ b/app/modules/device_types/edit.php
@@ -74,6 +74,13 @@ $pageTitle = $isEdit ? "Gerätetyp bearbeiten: " . htmlspecialchars($deviceType[
+
+
+
+ Beim Speichern werden bis zu dieser Zahl Platzhalter-Ports erstellt, bestehende Einträge bleiben erhalten.
+
+
+
@@ -76,7 +101,7 @@
Aktionen |
-
+
@@ -142,14 +167,99 @@
JS-Konfiguration
========================= -->
+
+
diff --git a/app/modules/device_types/save.php b/app/modules/device_types/save.php
index 859405d..5d12688 100644
--- a/app/modules/device_types/save.php
+++ b/app/modules/device_types/save.php
@@ -21,6 +21,7 @@ $deviceTypeId = (int)($_POST['id'] ?? 0);
$name = trim($_POST['name'] ?? '');
$category = $_POST['category'] ?? 'other';
$comment = trim($_POST['comment'] ?? '');
+$seedPortCount = max(0, (int)($_POST['seed_ports'] ?? 0));
// =========================
// Validierung
@@ -46,6 +47,7 @@ if (!empty($errors)) {
// Bild-Upload verarbeiten
// =========================
$imagePath = null;
+$imageType = null;
if (!empty($_FILES['image']['name'])) {
$file = $_FILES['image'];
$tmpName = $file['tmp_name'];
@@ -71,6 +73,7 @@ if (!empty($_FILES['image']['name'])) {
if (move_uploaded_file($tmpName, $destPath)) {
$imagePath = 'uploads/device_types/' . $newFileName;
+ $imageType = $fileExt === 'svg' ? 'svg' : 'bitmap';
} else {
$_SESSION['error'] = "Datei-Upload fehlgeschlagen";
header('Location: ?module=device_types&action=edit' . ($deviceTypeId ? "&id=$deviceTypeId" : ""));
@@ -83,22 +86,40 @@ if (!empty($_FILES['image']['name'])) {
// =========================
if ($deviceTypeId > 0) {
// UPDATE
- $sql->set(
- "UPDATE device_types SET name = ?, category = ?, comment = ?" . ($imagePath ? ", image_path = ?, image_type = ?" : "") . " WHERE id = ?",
- $imagePath ? "sssss" : "sssi",
- $imagePath ? [$name, $category, $comment, $imagePath, $fileExt, $deviceTypeId] : [$name, $category, $comment, $deviceTypeId]
- );
+ if ($imagePath) {
+ $sql->set(
+ "UPDATE device_types SET name = ?, category = ?, comment = ?, image_path = ?, image_type = ? WHERE id = ?",
+ "sssisi",
+ [$name, $category, $comment, $imagePath, $imageType, $deviceTypeId]
+ );
+ } else {
+ $sql->set(
+ "UPDATE device_types SET name = ?, category = ?, comment = ? WHERE id = ?",
+ "sssi",
+ [$name, $category, $comment, $deviceTypeId]
+ );
+ }
} else {
// INSERT
- $imageType = $imagePath ? $fileExt : null;
- $sql->set(
- "INSERT INTO device_types (name, category, comment, image_path, image_type) VALUES (?, ?, ?, ?, ?)",
- "sssss",
- [$name, $category, $comment, $imagePath, $imageType]
- );
- $deviceTypeId = $sql->h->insert_id;
+ if ($imagePath) {
+ $deviceTypeId = $sql->set(
+ "INSERT INTO device_types (name, category, comment, image_path, image_type) VALUES (?, ?, ?, ?, ?)",
+ "sssss",
+ [$name, $category, $comment, $imagePath, $imageType],
+ true
+ );
+ } else {
+ $deviceTypeId = $sql->set(
+ "INSERT INTO device_types (name, category, comment, image_path, image_type) VALUES (?, ?, ?, NULL, ?)",
+ "ssss",
+ [$name, $category, $comment, 'bitmap'],
+ true
+ );
+ }
}
+seedDeviceTypePorts($sql, $deviceTypeId, $seedPortCount);
+
$_SESSION['success'] = $deviceTypeId ? "Gerätetyp gespeichert" : "Fehler beim Speichern";
// =========================
@@ -107,3 +128,28 @@ $_SESSION['success'] = $deviceTypeId ? "Gerätetyp gespeichert" : "Fehler beim S
header('Location: ?module=device_types&action=list');
exit;
+function seedDeviceTypePorts($sql, $deviceTypeId, $targetCount)
+{
+ if ($deviceTypeId <= 0 || $targetCount <= 0) {
+ return;
+ }
+
+ $result = $sql->single(
+ "SELECT COUNT(*) AS count FROM device_type_ports WHERE device_type_id = ?",
+ "i",
+ [$deviceTypeId]
+ );
+
+ $existing = (int)($result['count'] ?? 0);
+ $toCreate = max(0, $targetCount - $existing);
+
+ for ($i = 1; $i <= $toCreate; $i++) {
+ $index = $existing + $i;
+ $sql->set(
+ "INSERT INTO device_type_ports (device_type_id, name, port_type_id, x, y) VALUES (?, ?, NULL, 0, 0)",
+ "is",
+ [$deviceTypeId, "Port $index"]
+ );
+ }
+}
+
diff --git a/app/modules/racks/save.php b/app/modules/racks/save.php
index 23de183..6dc0d59 100644
--- a/app/modules/racks/save.php
+++ b/app/modules/racks/save.php
@@ -59,7 +59,7 @@ if ($rackId > 0) {
// INSERT
$sql->set(
"INSERT INTO racks (name, floor_id, height_he, comment) VALUES (?, ?, ?, ?)",
- "sii s",
+ "siis",
[$name, $floorId, $heightHe, $comment]
);
}
diff --git a/app/templates/header.php b/app/templates/header.php
index 1fc5916..2930bac 100644
--- a/app/templates/header.php
+++ b/app/templates/header.php
@@ -43,12 +43,12 @@