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); } $compl .= " AND b.org_id = {$org_id}"; $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 .= ' ' . $id . ' ' . $nomeMostra . ' ' . $ramal . ' ' . $departamento . ' ' . $link . ' '; } $imgNovo = " Novo Ramal"; $smarty->assign('linhas', $resultados); $smarty->assign('nomeRamal', $nomeRamal); $smarty->assign("paramPesquisa", $paramPesquisa); $smarty->assign("imgNovo", $imgNovo); $smarty->assign("links", $links); $smarty->assign("pagMostra", $pagMostra); $smarty->assign("totalReg", $totalReg); $smarty->assign("pgn", $_REQUEST["pgn"]); $smarty->assign("bloco", $_REQUEST["bloco"]); $smarty->assign("pg", $_REQUEST["pg"]); GetTemplate($smarty, $tpl);