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 @@
+
+
+
📧 Zammad (O365-sähköposti)
+
Synkronoi tiketit Zammad-helpdeskistä. Yhdistää O365-sähköpostit tikettijärjestelmään.
+
+
+
+
@@ -1640,46 +1666,6 @@
-
-
-
-
-
📧 Zammad-asetukset
-
-
-
@@ -1687,6 +1673,22 @@
+
+
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';
}