Browse Source

Merge pull request 'Removido opcao do usuario escolher empresa master e corrigido tela inicial das rotas de entrada' (#353) from matheorb/developer:dev-1.9 into 1.9

Reviewed-on: SimplesIP/pabx-app#353
1.9
Matheo Bonucia 2 months ago
parent
commit
607f2212c1
  1. 6
      admin/rotasEntrada.php
  2. 23
      asterisk/var_lib_asterisk/agi-bin/intercala_lgpd.php
  3. 42
      cadastros/organizacao/cadOrganizacao.php
  4. 8
      templates/cadastros/organizacao/cadOrganizacao.tpl

6
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);

23
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);
}

42
cadastros/organizacao/cadOrganizacao.php

@ -6,12 +6,11 @@ $tpLayout = 1;
$id = isset($_GET["id"]) ? $_GET["id"] : $_POST["id"];
$nome = isset($_POST["nome"]) ? $_POST["nome"] : null;
$status = isset($_POST["status"]);
$master = isset($_POST["master"]);
try {
if (isset($_POST["btGravar"])) {
$ret = setOrganizacao($dbcon, ['nome' => $nome, 'status' => $status, 'master' => $master], $id);
$ret = setOrganizacao($dbcon, ['nome' => $nome, 'status' => $status,], $id);
}
if ($id || $ret) {
@ -31,7 +30,6 @@ try {
$smarty->assign("id", $id);
$smarty->assign("nome", $nome);
$smarty->assign("status", $status ? "checked" : "");
$smarty->assign("master", $master ? "checked" : "");
$smarty->assign("acaoUser", $acaoUser);
GetTemplate($smarty, 'cadastros/organizacao/cadOrganizacao.tpl');
@ -43,21 +41,16 @@ function setOrganizacao($dbcon, $dados, $id = null)
throw new Exception($isExists ? "O nome da organização já existe!" : "Por favor, preencha o campo nome!");
}
$isExistsMaster = verificaMaster($dbcon);
if ($isExistsMaster == true && $dados['master'] == "checked") {
throw new Exception("Já existe uma empresa master ativa!");
}
if ($id) {
$query = "UPDATE pbx_organizacao
SET nome = %s,
status = %s,
master = %s
WHERE id = %s;";
$query = sprintf($query, QuotedStr($dados['nome']), $dados['status'] == "checked" ? 1 : 0, $dados['master'] == "checked" ? 1 : 0, $id);
SET nome = %s,
status = %d,
master = %d
WHERE id = %d;";
$query = sprintf($query, QuotedStr($dados['nome']), $dados['status'] == "checked" ? 1 : 0, 0, $id);
} else {
$query = "INSERT INTO pbx_organizacao (nome, status, master) VALUES(%s, %s, %s) RETURNING id";
$query = sprintf($query, QuotedStr($dados['nome']), $dados['status'] == "checked" ? 1 : 0, $dados['master'] == "checked" ? 1 : 0);
$query = "INSERT INTO pbx_organizacao (nome, status, master) VALUES(%s, %d, %d) RETURNING id";
$query = sprintf($query, QuotedStr($dados['nome']), $dados['status'] == "checked" ? 1 : 0, 0);
}
$result = pg_query($dbcon, $query);
@ -209,22 +202,3 @@ function ___Gravalog($message)
$line .= "----------------------------------------------";
file_put_contents('/var/log/asterisk/cadOrganizacao.log', $line, FILE_APPEND);
}
function verificaMaster($dbcon)
{
$query = "SELECT id, master, status FROM pbx_organizacao;";
$result = pg_query($dbcon, $query);
$resposta = false;
if (!$result) {
throw new Exception("Não foi possível verificar se existe organizaçao master!");
}
$dados = pg_fetch_all($result);
if ($dados) {
foreach ($dados as $linha) {
if ($linha['master'] == 1 && $linha['status'] == 1) {
$resposta = true;
}
}
}
return $resposta;
}

8
templates/cadastros/organizacao/cadOrganizacao.tpl

@ -10,14 +10,6 @@
<th width="120" align="left">Nome da Organização</th>
<td><input name="nome" type="text" id="nome" value="{$nome}" size="60" maxlength="60" ></td>
</tr>
{if isAdmin()}
<tr>
<th align="left">Empresa Master</th>
<td>
<input name="master" type="checkbox" id="status" value= "1" {$master}>
</td>
</tr>
{/if}
<tr>
<th align="left">Status</th>
<td>

Loading…
Cancel
Save