<?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; }

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

$result = vicidial_api([
    'function'   => $pausa ? 'pause_agent' : 'resume_agent',
    'agent_user' => $agent,
]);

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