From 725b182b7a4426529fafa6083c04959912f6df1e Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 18 Jul 2024 10:48:03 -0400 Subject: [PATCH] Limpar dados da tela do agente(agentert) quando muda de empresa --- agente/agentert.php | 4 ++-- agente/funcoesAgente.php | 4 +++- ajaxPhp.php | 32 +++++++++++++++++++++++++++++++- include/util/funcoesApl.php | 2 +- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/agente/agentert.php b/agente/agentert.php index b9f7b56b..f7b8ec38 100644 --- a/agente/agentert.php +++ b/agente/agentert.php @@ -1637,14 +1637,14 @@ function DesConectaAgenteRt($db, $type = '', $org_id) * Se o agente estiver em pausa é removido antes de deslogar. */ if ($_SESSION[SS_PAUSA_AGENTE]) { - @SairPausa($db, $org_id); + SairPausa($db, $org_id); } /* * Se o tipo de atendimento for manual remove agente da fila. */ if ($_SESSION[SS_MODO_ATENDIMENTO_COD] == ATENDIMENTO_MANUAL) { - @GetUrl(AST_REM_FILA); + GetUrl(AST_REM_FILA); } /* diff --git a/agente/funcoesAgente.php b/agente/funcoesAgente.php index 167aa806..7b7f0d08 100644 --- a/agente/funcoesAgente.php +++ b/agente/funcoesAgente.php @@ -445,6 +445,8 @@ function GetAgenteDisponivelFila() function DesconectarDac() { + $org_id = $_SESSION['SSEmpresaPadrao']; + /* * Verifica se o usuário clicou no botao desconectar. */ @@ -455,7 +457,7 @@ function DesconectarDac() * Retorna true se o usuário estiver conectado. */ $matricula = GetMatricula(); - $query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' "; + $query = "select count(*) from pbx_supervisor_agentes where matricula = '$matricula' and org_id = $org_id"; $result = pg_query($query); $row = @pg_fetch_row($result); return $row[0]; diff --git a/ajaxPhp.php b/ajaxPhp.php index 9f76ce50..a76f8150 100644 --- a/ajaxPhp.php +++ b/ajaxPhp.php @@ -25,11 +25,41 @@ if (isset($_GET['GetUser'])) { if (isset($_GET['org_id'])) { $organizacao = GetAllOrganizacao(); + foreach ($organizacao as $v) { if ($v['id'] == $_GET['org_id']) { - $_SESSION['SSEmpresaPadrao'] = $v['id']; + $_SESSION['SSEmpresaPadrao'] = $v['id']; /* defini nova empresa Session da nova empresa*/ + clearInfoOrganization(); GetParametros($dbcon); break; } } } + +/* \brief Limpar valores $SESSION e cookie quando troca de empresa. + * + * Apenas o administrador e o Admin(simplesip) poderá trocar de empresa + * + */ +function clearInfoOrganization(){ + + /* informação do agente */ + SetCookieApl(RAMAL_MONITOR_AUDIO, ""); + SetCookieApl(CANAL_MONITOR_AUDIO, ""); + SetCookieApl(RAMAL_MONITOR_SUPERVISOR, ""); + SetCookieApl(CANAL_MONITOR_SUPERVISOR, ""); + SetCookieApl(RAMAL_MONITOR_AGENTE, ""); + SetCookieApl(CANAL_MONITOR_AGENTE, "") ; + + $_SESSION[RAMAL_MONITOR_AGENTE] = ""; + $_SESSION[CANAL_MONITOR_AGENTE] = ""; + $_SESSION[SS_DAC_CODIGO] = 0; + $_SESSION[RAMAL_DESTINO] = 0; + $_SESSION[SS_STATUS_AGENTE] = 'OFF'; + $_SESSION[SS_PAUSA_AGENTE] = 0; + $_SESSION[AGT_NUM_DISC] = ""; + $_SESSION[AGT_CHANNEL_TRANSF] = NULL; + $_SESSION[SS_AGT_CHANNEL_AGENTE] = NULL; + $_SESSION[SS_PAUSA_AGENTE_MOTIVO] = NULL; + $_SESSION[AGT_CHANNEL_TRCONSULTA] = NULL; +} \ No newline at end of file diff --git a/include/util/funcoesApl.php b/include/util/funcoesApl.php index 91576372..9d72fbb9 100755 --- a/include/util/funcoesApl.php +++ b/include/util/funcoesApl.php @@ -3785,7 +3785,7 @@ function ConfigRamalMonitorar() { * Ramal invélido retorna falso. */ if ($canalMonitorar === false) { - GeraExcept("Erro;Ramal invélido!"); + GeraExcept("Erro;Ramal inválido!"); } if (!SetCookieApl($nomeRamalMonitorar, $ramalMonitorar)) {