query('SELECT * FROM ai_call_logs ORDER BY call_start_time DESC'); $call_logs = $stmt_call_logs->fetchAll(); // Calculate performance metrics $total_calls = count($call_logs); $total_duration_seconds = 0; foreach ($call_logs as $log) { $start = new DateTime($log['call_start_time']); $end = new DateTime($log['call_end_time']); $duration = $end->getTimestamp() - $start->getTimestamp(); $total_duration_seconds += $duration; } $avg_call_duration = $total_calls > 0 ? $total_duration_seconds / $total_calls : 0; // Data for charts $intent_distribution = []; $outcome_distribution = []; foreach ($call_logs as $log) { $intent_distribution[$log['call_intent']] = ($intent_distribution[$log['call_intent']] ?? 0) + 1; $outcome_distribution[$log['call_outcome']] = ($outcome_distribution[$log['call_outcome']] ?? 0) + 1; } } catch (PDOException $e) { $error = "Database error: " . $e->getMessage(); } $project_name = "HVAC Command Center"; $page_title = "AI Call Logs"; ?> <?= htmlspecialchars($page_title) ?> | <?= htmlspecialchars($project_name) ?>

Total Calls

Avg. Call Duration

s

Call Intent Distribution
Call Outcome Distribution
All AI Call Logs
Call ID Start Time End Time Intent Outcome Summary
No call logs found.