/** * Método que lista todos os dados de acompanhamento. * * @param Filtros $filtros Objeto do sistema de filtros * * @return ResultSetHydrator Um objeto contendo a resposta da consulta */ public function listarTodos(Filtros $filtros) { $where = "1=1 "; $t = $this->tg->getTabela(); //Filtrando if ($filtros->getInstance("periodo") instanceof Periodo) { $where .= $filtros->issetGet("de") ? "and {$t}.data_aula>={$filtros->get("de")->format(Date::FORMAT_SQL_DATE)} " : ""; $where .= $filtros->issetGet("ate") ? "and {$t}.data_aula<={$filtros->get("ate")->format(Date::FORMAT_SQL_DATE)} " : ""; } else { $where .= "and extract(year from {$t}.data_aula)={$this->anoLetivo} "; } if ($filtros->issetGet("turma")) { $where .= "and pk_turma={$filtros->get("turma")}"; } return $this->tg->selectObj($this->select()->where($where)->distinct("pk_acompanhamento")); }
/** * Método que define a filtragem por periodo para a consulta. * O where neste caso deve ser exclusivamente uma string * * @param string $where A clausula de teste da consulta * @param Filtros $filtros Objeto do sistema de filtros * @param string $colData A coluna referente a data a ser usada na filtragem */ protected function filtrosPeriodo(&$where, Filtros $filtros, $colData = 'data_evento') { if (!is_string($where)) { throw new SqlException("A consulta foi mal elaborada", 100); } if ($filtros->getInstance("periodo") instanceof Periodo) { if ($filtros->getInstance("periodo")->getDe() instanceof Date) { $where .= (strlen($where) ? ' and ' : '') . "{$colData}>='{$filtros->getInstance("periodo")->getDe()->format(Date::FORMAT_SQL_DATE)}' "; } if ($filtros->getInstance("periodo")->getAte() instanceof Date) { $where .= (strlen($where) ? ' and ' : '') . "{$colData}<='{$filtros->getInstance("periodo")->getAte()->format(Date::FORMAT_SQL_DATE)}' "; } } else { $where .= strlen($where) ? ' and ' : ''; $where .= "extract(year from {$colData})={$this->anoLetivo} "; } }