diff --git a/api.php b/api.php
index 6b0f760..d3339c2 100644
--- a/api.php
+++ b/api.php
@@ -4266,6 +4266,56 @@ switch ($action) {
}
break;
+ case 'netadmin_connection':
+ requireAuth();
+ $companyId = requireCompany();
+ try {
+ $connId = (int)($_GET['id'] ?? 0);
+ if (!$connId) {
+ http_response_code(400);
+ echo json_encode(['error' => 'Liittymän ID puuttuu']);
+ break;
+ }
+ $conn = dbLoadConnection($connId);
+ if (!$conn || $conn['company_id'] !== $companyId) {
+ http_response_code(404);
+ echo json_encode(['error' => 'Liittymää ei löytynyt']);
+ break;
+ }
+ echo json_encode($conn);
+ } catch (Exception $e) {
+ http_response_code(500);
+ echo json_encode(['error' => 'Liittymän haku epäonnistui: ' . $e->getMessage()]);
+ }
+ break;
+
+ case 'netadmin_connection_update':
+ requireAuth();
+ $companyId = requireCompany();
+ if ($method !== 'POST') break;
+ try {
+ $input = json_decode(file_get_contents('php://input'), true);
+ $connId = (int)($input['id'] ?? 0);
+ if (!$connId) {
+ http_response_code(400);
+ echo json_encode(['error' => 'Liittymän ID puuttuu']);
+ break;
+ }
+ $conn = dbLoadConnection($connId);
+ if (!$conn || $conn['company_id'] !== $companyId) {
+ http_response_code(404);
+ echo json_encode(['error' => 'Liittymää ei löytynyt']);
+ break;
+ }
+ dbUpdateConnection($connId, $input);
+ $updated = dbLoadConnection($connId);
+ echo json_encode($updated);
+ } catch (Exception $e) {
+ http_response_code(500);
+ echo json_encode(['error' => 'Liittymän päivitys epäonnistui: ' . $e->getMessage()]);
+ }
+ break;
+
// ==================== LAITETILAT ====================
case 'laitetilat':
diff --git a/db.php b/db.php
index c458569..030febd 100644
--- a/db.php
+++ b/db.php
@@ -1895,3 +1895,29 @@ function dbLoadAllConnections(string $companyId): array {
ORDER BY cc.kaupunki, cc.asennusosoite
", ['companyId' => $companyId]);
}
+
+function dbLoadConnection(int $connectionId): ?array {
+ return _dbFetchOne("
+ SELECT cc.*, c.yritys AS customer_name, c.company_id
+ FROM customer_connections cc
+ JOIN customers c ON c.id = cc.customer_id
+ WHERE cc.id = ?
+ ", [$connectionId]);
+}
+
+function dbUpdateConnection(int $connectionId, array $data): void {
+ _dbExecute("UPDATE customer_connections SET
+ liittymanopeus = ?, vlan = ?, laite = ?, portti = ?, ip = ?,
+ asennusosoite = ?, postinumero = ?, kaupunki = ?
+ WHERE id = ?", [
+ $data['liittymanopeus'] ?? '',
+ $data['vlan'] ?? '',
+ $data['laite'] ?? '',
+ $data['portti'] ?? '',
+ $data['ip'] ?? '',
+ $data['asennusosoite'] ?? '',
+ $data['postinumero'] ?? '',
+ $data['kaupunki'] ?? '',
+ $connectionId
+ ]);
+}
diff --git a/index.html b/index.html
index fc06809..574d1ee 100644
--- a/index.html
+++ b/index.html
@@ -1006,6 +1006,73 @@
Ei liittymiä.
+
+
+
+
+
+
+
Liittymän tiedot
+
+
+
+
+
+
+
diff --git a/script.js b/script.js
index c1c521c..9471315 100644
--- a/script.js
+++ b/script.js
@@ -650,7 +650,12 @@ function createLiittymaRow(data = {}, index = 0) {
-
+