= 1 then '-'||(length(nome) - length(ltrim(nome,'0')))::bigint ELSE nome END AS bigint) AS ramal FROM pbx_sip_ramais WHERE org_id = {$org_id} $compl ORDER BY ramal ASC, nome ASC"; return $query; } /* complemento do filtro em sql para pesquisa específica de uma ramal, será inserido na query os filtros */ function SetFiltroSQL($filtro){ global $dbcon; $tpParcial = 0; // Procurar ramais específicos, campo procurar no site if (strpos($filtro, ',')) { $tpParcial = 1; } elseif (strpos($filtro, '-')) { $sql = "select count(*) from pbx_sip_ramais where callerid ilike '%$filtro%'"; $result = pg_query($dbcon, $sql); $param = pg_fetch_row($result); if ($param[0] > 0) { $tpParcial = 0; } else { $tpParcial = 2; } } if ((!empty($filtro)) && ($tpParcial == 0)) { $compl = " where (nome ilike '%$filtro%' or callerid ilike '%$filtro%')"; } elseif ((!empty($filtro)) && ($tpParcial == 1)) { $params = explode(",", $filtro); $compl = ""; $dado = null; foreach ($params as $param) { $dado .= empty($dado) ? "'$param'" : ",'$param'"; } $compl = " where (nome in($dado) or callerid in($dado))"; } elseif ((!empty($filtro)) && ($tpParcial == 2)) { $params = explode("-", $filtro); $compl = ""; $ini = $params[0]; $fim = $params[1]; $qtd1 = strlen($ini) - strlen(ltrim($ini, "0")); $qtd2 = strlen($fim) - strlen(ltrim($fim, "0")); if ($qtd1 >= 1) { $ini1 = '-' . $qtd1; } else { $ini1 = $ini; } if ($qtd2 >= 1) { $fim1 = '-' . $qtd2; } else { $fim1 = $fim; } $compl = " where nome between '$ini' and '$fim' and ramal between '$ini1' and '$fim1'"; } else { $compl = ""; } return $compl; } /* Buscar ramais com filtros */ function GetRamalFiltro( $idProg, $filtro ){ $org_id = $_SESSION['SSEmpresaPadrao']; global $dbcon; $compl = SetFiltroSQL( $filtro ); $query = GetQueryRamal( $compl ); $params = "&pbxRequest=1&numRamal=$filtro"; $links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); $query .= " limit $regPagina offset $offSet"; $result = pg_query($dbcon, $query); return array("ramais_db" => $result, "ramais_rodape" => $links); } /* Buscar todos os ramais da página */ function GetALLRamal($idProg, $filtro = null ){ global $dbcon; $org_id = $_SESSION['SSEmpresaPadrao']; $query = GetQueryRamal(); $params = "&pbxRequest=1&numRamal=$filtro"; $links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); $query .= " limit $regPagina offset $offSet"; $result = pg_query($dbcon, $query); return array("ramais_db" => $result, "ramais_rodape" => $links); } $acao = isset($_GET['acao']) ? trim($_GET['acao']) : 'select'; $id = isset($_GET['id']) ? intval(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"], intval($_GET["pg"])); $recontaPag = ($acao == 'inseri') || ($acao == "deleta") || isset($_GET['pesquisa']); $janW = '700'; $janH = '400'; $verificaMaster = IsOrganizacaoMaster(); $org_id = $_SESSION['SSEmpresaPadrao']; if ($acao == "deleta") { $id = $_GET["id"] ?? "0"; $query = "SELECT * FROM pbx_sip_ramais where id=$id and org_id = $org_id"; $result = pg_query($dbcon, $query); $dados = pg_fetch_array($result); $ramal = $dados['nome']; //Apaga a relacao entre rotas e ramais $query = "delete from pbx_rotas_saida_ramais where ramal = '$ramal' and org_id = $org_id"; pg_query($dbcon, $query); //Apaga ch secretaria $query = "delete from pbx_chefe_secretaria where numero = '$ramal' and org_id = $org_id"; pg_query($dbcon, $query); //Relação de restrição a audios cadastrada na interface de grupo de usuarios $query = "delete from pbx_grupo_audio_ramal where nome = '$ramal' and org_id = $org_id"; pg_query($dbcon, $query); //Remove ramais da agenda $query = "delete from rma_depto_ramais where nome = '$ramal' and org_id = $org_id"; pg_query($dbcon, $query); $query = "delete from pbx_sip_ramais where id='$id' and org_id = $org_id"; pg_query($dbcon, $query); GrvAudita($dbcon, $idProg, 'pbx_sip_ramais', 'DEL', array(), array('id' => $id), array('id' => 'ID'), array('id'), true); $query = "delete from pbx_voicemail_usuarios where numero_ramal ='$ramal' and org_id = $org_id"; pg_query($dbcon, $query); Ajusta_ramais($ramal, $dbcon, false, false); Ajusta_tabelas('ramal', $ramal, $dbcon); } if(empty($filtro)){ $ramais = GetALLRamal( $idProg, $filtro ); } else { $result = GetRamalFiltro($idProg, $filtro); } ?>
Ramal/Bina
" onkeyup="ConsultaRamal('index.php?idProg=10009&pbxRequest=1', event);" size="20"> NOVO RAMAL SIP CONFIGURAÇÃO GLOBAL
Id Ramal Bina Contexto Ramal Autenticação Saldo Pré-pago Pré-pago Dep Ações
' : 'Desabilitado!'; ?>
Este registro não pode ser apagado!
Não foram encontrados registros