Commit 85c4c1fa9bbd01bc896272b43b231c4773a471f8
1 parent
de158209
Exists in
master
Adicionado processo de limpar notas e faltas ao alterar componentes;
portabilis/ieducar#159
Showing
4 changed files
with
55 additions
and
11 deletions
Show diff stats
ieducar/intranet/educar_escola_serie_cad.php
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | * do GNU para mais detalhes. |
18 | 18 | * |
19 | 19 | * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto |
20 | - * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
20 | + | |
21 | 21 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. |
22 | 22 | * |
23 | 23 | * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> |
... | ... | @@ -34,6 +34,7 @@ require_once 'include/clsBanco.inc.php'; |
34 | 34 | require_once 'include/pmieducar/geral.inc.php'; |
35 | 35 | require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; |
36 | 36 | require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; |
37 | +require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php'; | |
37 | 38 | |
38 | 39 | /** |
39 | 40 | * clsIndexBase class. |
... | ... | @@ -467,6 +468,13 @@ class indice extends clsCadastro |
467 | 468 | } |
468 | 469 | } |
469 | 470 | } |
471 | + //Verifica/limpa disciplinas não alteradas quando a escola/série for editada e tiver disciplinas marcadas | |
472 | + //não padrão do ano letivo. | |
473 | + $obj_ano_letivo = new clsPmieducarEscolaAnoLetivo(); | |
474 | + $existe_ano_andamento = $obj_ano_letivo->lista($this->ref_cod_escola,null,null,null,1,null,null,null,null,1); | |
475 | + foreach ($existe_ano_andamento as $reg) { | |
476 | + CleanComponentesCurriculares::destroyOldResources($reg['ano']); | |
477 | + } | |
470 | 478 | } |
471 | 479 | |
472 | 480 | $this->mensagem .= 'Edição efetuada com sucesso.<br>'; | ... | ... |
ieducar/intranet/educar_turma_cad.php
... | ... | @@ -34,6 +34,7 @@ require_once 'include/clsBanco.inc.php'; |
34 | 34 | require_once 'include/pmieducar/geral.inc.php'; |
35 | 35 | require_once 'Portabilis/String/Utils.php'; |
36 | 36 | require_once 'lib/Portabilis/Date/Utils.php'; |
37 | +require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php'; | |
37 | 38 | |
38 | 39 | /** |
39 | 40 | * clsIndexBase class. |
... | ... | @@ -263,8 +264,6 @@ class indice extends clsCadastro |
263 | 264 | $this->campoLista('ref_ref_cod_serie', 'Série', $opcoes_serie, $this->ref_ref_cod_serie, |
264 | 265 | '', FALSE, '', NULL, $bloqueia); |
265 | 266 | |
266 | - $this->campoOculto('ref_ref_cod_serie',$this->ref_ref_cod_serie); | |
267 | - | |
268 | 267 | // o campo ano somente é exibido para turmas novas ou cadastradas após inclusão deste campo. |
269 | 268 | if ($anoVisivel){ |
270 | 269 | $this->inputsHelper()->dynamic('anoLetivo', array('disabled' => $bloqueia)); |
... | ... | @@ -964,6 +963,13 @@ class indice extends clsCadastro |
964 | 963 | $this->disciplinas, $this->carga_horaria, $this->usar_componente |
965 | 964 | ); |
966 | 965 | |
966 | + // Caso tenham sido selecionadas discplinas, como se trata de uma edição de turma será rodado uma consulta | |
967 | + // que limpa os Componentes Curriculares antigos. | |
968 | + if($this->disciplinas != 1){ | |
969 | + $anoLetivo = $this->ano ? $this->ano : date("Y"); | |
970 | + CleanComponentesCurriculares::destroyOldResources($anoLetivo); | |
971 | + } | |
972 | + | |
967 | 973 | if ($editou) { |
968 | 974 | $this->mensagem .= 'Edição efetuada com sucesso.'; |
969 | 975 | header('Location: educar_turma_lst.php'); | ... | ... |
ieducar/intranet/include/pmieducar/clsPmieducarMatriculaTurma.inc.php
... | ... | @@ -29,6 +29,7 @@ |
29 | 29 | */ |
30 | 30 | |
31 | 31 | require_once 'include/pmieducar/geral.inc.php'; |
32 | +require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php'; | |
32 | 33 | |
33 | 34 | /** |
34 | 35 | * clsPmieducarMatriculaTurma class. |
... | ... | @@ -307,6 +308,8 @@ class clsPmieducarMatriculaTurma |
307 | 308 | |
308 | 309 | $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)"); |
309 | 310 | |
311 | + $this->limpaComponentesCurriculares(); | |
312 | + | |
310 | 313 | return TRUE; |
311 | 314 | } |
312 | 315 | |
... | ... | @@ -363,6 +366,7 @@ class clsPmieducarMatriculaTurma |
363 | 366 | |
364 | 367 | if ($set) { |
365 | 368 | $db->Consulta("UPDATE {$this->_tabela} SET $set WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_turma = '{$this->ref_cod_turma}' and sequencial = '$this->sequencial' "); |
369 | + $this->limpaComponentesCurriculares(); | |
366 | 370 | return TRUE; |
367 | 371 | } |
368 | 372 | } |
... | ... | @@ -1327,5 +1331,13 @@ class clsPmieducarMatriculaTurma |
1327 | 1331 | return 0; |
1328 | 1332 | }else |
1329 | 1333 | return 0; |
1330 | - } | |
1334 | + } | |
1335 | + | |
1336 | + function limpaComponentesCurriculares(){ | |
1337 | + $db = new clsBanco(); | |
1338 | + $ano = $db->CampoUnico("SELECT ano FROM pmieducar.matricula WHERE cod_matricula = {$this->ref_cod_matricula}"); | |
1339 | + echo "$ano --"; | |
1340 | + CleanComponentesCurriculares::destroyOldResources($ano, $this->ref_cod_matricula); | |
1341 | + } | |
1342 | + | |
1331 | 1343 | } | ... | ... |
ieducar/modules/Avaliacao/Fixups/CleanComponentesCurriculares.php
... | ... | @@ -48,13 +48,18 @@ require_once 'lib/Portabilis/Utils/Database.php'; |
48 | 48 | |
49 | 49 | class CleanComponentesCurriculares { |
50 | 50 | |
51 | - public static function destroyOldResources($anoEscolar) { | |
52 | - self::destroyOldNotas($anoEscolar); | |
53 | - self::destroyOldNotasMedias($anoEscolar); | |
54 | - self::destroyOldFaltas($anoEscolar); | |
51 | + public static function destroyOldResources($anoEscolar, $cod_matricula = NULL) { | |
52 | + self::destroyOldNotas($anoEscolar, $cod_matricula); | |
53 | + self::destroyOldNotasMedias($anoEscolar, $cod_matricula); | |
54 | + self::destroyOldFaltas($anoEscolar, $cod_matricula); | |
55 | 55 | } |
56 | 56 | |
57 | - protected static function destroyOldNotas($anoEscolar) { | |
57 | + protected static function destroyOldNotas($anoEscolar, $cod_matricula) { | |
58 | + $filtro = ""; | |
59 | + | |
60 | + if (is_Numeric($cod_matricula)) | |
61 | + $filtro .= " m.cod_matricula = {$cod_matricula} AND "; | |
62 | + | |
58 | 63 | $sql = "delete from modules.nota_componente_curricular where id in ( |
59 | 64 | select ncc.id from modules.nota_componente_curricular as ncc, |
60 | 65 | modules.nota_aluno as na, |
... | ... | @@ -67,6 +72,7 @@ class CleanComponentesCurriculares { |
67 | 72 | m.ativo = 1 and |
68 | 73 | mt.ativo = m.ativo and |
69 | 74 | m.ano = $1 and |
75 | + {$filtro} | |
70 | 76 | --m.aprovado = 3 and |
71 | 77 | |
72 | 78 | CASE WHEN (select 1 from modules.componente_curricular_turma |
... | ... | @@ -87,7 +93,12 @@ class CleanComponentesCurriculares { |
87 | 93 | self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); |
88 | 94 | } |
89 | 95 | |
90 | - protected static function destroyOldNotasMedias($anoEscolar) { | |
96 | + protected static function destroyOldNotasMedias($anoEscolar, $cod_matricula) { | |
97 | + $filtro = ""; | |
98 | + | |
99 | + if (is_Numeric($cod_matricula)) | |
100 | + $filtro .= " m.cod_matricula = {$cod_matricula} AND "; | |
101 | + | |
91 | 102 | $sql = "delete from modules.nota_componente_curricular_media where nota_aluno_id||componente_curricular_id in ( |
92 | 103 | select nccm.nota_aluno_id|| nccm.componente_curricular_id from modules.nota_componente_curricular_media as nccm, |
93 | 104 | modules.nota_aluno as na, |
... | ... | @@ -100,6 +111,7 @@ class CleanComponentesCurriculares { |
100 | 111 | m.ativo = 1 and |
101 | 112 | mt.ativo = m.ativo and |
102 | 113 | m.ano = $1 and |
114 | + {$filtro} | |
103 | 115 | --m.aprovado = 3 and |
104 | 116 | |
105 | 117 | CASE WHEN (select 1 from modules.componente_curricular_turma |
... | ... | @@ -120,7 +132,12 @@ class CleanComponentesCurriculares { |
120 | 132 | self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); |
121 | 133 | } |
122 | 134 | |
123 | - protected static function destroyOldFaltas($anoEscolar) { | |
135 | + protected static function destroyOldFaltas($anoEscolar, $cod_matricula) { | |
136 | + $filtro = ""; | |
137 | + | |
138 | + if (is_Numeric($cod_matricula)) | |
139 | + $filtro .= " m.cod_matricula = {$cod_matricula} AND "; | |
140 | + | |
124 | 141 | $sql = "delete from modules.falta_componente_curricular where id in ( |
125 | 142 | select fcc.id from modules.falta_componente_curricular as fcc, |
126 | 143 | modules.falta_aluno as fa, |
... | ... | @@ -133,6 +150,7 @@ class CleanComponentesCurriculares { |
133 | 150 | m.ativo = 1 and |
134 | 151 | mt.ativo = m.ativo and |
135 | 152 | m.ano = $1 and |
153 | + {$filtro} | |
136 | 154 | --m.aprovado = 3 and |
137 | 155 | |
138 | 156 | CASE WHEN (select 1 from modules.componente_curricular_turma | ... | ... |