<?php
session_start();
header('Content-Type: application/json');
include '../../config/db.php';
include '../../config/vicidial.php';

if(!isset($_SESSION['user_id'])){ echo json_encode(['success'=>false]); exit; }

$agent = $_SESSION['vici_agent'] ?? ('agente'.intval($_SESSION['user_id']));

$result = vicidial_api([
    'function'   => 'agent_logout',
    'agent_user' => $agent,
]);

echo json_encode(['success'=>$result['success']]);
