getMessage()); } } $compl = ''; if (isset($_REQUEST['paramPesquisa']) && $_REQUEST['paramPesquisa']) { $compl = PreparaLike($filtro, true); $compl = sprintf("and (a.nome::text ilike %s or a.callerid::text ilike %s)", $compl, $compl); } $query = " SELECT a.id, coalesce(c.dpto_nome, 'PADRÃO') as dpto_nome, a.nome, a.callerid, a.tipo_table FROM pbx_ramais_mesa a left join rma_depto_ramais b ON b.nome = a.nome left join rma_departamentos c ON c.dpto_id = b.dpto_id where 1=1 $compl ORDER BY a.nome ASC"; $params = "¶mPesquisa=$filtro"; $links = PaginaDados($idProg, $query, $params, $regPagina, $offSet, $pagMostra, true); $query .= " limit $regPagina offset $offSet"; $result = pg_query($dbcon, $query); while ($rowRamais = pg_fetch_array($result)) { $id = $rowRamais['id']; $nome = $rowRamais['callerid']; $ramal = $rowRamais['nome']; $departamento = $rowRamais['dpto_nome']; $tipo_table = $rowRamais['tipo_table']; $nomeMostra = '' . $nome . ''; $link = ($tipo_table == "AGD") ? "" : ""; $resultados .= '