diff --git a/admin/GruposAtendimento.php b/admin/GruposAtendimento.php index 280968cc..e0ca3711 100644 --- a/admin/GruposAtendimento.php +++ b/admin/GruposAtendimento.php @@ -9,10 +9,10 @@ $recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_GET['pesquis if ($acao == "deleta") { LimpaGruposCapturaRamais($dbcon); - $query = "delete from pbx_grupos_atendimento where id='$id' and org_id='$org_id'"; + $query = "delete from pbx_grupos_atendimento where id='$id' and org_id=$org_id"; pg_query($dbcon, $query); - $query = "delete from pbx_grupos_atendimento_ramais where id_grupo='$id' and org_id='$org_id'"; + $query = "delete from pbx_grupos_atendimento_ramais where id_grupo='$id' and org_id=$org_id"; pg_query($dbcon, $query); AtualizaRamaisCaptura($dbcon); diff --git a/admin/cadAnuncios.php b/admin/cadAnuncios.php index cc73b34e..751be3da 100644 --- a/admin/cadAnuncios.php +++ b/admin/cadAnuncios.php @@ -55,7 +55,7 @@ if ($acao == "inseri") { $query = "INSERT INTO pbx_anuncios(nome,musica,teste, opcao, acao, org_id) - VALUES ('$nome','$som_ura','$teste', '$opcao', '$acaoDest', '$org_id')"; + VALUES ('$nome','$som_ura','$teste', '$opcao', '$acaoDest', $org_id)"; pg_query($dbcon, $query); } diff --git a/admin/cadRamais.php b/admin/cadRamais.php index 53bde07d..3fa888e3 100644 --- a/admin/cadRamais.php +++ b/admin/cadRamais.php @@ -188,12 +188,12 @@ if ($_GET['ajax'] == 1) { if ($v_numero <> '') { if ($i == 1) { $query = "INSERT INTO pbx_voicemail_usuarios (caixa_postal,senha,email,nome,attach,delete,saycid,envelope, numero_ramal, org_id) values - ('$v_numero','$v_senha','$v_email','$v_nome','$attach','$delete','$saycid','$envelope', '$nome2', '$org_id') "; + ('$v_numero','$v_senha','$v_email','$v_nome','$attach','$delete','$saycid','$envelope', '$nome2', $org_id) "; CommandAsterisk2($dbcon, 'VOICE2', $org_id . $nome2, $v_numero); } } else { $query = "INSERT INTO pbx_voicemail_usuarios (caixa_postal,senha,email,nome,attach,delete,saycid,envelope, numero_ramal, org_id) values - ('$nome2','$nome2','$v_email','$v_nome','$attach','$delete','$saycid','$envelope', '$nome2', '$org_id') "; //executa insersao na base interna do asterisk + ('$nome2','$nome2','$v_email','$v_nome','$attach','$delete','$saycid','$envelope', '$nome2', $org_id) "; //executa insersao na base interna do asterisk CommandAsterisk2($dbcon, 'VOICE2', $org_id . $nome2, $nome2); } pg_query($dbcon, $query); @@ -210,7 +210,7 @@ if ($_GET['ajax'] == 1) { '$accountcode', '$call_limit', '$allow2', 'all','$deny','$fromuser','$fromdomain','$insecure','$t38pt_udptl','$videosupport', '$espera','$sigame_interno','$sigame_externo','$sigame_nao_atende','$sigame_ocupado','$gravacao','$musicclass', '$pertube','$cadeado','$v_senha','$dispositivo','$gravacao_saida','$senha_facilidade', '$callerid2', '$timeout', - '$ramalSecretaria', '$habilita_prepago', '$ringTime', '$extranet', '$ispbx_tronco', '$org_id', '$org_id$nome2')"; + '$ramalSecretaria', '$habilita_prepago', '$ringTime', '$extranet', '$ispbx_tronco', $org_id, '$org_id$nome2')"; $result = pg_query($dbcon, $query); @@ -365,7 +365,7 @@ if ($_GET['ajax'] == 1) { } $query = "INSERT INTO pbx_voicemail_usuarios (caixa_postal,senha,email,nome,attach,delete,saycid,envelope, numero_ramal, org_id) - VALUES ('$v_numero','$v_senha','$v_email','$v_nome','$attach','$delete','$saycid','$envelope', '$nome', '$org_id') "; + VALUES ('$v_numero','$v_senha','$v_email','$v_nome','$attach','$delete','$saycid','$envelope', '$nome', $org_id) "; pg_query($dbcon, $query); //executa insersao na base interna do asterisk $fields = array('caixa_postal', 'senha', 'email', 'nome', 'attach', 'delete', 'saycid', 'envelope', 'numero_ramal'); diff --git a/admin/horarios.php b/admin/horarios.php index aba0c3ae..096a512e 100644 --- a/admin/horarios.php +++ b/admin/horarios.php @@ -9,10 +9,10 @@ $org_id = GetOrganizacao(); if ($acao == "deleta") { - $query = "delete from pbx_horarios_itens where id_horario = '$id' and org_id='$org_id'"; + $query = "delete from pbx_horarios_itens where id_horario = '$id' and org_id=$org_id"; pg_query($dbcon, $query); //g - $query = "delete from pbx_horarios where id='$id' and org_id='$org_id'"; + $query = "delete from pbx_horarios where id='$id' and org_id=$org_id"; pg_query($dbcon, $query); //gera arquivos e executa o reload dos dados no asterisk // gera_arquivos($dbcon, 'HORARIOS'); @@ -40,8 +40,8 @@ if ($acao == "deleta") { Nome Discar Status - Dep - Ações + Dep + Ações @@ -109,7 +109,7 @@ if ($acao == "deleta") { ?> -
Não foram encontrados registros
+
Não foram encontrados registros
'.') THEN replace('^'||replace(replace(modelo||'$','X','[0-9]'),'Z','[1-9]'),'N','[2-9]') WHEN (substring(modelo FROM '.$') = '.') THEN replace('^'||replace(replace(modelo,'X','[0-9]'),'Z','[1-9]'),'N','[2-9]') END -<<<<<<< HEAD - AND tipo_acesso <> '0' - AND org_id = '$org_id' -======= AND tipo_acesso <> '0' and a.org_id = $org_id ->>>>>>> 5bc84ee (Agi verifica-rota para multiempresa) ORDER BY prioridade LIMIT 1"; WriteLog($query, '/var/log/asterisk/rotas_saida.log'); diff --git a/contacteFunc.php b/contacteFunc.php index f3b4bad9..96ace16f 100644 --- a/contacteFunc.php +++ b/contacteFunc.php @@ -746,10 +746,10 @@ function GetAgenteRamais($dbcon, $ramalAgente) return $ramais; } -function VerificaRamalLogado($db, &$dac, &$agente) +function VerificaRamalLogado($db, &$dac, &$agente, $org_id) { $ramal = GetRamalMonitorar(RAMAL_MONITOR_AGENTE); - $query = "select dac, nome, count(*) from pbx_supervisor_agentes where ramal = '$ramal' group by dac, nome"; + $query = "select dac, nome, count(*) from pbx_supervisor_agentes where ramal = '$ramal' and org_id = $org_id group by dac, nome"; $result = pg_query($db, $query); $row = pg_fetch_array($result); @@ -778,9 +778,9 @@ function VerficaAgenteLogado($db) pg_query($db, $query); return false; */ - + $org_id = GetOrganizacao(); $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($db, $query); $row = pg_fetch_row($result); $ret = $row[0]; @@ -809,21 +809,21 @@ function GetRamalAgenteLogado($db) return $row[0]; } -function VerificaRamalSigame($db, $ramal) +function VerificaRamalSigame($db, $ramal, $org_id) { $matricula = GetMatricula(); - $query = "select trim(coalesce(sigame_interno, '')) as sigame_interno, trim(coalesce(sigame_externo, '')) as sigame_externo, trim(coalesce(sigame_naoatende, '')) as sigame_naoatende, trim(coalesce(sigame_ocupado, '')) as sigame_ocupado from pbx_ramais where nome = '$ramal'"; + $query = "select trim(coalesce(sigame_interno, '')) as sigame_interno, trim(coalesce(sigame_externo, '')) as sigame_externo, trim(coalesce(sigame_naoatende, '')) as sigame_naoatende, trim(coalesce(sigame_ocupado, '')) as sigame_ocupado from pbx_ramais where nome = '$ramal' and org_id=$org_id"; $result = pg_query($db, $query); $row = pg_fetch_array($result); //return ($row['sigame_interno'] || $row['sigame_externo'] || $row['sigame_naoatende'] || $row['sigame_ocupado']); return ($row['sigame_interno'] || $row['sigame_externo']); } -function VerificaClassObrigatoria($db, $dac) +function VerificaClassObrigatoria($db, $dac, $org_id) { if (!GetExigeClas($db, $dac)) return false; - $query = "select count(*) as num_dac from pbx_classifica_dacs where id_dac = '$dac'"; + $query = "select count(*) as num_dac from pbx_classifica_dacs where id_dac = '$dac' and org_id=$org_id"; $result = pg_query($db, $query); $row = pg_fetch_row($result); return $row[0] ? false : true; @@ -845,10 +845,10 @@ function VerificaAgenteFixo($db) return true; } -function VerificaMaxAgenteLogado($db) +function VerificaMaxAgenteLogado($db, $org_id) { //$numAgt = GetModeloPa(); - $result = pg_query($db, "select coalesce(prm_max_licenca,0) as prm_max_licenca, coalesce(prm_max_licenca_fixo,0) as prm_max_licenca_fixo FROM pbx_parametros"); + $result = pg_query($db, "select coalesce(prm_max_licenca,0) as prm_max_licenca, coalesce(prm_max_licenca_fixo,0) as prm_max_licenca_fixo FROM pbx_parametros where org_id=$org_id"); $dadosLicenca = pg_fetch_assoc($result); $numLicencaDinanmica = $dadosLicenca['prm_max_licenca']; $numLicencaFixa = $dadosLicenca['prm_max_licenca_fixo']; diff --git a/include/util/funcoesApl.php b/include/util/funcoesApl.php index 9d72fbb9..5f02c955 100755 --- a/include/util/funcoesApl.php +++ b/include/util/funcoesApl.php @@ -1945,7 +1945,7 @@ function GetErrorLast($message, $display = 0, $html = 0) { } */ function GetContextoRamal($db, $ramal, $org_id) { - $query = "select contexto from pbx_ramais where nome = '$ramal' and org_id = '$org_id'"; + $query = "select contexto from pbx_ramais where nome = '$ramal' and org_id = $org_id"; $result = pg_query($db, $query); $row = pg_fetch_row($result); return $row[0]; @@ -1959,7 +1959,7 @@ function ChamdaClassificadaAgente($db, $matricula) { } function GetRamalLogado($db, $matricula, $org_id) { - $query = "select ramal from pbx_supervisor_agentes where matricula = '$matricula' and org_id='$org_id'"; + $query = "select ramal from pbx_supervisor_agentes where matricula = '$matricula' and org_id=$org_id"; $result = pg_query($db, $query); $row = pg_fetch_row($result); return $row[0]; @@ -2082,10 +2082,10 @@ function InsereRotasRamais($dbcon, $rotas, $ramal) { $dadosRotas = explode(";", $rota); $tipoAcesso = $dadosRotas[0]; $id = $dadosRotas[1]; - $query = "update pbx_rotas_saida_ramais set tipo_acesso = '$tipoAcesso' where id_rota = '$id' and ramal = '$ramal' and org_id='$org_id'; + $query = "update pbx_rotas_saida_ramais set tipo_acesso = '$tipoAcesso' where id_rota = '$id' and ramal = '$ramal' and org_id=$org_id; insert into pbx_rotas_saida_ramais(id_rota, ramal, tipo_acesso,org_id) select '$id', '$ramal', '$tipoAcesso', $org_id - where not exists(select '' from pbx_rotas_saida_ramais where id_rota = '$id' and ramal = '$ramal' and org_id='$org_id');"; + where not exists(select '' from pbx_rotas_saida_ramais where id_rota = '$id' and ramal = '$ramal' and org_id=$org_id);"; $novo = array('id_rota' => $id, 'ramal' => $ramal, 'tipo_acesso' => $tipoAcesso); GrvAudita($dbcon, $idProg, 'pbx_rotas_saida_ramais', 'INS', array(), $novo, array('id_rota', 'ramal', 'tipo_acesso'), array('id_rota'), true); @@ -2101,10 +2101,10 @@ function InsereRamaisRotas($dbcon, $ramais, $rota) { $ramal = soNumero($key); //$ramal = $org_id . $ramal; $tipoAcesso = $dadosRamais[0]; - $query = "update pbx_rotas_saida_ramais set tipo_acesso = '$tipoAcesso' where id_rota = '$rota' and ramal = '$ramal' and org_id = '$org_id'; + $query = "update pbx_rotas_saida_ramais set tipo_acesso = '$tipoAcesso' where id_rota = '$rota' and ramal = '$ramal' and org_id = $org_id; insert into pbx_rotas_saida_ramais(id_rota, ramal, tipo_acesso,org_id) - select '$rota', '$ramal', '$tipoAcesso', '$org_id' - where not exists(select '' from pbx_rotas_saida_ramais where id_rota = '$rota' and ramal = '$ramal' and org_id='$org_id');"; + select '$rota', '$ramal', '$tipoAcesso', $org_id + where not exists(select '' from pbx_rotas_saida_ramais where id_rota = '$rota' and ramal = '$ramal' and org_id=$org_id);"; $novo = array('id_rota' => $rota, 'ramal' => $ramal, 'tipo_acesso' => $tipoAcesso); GrvAudita($dbcon, $idProg, 'pbx_rotas_saida_ramais', 'INS', array(), $novo, array('id_rota', 'ramal', 'tipo_acesso'), array('id_rota'), true); pg_query($dbcon, $query); @@ -3718,7 +3718,7 @@ function ValidaRamalApl($ramal, $org_id) { * Esta função verifica se o ramal existe, e retorna o canal se o ramal é valido. */ global $dbcon; - $query = "select dispositivo from pbx_ramais where nome = '$ramal' and org_id = '$org_id'"; + $query = "select dispositivo from pbx_ramais where nome = '$ramal' and org_id = $org_id"; $result = pg_query($dbcon, $query); if (!$result || !pg_num_rows($result)) { @@ -4732,11 +4732,11 @@ function GetTotalDependencias($recurso, $key) { if ($recurso == 'contextos') { $query .= " union all - select '' from pbx_queues_grupos where context = '$key' and org_id='$org_id' + select '' from pbx_queues_grupos where context = '$key' and org_id=$org_id union all - select '' from pbx_ramais where contexto = '$key' and org_id='$org_id' + select '' from pbx_ramais where contexto = '$key' and org_id=$org_id union all - select '' from pbx_troncos where context = '$key' and org_id='$org_id'"; + select '' from pbx_troncos where context = '$key' and org_id=$org_id"; } if ($recurso == 'troncos') { $query .= "union all