Browse Source

Colocar org_id

1.9-pjsip
bruno 3 months ago
parent
commit
9578944da5
  1. 35
      admin/funcoes.php

35
admin/funcoes.php

@ -13,22 +13,25 @@ function inverte_data($data) {
//Fun<EFBFBD><EFBFBD>o<EFBFBD><EFBFBD>o para limpar os relacionamentos do banco de dados
function Ajusta_ramais($nome, $conexao, $reload = false, $reloadUra = false) {
$query = "delete from pbx_agenda where tipo = 'R' and ramal = '$nome'";
$org_id = $_SESSION['SSEmpresaPadrao'];
$query = "delete from pbx_agenda where tipo = 'R' and ramal = '$nome' and org_id = $org_id";
$result = pg_query($conexao, $query);
$query = "delete from pbx_grupos_numeros where ramal = '$nome'";
$query = "delete from pbx_grupos_numeros where ramal = '$nome' and org_id = $org_id";
if ($result)
$result = pg_query($conexao, $query);
$query = "delete from pbx_grupos_atendimento_ramais where ramal = '$nome'";
$query = "delete from pbx_grupos_atendimento_ramais where ramal = '$nome' and org_id = $org_id";
if ($result)
$result = pg_query($conexao, $query);
$query = "delete from pbx_queues_membros where dispositivo like '%/$nome'";
$query = "delete from pbx_queues_membros where dispositivo like '%/$nome' and org_id = $org_id";
if ($result)
$result = pg_query($conexao, $query);
$query = "delete from rma_depto_ramais where nome = '$nome'";
$query = "delete from rma_depto_ramais where nome = '$nome' and org_id = $org_id";
if ($result)
$result = pg_query($conexao, $query);
@ -44,9 +47,12 @@ function Ajusta_ramais($nome, $conexao, $reload = false, $reloadUra = false) {
//Fun<EFBFBD><EFBFBD>o<EFBFBD><EFBFBD>o para limpar os relacionamentos do banco de dados
function Ajusta_troncos($nome, $conexao) {
$query1 = "delete from pbx_rotas_entrada_troncos where id_tronco='$nome'";
$query2 = "delete from pbx_grupos_atendimento_ramais where ramal='$nome'";
$query3 = "delete from pbx_queues_membros where dispositivo='%/$nome'";
$org_id = $_SESSION['SSEmpresaPadrao'];
$query1 = "delete from pbx_rotas_entrada_troncos where id_tronco='$nome' and org_id = $org_id";
$query2 = "delete from pbx_grupos_atendimento_ramais where ramal='$nome' and org_id = $org_id";
$query3 = "delete from pbx_queues_membros where dispositivo='%/$nome' and org_id = $org_id";
pg_query($conexao, $query1);
pg_query($conexao, $query2);
@ -63,6 +69,8 @@ function Ajusta_troncos($nome, $conexao) {
*/
function Ajusta_tabelas($opcao, $acao, $conexao, $reload = true, $reloadUra = true) {
$org_id = $_SESSION['SSEmpresaPadrao'];
$path = '/var/log/asterisk/ajusta_tabelas.log';
$tables = array(
@ -103,7 +111,7 @@ function Ajusta_tabelas($opcao, $acao, $conexao, $reload = true, $reloadUra = tr
$reloadDialPlan = $dados[4] === 'Y' ? $reloadUra : false;
if (($table != 'NOTABLE') && ($opcao)) {
$query = sprintf("update %s set %s = '', %s = '' where %s = %s and %s like %s", $table, $fOpcao, $fAcao, $fOpcao, QuotedStr($opcao), $fAcao, QuotedStr($acao));
$query = sprintf("update %s set %s = '', %s = '' where %s = %s and org_id = $org_id and %s like %s", $table, $fOpcao, $fAcao, $fOpcao, QuotedStr($opcao), $org_id, $fAcao, QuotedStr($acao));
//WriteLog($query . "\n", $path);
if (!pg_query($conexao, $query)) {
GeraExcept(sprintf("Comando: [%s] Erro: %s\n", $query, GetLasterror()));
@ -208,7 +216,7 @@ function CommandAsterisk($conexao, $tipo, $paramAdic = array()) {
$params = GetParamAmi($tipo, $paramAdic);
if (count($params)) {
$get = ExecutaAmi($socket, $params);
return ($get && (stripos($get, "Error") === false));
return $get && (stripos($get, "Error") === false);
}
}
}
@ -232,7 +240,7 @@ function _CommandAsterisk($conexao, $tipo) {
$result = pg_query($conexao, $query);
while ($dados = pg_fetch_array($result)) {
$get = @file_get_contents($url_asterisk . eregi_replace('&actionid=100', '', $dados['endereco']) . '&actionid=' . rand(0, 99999999999999));
$get = @file_get_contents($url_asterisk . preg_replace('&actionid=100', '', $dados['endereco']) . '&actionid=' . rand(0, 99999999999999));
// echo $url_asterisk.eregi_replace('&actionid=100','',$dados['endereco']).'&actionid='.rand(0,99999999999999);
if ($get)
return !stripos($get, "Error");
@ -277,9 +285,9 @@ function _CommandAsterisk2($conexao, $tipo, $chave, $valor) {
while ($dados = pg_fetch_array($result)) {
if (substr($tipo, 0, 3) != 'DEL') {
$url = $url_asterisk . eregi_replace('action:', 'action=', $dados['endereco']) . '&Key=' . eregi_replace('/', '%2F', $chave) . '&Val=' . eregi_replace('/', '%2F', $valor);
$url = $url_asterisk . preg_replace('action:', 'action=', $dados['endereco']) . '&Key=' . preg_replace('/', '%2F', $chave) . '&Val=' . preg_replace('/', '%2F', $valor);
} else {
$url = $url_asterisk . eregi_replace('action:', 'action=', $dados['endereco']) . ' ' . eregi_replace('/', '%2F', $chave);
$url = $url_asterisk . preg_replace('action:', 'action=', $dados['endereco']) . ' ' . preg_replace('/', '%2F', $chave);
}
//echo $url;
$get = file_get_contents($url);
@ -4086,6 +4094,7 @@ select 'Contextos' as dep, c.id, c.nome from pbx_contextos_canais a, pbx_tronco
}
function GetSetUra($db, $id) {
$query = sprintf("select '' from pbx_ura_destino where id_ura = %s and trim(tipo) = 'integativa' and trim(numero) = '_X.'", QuotedStr($id));
$result = pg_query($db, $query);

Loading…
Cancel
Save