0) { $where[] = "(d1.id = ? OR d2.id = ?)"; $types .= "ii"; $params[] = $deviceId; $params[] = $deviceId; } $whereSql = $where ? "WHERE " . implode(" AND ", $where) : ""; // ========================= // Verbindungen laden // ========================= $connections = $sql->get( "SELECT c.id, c.port_a_type, c.port_a_id, c.port_b_type, c.port_b_id, d1.name AS device_a_name, d2.name AS device_b_name, dpt1.name AS port_a_name, dpt2.name AS port_b_name, c.vlan_config, c.comment FROM connections c LEFT JOIN device_ports dpt1 ON c.port_a_type = 'device' AND c.port_a_id = dpt1.id LEFT JOIN devices d1 ON dpt1.device_id = d1.id LEFT JOIN device_ports dpt2 ON c.port_b_type = 'device' AND c.port_b_id = dpt2.id LEFT JOIN devices d2 ON dpt2.device_id = d2.id $whereSql ORDER BY d1.name, d2.name", $types, $params ); // ========================= // Filter-Daten // ========================= $devices = $sql->get("SELECT id, name FROM devices ORDER BY name", "", []); $selectedDevice = null; $selectedDevicePorts = []; $selectedDeviceVlans = []; if ($deviceId > 0) { $selectedDevice = $sql->single( "SELECT d.id, d.name, dt.name AS type_name FROM devices d LEFT JOIN device_types dt ON d.device_type_id = dt.id WHERE d.id = ?", "i", [$deviceId] ); if ($selectedDevice) { $selectedDevice['port_count'] = (int)($sql->single( "SELECT COUNT(*) AS cnt FROM device_ports WHERE device_id = ?", "i", [$deviceId] )['cnt'] ?? 0); $selectedDevice['connection_count'] = (int)($sql->single( "SELECT COUNT(DISTINCT c.id) AS cnt FROM connections c LEFT JOIN device_ports dpt1 ON c.port_a_type = 'device' AND c.port_a_id = dpt1.id LEFT JOIN device_ports dpt2 ON c.port_b_type = 'device' AND c.port_b_id = dpt2.id WHERE dpt1.device_id = ? OR dpt2.device_id = ?", "ii", [$deviceId, $deviceId] )['cnt'] ?? 0); $selectedDevicePorts = $sql->get( "SELECT name, vlan_config FROM device_ports WHERE device_id = ? ORDER BY id LIMIT 12", "i", [$deviceId] ); foreach ($selectedDevicePorts as $port) { if (empty($port['vlan_config'])) { continue; } $vlans = json_decode($port['vlan_config'], true); foreach ((array)$vlans as $vlan) { $vlan = trim((string)$vlan); if ($vlan !== '') { $selectedDeviceVlans[$vlan] = true; } } } $selectedDeviceVlans = array_keys($selectedDeviceVlans); natcasesort($selectedDeviceVlans); } } ?>
| Von (Gerät → Port) | Nach (Gerät → Port) | VLANs | Beschreibung | Status | Aktionen |
|---|---|---|---|---|---|
|
|
|
⚠️ Warnung ✔️ OK | Bearbeiten Löschen |
Keine Verbindungen gefunden.