FS
Filtro por período inicial e final
Fechado
Boa noite pessoal,
Preciso fazer um filtro onde eu informo data inicial e data final, onde é comparado com a data de vencimento para listar os dados através da função onSearch().
O problema é que só lista os dados se eu colocar na mão, por exemplo:
Se eu colocar pra filtrar chamando pela variável conforme abaixo, não lista nada, retornando em branco. 99,9% de chance de eu estar chamando a variável da forma errada, lembrando que dtinicial e dtfinal não tem no banco de dados, servem somente para o filtro.
Obrigado.
Esta é a função onSearch() completa.
Preciso fazer um filtro onde eu informo data inicial e data final, onde é comparado com a data de vencimento para listar os dados através da função onSearch().
O problema é que só lista os dados se eu colocar na mão, por exemplo:
- <?php
- if ($data->dtinicio){
- $filter = new TFilter('vencimento', '=', '2015/10/26'); // create the filter
- TSession::setValue('ParcelasList_filter_dtinicio', $filter); // stores the filter in the session
- }
- ?>
Se eu colocar pra filtrar chamando pela variável conforme abaixo, não lista nada, retornando em branco. 99,9% de chance de eu estar chamando a variável da forma errada, lembrando que dtinicial e dtfinal não tem no banco de dados, servem somente para o filtro.
- <?php
- if ($data->dtfim){
- $filter = new TFilter('vencimento', '<=', $data->dtfim); // create the filter
- TSession::setValue('ParcelasList_filter_dtfim', $filter); // stores the filter in the session
- }
- ?>
Obrigado.
Esta é a função onSearch() completa.
- <?php
- function onSearch()
- {
- // get the search form data
- $data = $this->form->getData();
- // clear session filters
- TSession::setValue('ParcelasList_filter_nome_aluno', NULL);
- TSession::setValue('ParcelasList_filter_dtinicio', NULL);
- TSession::setValue('ParcelasList_filter_dtfim', NULL);
- if (isset($data->nome_aluno) AND ($data->nome_aluno)) {
- $filter = new TFilter('nome_aluno', 'like', "%{$data->nome_aluno}%"); // create the filter
- TSession::setValue('ParcelasList_filter_nome_aluno', $filter); // stores the filter in the session
- }
- if ($data->dtinicio){
- $filter = new TFilter('vencimento', '=', '2015/10/26'); // create the filter
- TSession::setValue('ParcelasList_filter_dtinicio', $filter); // stores the filter in the session
- }
- if ($data->dtfim){
- $filter = new TFilter('vencimento', '<=', $data->dtfim); // create the filter
- TSession::setValue('ParcelasList_filter_dtfim', $filter); // stores the filter in the session
- }
- // fill the form with data again
- $this->form->setData($data);
- // keep the search data in the session
- TSession::setValue('Parcelas_filter_data', $data);
- $param=array();
- $param['offset'] =0;
- $param['first_page']=1;
- $this->onReload($param);
- }
- ?>
Olá Fabiano, converta a data para o formato americano antes de enviar para o filtro:
Deu certo Ivan,
Muito obrigado!!!