infrastruktur

This commit is contained in:
2026-02-13 10:00:57 +01:00
parent 09e568d4d1
commit 24b2980d76
9 changed files with 614 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ $module = $_GET['module'] ?? 'dashboard';
$action = $_GET['action'] ?? 'list';
// Whitelist der Module
$validModules = ['dashboard', 'locations', 'buildings', 'device_types', 'devices', 'racks', 'floors', 'connections', 'port_types'];
$validModules = ['dashboard', 'locations', 'buildings', 'device_types', 'devices', 'racks', 'floors', 'floor_infrastructure', 'connections', 'port_types'];
// Whitelist der Aktionen
$validActions = ['list', 'edit', 'save', 'ports', 'delete'];

View File

@@ -0,0 +1,177 @@
<?php
/**
* app/modules/floor_infrastructure/edit.php
*
* Formular zum Anlegen/Bearbeiten von Patchpanels und Wandbuchsen
*/
//TODO die auswahl der stockwerke in gebäude gruppieren und gebäude in locations gruppieren
$type = $_GET['type'] ?? 'patchpanel';
$id = (int)($_GET['id'] ?? 0);
$floors = $sql->get("SELECT id, name FROM floors ORDER BY name", "", []);
$rooms = $sql->get(
"SELECT r.id, r.name, f.name AS floor_name
FROM rooms r
LEFT JOIN floors f ON f.id = r.floor_id
ORDER BY f.name, r.name",
"",
[]
);
$panel = null;
$outlet = null;
$pageTitle = $type === 'outlet' ? 'Wandbuchse bearbeiten' : 'Patchpanel bearbeiten';
if ($type === 'patchpanel' && $id > 0) {
$panel = $sql->single(
"SELECT * FROM floor_patchpanels WHERE id = ?",
"i",
[$id]
);
if ($panel) {
$pageTitle = "Patchpanel bearbeiten: " . htmlspecialchars($panel['name']);
}
}
if ($type === 'outlet' && $id > 0) {
$outlet = $sql->single(
"SELECT * FROM network_outlets WHERE id = ?",
"i",
[$id]
);
if ($outlet) {
$pageTitle = "Wandbuchse bearbeiten: " . htmlspecialchars($outlet['name']);
}
}
?>
<div class="floor-infra-edit">
<h1><?php echo $pageTitle; ?></h1>
<form method="post" action="?module=floor_infrastructure&action=save" class="infra-edit-form">
<input type="hidden" name="type" value="<?php echo htmlspecialchars($type); ?>">
<input type="hidden" name="id" value="<?php echo $type === 'patchpanel' ? ($panel['id'] ?? $id) : ($outlet['id'] ?? $id); ?>">
<?php if ($type === 'patchpanel'): ?>
<div class="form-group">
<label>Name</label>
<input type="text" name="name" value="<?php echo htmlspecialchars($panel['name'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label>Stockwerk</label>
<select name="floor_id" required>
<option value="">- wählen -</option>
<?php foreach ($floors as $floor): ?>
<option value="<?php echo $floor['id']; ?>" <?php echo ($panel['floor_id'] ?? 0) === $floor['id'] ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($floor['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-grid">
<div class="form-group">
<label>X</label>
<input type="number" name="pos_x" value="<?php echo $panel['pos_x'] ?? 0; ?>" required>
</div>
<div class="form-group">
<label>Y</label>
<input type="number" name="pos_y" value="<?php echo $panel['pos_y'] ?? 0; ?>" required>
</div>
<div class="form-group">
<label>Breite</label>
<input type="number" name="width" value="<?php echo $panel['width'] ?? 0; ?>" required>
</div>
<div class="form-group">
<label>Höhe</label>
<input type="number" name="height" value="<?php echo $panel['height'] ?? 0; ?>" required>
</div>
</div>
<div class="form-group">
<label>Port-Anzahl</label>
<input type="number" name="port_count" value="<?php echo $panel['port_count'] ?? 0; ?>" min="0">
</div>
<div class="form-group">
<label>Kommentar</label>
<textarea name="comment"><?php echo htmlspecialchars($panel['comment'] ?? ''); ?></textarea>
</div>
<p class="info">TODO: Drag & Drop auf dem SVG-Plan erlauben.</p>
<?php else: ?>
<div class="form-group">
<label>Name</label>
<input type="text" name="name" value="<?php echo htmlspecialchars($outlet['name'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label>Raum</label>
<select name="room_id" required>
<option value="">- Raum wählen -</option>
<?php foreach ($rooms as $room): ?>
<option value="<?php echo $room['id']; ?>" <?php echo ($outlet['room_id'] ?? 0) === $room['id'] ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($room['floor_name'] . ' / ' . $room['name']); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label>X</label>
<input type="number" name="x" value="<?php echo $outlet['x'] ?? 0; ?>">
</div>
<div class="form-group">
<label>Y</label>
<input type="number" name="y" value="<?php echo $outlet['y'] ?? 0; ?>">
</div>
<div class="form-group">
<label>Kommentar</label>
<textarea name="comment"><?php echo htmlspecialchars($outlet['comment'] ?? ''); ?></textarea>
</div>
<p class="info">TODO: Wandbuchsen gezielt auf dem Stockwerksplan platzieren.</p>
<?php endif; ?>
<div class="form-actions">
<button type="submit" class="button button-primary">Speichern</button>
<a href="?module=floor_infrastructure&action=list" class="button">Abbrechen</a>
</div>
</form>
</div>
<style>
.floor-infra-edit {
padding: 25px;
max-width: 700px;
}
.infra-edit-form {
display: flex;
flex-direction: column;
gap: 15px;
}
.form-group {
display: flex;
flex-direction: column;
gap: 6px;
}
.form-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
gap: 12px;
}
.form-actions {
display: flex;
gap: 10px;
}
.info {
font-size: 0.9em;
color: #555;
}
</style>

View File

@@ -0,0 +1,196 @@
<?php
/**
* app/modules/floor_infrastructure/list.php
*
* Übersicht über Patchpanels und Netzwerkbuchsen auf Stockwerken
*/
$floorId = (int)($_GET['floor_id'] ?? 0);
$floors = $sql->get("SELECT id, name FROM floors ORDER BY name", "", []);
$where = '';
$types = '';
$params = [];
if ($floorId > 0) {
$where = "WHERE p.floor_id = ?";
$types = "i";
$params[] = $floorId;
}
$patchPanels = $sql->get(
"SELECT p.*, f.name AS floor_name
FROM floor_patchpanels p
LEFT JOIN floors f ON f.id = p.floor_id
$where
ORDER BY f.name, p.name",
$types,
$params
);
$networkOutlets = $sql->get(
"SELECT o.*, r.name AS room_name, f.name AS floor_name
FROM network_outlets o
LEFT JOIN rooms r ON r.id = o.room_id
LEFT JOIN floors f ON f.id = r.floor_id
ORDER BY f.name, r.name, o.name",
"",
[]
);
?>
<div class="floor-infra">
<h1>Stockwerksinfrastruktur</h1>
<div class="toolbar">
<a href="?module=floor_infrastructure&action=edit&type=patchpanel" class="button button-primary">
+ Patchpanel hinzufügen
</a>
<a href="?module=floor_infrastructure&action=edit&type=outlet" class="button">
+ Wandbuchse hinzufügen
</a>
</div>
<form method="get" class="filter-form">
<input type="hidden" name="module" value="floor_infrastructure">
<input type="hidden" name="action" value="list">
<select name="floor_id">
<option value="">- Alle Stockwerke -</option>
<?php foreach ($floors as $floor): ?>
<option value="<?php echo $floor['id']; ?>" <?php echo $floor['id'] === $floorId ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($floor['name']); ?>
</option>
<?php endforeach; ?>
</select>
<button class="button">Filter</button>
<a href="?module=floor_infrastructure&action=list" class="button">Zurücksetzen</a>
</form>
<section class="infra-section">
<h2>Patchpanels</h2>
<?php if (!empty($patchPanels)): ?>
<table class="infra-table">
<thead>
<tr>
<th>Name</th>
<th>Stockwerk</th>
<th>Position</th>
<th>Größe</th>
<th>Ports</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($patchPanels as $panel): ?>
<tr>
<td><?php echo htmlspecialchars($panel['name']); ?></td>
<td><?php echo htmlspecialchars($panel['floor_name'] ?? '—'); ?></td>
<td><?php echo $panel['pos_x'] . ' × ' . $panel['pos_y']; ?></td>
<td><?php echo $panel['width'] . ' × ' . $panel['height']; ?></td>
<td><?php echo $panel['port_count']; ?></td>
<td class="actions">
<a href="?module=floor_infrastructure&action=edit&type=patchpanel&id=<?php echo $panel['id']; ?>" class="button button-small">Bearbeiten</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p class="empty-state">Noch keine Patchpanels definiert.</p>
<?php endif; ?>
</section>
<section class="infra-section">
<h2>Wandbuchsen</h2>
<?php if (!empty($networkOutlets)): ?>
<table class="infra-table">
<thead>
<tr>
<th>Name</th>
<th>Stockwerk</th>
<th>Raum</th>
<th>Koordinaten</th>
<th>Kommentar</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<?php foreach ($networkOutlets as $outlet): ?>
<tr>
<td><?php echo htmlspecialchars($outlet['name']); ?></td>
<td><?php echo htmlspecialchars($outlet['floor_name'] ?? '—'); ?></td>
<td><?php echo htmlspecialchars($outlet['room_name'] ?? '—'); ?></td>
<td><?php echo $outlet['x'] . ' × ' . $outlet['y']; ?></td>
<td><?php echo htmlspecialchars($outlet['comment']); ?></td>
<td class="actions">
<a href="?module=floor_infrastructure&action=edit&type=outlet&id=<?php echo $outlet['id']; ?>" class="button button-small">Bearbeiten</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p class="empty-state">Noch keine Wandbuchsen angelegt.</p>
<?php endif; ?>
</section>
<section class="infra-plan">
<h2>Stockwerksplan-Verortung</h2>
<p>Die eingetragenen Patchpanels und Wandbuchsen erscheinen später als feste Objekte auf dem Stockwerks-SVG. Die Polygon-Positionen werden momentan noch durch numerische X/Y-Werte gesteuert.</p>
<p><small>TODO: SVG-Editor mit Drag & Drop für diese Objekte erweitern (siehe Stockwerke-Modul).</small></p>
</section>
</div>
<style>
.floor-infra {
padding: 25px;
}
.toolbar {
display: flex;
gap: 10px;
margin-bottom: 15px;
}
.filter-form {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
margin-bottom: 25px;
}
.filter-form select {
padding: 8px 10px;
border-radius: 4px;
border: 1px solid #ccc;
}
.infra-section {
margin-bottom: 30px;
}
.infra-table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
.infra-table th,
.infra-table td {
padding: 10px;
border-bottom: 1px solid #ddd;
}
.infra-plan {
padding: 15px;
background: #f7f7f7;
border: 1px dashed #ccc;
border-radius: 6px;
}
.empty-state {
padding: 20px;
background: #fafafa;
border: 1px dashed #ccc;
border-radius: 6px;
}
.actions .button-small {
margin-right: 6px;
}
</style>

View File

@@ -0,0 +1,57 @@
<?php
/**
* app/modules/floor_infrastructure/save.php
*
* Speichert Patchpanel- und Wandbuchsen-Einträge
*/
$type = $_POST['type'] ?? '';
$id = (int)($_POST['id'] ?? 0);
if ($type === 'patchpanel') {
$name = trim($_POST['name'] ?? '');
$floorId = (int)($_POST['floor_id'] ?? 0);
$posX = (int)($_POST['pos_x'] ?? 0);
$posY = (int)($_POST['pos_y'] ?? 0);
$width = (int)($_POST['width'] ?? 0);
$height = (int)($_POST['height'] ?? 0);
$portCount = (int)($_POST['port_count'] ?? 0);
$comment = trim($_POST['comment'] ?? '');
if ($id > 0) {
$sql->set(
"UPDATE floor_patchpanels SET name = ?, floor_id = ?, pos_x = ?, pos_y = ?, width = ?, height = ?, port_count = ?, comment = ? WHERE id = ?",
"siiiiisii",
[$name, $floorId, $posX, $posY, $width, $height, $portCount, $comment, $id]
);
} else {
$sql->set(
"INSERT INTO floor_patchpanels (name, floor_id, pos_x, pos_y, width, height, port_count, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
"siiiiiss",
[$name, $floorId, $posX, $posY, $width, $height, $portCount, $comment]
);
}
} elseif ($type === 'outlet') {
$name = trim($_POST['name'] ?? '');
$roomId = (int)($_POST['room_id'] ?? 0);
$x = (int)($_POST['x'] ?? 0);
$y = (int)($_POST['y'] ?? 0);
$comment = trim($_POST['comment'] ?? '');
if ($id > 0) {
$sql->set(
"UPDATE network_outlets SET name = ?, room_id = ?, x = ?, y = ?, comment = ? WHERE id = ?",
"siiisi",
[$name, $roomId, $x, $y, $comment, $id]
);
} else {
$sql->set(
"INSERT INTO network_outlets (name, room_id, x, y, comment) VALUES (?, ?, ?, ?, ?)",
"siiis",
[$name, $roomId, $x, $y, $comment]
);
}
}
header('Location: ?module=floor_infrastructure&action=list');
exit;

View File

@@ -40,6 +40,7 @@
'port_types' => 'Porttypen',
'devices' => 'Geräte',
'racks' => 'Racks',
'floor_infrastructure' => 'Infrastruktur',
'connections' => 'Verbindungen',
];
?>