* retornara informa<EFBFBD><EFBFBD>es para o agente
*/
define("TIME_SLEEP_AGT", 1);
/*
* Define o tempo maximo em que informa<EFBFBD><EFBFBD>es
* do dac ser<EFBFBD>o retornados para a aplica<EFBFBD><EFBFBD>o.
*/
define("TIME_MIN_INFO_DAC", 10);
/*
* Este valor ser<EFBFBD> multiplicado pelo tempo
* definido para retornar as informa<EFBFBD><EFBFBD>es do agente, pois,
* as informa<EFBFBD><EFBFBD>es do dac n<EFBFBD>o precisam ser atualizadas com
* a mesma frequencia do agente
*/
define("TIME_ADIC_INFO_DAC", 3);
class MonitorAgente {
public function __construct($dbConect) {
$this->endScrp = false;
$this->statusAgt = false;
$this->matricula = GetMatricula();
$this->ramal = GetRamal();
$this->login = GetLogin();
$this->dac = $_SESSION[SS_DAC_CODIGO];
$this->dacDesc = $_SESSION[SS_DAC_DESCRICAO];
$this->db = $dbConect;
/*
* tempo em segundos que o aplicativo ira
* chacar os dados
*/
$this->tempoVerificaAgt = (SEG * TIME_SLEEP_AGT);
}
private function RetStatusAgt() {
return $this->statusAgt;
}
function __destruct() {
$this->LogoffAgente();
}
private function GetQueryMonitor($qr) {
$matricula = $this->matricula;
$dac = $this->dac;
$fila = $this->dacDesc;
if ($qr == 1) {
return "select (LOCALTIMESTAMP(0) - tempo_login) as tempo_logado, origem_destino as fone,
trim(status) as status_agente, (LOCALTIMESTAMP(0) - duracao) as duracao,
protocolo as num_protocolo, ramal as ramal_agente,
uniqueid2, extract(epoch from (now() - logado))::int as tempo_atualiza,
trim(motivo_pausa) as pausa_motivo_rt,
trim(uniqueid) as uniqueid, disponivel_atendimento
from pbx_supervisor_agentes
where matricula = '$matricula' ";
}
if ($qr == 2) {
/*
* Informa<EFBFBD><EFBFBD>es sobre a fila de atendimento
*/
return "SELECT
ATENDIDAS_PA
,ORIGINADAS_PA
,round( CASE WHEN(ESPERA = 0)THEN 0 ELSE (TEMPO_ESPERA / ESPERA) END ) * INTERVAL '1 SECOND' AS TME
,round( CASE WHEN(ATENDIDAS_PA = 0)THEN 0 ELSE ((TEMPO_ATENDIMENTO + TEMPO_ORIGINDADA) / (ATENDIDAS_PA + ORIGINADAS_PA))END) * INTERVAL '1 SECOND' AS TMA
FROM (
SELECT fila
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER', 'TRANSFER') THEN 1 ELSE 0 END) AS ATENDIDAS_PA
,SUM (CASE WHEN EVENTO IN ('COMPLETAAGENT','COMPLETACALLER', 'TRANSFERORIG') THEN 1 ELSE 0 END) AS ORIGINADAS_PA
,SUM (CASE WHEN EVENTO IN ('CONNECT') AND to_number(param1,'999999999') > '3' THEN 1 ELSE 0 END) AS ESPERA
,SUM (CASE WHEN EVENTO IN ('CONNECT') AND to_number(param1,'999999999') > '1' THEN to_number(param1,'999999999') ELSE 0 END) AS TEMPO_ESPERA
,SUM (CASE WHEN EVENTO IN ('COMPLETEAGENT','COMPLETECALLER') AND to_number(param2,'999999999') > '1' THEN to_number(param2,'999999999') ELSE 0 END) AS TEMPO_ATENDIMENTO
,SUM (CASE WHEN EVENTO IN ('COMPLETAAGENT','COMPLETACALLER') AND to_number(param2,'999999999') > '1' THEN to_number(param2,'999999999') ELSE 0 END) AS TEMPO_ORIGINDADA
,SUM (CASE WHEN( (EVENTO = 'ABANDON') AND (to_number(param2,'999999999') > '1') ) THEN to_number(param3,'999999999') ELSE 0 END) AS TEMPO_ABANDONO