You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.5 KiB

<?php
namespace app\Actions;
use app\Models\AtendimentoModel;
use app\Models\ParametrosModel;
use app\Models\SupervisorModel;
class AtualizaStatusAgenteAction
{
private SupervisorModel $supervisorModel;
private AtendimentoModel $atendimentoModel;
private ParametrosModel $parametrosModel;
function __construct()
{
$this->supervisorModel = new SupervisorModel;
$this->atendimentoModel = new AtendimentoModel;
$this->parametrosModel = new ParametrosModel;
}
function __invoke($agente): string
{
$atendimentosAbertos = $this->atendimentoModel->getAtendimentoAbertoByAgente($agente->matricula);
$param = $this->parametrosModel->get([]);
if ($agente->status == CONF_AGENT_STATUS_LIVRE || $agente->status == CONF_AGENT_STATUS_OCUPADO) {
if (count($atendimentosAbertos) < $param->prm_media_simultaneo) {
$this->supervisorModel->update(['matricula' => $agente->matricula, 'status' => CONF_AGENT_STATUS_LIVRE]);
return CONF_AGENT_STATUS_LIVRE;
} else {
$this->supervisorModel->update(['matricula' => $agente->matricula, 'status' => CONF_AGENT_STATUS_OCUPADO]);
return CONF_AGENT_STATUS_OCUPADO;
}
}
if ($agente->status == CONF_AGENT_STATUS_INDISPONIVEL) {
if (empty($atendimentosAbertos)) {
$action = new EntrarPausaAction();
return $action($agente, $agente->motivo_pausa);
}
}
}
}