NetAdmin: Gateway-kenttä, IPAM-integraatio VLAN/IP-tietoihin
- Lisää Gateway-sarake ja -valitsin NetAdmin-näkymään (devices-linkitys) - VLAN ja IP näytetään IPAM:sta automaattisesti asiakkaan nimellä - Muokkausmodaalissa asiakkaan IPAM VLANit/IP:t näkyvät ensimmäisinä - DB: gateway_device_id LEFT JOIN devices, IPAM-enrichment API:ssa Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
15
db.php
15
db.php
@@ -616,6 +616,7 @@ function initDatabase(): void {
|
||||
"ALTER TABLE document_versions ADD COLUMN content MEDIUMTEXT DEFAULT NULL AFTER mime_type",
|
||||
"ALTER TABLE devices ADD COLUMN laitetila_id VARCHAR(20) DEFAULT NULL AFTER site_id",
|
||||
"ALTER TABLE document_folders ADD COLUMN customer_id VARCHAR(20) DEFAULT NULL AFTER company_id",
|
||||
"ALTER TABLE customer_connections ADD COLUMN gateway_device_id VARCHAR(20) DEFAULT NULL AFTER ip",
|
||||
];
|
||||
foreach ($alters as $sql) {
|
||||
try { $db->query($sql); } catch (\Throwable $e) { /* sarake on jo olemassa / jo ajettu */ }
|
||||
@@ -2051,9 +2052,13 @@ function dbLoadAllConnections(string $companyId): array {
|
||||
c.yhteyshenkilö AS customer_contact,
|
||||
c.puhelin AS customer_phone,
|
||||
c.sahkoposti AS customer_email,
|
||||
c.id AS customer_id
|
||||
c.id AS customer_id,
|
||||
gw.nimi AS gateway_name,
|
||||
gw.hallintaosoite AS gateway_ip,
|
||||
gw.malli AS gateway_model
|
||||
FROM customer_connections cc
|
||||
JOIN customers c ON c.id = cc.customer_id
|
||||
LEFT JOIN devices gw ON cc.gateway_device_id = gw.id
|
||||
WHERE c.company_id = :companyId
|
||||
ORDER BY cc.kaupunki, cc.asennusosoite
|
||||
", ['companyId' => $companyId]);
|
||||
@@ -2061,9 +2066,11 @@ function dbLoadAllConnections(string $companyId): array {
|
||||
|
||||
function dbLoadConnection(int $connectionId): ?array {
|
||||
return _dbFetchOne("
|
||||
SELECT cc.*, c.yritys AS customer_name, c.company_id
|
||||
SELECT cc.*, c.yritys AS customer_name, c.company_id,
|
||||
gw.nimi AS gateway_name, gw.hallintaosoite AS gateway_ip, gw.malli AS gateway_model
|
||||
FROM customer_connections cc
|
||||
JOIN customers c ON c.id = cc.customer_id
|
||||
LEFT JOIN devices gw ON cc.gateway_device_id = gw.id
|
||||
WHERE cc.id = ?
|
||||
", [$connectionId]);
|
||||
}
|
||||
@@ -2071,7 +2078,8 @@ function dbLoadConnection(int $connectionId): ?array {
|
||||
function dbUpdateConnection(int $connectionId, array $data): void {
|
||||
_dbExecute("UPDATE customer_connections SET
|
||||
liittymanopeus = ?, vlan = ?, laite = ?, portti = ?, ip = ?,
|
||||
asennusosoite = ?, postinumero = ?, kaupunki = ?
|
||||
asennusosoite = ?, postinumero = ?, kaupunki = ?,
|
||||
gateway_device_id = ?
|
||||
WHERE id = ?", [
|
||||
$data['liittymanopeus'] ?? '',
|
||||
$data['vlan'] ?? '',
|
||||
@@ -2081,6 +2089,7 @@ function dbUpdateConnection(int $connectionId, array $data): void {
|
||||
$data['asennusosoite'] ?? '',
|
||||
$data['postinumero'] ?? '',
|
||||
$data['kaupunki'] ?? '',
|
||||
!empty($data['gateway_device_id']) ? $data['gateway_device_id'] : null,
|
||||
$connectionId
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user