prepare("SELECT * FROM integrations WHERE user_id = ? AND provider = 'OUTLOOK'"); $stmtExisting->execute([$userId]); $existing = $stmtExisting->fetch(); $existingSettings = json_decode($existing['settings'] ?? '{}', true) ?: []; // Als geheim veld leeg is gelaten of bullet tekens bevat, behoud het bestaande geheim if (($clientSecret === '' || $clientSecret === '••••••••••••••••') && !empty($existingSettings['client_secret']) && $existingSettings['client_secret'] !== '••••••••••••••••') { $clientSecret = $existingSettings['client_secret']; } $newSettings = array_merge($existingSettings, [ 'client_id' => $clientId, 'client_secret' => $clientSecret, 'tenant_id' => $tenantId, ]); $stmt = $db->prepare(" INSERT INTO integrations (user_id, provider, is_enabled, is_demo_mode, settings, last_sync_at) VALUES (?, 'OUTLOOK', 1, ?, ?, NOW()) ON DUPLICATE KEY UPDATE is_demo_mode = VALUES(is_demo_mode), settings = VALUES(settings), last_sync_at = NOW() "); $stmt->execute([$userId, $isDemo, json_encode($newSettings)]); // Als gebruiker direct op 'Koppel nu' klikte if ($action === 'connect_oauth') { if (empty($clientId)) { $message = "Vul eerst de Application (Client) ID in van uw Azure App Registratie."; $messageType = 'error'; } elseif (empty($clientSecret)) { $message = "Vul eerst het Client Secret in van uw Azure App Registratie."; $messageType = 'error'; } else { header("Location: /auth/oauth_microsoft.php?client_id=" . urlencode($clientId) . "&tenant_id=" . urlencode($tenantId)); exit; } } else { $message = "Instellingen voor Microsoft Outlook zijn succesvol opgeslagen."; $messageType = 'success'; } } // 3. Teams Opslaan elseif ($provider === 'TEAMS') { $isDemo = isset($_POST['is_demo_mode']) ? 1 : 0; $stmt = $db->prepare(" INSERT INTO integrations (user_id, provider, is_enabled, is_demo_mode, last_sync_at) VALUES (?, 'TEAMS', 1, ?, NOW()) ON DUPLICATE KEY UPDATE is_demo_mode = VALUES(is_demo_mode), last_sync_at = NOW() "); $stmt->execute([$userId, $isDemo]); $message = "Instellingen voor Microsoft Teams zijn bijgewerkt."; } // 4. Jira Opslaan & Testen elseif ($provider === 'JIRA') { $jiraDomain = jira_normalize_domain($_POST['jira_domain'] ?? ''); $jiraEmail = trim($_POST['jira_email'] ?? ''); $jiraToken = trim($_POST['jira_api_token'] ?? ''); $isDemo = isset($_POST['is_demo_mode']) ? 1 : 0; // Haal bestaande instellingen op $stmtExisting = $db->prepare("SELECT * FROM integrations WHERE user_id = ? AND provider = 'JIRA'"); $stmtExisting->execute([$userId]); $existing = $stmtExisting->fetch(); $existingSettings = json_decode($existing['settings'] ?? '{}', true) ?: []; if (($jiraToken === '' || $jiraToken === '••••••••••••••••') && !empty($existingSettings['jira_api_token']) && $existingSettings['jira_api_token'] !== '••••••••••••••••') { $jiraToken = $existingSettings['jira_api_token']; } // Als niet in demo mode, test verbinding $accountName = $existingSettings['account_name'] ?? ''; $accountId = $existingSettings['account_id'] ?? ''; if (!$isDemo && !empty($jiraDomain) && !empty($jiraEmail) && !empty($jiraToken)) { $testRes = jira_test_connection($jiraDomain, $jiraEmail, $jiraToken); if (!$testRes['success']) { $message = "Jira Verbindingsfout: " . $testRes['error']; $messageType = 'error'; } else { $accountName = $testRes['user']['displayName'] ?? 'Jira Gebruiker'; $accountId = $testRes['user']['accountId'] ?? ''; $message = "Verbinding met Jira geslaagd! Ingelogd als: {$accountName}"; $messageType = 'success'; } } else { $message = "Jira instellingen opgeslagen."; $messageType = 'success'; } $newSettings = [ 'jira_domain' => $jiraDomain, 'jira_email' => $jiraEmail, 'jira_api_token' => $jiraToken, 'account_name' => $accountName, 'account_id' => $accountId, ]; $stmt = $db->prepare(" INSERT INTO integrations (user_id, provider, is_enabled, is_demo_mode, settings, last_sync_at) VALUES (?, 'JIRA', 1, ?, ?, NOW()) ON DUPLICATE KEY UPDATE is_demo_mode = VALUES(is_demo_mode), settings = VALUES(settings), last_sync_at = NOW() "); $stmt->execute([$userId, $isDemo, json_encode($newSettings)]); // Wis cache unset($_SESSION["jira_issues_user_{$userId}"]); } } // Laad nu pas de HTML header in require_once __DIR__ . '/includes/header.php'; // Haal huidige configuraties op $stmtConfigs = $db->prepare("SELECT * FROM integrations WHERE user_id = ?"); $stmtConfigs->execute([$userId]); $configsRaw = $stmtConfigs->fetchAll(); $configs = []; foreach ($configsRaw as $c) { $configs[$c['provider']] = $c; $configs[$c['provider']]['settings_parsed'] = json_decode($c['settings'] ?? '{}', true) ?: []; } // Bepaal statussen $isOutlookConnected = !empty($configs['OUTLOOK']['access_token']) && empty($configs['OUTLOOK']['is_demo_mode']); $outlookSettings = $configs['OUTLOOK']['settings_parsed'] ?? []; $isJiraConnected = !empty($configs['JIRA']) && empty($configs['JIRA']['is_demo_mode']) && !empty($configs['JIRA']['settings_parsed']['jira_api_token']); $jiraSettings = $configs['JIRA']['settings_parsed'] ?? []; // Haal actuele Jira issues op $forceRefresh = isset($_GET['refresh_jira']); $jiraData = jira_get_user_issues($userId, $forceRefresh); $jiraIssues = $jiraData['issues'] ?? []; $jiraIsDemo = !empty($jiraData['is_demo']); // Callback redirect URI $redirectUri = rtrim(APP_URL, '/') . '/auth/callback_microsoft.php'; ?>
Koppel Microsoft 365 Outlook (voor realtime agenda & Teams meetings) en Atlassian Jira Cloud (om direct uw toegewezen tickets in te plannen).
Synchroniseert automatisch uw zakelijke agenda-afspraken en meetings naar de dagplanner tijdlijn.
1. Open Azure App Registraties en maak een nieuwe registratie.
2. Kies Accounts in elke organisatiemap (...) en persoonlijke Microsoft-accounts.
3. Voeg een Web Omleidings-URI toe:
4. Maak een geheim aan onder Certificaten en geheimen.
5. Voeg API-machtigingen toe: Calendars.Read, User.Read, offline_access.
Detecteert Teams vergaderingen automatisch vanuit uw Outlook agenda en toont directe 'Deelnemen' knoppen.
Teams vergaderingen worden automatisch uitgelezen zodra Microsoft Outlook is gekoppeld. U hoeft voor Teams geen aparte koppeling te configureren!
Koppelt uw Jira tickets rechtstreeks aan de Fociz dagplanning en roadmap.