<?php
session_start();
include_once($_SESSION['basedir'] . "veriflog.php");
include_once($_SESSION['basedir'] . "core.php");
include_once($_SESSION['basedir'] . "Class.Asterisk.cust.php");

$tool = new svaTool();

$queueInfoOutput = $custAstManager->getQueueInfo();
$queueInfoOutput2 = $custAstManager->getSipPeersInfo();

$onlineUsersCount = $queueInfoOutput2['onlineuser'];

$TempsAtenteMoyen = $tool->convertSecondsToHMS(round($queueInfoOutput['averageWaitTime'], 2));

//date exemple '2023-03-26'
$DureeMoyenneCommunication = $dba->getAverageDurationByDate(date("Y-m-d"));
$StatJourAppelNonDecroche = $dba->getUnpickedCallsCountByDate(date("Y-m-d"));
$VolumeAppelTraite = $dba->getProcessedCallsCountByDate(date("Y-m-d"));
$avgCallRespRate = $dba->getSCCAvgCallRespRate(date("Y-m-d"));

$response = array(
    "queueCount" => $queueInfoOutput['callsInQueue'],
    "avgCommDuration" => round($DureeMoyenneCommunication, 2),
    "processedCalls" => $VolumeAppelTraite,
    "responseRate" => $avgCallRespRate,
    "avgWaitTime" => $TempsAtenteMoyen,
    "missedCalls" => $StatJourAppelNonDecroche,
    "onlineuser" => $onlineUsersCount,
    "callsInProgress" => $queueInfoOutput['callsInProgress']
);

//var_dump($response);
echo json_encode($response);
?>
