feat: lisätiedot-kenttä asiakasyhteyksiin (kytkin, IP, VLAN yms.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 19:09:45 +02:00
parent 18d378be63
commit c6e68fd1e3
3 changed files with 11 additions and 4 deletions

7
db.php
View File

@@ -408,6 +408,7 @@ function initDatabase(): void {
"ALTER TABLE customers ADD COLUMN priority_emails TEXT DEFAULT '' AFTER lisatiedot",
"ALTER TABLE companies ADD COLUMN enabled_modules TEXT DEFAULT '' AFTER cors_origins",
"ALTER TABLE users MODIFY COLUMN role ENUM('superadmin','admin','user') DEFAULT 'user'",
"ALTER TABLE customer_connections ADD COLUMN lisatiedot TEXT DEFAULT '' AFTER alkupvm",
];
foreach ($alters as $sql) {
try { $db->query($sql); } catch (\Throwable $e) { /* sarake on jo olemassa / jo ajettu */ }
@@ -702,6 +703,7 @@ function dbLoadCustomers(string $companyId): array {
'hinta' => (float)($conn['hinta'] ?? 0),
'sopimuskausi' => $conn['sopimuskausi'] ?? '',
'alkupvm' => $conn['alkupvm'] ?? '',
'lisatiedot' => $conn['lisatiedot'] ?? '',
];
}, $conns);
unset($c['company_id']);
@@ -755,8 +757,8 @@ function dbSaveCustomer(string $companyId, array $customer): void {
if (!empty($customer['liittymat'])) {
foreach ($customer['liittymat'] as $l) {
_dbExecute("
INSERT INTO customer_connections (customer_id, asennusosoite, postinumero, kaupunki, liittymanopeus, hinta, sopimuskausi, alkupvm)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
INSERT INTO customer_connections (customer_id, asennusosoite, postinumero, kaupunki, liittymanopeus, hinta, sopimuskausi, alkupvm, lisatiedot)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
", [
$customer['id'],
$l['asennusosoite'] ?? '',
@@ -766,6 +768,7 @@ function dbSaveCustomer(string $companyId, array $customer): void {
$l['hinta'] ?? 0,
$l['sopimuskausi'] ?? '',
$l['alkupvm'] ?? '',
$l['lisatiedot'] ?? '',
]);
}
}