From 4a46ce56f3f9419a1c249f9ca0c9713f815a27f4 Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Thu, 12 Mar 2026 20:00:36 +0200 Subject: [PATCH] =?UTF-8?q?Zammad-asetukset=20API-v=C3=A4lilehdelle,=20int?= =?UTF-8?q?egraatio-checkboxit=20erilliseksi=20kortiksi,=20korjaa=20tyyppi?= =?UTF-8?q?=20puuttuu=20-virhe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Integraatiot erillinen table-card yrityksen asetuksissa (vain superadmin) - Zammad-konfiguraatio (URL, token, ryhmät, synkronointi) siirretty API-tabiin - Saatavuus-API, Telegram ja Zammad kortit näkyvät API-tabissa kun integraatio on enabloitu - Korjattu integration_save ja integration_test: puuttuva $input json_decode Co-Authored-By: Claude Opus 4.6 --- api.php | 2 ++ index.html | 82 ++++++++++++++++++++++++++++-------------------------- script.js | 20 +++++++++++-- 3 files changed, 61 insertions(+), 43 deletions(-) diff --git a/api.php b/api.php index 07f58ea..d34b6aa 100644 --- a/api.php +++ b/api.php @@ -4987,6 +4987,7 @@ switch ($action) { case 'integration_save': requireCompany(); + $input = json_decode(file_get_contents('php://input'), true); $type = $input['type'] ?? ''; $enabled = (bool)($input['enabled'] ?? false); $config = $input['config'] ?? []; @@ -5006,6 +5007,7 @@ switch ($action) { case 'integration_test': requireCompany(); + $input = json_decode(file_get_contents('php://input'), true); $type = $input['type'] ?? $_GET['type'] ?? ''; $integ = dbGetIntegration($companyId, $type); if (!$integ) { http_response_code(404); echo json_encode(['error' => 'Integraatiota ei löydy']); break; } diff --git a/index.html b/index.html index 2ab86ee..b9a8a48 100644 --- a/index.html +++ b/index.html @@ -1535,6 +1535,32 @@ + + + @@ -1640,46 +1666,6 @@ - - - - + +
diff --git a/script.js b/script.js index 28c9ad9..67938bf 100644 --- a/script.js +++ b/script.js @@ -2366,10 +2366,25 @@ async function loadSettings() { const integs = await apiCall('integrations'); const saatavuusEnabled = integs.find(i => i.type === 'saatavuus_api')?.enabled; const telegramEnabled = integs.find(i => i.type === 'telegram')?.enabled; + const zammadInteg = integs.find(i => i.type === 'zammad'); + const zammadEnabled = zammadInteg?.enabled; const saatCard = document.getElementById('settings-saatavuus-api-card'); const teleCard = document.getElementById('settings-telegram-card'); + const zammadCard = document.getElementById('settings-zammad-card'); if (saatCard) saatCard.style.display = saatavuusEnabled ? '' : 'none'; if (teleCard) teleCard.style.display = telegramEnabled ? '' : 'none'; + if (zammadCard) zammadCard.style.display = zammadEnabled ? '' : 'none'; + // Lataa Zammad-asetukset korttiin + if (zammadEnabled && zammadInteg?.config) { + document.getElementById('company-zammad-url').value = zammadInteg.config.url || ''; + document.getElementById('company-zammad-token').value = zammadInteg.config.token || ''; + if (zammadInteg.config.group_ids && zammadInteg.config.group_names) { + renderCompanyZammadGroups( + zammadInteg.config.group_names.map((name, i) => ({ id: zammadInteg.config.group_ids[i], name })), + zammadInteg.config.group_ids + ); + } + } } catch (e) { console.error(e); } // Vastauspohjat @@ -2572,11 +2587,9 @@ async function showCompanyDetail(id) { const isSA = currentUser?.role === 'superadmin'; const modulesSection = document.getElementById('company-modules-section'); const integrationsSection = document.getElementById('company-integrations-section'); - const zammadConfig = document.getElementById('company-zammad-config'); const ipsSection = document.getElementById('company-allowed-ips-section'); if (modulesSection) modulesSection.style.display = isSA ? '' : 'none'; if (integrationsSection) integrationsSection.style.display = isSA ? '' : 'none'; - if (!isSA && zammadConfig) zammadConfig.style.display = 'none'; if (ipsSection) ipsSection.style.display = isSA ? '' : 'none'; // Moduuli-checkboxit (yhteensopivuus: vanha 'devices' → 'tekniikka') @@ -2641,7 +2654,8 @@ async function loadCompanyIntegrations() { } function toggleCompanyZammadConfig(show) { - const card = document.getElementById('company-zammad-config'); + // Zammad-kortti on nyt API-tabissa + const card = document.getElementById('settings-zammad-card'); if (card) card.style.display = show ? '' : 'none'; }