-
+
- Id |
- Ramal |
- Bina |
- Contexto |
- Dispositivo |
+
+ Id
+ |
+ Ramal |
+ Bina |
+ Contexto |
+ Dispositivo |
Dep |
- Ações |
+ Ações |
0) {
+ $tpParcial = 0;
+ } else {
+ $tpParcial = 2;
+ }
+ }
- $tpParcial = 0;
-
- if (strpos($filtro, ',')) {
- $tpParcial = 1;
- } else if (strpos($filtro, '-')) {
- $sql = "select count(*) from pbx_iax_pbx where identificador 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 = " AND (nome ilike '%$filtro%' OR callerid ILIKE '%$filtro%')";
+ } else if ((!empty($filtro)) && ($tpParcial == 1)) {
+ $params = explode(",", $filtro);
+ $compl = "";
+ foreach ($params as $param) {
+ //$param = trim(str_replace("'", "", $param));
+ $dado .= empty($dado) ? "'$param'" : ",'$param'";
}
- if ((!empty($filtro)) && ($tpParcial == 0)) {
- $compl = " where (nome ilike '%$filtro%' or callerid ilike '%$filtro%')";
- } else if ((!empty($filtro)) && ($tpParcial == 1)) {
- $params = explode(",", $filtro);
- $compl = "";
- foreach ($params as $param) {
- //$param = trim(str_replace("'", "", $param));
- $dado .= empty($dado) ? "'$param'" : ",'$param'";
- }
-
- $compl = " where (nome in($dado) or callerid in($dado))";
- } else if ((!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'";
+ $compl = " AND (nome IN($dado) OR callerid IN($dado))";
+ } else if ((!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 {
- $compl = "";
+ $fim1 = $fim;
}
- $query = "drop table if exists ramal_iax;
- create temporary table ramal_iax(
- id integer,
- nome character varying(100),
- context character varying(100),
- dispositivo character varying(250),
- saldo_prepago numeric(12,4),
- habilita_prepago integer,
- callerid character varying(100),
- ramal integer
- );
-
- insert into ramal_iax (id,nome, context,dispositivo, saldo_prepago, habilita_prepago,callerid,ramal)
- SELECT id,nome, context,dispositivo, saldo_prepago, habilita_prepago,identificador,
- cast(case when (length(nome) - length(ltrim(nome,'0'))) >= 1 then '-'||(length(nome) - length(ltrim(nome,'0')))::int--||nome
+ $compl = " AND nome BETWEEN '$ini' AND '$fim' AND ramal BETWEEN '$ini1' AND '$fim1'";
+ } else {
+ $compl = "";
+ }
+
+ $query = "SELECT id, nome, context, dispositivo, saldo_prepago, habilita_prepago, identificador,
+ cast(case when (length(nome) - length(ltrim(nome,'0'))) >= 1 then '-'||(length(nome) - length(ltrim(nome,'0')))::int
else nome
- end as int)
- FROM pbx_iax_pbx;
-
- select * from ramal_iax $compl order by ramal asc,nome asc ";
-
- $params = "&pbxRequest=1&numRamal=$filtro";
- $links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
- $query .= " limit $regPagina offset $offSet";
- $result = pg_query($dbcon, $query);
- $z = 0;
- while ($dados = pg_fetch_array($result)) {
- $totaldep = GetTotalDependencias('ramal', $dados['nome']);
- $opcao = 'ramal';
- $acao = $dados['nome'];
- $recursoTipo = 'Ramal';
- $nomeRecurso = $dados['nome'];
- $dep = GetLinkDependenciaRecurso($opcao, $acao, $recursoTipo, $nomeRecurso, $totaldep);
- ?>
-
- |
- |
- |
- |
- |
- |
-
-
- |
-
-
-
- Não foram encontrados registros |
-
-
-
- |
+ end as int) AS ramal
+ FROM pbx_iax_pbx
+ WHERE 1=1
+ $compl ORDER BY nome ASC";
+
+ $params = "&pbxRequest=1&numRamal=$filtro";
+ $links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true);
+ $query .= " LIMIT $regPagina OFFSET $offSet";
+
+ $result = pg_query($dbcon, $query);
+ $z = 0;
+ while ($dados = pg_fetch_array($result)) {
+ $totaldep = GetTotalDependencias('ramal', $dados['nome']);
+ $opcao = 'ramal';
+ $acao = $dados['nome'];
+ $recursoTipo = 'Ramal';
+ $nomeRecurso = $dados['nome'];
+ $dep = GetLinkDependenciaRecurso($opcao, $acao, $recursoTipo, $nomeRecurso, $totaldep);
+ ?>
+
+
+
+ |
+ |
+ |
+ |
+ |
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+ Não foram encontrados registros
+ |
+
+
+
+
+
+ |
-
+
|