feat: Add story points support and AI daily briefing feature
- Enhanced JIRA integration to fetch story points from multiple custom fields. - Updated task display to show story points and their estimated duration. - Introduced AI daily briefing banner with dynamic content loading. - Implemented subtasks functionality with add, toggle, and delete capabilities. - Improved task management UI with better accessibility and interaction.
This commit is contained in:
+93
@@ -205,6 +205,99 @@ try {
|
||||
exit;
|
||||
}
|
||||
|
||||
// 5. Persoonlijke AI Dagbriefing genereren
|
||||
if ($action === 'daily_briefing') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$date = !empty($data['date']) ? trim($data['date']) : date('Y-m-d');
|
||||
$today = date('Y-m-d');
|
||||
|
||||
// Haal openstaande taken van vandaag op
|
||||
$stmtPlan = $db->prepare("SELECT id FROM daily_plans WHERE user_id = ? AND plan_date = ?");
|
||||
$stmtPlan->execute([$user['id'], $date]);
|
||||
$planId = $stmtPlan->fetchColumn();
|
||||
|
||||
$isToday = ($date === $today);
|
||||
$taskFilter = $planId
|
||||
? "t.daily_plan_id = " . (int)$planId . ($isToday ? " OR t.daily_plan_id IS NULL" : "")
|
||||
: ($isToday ? "t.daily_plan_id IS NULL" : "1=0");
|
||||
|
||||
$tasks = $db->query("
|
||||
SELECT id, title, priority, time_block_start, duration_minutes
|
||||
FROM tasks
|
||||
WHERE user_id = {$user['id']} AND is_completed = 0 AND ({$taskFilter})
|
||||
ORDER BY priority ASC, time_block_start ASC
|
||||
LIMIT 15
|
||||
")->fetchAll();
|
||||
|
||||
// Haal gisteren niet-voltooide taken op
|
||||
$yesterday = date('Y-m-d', strtotime('-1 day', strtotime($date)));
|
||||
$stmtYest = $db->prepare("SELECT id FROM daily_plans WHERE user_id = ? AND plan_date = ?");
|
||||
$stmtYest->execute([$user['id'], $yesterday]);
|
||||
$yesterdayPlanId = $stmtYest->fetchColumn();
|
||||
$unfinishedYest = [];
|
||||
if ($yesterdayPlanId) {
|
||||
$stmtUnf = $db->prepare("
|
||||
SELECT title FROM tasks
|
||||
WHERE user_id = ? AND daily_plan_id = ? AND is_completed = 0
|
||||
LIMIT 5
|
||||
");
|
||||
$stmtUnf->execute([$user['id'], $yesterdayPlanId]);
|
||||
$unfinishedYest = $stmtUnf->fetchAll();
|
||||
}
|
||||
|
||||
// Haal Outlook meetings op als beschikbaar
|
||||
$meetings = [];
|
||||
try {
|
||||
require_once __DIR__ . '/../includes/integrations/microsoft.php';
|
||||
$meetings = microsoft_fetch_today_events($user['id'], $date);
|
||||
} catch (Throwable $e) {
|
||||
// meetings niet beschikbaar, geen probleem
|
||||
}
|
||||
|
||||
// Haal urgente Jira tickets op als beschikbaar
|
||||
$jiraIssues = [];
|
||||
try {
|
||||
require_once __DIR__ . '/../includes/integrations/jira.php';
|
||||
$jiraData = jira_get_dashboard_data($user['id'], false);
|
||||
$jiraIssues = array_merge(
|
||||
$jiraData['assigned_issues'] ?? [],
|
||||
$jiraData['team_issues'] ?? []
|
||||
);
|
||||
} catch (Throwable $e) {
|
||||
// Jira niet beschikbaar, geen probleem
|
||||
}
|
||||
|
||||
$aiSettings = get_ai_settings();
|
||||
if (empty($aiSettings['ai_enabled']) || empty($aiSettings['has_key'])) {
|
||||
echo json_encode(['error' => 'AI Co-Pilot is niet geconfigureerd']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$aiRes = fociz_ai_daily_briefing(
|
||||
$user['name'] ?? 'Jij',
|
||||
$date,
|
||||
$tasks,
|
||||
$meetings,
|
||||
$jiraIssues,
|
||||
$unfinishedYest
|
||||
);
|
||||
|
||||
if (!$aiRes['success']) {
|
||||
echo json_encode(['error' => $aiRes['error']]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'greeting' => $aiRes['greeting'],
|
||||
'focus_task' => $aiRes['focus_task'],
|
||||
'tip' => $aiRes['tip'],
|
||||
'warnings' => $aiRes['warnings'],
|
||||
'date' => $date,
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['error' => 'Onbekende actie']);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
|
||||
Reference in New Issue
Block a user