|
|
|
@ -6,7 +6,6 @@ use app\Actions\EntrarPausaAction;
|
|
|
|
|
use app\Actions\SairPausaAction; |
|
|
|
|
use app\Core\Controller; |
|
|
|
|
use app\Interfaces\IModule; |
|
|
|
|
use app\Models\AtendimentoModel; |
|
|
|
|
use app\Models\SupervisorModel; |
|
|
|
|
use app\Repositories\PauseRepository; |
|
|
|
|
use app\Repositories\SupervisorRepository; |
|
|
|
@ -30,13 +29,12 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
static function route() |
|
|
|
|
{ |
|
|
|
|
return function (RouteCollectorProxy $group) { |
|
|
|
|
$group->get('', [self::class, 'listarAgentes']); |
|
|
|
|
$group->post('/entrarPausa', [self::class, 'enterPause']); |
|
|
|
|
$group->post('/sairPausa', [self::class, 'exitPause']); |
|
|
|
|
$group->get('', [self::class , 'listarAgentes']); |
|
|
|
|
$group->post('/entrarPausa', [self::class , 'enterPause']); |
|
|
|
|
$group->post('/sairPausa', [self::class , 'exitPause']); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function __construct() |
|
|
|
|
{ |
|
|
|
|
$this->supervisorRepository = new SupervisorRepository; |
|
|
|
@ -50,12 +48,13 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
$agentes = $this->supervisorRepository->list($params); |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno( |
|
|
|
|
"Sucesso", |
|
|
|
|
true, |
|
|
|
|
$agentes |
|
|
|
|
) |
|
|
|
|
"Sucesso", |
|
|
|
|
true, |
|
|
|
|
$agentes |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} catch (Throwable $th) { |
|
|
|
|
} |
|
|
|
|
catch (Throwable $th) { |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno($th->getMessage()) |
|
|
|
|
); |
|
|
|
@ -72,18 +71,18 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
$dados = $this->supervisorRepository->get(['matricula' => $body['matricula']]); |
|
|
|
|
//verifica se existe agente |
|
|
|
|
if (empty($dados)) { |
|
|
|
|
throw new Exception("Agente não encontrado"); |
|
|
|
|
throw new Exception("Agente não encontrado"); |
|
|
|
|
} |
|
|
|
|
$agente = SupervisorModel::ArrayTo(get_object_vars($dados)); |
|
|
|
|
$pausa = $this->pausaRepository->get(['id' => $body['id_pausa']]); |
|
|
|
|
if (empty($pausa)) { |
|
|
|
|
throw new Exception("Pausa não encontrado"); |
|
|
|
|
throw new Exception("Pausa não encontrado"); |
|
|
|
|
} |
|
|
|
|
if ($agente->status == CONF_AGENT_STATUS_PAUSA || $agente->status == CONF_AGENT_STATUS_INDISPONIVEL) { |
|
|
|
|
throw new Exception('Agente precisa estar livre para entrar em pausa!'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Coloca em pausa ou indisponivel se tiver atendimento aberto |
|
|
|
|
//Coloca em pausa ou indisponivel se tiver atendimento aberto |
|
|
|
|
$action = new EntrarPausaAction(); |
|
|
|
|
$statusAgente = $action($agente, $pausa); |
|
|
|
|
$this->supervisorRepository->db->commit(); |
|
|
|
@ -93,11 +92,12 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
|
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno( |
|
|
|
|
"Agente em '$statusAgente'", |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
"Agente em '$statusAgente'", |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} catch (Throwable $th) { |
|
|
|
|
} |
|
|
|
|
catch (Throwable $th) { |
|
|
|
|
$this->supervisorRepository->db->rollback(); |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno($th->getMessage()) |
|
|
|
@ -113,11 +113,11 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
$body = json_decode($request->getBody()->getContents(), true); |
|
|
|
|
$dadosAgent = $this->supervisorRepository->get(['matricula' => $body['matricula']]); |
|
|
|
|
if (!$dadosAgent) { |
|
|
|
|
throw new Exception('Telefone não identificado!'); |
|
|
|
|
throw new Exception('Telefone não identificado!'); |
|
|
|
|
} |
|
|
|
|
$agent = SupervisorModel::ArrayTo(get_object_vars($dadosAgent)); |
|
|
|
|
if ($agent->status != CONF_AGENT_STATUS_PAUSA && $agent->status != CONF_AGENT_STATUS_INDISPONIVEL) { |
|
|
|
|
throw new Exception('Agente não está em pausa!'); |
|
|
|
|
throw new Exception('Agente não está em pausa!'); |
|
|
|
|
} |
|
|
|
|
$action = new SairPausaAction(); |
|
|
|
|
$action($agent); |
|
|
|
@ -126,11 +126,12 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
$ws->enviaMsg($ws->enviaActions("Agente 'livre'", 'att_status', $agent->matricula)); |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno( |
|
|
|
|
"Agente 'livre'", |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
"Agente 'livre'", |
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} catch (Throwable $th) { |
|
|
|
|
} |
|
|
|
|
catch (Throwable $th) { |
|
|
|
|
$this->supervisorRepository->db->rollback(); |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno($th->getMessage()) |
|
|
|
|