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.
42 lines
1.8 KiB
42 lines
1.8 KiB
<?php |
|
|
|
namespace app\Actions; |
|
|
|
use app\Repositories\AtendimentoRepository; |
|
use app\Repositories\ConfigAtendimentoRepository; |
|
use app\Repositories\SupervisorRepository; |
|
use app\Models\SupervisorModel; |
|
|
|
class AtualizaStatusAgenteAction |
|
{ |
|
private SupervisorRepository $supervisorRepository; |
|
private AtendimentoRepository $atendimentoRepository; |
|
private ConfigAtendimentoRepository $configAtendimentoRepository; |
|
function __construct() |
|
{ |
|
$this->supervisorRepository = new SupervisorRepository; |
|
$this->atendimentoRepository = new AtendimentoRepository; |
|
$this->configAtendimentoRepository = new ConfigAtendimentoRepository; |
|
} |
|
function __invoke(SupervisorModel $agente): string |
|
{ |
|
$atendimentosAbertos = $this->atendimentoRepository->getAtendimentoAbertoByAgente($agente->matricula); |
|
$param = $this->configAtendimentoRepository->get(['id_empresa'=>$agente->id_empresa ]); |
|
if ($agente->status == CONF_AGENT_STATUS_LIVRE || $agente->status == CONF_AGENT_STATUS_OCUPADO) { |
|
if (count($atendimentosAbertos) < $param->quantidade_simutaneo) { |
|
$this->supervisorRepository->update(['matricula' => $agente->matricula, 'status' => CONF_AGENT_STATUS_LIVRE]); |
|
return CONF_AGENT_STATUS_LIVRE; |
|
} else { |
|
$this->supervisorRepository->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); |
|
} |
|
} |
|
return 'None'; |
|
} |
|
} |