|
|
|
@ -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; |
|
|
|
@ -36,7 +35,6 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function __construct() |
|
|
|
|
{ |
|
|
|
|
$this->supervisorRepository = new SupervisorRepository; |
|
|
|
@ -55,7 +53,8 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
$agentes |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} catch (Throwable $th) { |
|
|
|
|
} |
|
|
|
|
catch (Throwable $th) { |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno($th->getMessage()) |
|
|
|
|
); |
|
|
|
@ -72,12 +71,12 @@ 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!'); |
|
|
|
@ -97,7 +96,8 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
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); |
|
|
|
@ -130,7 +130,8 @@ class SupervisorController extends Controller implements IModule
|
|
|
|
|
true |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} catch (Throwable $th) { |
|
|
|
|
} |
|
|
|
|
catch (Throwable $th) { |
|
|
|
|
$this->supervisorRepository->db->rollback(); |
|
|
|
|
$response->getBody()->write( |
|
|
|
|
$this->retorno($th->getMessage()) |
|
|
|
|