From 4cb18fe22fd81e6d48386d215c83a83a867dec61 Mon Sep 17 00:00:00 2001 From: Lucas Schmoeller da Silva Date: Thu, 14 Nov 2013 11:01:18 -0200 Subject: [PATCH] #24 Listando somente turmas do ano atual nas listas de enturmações --- ieducar/intranet/educar_matricula_turma_lst.php | 6 +++--- ieducar/intranet/educar_matriculas_turma_lst.php | 2 +- ieducar/intranet/include/pmieducar/clsPmieducarTurma.inc.php | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 260 insertions(+), 4 deletions(-) diff --git a/ieducar/intranet/educar_matricula_turma_lst.php b/ieducar/intranet/educar_matricula_turma_lst.php index 9e9a522..ada89f6 100644 --- a/ieducar/intranet/educar_matricula_turma_lst.php +++ b/ieducar/intranet/educar_matricula_turma_lst.php @@ -138,7 +138,7 @@ class indice extends clsListagem // Opções de turma $objTemp = new clsPmieducarTurma(); - $lista = $objTemp->lista(NULL, NULL, NULL, $this->ref_cod_serie, + $lista = $objTemp->lista3(NULL, NULL, NULL, $this->ref_cod_serie, $this->ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_curso); @@ -169,7 +169,7 @@ class indice extends clsListagem $obj_matricula_turma->setOrderby('data_cadastro ASC'); $obj_matricula_turma->setLimite($this->limite, $this->offset); - $lista = $obj_matricula_turma->lista($this->ref_cod_turma, NULL, NULL, + $lista = $obj_matricula_turma->lista3($this->ref_cod_turma, NULL, NULL, $this->ref_cod_serie,$this->ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,$this->ref_cod_curso, NULL, NULL, NULL, NULL, NULL, NULL, TRUE); @@ -216,7 +216,7 @@ WHERE } $enturmacoesMatricula = new clsPmieducarMatriculaTurma(); - $enturmacoesMatricula = $enturmacoesMatricula->lista($this->ref_cod_matricula, NULL, NULL, + $enturmacoesMatricula = $enturmacoesMatricula->lista3($this->ref_cod_matricula, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); $turmasThisSerie = $lista; diff --git a/ieducar/intranet/educar_matriculas_turma_lst.php b/ieducar/intranet/educar_matriculas_turma_lst.php index 54a13c6..c355725 100644 --- a/ieducar/intranet/educar_matriculas_turma_lst.php +++ b/ieducar/intranet/educar_matriculas_turma_lst.php @@ -128,7 +128,7 @@ class indice extends clsListagem $obj_turma->setOrderby( "nm_turma ASC" ); $obj_turma->setLimite( $this->limite, $this->offset ); - $lista = $obj_turma->lista2( + $lista = $obj_turma->lista3( $this->ref_cod_turma, null, null, diff --git a/ieducar/intranet/include/pmieducar/clsPmieducarTurma.inc.php b/ieducar/intranet/include/pmieducar/clsPmieducarTurma.inc.php index 4677688..2c7bd91 100644 --- a/ieducar/intranet/include/pmieducar/clsPmieducarTurma.inc.php +++ b/ieducar/intranet/include/pmieducar/clsPmieducarTurma.inc.php @@ -1690,6 +1690,262 @@ and e.cod_escola = t.ref_ref_cod_escola } /** + * Retorna uma lista filtrados de acordo com os parametros + * (Modificação da lista2, agora trazendo somente turmas do ano atual) + * @return array + */ + function lista3( $int_cod_turma = null, $int_ref_usuario_exc = null, $int_ref_usuario_cad = null, $int_ref_ref_cod_serie = null, $int_ref_ref_cod_escola = null, $int_ref_cod_infra_predio_comodo = null, $str_nm_turma = null, $str_sgl_turma = null, $int_max_aluno = null, $int_multiseriada = null, $date_data_cadastro_ini = null, $date_data_cadastro_fim = null, $date_data_exclusao_ini = null, $date_data_exclusao_fim = null, $int_ativo = null, $int_ref_cod_turma_tipo = null, $time_hora_inicial_ini = null, $time_hora_inicial_fim = null, $time_hora_final_ini = null, $time_hora_final_fim = null, $time_hora_inicio_intervalo_ini = null, $time_hora_inicio_intervalo_fim = null, $time_hora_fim_intervalo_ini = null, $time_hora_fim_intervalo_fim = null, $int_ref_cod_curso = null, $int_ref_cod_instituicao = null, $int_ref_cod_regente = null, $int_ref_cod_instituicao_regente = null, $int_ref_ref_cod_escola_mult = null, $int_ref_ref_cod_serie_mult = null, $int_qtd_min_alunos_matriculados = null, $visivel = null, $turma_turno_id = null, $tipo_boletim = null, $ano = null ) + { + + + $sql = "SELECT {$this->_campos_lista},c.nm_curso,s.nm_serie,i.nm_instituicao FROM {$this->_tabela} t left outer join {$this->_schema}serie s on (t.ref_ref_cod_serie = s.cod_serie), {$this->_schema}curso c, {$this->_schema}instituicao i "; + $filtros = ""; + + $whereAnd = " WHERE t.ref_cod_curso = c.cod_curso AND c.ref_cod_instituicao = i.cod_instituicao AND "; + + if( is_numeric( $int_cod_turma ) ) + { + $filtros .= "{$whereAnd} t.cod_turma = '{$int_cod_turma}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_usuario_exc ) ) + { + $filtros .= "{$whereAnd} t.ref_usuario_exc = '{$int_ref_usuario_exc}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_usuario_cad ) ) + { + $filtros .= "{$whereAnd} t.ref_usuario_cad = '{$int_ref_usuario_cad}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_ref_cod_serie ) ) + { + $filtros .= "{$whereAnd} t.ref_ref_cod_serie = '{$int_ref_ref_cod_serie}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_ref_cod_escola ) ) + { + $filtros .= "{$whereAnd} t.ref_ref_cod_escola = '{$int_ref_ref_cod_escola}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_cod_infra_predio_comodo ) ) + { + $filtros .= "{$whereAnd} t.ref_cod_infra_predio_comodo = '{$int_ref_cod_infra_predio_comodo}'"; + $whereAnd = " AND "; + } + if( is_string( $str_nm_turma ) ) + { + $filtros .= "{$whereAnd} t.nm_turma LIKE '%{$str_nm_turma}%'"; + $whereAnd = " AND "; + } + if( is_string( $str_sgl_turma ) ) + { + $filtros .= "{$whereAnd} t.sgl_turma LIKE '%{$str_sgl_turma}%'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_max_aluno ) ) + { + $filtros .= "{$whereAnd} t.max_aluno = '{$int_max_aluno}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_multiseriada ) ) + { + $filtros .= "{$whereAnd} t.multiseriada = '{$int_multiseriada}'"; + $whereAnd = " AND "; + } + if( is_string( $date_data_cadastro_ini ) ) + { + $filtros .= "{$whereAnd} t.data_cadastro >= '{$date_data_cadastro_ini}'"; + $whereAnd = " AND "; + } + if( is_string( $date_data_cadastro_fim ) ) + { + $filtros .= "{$whereAnd} t.data_cadastro <= '{$date_data_cadastro_fim}'"; + $whereAnd = " AND "; + } + if( is_string( $date_data_exclusao_ini ) ) + { + $filtros .= "{$whereAnd} t.data_exclusao >= '{$date_data_exclusao_ini}'"; + $whereAnd = " AND "; + } + if( is_string( $date_data_exclusao_fim ) ) + { + $filtros .= "{$whereAnd} t.data_exclusao <= '{$date_data_exclusao_fim}'"; + $whereAnd = " AND "; + } + if( is_null( $int_ativo ) || $int_ativo ) + { + $filtros .= "{$whereAnd} t.ativo = '1'"; + $whereAnd = " AND "; + } + else + { + $filtros .= "{$whereAnd} t.ativo = '0'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_cod_turma_tipo ) ) + { + $filtros .= "{$whereAnd} t.ref_cod_turma_tipo = '{$int_ref_cod_turma_tipo}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_inicial_ini ) ) + { + $filtros .= "{$whereAnd} t.hora_inicial >= '{$time_hora_inicial_ini}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_inicial_fim ) ) + { + $filtros .= "{$whereAnd} t.hora_inicial <= '{$time_hora_inicial_fim}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_final_ini ) ) + { + $filtros .= "{$whereAnd} t.hora_final >= '{$time_hora_final_ini}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_final_fim ) ) + { + $filtros .= "{$whereAnd} t.hora_final <= '{$time_hora_final_fim}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_inicio_intervalo_ini ) ) + { + $filtros .= "{$whereAnd} t.hora_inicio_intervalo >= '{$time_hora_inicio_intervalo_ini}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_inicio_intervalo_fim ) ) + { + $filtros .= "{$whereAnd} t.hora_inicio_intervalo <= '{$time_hora_inicio_intervalo_fim}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_fim_intervalo_ini ) ) + { + $filtros .= "{$whereAnd} t.hora_fim_intervalo >= '{$time_hora_fim_intervalo_ini}'"; + $whereAnd = " AND "; + } + if( ( $time_hora_fim_intervalo_fim ) ) + { + $filtros .= "{$whereAnd} t.hora_fim_intervalo <= '{$time_hora_fim_intervalo_fim}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_cod_regente ) ) + { + $filtros .= "{$whereAnd} t.ref_cod_regente = '{$int_ref_cod_regente}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_cod_instituicao_regente ) ) + { + $filtros .= "{$whereAnd} t.ref_cod_instituicao_regente = '{$int_ref_cod_instituicao_regente}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_cod_instituicao ) ) + { + $filtros .= "{$whereAnd} t.ref_cod_instituicao = '{$int_ref_cod_instituicao}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_cod_curso ) ) + { + $filtros .= "{$whereAnd} t.ref_cod_curso = '{$int_ref_cod_curso}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_ref_cod_escola_mult ) ) + { + $filtros .= "{$whereAnd} t.ref_ref_cod_escola_mult = '{$int_ref_ref_cod_escola_mult}'"; + $whereAnd = " AND "; + } + if( is_numeric( $int_ref_ref_cod_serie_mult ) ) + { + $filtros .= "{$whereAnd} t.int_ref_ref_cod_serie_mult = '{$int_ref_ref_cod_serie_mult}'"; + $whereAnd = " AND "; + } + if( is_numeric($int_qtd_min_alunos_matriculados) ) + { + $filtros .= "{$whereAnd} (SELECT COUNT(0) FROM pmieducar.matricula_turma WHERE ref_cod_turma = t.cod_turma) >= '{$int_qtd_min_alunos_matriculados}' "; + $whereAnd = " AND "; + } + if (is_bool($visivel)) + { + if ($visivel) + { + $filtros .= "{$whereAnd} t.visivel = TRUE"; + $whereAnd = " AND "; + } + else + { + $filtros .= "{$whereAnd} t.visivel = FALSE"; + $whereAnd = " AND "; + } + } + elseif (is_array($visivel) && count($visivel)) + { + $filtros .= "{$whereAnd} t.visivel IN (".implode(",", $visivel).")"; + $whereAnd = " AND "; + } + else + { + $filtros .= "{$whereAnd} t.visivel = TRUE"; + $whereAnd = " AND "; + } + + if( is_numeric( $turma_turno_id ) ) { + $filtros .= "{$whereAnd} t.turma_turno_id = '{$turma_turno_id}'"; + $whereAnd = " AND "; + } + + if( is_numeric( $tipo_boletim ) ) { + $filtros .= "{$whereAnd} t.tipo_boletim = '{$tipo_boletim}'"; + $whereAnd = " AND "; + } + + if( is_numeric( $ano ) ) { + $filtros .= "{$whereAnd} t.ano = '{$ano}'"; + $whereAnd = " AND "; + } + + $filtros .= "{$whereAnd} (ano = (SELECT max(ano) + FROM pmieducar.escola_ano_letivo mat + WHERE ativo = 1 and mat.andamento = 1) or ((t.ano is null) AND (select 1 from pmieducar.matricula_turma + where ativo = 1 and date_part('year',data_cadastro) = (SELECT max(ano) + FROM pmieducar.escola_ano_letivo + WHERE ativo = 1 and andamento = 1) and t.cod_turma = ref_cod_turma limit 1) is not null))"; + + $db = new clsBanco(); + $countCampos = count( explode( ",", $this->_campos_lista ) ); + $resultado = array(); + + $sql .= $filtros . $this->getOrderby() . $this->getLimite(); + + $this->_total = $db->CampoUnico( "SELECT COUNT(0) FROM {$this->_tabela} t left outer join {$this->_schema}serie s on (t.ref_ref_cod_serie = s.cod_serie), {$this->_schema}curso c , {$this->_schema}instituicao i {$filtros}" ); + + + $db->Consulta( $sql); + + if( $countCampos > 1 ) + { + while ( $db->ProximoRegistro() ) + { + $tupla = $db->Tupla(); + + $tupla["_total"] = $this->_total; + $resultado[] = $tupla; + } + } + else + { + while ( $db->ProximoRegistro() ) + { + $tupla = $db->Tupla(); + $resultado[] = $tupla[$this->_campos_lista]; + } + } + if( count( $resultado ) ) + { + return $resultado; + } + return false; + } + + /** * Retorna um array com os dados de um registro * * @return array -- libgit2 0.21.2