Skip to content

Commit

Permalink
finalizando a consulta
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquemota committed Jul 8, 2010
1 parent edc3219 commit 122a9d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/Catalogo/Negocio/TermoReferencia.pm
Expand Up @@ -8,13 +8,14 @@ has schema => (is => 'ro', required => 1);
has user => (is => 'ro', required => 1);

method listar_tr_categorias
( Str $pesquisa? = '%', Int $categoria_inicial?, Int $profundidade? = 2,
Int $linhas_por_pagina? = 50, Int $pagina? = 1)
( Str $pesquisa? = '%', Int $pagina? = 1, Int $linhas_por_pagina? = 50,
Int $categoria_inicial?, Int $profundidade? = 2 )
does Transactional
does Authorized(requires => ['adm_catalogo_tr']) {

$self->schema->resultset('TrCategoria')->search({ -or => { nome => { like => $pesquisa },
descricao => { like => $pesquisa } } });
$self->schema->resultset('TrCategoria')->search_rs({ -or => { nome => { like => $pesquisa },
descricao => { like => $pesquisa } } },
{ rows => $linhas_por_pagina, page => $pagina });

};

Expand Down
26 changes: 25 additions & 1 deletion root/auth/trcategorias/index.tt
@@ -1,10 +1,34 @@
[% c.place_bread(c.req.uri, 'Lista de categorias TR') %]
[% INCLUDE 'header.tt' %]

[%
IF (!defined(c.req.param('pagina')));
CALL c.req.param('pagina',1);
END;
IF (defined(c.req.param('txtfiltro')));
SET v = c.req.param('txtfiltro');
ELSE;
SET v = '%';
END;
SET linhas_por_pagina = 1;
SET categoria_rs = c.model('TermoReferencia').listar_tr_categorias(
v, c.req.param('pagina'), linhas_por_pagina );
SET registros = categoria_rs.count();
SET num_paginas = int(registros / linhas_por_pagina) + 1;
%]

<FORM ACTION='[% c.uri_for_action('/auth/trcategorias/index') %]' METHOD='GET'>
<INPUT TYPE='text' name='txtfiltro' VALUE="[% c.req.param('txtfiltro') | html %]" />
<INPUT TYPE='submit' name='btnenviar' value='enviar' />
</FORM>

<UL>
[% FOREACH categoria IN c.model('TermoReferencia').listar_tr_categorias() %]
[% FOREACH categoria IN categoria_rs.all %]
<LI>[% categoria.nome %]</LI>
[% END %]
</UL>

<P>Página [% c.req.param('pagina') %] de [% num_paginas %] ([% registros %] registros)</P>


[% INCLUDE 'footer.tt' %]

0 comments on commit 122a9d7

Please sign in to comment.