Commit f02403ebe4411f240b6fb6f1f3f2853bb78157da
Exists in
master
Merge branch 'master' into 'master'
Adicionado processo de limpar notas e faltas ao alterar componentes; Referente a issue #16. See merge request !14
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,7 +17,7 @@ | ||
17 | * do GNU para mais detalhes. | 17 | * do GNU para mais detalhes. |
18 | * | 18 | * |
19 | * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | 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 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | 21 | * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. |
22 | * | 22 | * |
23 | * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | 23 | * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> |
@@ -34,6 +34,7 @@ require_once 'include/clsBanco.inc.php'; | @@ -34,6 +34,7 @@ require_once 'include/clsBanco.inc.php'; | ||
34 | require_once 'include/pmieducar/geral.inc.php'; | 34 | require_once 'include/pmieducar/geral.inc.php'; |
35 | require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; | 35 | require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; |
36 | require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; | 36 | require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; |
37 | +require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php'; | ||
37 | 38 | ||
38 | /** | 39 | /** |
39 | * clsIndexBase class. | 40 | * clsIndexBase class. |
@@ -467,6 +468,13 @@ class indice extends clsCadastro | @@ -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 | $this->mensagem .= 'Edição efetuada com sucesso.<br>'; | 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,6 +34,7 @@ require_once 'include/clsBanco.inc.php'; | ||
34 | require_once 'include/pmieducar/geral.inc.php'; | 34 | require_once 'include/pmieducar/geral.inc.php'; |
35 | require_once 'Portabilis/String/Utils.php'; | 35 | require_once 'Portabilis/String/Utils.php'; |
36 | require_once 'lib/Portabilis/Date/Utils.php'; | 36 | require_once 'lib/Portabilis/Date/Utils.php'; |
37 | +require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php'; | ||
37 | 38 | ||
38 | /** | 39 | /** |
39 | * clsIndexBase class. | 40 | * clsIndexBase class. |
@@ -263,8 +264,6 @@ class indice extends clsCadastro | @@ -263,8 +264,6 @@ class indice extends clsCadastro | ||
263 | $this->campoLista('ref_ref_cod_serie', 'Série', $opcoes_serie, $this->ref_ref_cod_serie, | 264 | $this->campoLista('ref_ref_cod_serie', 'Série', $opcoes_serie, $this->ref_ref_cod_serie, |
264 | '', FALSE, '', NULL, $bloqueia); | 265 | '', FALSE, '', NULL, $bloqueia); |
265 | 266 | ||
266 | - $this->campoOculto('ref_ref_cod_serie',$this->ref_ref_cod_serie); | ||
267 | - | ||
268 | // o campo ano somente é exibido para turmas novas ou cadastradas após inclusão deste campo. | 267 | // o campo ano somente é exibido para turmas novas ou cadastradas após inclusão deste campo. |
269 | if ($anoVisivel){ | 268 | if ($anoVisivel){ |
270 | $this->inputsHelper()->dynamic('anoLetivo', array('disabled' => $bloqueia)); | 269 | $this->inputsHelper()->dynamic('anoLetivo', array('disabled' => $bloqueia)); |
@@ -964,6 +963,13 @@ class indice extends clsCadastro | @@ -964,6 +963,13 @@ class indice extends clsCadastro | ||
964 | $this->disciplinas, $this->carga_horaria, $this->usar_componente | 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 | if ($editou) { | 973 | if ($editou) { |
968 | $this->mensagem .= 'Edição efetuada com sucesso.'; | 974 | $this->mensagem .= 'Edição efetuada com sucesso.'; |
969 | header('Location: educar_turma_lst.php'); | 975 | header('Location: educar_turma_lst.php'); |
ieducar/intranet/include/pmieducar/clsPmieducarMatriculaTurma.inc.php
@@ -29,6 +29,7 @@ | @@ -29,6 +29,7 @@ | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | require_once 'include/pmieducar/geral.inc.php'; | 31 | require_once 'include/pmieducar/geral.inc.php'; |
32 | +require_once 'Avaliacao/Fixups/CleanComponentesCurriculares.php'; | ||
32 | 33 | ||
33 | /** | 34 | /** |
34 | * clsPmieducarMatriculaTurma class. | 35 | * clsPmieducarMatriculaTurma class. |
@@ -307,6 +308,8 @@ class clsPmieducarMatriculaTurma | @@ -307,6 +308,8 @@ class clsPmieducarMatriculaTurma | ||
307 | 308 | ||
308 | $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)"); | 309 | $db->Consulta("INSERT INTO {$this->_tabela} ($campos) VALUES ($valores)"); |
309 | 310 | ||
311 | + $this->limpaComponentesCurriculares(); | ||
312 | + | ||
310 | return TRUE; | 313 | return TRUE; |
311 | } | 314 | } |
312 | 315 | ||
@@ -363,6 +366,7 @@ class clsPmieducarMatriculaTurma | @@ -363,6 +366,7 @@ class clsPmieducarMatriculaTurma | ||
363 | 366 | ||
364 | if ($set) { | 367 | if ($set) { |
365 | $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' "); | 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 | return TRUE; | 370 | return TRUE; |
367 | } | 371 | } |
368 | } | 372 | } |
@@ -1327,5 +1331,13 @@ class clsPmieducarMatriculaTurma | @@ -1327,5 +1331,13 @@ class clsPmieducarMatriculaTurma | ||
1327 | return 0; | 1331 | return 0; |
1328 | }else | 1332 | }else |
1329 | return 0; | 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,13 +48,18 @@ require_once 'lib/Portabilis/Utils/Database.php'; | ||
48 | 48 | ||
49 | class CleanComponentesCurriculares { | 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 | $sql = "delete from modules.nota_componente_curricular where id in ( | 63 | $sql = "delete from modules.nota_componente_curricular where id in ( |
59 | select ncc.id from modules.nota_componente_curricular as ncc, | 64 | select ncc.id from modules.nota_componente_curricular as ncc, |
60 | modules.nota_aluno as na, | 65 | modules.nota_aluno as na, |
@@ -67,6 +72,7 @@ class CleanComponentesCurriculares { | @@ -67,6 +72,7 @@ class CleanComponentesCurriculares { | ||
67 | m.ativo = 1 and | 72 | m.ativo = 1 and |
68 | mt.ativo = m.ativo and | 73 | mt.ativo = m.ativo and |
69 | m.ano = $1 and | 74 | m.ano = $1 and |
75 | + {$filtro} | ||
70 | --m.aprovado = 3 and | 76 | --m.aprovado = 3 and |
71 | 77 | ||
72 | CASE WHEN (select 1 from modules.componente_curricular_turma | 78 | CASE WHEN (select 1 from modules.componente_curricular_turma |
@@ -87,7 +93,12 @@ class CleanComponentesCurriculares { | @@ -87,7 +93,12 @@ class CleanComponentesCurriculares { | ||
87 | self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); | 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 | $sql = "delete from modules.nota_componente_curricular_media where nota_aluno_id||componente_curricular_id in ( | 102 | $sql = "delete from modules.nota_componente_curricular_media where nota_aluno_id||componente_curricular_id in ( |
92 | select nccm.nota_aluno_id|| nccm.componente_curricular_id from modules.nota_componente_curricular_media as nccm, | 103 | select nccm.nota_aluno_id|| nccm.componente_curricular_id from modules.nota_componente_curricular_media as nccm, |
93 | modules.nota_aluno as na, | 104 | modules.nota_aluno as na, |
@@ -100,6 +111,7 @@ class CleanComponentesCurriculares { | @@ -100,6 +111,7 @@ class CleanComponentesCurriculares { | ||
100 | m.ativo = 1 and | 111 | m.ativo = 1 and |
101 | mt.ativo = m.ativo and | 112 | mt.ativo = m.ativo and |
102 | m.ano = $1 and | 113 | m.ano = $1 and |
114 | + {$filtro} | ||
103 | --m.aprovado = 3 and | 115 | --m.aprovado = 3 and |
104 | 116 | ||
105 | CASE WHEN (select 1 from modules.componente_curricular_turma | 117 | CASE WHEN (select 1 from modules.componente_curricular_turma |
@@ -120,7 +132,12 @@ class CleanComponentesCurriculares { | @@ -120,7 +132,12 @@ class CleanComponentesCurriculares { | ||
120 | self::fetchPreparedQuery($sql, array('params' => $anoEscolar)); | 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 | $sql = "delete from modules.falta_componente_curricular where id in ( | 141 | $sql = "delete from modules.falta_componente_curricular where id in ( |
125 | select fcc.id from modules.falta_componente_curricular as fcc, | 142 | select fcc.id from modules.falta_componente_curricular as fcc, |
126 | modules.falta_aluno as fa, | 143 | modules.falta_aluno as fa, |
@@ -133,6 +150,7 @@ class CleanComponentesCurriculares { | @@ -133,6 +150,7 @@ class CleanComponentesCurriculares { | ||
133 | m.ativo = 1 and | 150 | m.ativo = 1 and |
134 | mt.ativo = m.ativo and | 151 | mt.ativo = m.ativo and |
135 | m.ano = $1 and | 152 | m.ano = $1 and |
153 | + {$filtro} | ||
136 | --m.aprovado = 3 and | 154 | --m.aprovado = 3 and |
137 | 155 | ||
138 | CASE WHEN (select 1 from modules.componente_curricular_turma | 156 | CASE WHEN (select 1 from modules.componente_curricular_turma |