Browse Source

validar inatividade do agente

websocket
lucas cardoso 3 years ago
parent
commit
e879bdfa16
  1. 29
      service/ServiceSupervisorPBx.php

29
service/ServiceSupervisorPBx.php

@ -16,18 +16,24 @@ class ServiceSupervisorPBx implements IService
$this->supervisorModel = new SupervisorModel;
$agentes = $this->supervisorModel->listaAgentesDisponivel(null, false);
foreach ($agentes as $key => $agente) {
$agentPbx = $this->validaAgentCriado($agente->matricula);
if (!$agentPbx) {
$this->criaRegistroSupervisor($agente);
if ($this->validaInatividade($agente->duracao)) {
$agentPbx = $this->validaAgentCriado($agente->matricula);
if (!$agentPbx) {
$this->criaRegistroSupervisor($agente);
} else {
$this->atualizaTabelaSupervisor($agente, $agentPbx);
}
} else {
$this->atualizaTabelaSupervisor($agente, $agentPbx);
$this->supervisorModel->deleteAgent($agente->matricula);
}
}
$agentesPbx = $this->supervisorModel->findAllAgentesPBX();
foreach ($agentesPbx as $key => $pbx) {
$age = $this->supervisorModel->findAgentByMatricula($pbx->matricula);
if (empty($age) && empty($pbx->ramal)) {
$this->supervisorModel->deleteAgentPbx($pbx->matricula);
if (empty($pbx->ramal)) {
$age = $this->supervisorModel->findAgentByMatricula($pbx->matricula);
if (empty($age) && empty($pbx->ramal)) {
$this->supervisorModel->deleteAgentPbx($pbx->matricula);
}
}
}
}
@ -84,4 +90,13 @@ class ServiceSupervisorPBx implements IService
}
return 0;
}
function validaInatividade($dateTime)
{
$timealert = strtotime($dateTime . '+40 seconds');
if ($timealert < strtotime(date('Y-m-d H:i:s'))) {
return false;
}
return true;
}
}
Loading…
Cancel
Save