diff --git a/admin/rotasEntrada.php b/admin/rotasEntrada.php index 18998823..06169876 100644 --- a/admin/rotasEntrada.php +++ b/admin/rotasEntrada.php @@ -4,6 +4,7 @@ $id = isset($_GET['id']) ? trim($_GET['id']) : 0; $filtro = isset($_GET["numRamal"]) ? trim($_GET["numRamal"]) : ''; $filtroNovo = !isset($_GET["pgn"]) ? '' : sprintf("&numRamal%s&pgn=%s&bloco=%s&pg=%s", $_GET["numRamal"], $_GET["pgn"], $_GET["bloco"], $_GET["pg"]); $recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_GET['pesquisa']); +$org_id = $_SESSION['SSEmpresaPadrao']; if ($acao == "deleta") { try { @@ -15,13 +16,13 @@ if ($acao == "deleta") { $inTran = 1; $id = $_GET["id"] ?? "0"; - $query = "delete from pbx_rotas_entrada where id='$id'"; + $query = "delete from pbx_rotas_entrada where id='$id' and org_id = $org_id"; $result = pg_query($dbcon, $query); if (!$result) { GeraExcept("Não foi posível excluir a \"Rota de Entrada\"!"); } - $query = "delete from pbx_rotas_entrada_troncos where id_rota='$id'"; + $query = "delete from pbx_rotas_entrada_troncos where id_rota='$id' and org_id = $org_id"; $result = pg_query($dbcon, $query); if (!$result) { GeraExcept("Não foi posível excluir os \"Troncos\" relacionados!"); @@ -55,6 +56,7 @@ if (isset($_GET['pesquisa']) && $_GET['pesquisa']) { $pesquisa = "&pesquisa=1"; } +$compl .= sprintf("and org_id = %d", $org_id); $query = "SELECT id, nome, modelos, identificador, serv_id as servicos FROM pbx_rotas_entrada where 1=1 $compl order by id asc"; $params = "&pbxRequest=1&numRamal=$filtro" . $pesquisa; $links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, false); diff --git a/asterisk/var_lib_asterisk/agi-bin/intercala_lgpd.php b/asterisk/var_lib_asterisk/agi-bin/intercala_lgpd.php index 59a17e9f..2c1e1ee5 100755 --- a/asterisk/var_lib_asterisk/agi-bin/intercala_lgpd.php +++ b/asterisk/var_lib_asterisk/agi-bin/intercala_lgpd.php @@ -96,7 +96,7 @@ try { if ($tipo == 'SUPERVISOR') { try { GravaLog(sprintf("### INICIO [%s] SUPERVISOR ###\n", ++$seq), $pathLog); - $infoLgpd = ___GetInfoLgpd($ramal_agente, '0'); + $infoLgpd = ___GetInfoLgpd($ramal_agente, '0', $org_id); /* * Dial plan espcifico para supervisor. */ @@ -114,7 +114,7 @@ try { $repostaSupervisor = is_numeric($argv[2]) ? $argv[2] : '0'; $pLgpd = $infoLgpd['lgpd_lgpdm_id']; $query = "update pbx_lgpd_monitora set lgpdm_resposta_supervisor = '{$repostaSupervisor}', lgpdm_resposta_supervisor_reg = now() where lgpdm_id = '{$pLgpd}' and org_id = $org_id"; - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao registrar a resposta do supervisor.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GeraExcept($msg); } @@ -169,7 +169,7 @@ try { GravaLog(sprintf("callerid = %s canal = %s\n", $agi['callerid'], $agi['channel']), $pathLog); $query = "select canal_agente, uniqueid2 from pbx_supervisor_agentes where (ramal = '$ramal_agente') or (matricula = '$matricula') and org_id = $org_id"; - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao recuperar o ramal e canal intercala do agente na resposta 1.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GeraExcept($msg); } @@ -182,10 +182,10 @@ try { * Registra a resposta do agente * */ - $infoLgpd = ___GetInfoLgpd($ramal_agente, $matricula); + $infoLgpd = ___GetInfoLgpd($ramal_agente, $matricula, $org_id); $pLgpd = $infoLgpd['lgpd_lgpdm_id']; $query = "update pbx_lgpd_monitora set lgpdm_resposta_monitorado = '{$resposta}', lgpdm_uid = '{$uid}', lgpdm_resposta_monitorado_reg = now() where lgpdm_id = '{$pLgpd}' and org_id = $org_id"; - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao registrar a resposta do agente.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GravaLog($msg, $pathLog); } @@ -204,7 +204,7 @@ try { * */ $query = "select lgpd_canal_supervisor from pbx_supervisor_agentes where (ramal = '$ramal_agente') or (matricula = '$matricula') and org_id = $org_id"; - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao recuperar o ramal e canal intercala do agente na resposta 1.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GeraExcept($msg); } @@ -236,7 +236,7 @@ try { * RECUPERA O RAMAL INTERCALA E CANAL INTERCALA GUARDADO TEMPORARIAMENTE NOS CAMPOS sala_1 E sala_2 */ $query = "select lgpd_canal_supervisor from pbx_supervisor_agentes where (ramal = '$ramal_agente') or (matricula = '$matricula') and org_id = $org_id"; - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao recuperar o ramal e canal intercala do agente na resposta = 2.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GeraExcept($msg); } @@ -262,7 +262,7 @@ try { GravaLog(sprintf("\n####BLOCO FIM [%s] ####\n", ++$seq), $pathLog); $ramal_agente = $argv[2]; - $infoLgpd = ___GetInfoLgpd($ramal_agente, '0'); + $infoLgpd = ___GetInfoLgpd($ramal_agente, '0', $org_id); $pLgpd = $infoLgpd['lgpd_lgpdm_id']; /* @@ -270,7 +270,7 @@ try { * */ $query = "update pbx_lgpd_monitora set lgpdm_fim = now() where lgpdm_id = '{$pLgpd}' and lgpdm_fim is null and org_id = $org_id"; - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao registrar a resposta do agente.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GravaLog($msg, $pathLog); } @@ -446,11 +446,12 @@ function __fwrite($socket, $value, $function = '', $logOnly = false) { } } -function ___GetInfoLgpd($ramalAgente, $matriculaAgente) { +function ___GetInfoLgpd($ramalAgente, $matriculaAgente, $org_id) { global $pathLog; + global $conexao; $query = "select tipo_ligacao, lgpd_canal_supervisor, lgpd_canal_monitorado, lgpd_lgpdm_id from pbx_supervisor_agentes where (matricula = '$matriculaAgente' or ramal = '$ramalAgente') and org_id = $org_id"; GravaLog(sprintf("___GetInfoLgpd [%s]\n", $query), $pathLog); - if (!$result = pg_query($query)) { + if (!$result = pg_query($conexao, $query)) { $msg = "Erro ao recuperar canal do agente para hangup.\nCMD[{$query}]\nErro: " . ErrorGetLast(); GravaLog($msg, $pathLog); }