Esempio n. 1
0
 /**
  * Metodo que lista todos os registros do aluno informado feitos pelo coordenador informado.
  *
  * @param Aluno   $aluno   O aluno usado como filtro
  * @param Filtros $filtros Objeto do sistema de filtros
  *
  * @return ResultSetHydrator Um objeto contendo a resposta da consulta
  *
  * @throws RegistrosException
  */
 public function deAlunoCoordenador(Coordenador $coordenador, Aluno $aluno, Filtros $filtros)
 {
     if (!$aluno->getId()) {
         throw new RegistrosException('O aluno informado não é válido');
     }
     $where = "public.usuario_aluno.fk_usuario={$aluno->getId()} " . "and {$this->tabela}.fk_usuario_coordenador={$coordenador->getIdEspecifico()} ";
     //Aplicando os filtros
     //-Pertiodo
     if ($filtros->issetVar('de')) {
         $where .= "and data_evento>='{$filtros->read('de')->format(Date::FORMAT_SQL_DATE)}' ";
     }
     if ($filtros->issetVar('ate')) {
         $where .= "and data_evento<='{$filtros->read('ate')->format(Date::FORMAT_SQL_DATE)}' ";
     }
     //-Tipo e subtipo
     if (!$filtros->issetVar(array('tipo_afa', 'subtipo_afa'))) {
         //Este trecho bloqueia a exibição de qualquer outro tipo de anotação
         $where .= 'and (pk_afa_tipo_anotacao=' . Tipo::TIPO_POSITIVO . ' ';
         $where .= 'or pk_afa_tipo_anotacao=' . Tipo::TIPO_NEGATIVO . ') ';
     } else {
         $this->filtrosTipoSub($where, $filtros);
     }
     //
     $select = new Select(array('afa' => $this->select()->distinct('pk_afa_conceito_aluno')->join("public.usuario_aluno", array("pk_usuario_aluno" => "{$this->tg->getTabela()}.fk_usuario_aluno"))->where($where)));
     return $this->tg->selectObj($select->order('afa.pk_afa_conceito_aluno', Order::DSC));
 }