Commit 6e96203a7bb1604b7d8c22482caf4d9c15508438
1 parent
1ba28ca0
Exists in
master
Refactoring para coding standards
Showing
1 changed file
with
845 additions
and
762 deletions
Show diff stats
ieducar/intranet/educar_matricula_cad.php
| 1 | 1 | <?php |
| 2 | -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 3 | - * * | |
| 4 | - * @author Prefeitura Municipal de Itajaí * | |
| 5 | - * @updated 29/03/2007 * | |
| 6 | - * Pacote: i-PLB Software Público Livre e Brasileiro * | |
| 7 | - * * | |
| 8 | - * Copyright (C) 2006 PMI - Prefeitura Municipal de Itajaí * | |
| 9 | - * ctima@itajai.sc.gov.br * | |
| 10 | - * * | |
| 11 | - * Este programa é software livre, você pode redistribuí-lo e/ou * | |
| 12 | - * modificá-lo sob os termos da Licença Pública Geral GNU, conforme * | |
| 13 | - * publicada pela Free Software Foundation, tanto a versão 2 da * | |
| 14 | - * Licença como (a seu critério) qualquer versão mais nova. * | |
| 15 | - * * | |
| 16 | - * Este programa é distribuído na expectativa de ser útil, mas SEM * | |
| 17 | - * QUALQUER GARANTIA. Sem mesmo a garantia implícita de COMERCIALI- * | |
| 18 | - * ZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM PARTICULAR. Con- * | |
| 19 | - * sulte a Licença Pública Geral GNU para obter mais detalhes. * | |
| 20 | - * * | |
| 21 | - * Você deve ter recebido uma cópia da Licença Pública Geral GNU * | |
| 22 | - * junto com este programa. Se não, escreva para a Free Software * | |
| 23 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * | |
| 24 | - * 02111-1307, USA. * | |
| 25 | - * * | |
| 26 | - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
| 27 | -require_once ("include/clsBase.inc.php"); | |
| 28 | -require_once ("include/clsCadastro.inc.php"); | |
| 29 | -require_once ("include/clsBanco.inc.php"); | |
| 30 | -require_once( "include/pmieducar/geral.inc.php" ); | |
| 31 | 2 | |
| 3 | +/** | |
| 4 | + * i-Educar - Sistema de gestão escolar | |
| 5 | + * | |
| 6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
| 7 | + * <ctima@itajai.sc.gov.br> | |
| 8 | + * | |
| 9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
| 10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
| 11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
| 12 | + * qualquer versão posterior. | |
| 13 | + * | |
| 14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
| 15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
| 16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
| 17 | + * do GNU para mais detalhes. | |
| 18 | + * | |
| 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 | |
| 21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
| 22 | + * | |
| 23 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 24 | + * @category i-Educar | |
| 25 | + * @license @@license@@ | |
| 26 | + * @package iEd_Pmieducar | |
| 27 | + * @since Arquivo disponível desde a versão 1.0.0 | |
| 28 | + * @version $Id$ | |
| 29 | + */ | |
| 30 | + | |
| 31 | +require_once 'include/clsBase.inc.php'; | |
| 32 | +require_once 'include/clsCadastro.inc.php'; | |
| 33 | +require_once 'include/clsBanco.inc.php'; | |
| 34 | +require_once 'include/pmieducar/geral.inc.php'; | |
| 35 | + | |
| 36 | +/** | |
| 37 | + * clsIndexBase class. | |
| 38 | + * | |
| 39 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 40 | + * @category i-Educar | |
| 41 | + * @license @@license@@ | |
| 42 | + * @package iEd_Pmieducar | |
| 43 | + * @since Classe disponível desde a versão 1.0.0 | |
| 44 | + * @version @@package_version@@ | |
| 45 | + */ | |
| 32 | 46 | class clsIndexBase extends clsBase |
| 33 | 47 | { |
| 34 | - function Formular() | |
| 35 | - { | |
| 36 | - $this->SetTitulo( "{$this->_instituicao} i-Educar - Matrícula" ); | |
| 37 | - $this->processoAp = "578"; | |
| 38 | - } | |
| 48 | + function Formular() | |
| 49 | + { | |
| 50 | + $this->SetTitulo($this->_instituicao . ' i-Educar - Matrícula'); | |
| 51 | + $this->processoAp = 578; | |
| 52 | + } | |
| 39 | 53 | } |
| 40 | 54 | |
| 55 | +/** | |
| 56 | + * indice class. | |
| 57 | + * | |
| 58 | + * @author Prefeitura Municipal de Itajaí <ctima@itajai.sc.gov.br> | |
| 59 | + * @category i-Educar | |
| 60 | + * @license @@license@@ | |
| 61 | + * @package iEd_Pmieducar | |
| 62 | + * @since Classe disponível desde a versão 1.0.0 | |
| 63 | + * @version @@package_version@@ | |
| 64 | + */ | |
| 41 | 65 | class indice extends clsCadastro |
| 42 | 66 | { |
| 43 | - /** | |
| 44 | - * Referencia pega da session para o idpes do usuario atual | |
| 45 | - * | |
| 46 | - * @var int | |
| 47 | - */ | |
| 48 | - var $pessoa_logada; | |
| 49 | - | |
| 50 | - var $cod_matricula; | |
| 51 | - var $ref_cod_reserva_vaga; | |
| 52 | - var $ref_ref_cod_escola; | |
| 53 | - var $ref_ref_cod_serie; | |
| 54 | - var $ref_usuario_exc; | |
| 55 | - var $ref_usuario_cad; | |
| 56 | - var $ref_cod_aluno; | |
| 57 | - var $aprovado; | |
| 58 | - var $data_cadastro; | |
| 59 | - var $data_exclusao; | |
| 60 | - var $ativo; | |
| 61 | - var $ano; | |
| 62 | - | |
| 63 | - var $ref_cod_instituicao; | |
| 64 | - var $ref_cod_curso; | |
| 65 | - var $ref_cod_escola; | |
| 66 | - | |
| 67 | - var $matricula_transferencia; | |
| 68 | - var $semestre; | |
| 69 | - var $is_padrao; | |
| 70 | - | |
| 71 | - function Inicializar() | |
| 72 | - { | |
| 73 | - $retorno = "Novo"; | |
| 74 | - @session_start(); | |
| 75 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 76 | - @session_write_close(); | |
| 77 | - | |
| 78 | -// die('Serviço indisponivel temporariamente!'); | |
| 79 | - | |
| 80 | - $this->cod_matricula=$_GET["cod_matricula"]; | |
| 81 | - $this->ref_cod_aluno=$_GET["ref_cod_aluno"]; | |
| 82 | - | |
| 83 | - $obj_aluno = new clsPmieducarAluno($this->ref_cod_aluno); | |
| 84 | - if(!$obj_aluno->existe()) | |
| 85 | - { | |
| 86 | - header("location: educar_matricula_lst.php"); | |
| 87 | - die; | |
| 88 | - } | |
| 89 | - | |
| 90 | - $obj_permissoes = new clsPermissoes(); | |
| 91 | - $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); | |
| 92 | - | |
| 93 | - if ( is_numeric( $this->cod_matricula ) ) | |
| 94 | - { | |
| 95 | - if( $obj_permissoes->permissao_excluir( 578, $this->pessoa_logada, 7 ) ) | |
| 96 | - { | |
| 97 | - $this->Excluir(); | |
| 98 | - } | |
| 99 | - } | |
| 100 | -// else{ | |
| 101 | -// header("location: educar_matricula_lst.php"); | |
| 102 | -// die; | |
| 103 | -// } | |
| 104 | - $this->url_cancelar = "educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}"; | |
| 105 | - $this->nome_url_cancelar = "Cancelar"; | |
| 106 | - return $retorno; | |
| 107 | - } | |
| 108 | - | |
| 109 | - function Gerar() | |
| 110 | - { | |
| 111 | - // primary keys | |
| 112 | - $this->campoOculto( "cod_matricula", $this->cod_matricula ); | |
| 113 | - $this->campoOculto( "ref_cod_aluno", $this->ref_cod_aluno ); | |
| 114 | - | |
| 115 | - $obj_aluno = new clsPmieducarAluno(); | |
| 116 | - $lst_aluno = $obj_aluno->lista( $this->ref_cod_aluno,null,null,null,null,null,null,null,null,null,1 ); | |
| 117 | - if ( is_array($lst_aluno) ) | |
| 118 | - { | |
| 119 | - $det_aluno = array_shift($lst_aluno); | |
| 120 | - $this->nm_aluno = $det_aluno["nome_aluno"]; | |
| 121 | -// $this->campoRotulo( "nm_aluno", "Aluno", $this->nm_aluno, 30, 255, false,false,false,"","","","",true ); | |
| 122 | - $this->campoRotulo( "nm_aluno", "Aluno", $this->nm_aluno ); | |
| 123 | - } | |
| 124 | - | |
| 125 | - /** | |
| 126 | - * verifica se nao existem matriculas | |
| 127 | - * e exibe campo check para informar | |
| 128 | - * se a matricula vem de transferencia | |
| 129 | - * ex: um aluno esta sendo matriculado no 3º ano | |
| 130 | - * ele veio de outra escola mas nao vem como transferencia | |
| 131 | - * isto eh necessario para o relatorio de movimentacao mensal | |
| 132 | - */ | |
| 133 | - | |
| 134 | - $obj_matricula = new clsPmieducarMatricula(); | |
| 135 | - $lst_matricula = $obj_matricula->lista(null, null, null, null, null, null, $this->ref_cod_aluno); | |
| 136 | - | |
| 137 | - if(!$lst_matricula) | |
| 138 | - { | |
| 139 | - /** | |
| 140 | - * primeira matricula do sistema exibe campo check | |
| 141 | - */ | |
| 142 | - | |
| 143 | - $this->campoCheck("matricula_transferencia", "Matrícula de Transferência","","Caso seja transfência externa por favor marque esta opção."); | |
| 144 | - } | |
| 145 | - | |
| 146 | - // foreign keys | |
| 147 | -// $obrigatorio = true; | |
| 148 | - $instituicao_obrigatorio = true; | |
| 149 | - $curso_obrigatorio = true; | |
| 150 | - $escola_curso_obrigatorio = true; | |
| 151 | - $get_escola = true; | |
| 152 | - $get_curso = true; | |
| 153 | -// $get_escola_curso = true; | |
| 154 | - $get_escola_curso_serie = true; | |
| 155 | - $get_matricula = true; | |
| 156 | - $sem_padrao = true; | |
| 157 | - | |
| 158 | - include("include/pmieducar/educar_campo_lista.php"); | |
| 159 | - | |
| 160 | - if (is_numeric($this->ref_cod_curso)) | |
| 161 | - { | |
| 162 | - $obj_curso = new clsPmieducarCurso($this->ref_cod_curso); | |
| 163 | - $det_curso = $obj_curso->detalhe(); | |
| 164 | - if (is_numeric($det_curso["ref_cod_tipo_avaliacao"])) | |
| 165 | - { | |
| 166 | - $this->campoOculto("apagar_radios", $det_curso["padrao_ano_escolar"]); | |
| 167 | - $this->campoOculto("is_padrao", $det_curso["padrao_ano_escolar"]); | |
| 168 | - } | |
| 169 | - } | |
| 170 | - | |
| 171 | - if ( $this->ref_cod_escola ) | |
| 172 | - { | |
| 173 | - $this->ref_ref_cod_escola = $this->ref_cod_escola; | |
| 174 | - } | |
| 175 | - | |
| 176 | - $this->acao_enviar = "valida()"; | |
| 177 | - } | |
| 178 | - | |
| 179 | - function Novo() | |
| 180 | - { | |
| 181 | - @session_start(); | |
| 182 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 183 | - @session_write_close(); | |
| 184 | - | |
| 185 | - $obj_permissoes = new clsPermissoes(); | |
| 186 | - $obj_permissoes->permissao_cadastra( 578, $this->pessoa_logada, 7, "educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); | |
| 187 | - | |
| 188 | - $obj_escola_ano_letivo = new clsPmieducarEscolaAnoLetivo(); | |
| 189 | - $lst_escola_ano_letivo = $obj_escola_ano_letivo->lista( $this->ref_cod_escola,null,null,null,1,null,null,null,null,1 ); | |
| 190 | - if ( is_array($lst_escola_ano_letivo) ) | |
| 191 | - { | |
| 192 | - $det_escola_ano_letivo = array_shift($lst_escola_ano_letivo); | |
| 193 | - $this->ano = $det_escola_ano_letivo["ano"]; | |
| 194 | - | |
| 195 | - $obj_reserva_vaga = new clsPmieducarReservaVaga(); | |
| 196 | - $lst_reserva_vaga = $obj_reserva_vaga->lista( null,$this->ref_cod_escola,$this->ref_ref_cod_serie,null,null,$this->ref_cod_aluno,null,null,null,null,1 ); | |
| 197 | - // verifica se existe reserva de vaga para o aluno | |
| 198 | - if ( is_array($lst_reserva_vaga) ) | |
| 199 | - { | |
| 200 | - $det_reserva_vaga = array_shift($lst_reserva_vaga); | |
| 201 | - $this->ref_cod_reserva_vaga = $det_reserva_vaga["cod_reserva_vaga"]; | |
| 202 | - | |
| 203 | - $obj_reserva_vaga = new clsPmieducarReservaVaga( $this->ref_cod_reserva_vaga,null,null,$this->pessoa_logada,null,null,null,null,0 ); | |
| 204 | - $editou = $obj_reserva_vaga->edita(); | |
| 205 | - if ( !$editou ) | |
| 206 | - { | |
| 207 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 208 | - echo "<!--\nErro ao editar clsPmieducarReservaVaga\nvalores obrigatorios\nis_numeric( $this->ref_cod_reserva_vaga ) && is_numeric( $this->pessoa_logada )\n-->"; | |
| 209 | - return false; | |
| 210 | - } | |
| 211 | - } | |
| 212 | - | |
| 213 | - $vagas_restantes = 1; | |
| 214 | - | |
| 215 | - if ( !$this->ref_cod_reserva_vaga ) | |
| 216 | - { | |
| 217 | - $obj_turmas = new clsPmieducarTurma(); | |
| 218 | - $lst_turmas = $obj_turmas->lista( null,null,null,$this->ref_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,null,null,null,null,null,null,null,true ); | |
| 219 | - //,$this->ref_cod_escola,$this->ref_ref_cod_serie | |
| 220 | - //echo "$lst_turmas = $obj_turmas->lista( null,null,null,$this->ref_ref_cod_serie, $this->ref_cod_escola,null,null,null,null,null,null,null,null,null,1 );" | |
| 221 | - //print_r($lst_turmas);die; | |
| 222 | - | |
| 223 | - if ( is_array($lst_turmas) ) | |
| 224 | - { | |
| 225 | - $total_vagas = 0; | |
| 226 | - foreach ( $lst_turmas AS $turmas ) | |
| 227 | - { | |
| 228 | - $total_vagas += $turmas["max_aluno"]; | |
| 229 | - } | |
| 230 | - } | |
| 231 | - else | |
| 232 | - { | |
| 233 | - $this->mensagem = "Série não possui nenhuma Turma cadastrada.<br>"; | |
| 234 | - return false; | |
| 235 | - } | |
| 236 | - | |
| 237 | - $obj_matricula = new clsPmieducarMatricula(); | |
| 238 | - $lst_matricula = $obj_matricula->lista( null,null,$this->ref_cod_escola,$this->ref_ref_cod_serie,null,null,null,3,null,null,null,null,1,$this->ano,$this->ref_cod_curso,$this->ref_cod_instituicao,1 ); | |
| 239 | - if ( is_array($lst_matricula) ) | |
| 240 | - { | |
| 241 | - $matriculados = count($lst_matricula); | |
| 242 | - } | |
| 243 | - | |
| 244 | - $obj_reserva_vaga = new clsPmieducarReservaVaga(); | |
| 245 | - $lst_reserva_vaga = $obj_reserva_vaga->lista( null,$this->ref_cod_escola,$this->ref_ref_cod_serie,null,null,null,null,null,null,null,1,$this->ref_cod_instituicao,$this->ref_cod_curso ); | |
| 246 | - if ( is_array($lst_reserva_vaga) ) | |
| 247 | - { | |
| 248 | - $reservados = count($lst_reserva_vaga); | |
| 249 | - } | |
| 250 | - | |
| 251 | - $vagas_restantes = $total_vagas - ($matriculados + $reservados); | |
| 252 | - } | |
| 253 | - | |
| 254 | - if ($vagas_restantes <= 0) | |
| 255 | - { | |
| 256 | - echo "<script> if(!confirm('Excedido o número de total de vagas para Matricula! \\n Número total de matriculados:$matriculados \\n Número total de vagas reservadas: $reservados \\n Número total de vagas: $total_vagas \\n Deseja mesmo assim realizar a Matrícula?')) window.location = 'educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}';</script>"; | |
| 257 | -// return; | |
| 258 | - } | |
| 259 | - | |
| 260 | - $obj_matricula_aluno = new clsPmieducarMatricula(); | |
| 261 | - $lst_matricula_aluno = $obj_matricula_aluno->lista(null, null, null, null, null, null, $this->ref_cod_aluno); | |
| 262 | - if(!$lst_matricula_aluno) | |
| 263 | - { | |
| 264 | - /** | |
| 265 | - * primeira matricula do sistema - consistencia - | |
| 266 | - */ | |
| 267 | - $this->matricula_transferencia = $this->matricula_transferencia == 'on' ? 'true' : 'false'; | |
| 268 | - } | |
| 269 | - else | |
| 270 | - { | |
| 271 | - $this->matricula_transferencia = false; | |
| 272 | - } | |
| 273 | - | |
| 274 | - if ($this->is_padrao == 1) | |
| 275 | - { | |
| 276 | - $this->semestre = null; | |
| 277 | - } | |
| 278 | - $obj = new clsPmieducarMatricula( null, $this->ref_cod_reserva_vaga, $this->ref_cod_escola, $this->ref_ref_cod_serie, null, $this->pessoa_logada, $this->ref_cod_aluno, 3, null, null, 1, $this->ano, 1, null, null, null, null, $this->ref_cod_curso, $this->matricula_transferencia, $this->semestre ); | |
| 279 | - | |
| 280 | - $cadastrou = $obj->cadastra(); | |
| 281 | - if( $cadastrou ) | |
| 282 | - { | |
| 283 | - //$obj_matricula = new clsPmieducarMatricula(); | |
| 284 | - // $lst_matricula = $obj_matricula->lista(null,null,null,null,null,null,$this->ref_cod_aluno); | |
| 285 | - /** | |
| 286 | - * desmarca todas as matriculas como ultima matricula do aluno | |
| 287 | - */ | |
| 288 | - /* if($lt_matricula) | |
| 289 | - { | |
| 290 | - foreach ($lst_matricula as $matricula) | |
| 291 | - { | |
| 292 | - if($matricula['cod_matricula'] != $cadastrou) | |
| 293 | - { | |
| 294 | - $obj_matricula = new clsPmieducarMatricula($matricula['cod_matricula'],null,null,null,null,null,null,null,null,null,null,null,0); | |
| 295 | - $obj_matricula->edita(); | |
| 296 | - } | |
| 297 | - } | |
| 298 | - }*/ | |
| 299 | - | |
| 300 | - if($this->pessoa_logada == 21317) | |
| 301 | - $this->desativaMatriculasSequencia($cadastrou); | |
| 302 | - | |
| 303 | - | |
| 304 | - $obj_transferencia = new clsPmieducarTransferenciaSolicitacao(); | |
| 305 | - $lst_transferencia = $obj_transferencia->lista( null,null,null,null,null,null,null,null,null,null,null,1,null,null,$this->ref_cod_aluno,false,null,null,null,true,false ); | |
| 306 | - // verifica se existe solicitacao de transferencia do aluno | |
| 307 | - if ( is_array($lst_transferencia) ) | |
| 308 | - { | |
| 309 | - //echo "<pre>"; print_r("if"); die(); | |
| 310 | - $det_transferencia = array_shift($lst_transferencia); | |
| 311 | - | |
| 312 | - $obj_transferencia = new clsPmieducarTransferenciaSolicitacao( $det_transferencia['cod_transferencia_solicitacao'],null,$this->pessoa_logada,null,null,null,null,null,null,0 ); | |
| 313 | - $editou2 = $obj_transferencia->edita(); | |
| 314 | - if ( $editou2 ) | |
| 315 | - { | |
| 316 | - $obj = new clsPmieducarMatricula( $det_transferencia['ref_cod_matricula_saida'],null,null,null,$this->pessoa_logada,null,null,4,null,null,1,null,0 ); | |
| 317 | - $editou3 = $obj->edita(); | |
| 318 | - if (!$editou3) | |
| 319 | - { | |
| 320 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 321 | - echo "<!--\nErro ao editar clsPmieducarMatricula\nvalores obrigatorios\nis_numeric( {$det_transferencia['ref_cod_matricula_saida']} ) && is_numeric( $this->pessoa_logada )\n-->"; | |
| 322 | - return false; | |
| 323 | - } | |
| 324 | - } | |
| 325 | - else | |
| 326 | - { | |
| 327 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 328 | - echo "<!--\nErro ao cadastrar clsPmieducarTransferenciaSolicitacao\nvalores obrigatorios\nis_numeric( {$det_transferencia['cod_transferencia_solicitacao']} ) && is_numeric( {$this->pessoa_logada} ) \n-->"; | |
| 329 | - return false; | |
| 330 | - } | |
| 331 | - } | |
| 332 | - else | |
| 333 | - { | |
| 334 | - //echo "<pre>"; print_r("else"); die(); | |
| 335 | - $obj_transferencia = new clsPmieducarTransferenciaSolicitacao(); | |
| 336 | - $lst_transferencia = $obj_transferencia->lista( null,null,null,null,null,null,null,null,null,null,null,1,null,null,$this->ref_cod_aluno,false,null,null,null,false,false ); | |
| 337 | - // verifica se existe solicitacao de transferencia do aluno | |
| 338 | - if ( is_array($lst_transferencia) ) | |
| 339 | - { | |
| 340 | - // verifica cada solicitacao de transferencia do aluno | |
| 341 | - foreach ($lst_transferencia as $transferencia) | |
| 342 | - { | |
| 343 | - $obj_matricula = new clsPmieducarMatricula( $transferencia['ref_cod_matricula_saida'] ); | |
| 344 | - $det_matricula = $obj_matricula->detalhe(); | |
| 345 | - | |
| 346 | - // caso a solicitacao seja para uma mesma serie | |
| 347 | - if ($det_matricula['ref_ref_cod_serie'] == $this->ref_ref_cod_serie) | |
| 348 | - { | |
| 349 | - $ref_cod_transferencia = $transferencia["cod_transferencia_solicitacao"]; | |
| 350 | - break; | |
| 351 | - } | |
| 352 | - else // caso a solicitacao seja para a serie da sequencia | |
| 353 | - { | |
| 354 | - $obj_sequencia = new clsPmieducarSequenciaSerie( $det_matricula['ref_ref_cod_serie'],$this->ref_ref_cod_serie,null,null,null,null,1 ); | |
| 355 | - if ($obj_sequencia->existe()) | |
| 356 | - { | |
| 357 | - $ref_cod_transferencia = $transferencia["cod_transferencia_solicitacao"]; | |
| 358 | - break; | |
| 359 | - } | |
| 360 | - } | |
| 361 | - $ref_cod_transferencia = $transferencia["cod_transferencia_solicitacao"]; | |
| 362 | - } | |
| 363 | -// $ref_cod_transferencia = $det_transferencia["cod_transferencia_solicitacao"]; | |
| 364 | -// echo "<pre>"; echo "<br><br><br>"; print_r($ref_cod_transferencia); die(); | |
| 365 | - if ($ref_cod_transferencia) | |
| 366 | - { | |
| 367 | - $obj_transferencia = new clsPmieducarTransferenciaSolicitacao( $ref_cod_transferencia,null,$this->pessoa_logada,null,$cadastrou,null,null,null,null,1,date("Y-m-d") ); | |
| 368 | - $editou2 = $obj_transferencia->edita(); | |
| 369 | - if ( $editou2 ) | |
| 370 | - { | |
| 371 | - $obj_transferencia = new clsPmieducarTransferenciaSolicitacao( $ref_cod_transferencia ); | |
| 372 | - $det_transferencia = $obj_transferencia->detalhe(); | |
| 373 | - $matricula_saida = $det_transferencia["ref_cod_matricula_saida"]; | |
| 374 | - $obj_matricula = new clsPmieducarMatricula( $matricula_saida ); | |
| 375 | - $det_matricula = $obj_matricula->detalhe(); | |
| 376 | - // caso a situacao da matricula do aluno esteja em andamento | |
| 377 | - if( $det_matricula['aprovado'] == 3 ) | |
| 378 | - { | |
| 379 | - $obj_matricula = new clsPmieducarMatricula( $cadastrou,null,null,null,$this->pessoa_logada,null,null,null,null,null,1,null,null,$det_matricula['modulo'] ); | |
| 380 | - $editou_mat = $obj_matricula->edita(); | |
| 381 | - if ($editou_mat) | |
| 382 | - { | |
| 383 | - $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | |
| 384 | - $lst_matricula_turma = $obj_matricula_turma->lista( $matricula_saida,null,null,null,null,null,null,null,1 ); | |
| 385 | - if (is_array($lst_matricula_turma)) | |
| 386 | - { | |
| 387 | - $det_matricula_turma = array_shift($lst_matricula_turma); | |
| 388 | - | |
| 389 | - $obj_matricula_turma = new clsPmieducarMatriculaTurma( $matricula_saida,$det_matricula_turma['ref_cod_turma'],$this->pessoa_logada,null,null,null,0,null,$det_matricula_turma['sequencial'] ); | |
| 390 | - $editou_mat_turma = $obj_matricula_turma->edita(); | |
| 391 | - if (!$editou_mat_turma) | |
| 392 | - { | |
| 393 | - $this->mensagem = "Não foi possível editar a Matrícula Turma.<br>"; | |
| 394 | - return false; | |
| 395 | - } | |
| 396 | - } | |
| 397 | - // armazena as disciplinas utilizadas da nova escola | |
| 398 | - $obj_esd = new clsPmieducarEscolaSerieDisciplina(); | |
| 399 | - $lst_esd = $obj_esd->lista( $this->ref_ref_cod_serie,$this->ref_cod_escola,null,1 ); | |
| 400 | - if (is_array($lst_esd)) | |
| 401 | - { | |
| 402 | - foreach ($lst_esd as $campo) | |
| 403 | - { | |
| 404 | - $disciplinas[$campo['ref_cod_disciplina']] = $campo['ref_cod_disciplina']; | |
| 405 | - } | |
| 406 | - } | |
| 407 | - // lista as notas que o aluno ja tinha | |
| 408 | - $obj_nota_aluno = new clsPmieducarNotaAluno(); | |
| 409 | - $lst_nota_aluno = $obj_nota_aluno->lista( null,null,null,$this->ref_ref_cod_serie,null,null,$matricula_saida,null,null,null,null,null,null,1 ); | |
| 410 | - if (is_array($lst_nota_aluno)) | |
| 411 | - { | |
| 412 | - foreach ($lst_nota_aluno as $campo) | |
| 413 | - { | |
| 414 | - if ($disciplinas[$campo['ref_cod_disciplina']]) | |
| 415 | - { | |
| 416 | - // cadastra as notas existentes na nova matricula | |
| 417 | - $obj_nota_aluno = new clsPmieducarNotaAluno( null,$campo['ref_sequencial'],$campo['ref_ref_cod_tipo_avaliacao'],$this->ref_ref_cod_serie,$this->ref_cod_escola,$campo['ref_cod_disciplina'],$cadastrou,null,$this->pessoa_logada,null,null,1,$campo['modulo'] ); | |
| 418 | - $cadastrou_nota = $obj_nota_aluno->cadastra(); | |
| 419 | - if (!$cadastrou_nota) | |
| 420 | - { | |
| 421 | - $this->mensagem = "Cadastro não realizado.<br>"; | |
| 422 | - echo "<!--\nErro ao cadastrar clsPmieducarNotaAluno\nvalores obrigatorios\nis_numeric( {$campo['ref_sequencial']} ) && is_numeric( {$campo['ref_ref_cod_tipo_avaliacao']} ) && is_numeric( $this->ref_ref_cod_serie ) && is_numeric( $this->ref_cod_escola ) && is_numeric( {$campo['ref_cod_disciplina']} ) && is_numeric( $cadastrou ) && is_numeric( $this->pessoa_logada ) && is_numeric( {$campo['modulo']} )\n-->"; | |
| 423 | - return false; | |
| 424 | - } | |
| 425 | - } | |
| 426 | - } | |
| 427 | - } | |
| 428 | - // lista as faltas que o aluno ja tinha | |
| 429 | - $obj_falta_aluno = new clsPmieducarFaltaAluno(); | |
| 430 | - $lst_falta_aluno = $obj_falta_aluno->lista( null,null,null,$this->ref_ref_cod_serie,null,null,$matricula_saida,null,null,null,null,null,1 ); | |
| 431 | - if (is_array($lst_falta_aluno)) | |
| 432 | - { | |
| 433 | - foreach ($lst_falta_aluno as $campo) | |
| 434 | - { | |
| 435 | - if ($disciplinas[$campo['ref_cod_disciplina']]) | |
| 436 | - { | |
| 437 | - // cadastra as faltas existentes na nova matricula | |
| 438 | - $obj_falta_aluno = new clsPmieducarFaltaAluno( null,null,$this->pessoa_logada,$this->ref_ref_cod_serie,$this->ref_cod_escola,$campo['ref_cod_disciplina'],$cadastrou,$campo['faltas'],null,null,1,$campo['modulo'] ); | |
| 439 | - $cadastrou_falta = $obj_falta_aluno->cadastra(); | |
| 440 | - if (!$cadastrou_falta) | |
| 441 | - { | |
| 442 | - $this->mensagem = "Cadastro não realizado.<br>"; | |
| 443 | - echo "<!--\nErro ao cadastrar clsPmieducarFaltaAluno\nvalores obrigatorios\nis_numeric( $this->pessoa_logada ) && is_numeric( $this->ref_ref_cod_serie ) && is_numeric( $this->ref_cod_escola ) && is_numeric( {$campo['ref_cod_disciplina']} ) && is_numeric( $cadastrou ) && is_numeric( {$campo['faltas']} ) && is_numeric( {$campo['modulo']} )\n-->"; | |
| 444 | - return false; | |
| 445 | - } | |
| 446 | - } | |
| 447 | - } | |
| 448 | - } | |
| 449 | - // lista as notas que o aluno ja tinha (globalizada) | |
| 450 | - $obj_faltas = new clsPmieducarFaltas(); | |
| 451 | - $lst_faltas = $obj_faltas->lista( $matricula_saida ); | |
| 452 | - if (is_array($lst_faltas)) | |
| 453 | - { | |
| 454 | - foreach ($lst_faltas as $campo) | |
| 455 | - { | |
| 456 | - // cadastra as faltas existentes na nova matricula | |
| 457 | - $obj_faltas = new clsPmieducarFaltas( $cadastrou,$campo['sequencial'],$this->pessoa_logada,$campo['falta'] ); | |
| 458 | - $cadastrou_faltas = $obj_faltas->cadastra(); | |
| 459 | - if (!$cadastrou_faltas) | |
| 460 | - { | |
| 461 | - $this->mensagem = "Cadastro não realizado.<br>"; | |
| 462 | - echo "<!--\nErro ao cadastrar clsPmieducarFaltas\nvalores obrigatorios\nis_numeric( $cadastrou ) && is_numeric( {$campo['sequencial']} ) && is_numeric( $this->pessoa_logada ) && is_numeric( {$campo['falta']} )\n-->"; | |
| 463 | - return false; | |
| 464 | - } | |
| 465 | - } | |
| 466 | - } | |
| 467 | - } | |
| 468 | - } | |
| 469 | - | |
| 470 | - $obj = new clsPmieducarMatricula( $matricula_saida,null,null,null,$this->pessoa_logada,null,null,4,null,null,1,null,0 ); | |
| 471 | - $editou3 = $obj->edita(); | |
| 472 | - if (!$editou3) | |
| 473 | - { | |
| 474 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 475 | - echo "<!--\nErro ao editar clsPmieducarMatricula\nvalores obrigatorios\nis_numeric( $matricula_saida ) && is_numeric( $this->pessoa_logada )\n-->"; | |
| 476 | - return false; | |
| 477 | - } | |
| 478 | - } | |
| 479 | - else | |
| 480 | - { | |
| 481 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 482 | - echo "<!--\nErro ao editar clsPmieducarTransferenciaSolicitacao\nvalores obrigatorios\nis_numeric( $ref_cod_transferencia ) && is_numeric( $cadastrou ) && is_numeric( $this->pessoa_logada )\n-->"; | |
| 483 | - return false; | |
| 484 | - } | |
| 485 | - } | |
| 486 | - } | |
| 487 | - } | |
| 488 | - $this->mensagem .= "Cadastro efetuado com sucesso.<br>"; | |
| 489 | - header( "Location: educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); | |
| 490 | - die(); | |
| 491 | - return true; | |
| 492 | - } | |
| 493 | - $this->mensagem = "Cadastro não realizado.<br>"; | |
| 494 | - echo "<!--\nErro ao cadastrar clsPmieducarMatricula\nvalores obrigatorios\nis_numeric( $this->ref_cod_escola ) && is_numeric( $this->ref_ref_cod_serie ) && is_numeric( $this->pessoa_logada ) && is_numeric( $this->ref_cod_aluno ) && is_numeric( $this->ano )\n-->"; | |
| 495 | - return false; | |
| 496 | - } | |
| 497 | - else | |
| 498 | - { | |
| 499 | - $this->mensagem = "Não foi possível encontrar o Ano Letivo em andamento da Escola.<br>"; | |
| 500 | - return false; | |
| 501 | - } | |
| 502 | - } | |
| 503 | - | |
| 504 | - function Excluir() | |
| 505 | - { | |
| 506 | - @session_start(); | |
| 507 | - $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 508 | - @session_write_close(); | |
| 509 | - | |
| 510 | - $obj_permissoes = new clsPermissoes(); | |
| 511 | - $obj_permissoes->permissao_excluir( 578, $this->pessoa_logada, 7, "educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); | |
| 512 | - | |
| 513 | - $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | |
| 514 | - $lst_matricula_turma = $obj_matricula_turma->lista( $this->cod_matricula,null,null,null,null,null,null,null,1 ); | |
| 515 | - if (is_array($lst_matricula_turma)) | |
| 516 | - { | |
| 517 | - $det_matricula_turma = array_shift($lst_matricula_turma); | |
| 518 | - $obj_matricula_turma = new clsPmieducarMatriculaTurma( $det_matricula_turma["ref_cod_matricula"],$det_matricula_turma["ref_cod_turma"],$this->pessoa_logada,null,null,null,0,null,$det_matricula_turma["sequencial"] ); | |
| 519 | - $editou = $obj_matricula_turma->edita(); | |
| 520 | - if (!$editou) | |
| 521 | - { | |
| 522 | - $this->mensagem = "Edição não realizada.<br>"; | |
| 523 | - echo "<!--\nErro ao editar clsPmieducarMatriculaTurma\nvalores obrigatorios\nif( is_numeric( {$det_matricula_turma["ref_cod_matricula"]} ) && is_numeric( {$det_matricula_turma["ref_cod_turma"]} ) && is_numeric( {$det_matricula_turma["sequencial"]} ) && is_numeric( $this->pessoa_logada ) )\n-->"; | |
| 524 | - return false; | |
| 525 | - } | |
| 526 | - } | |
| 527 | - | |
| 528 | - $obj_matricula = new clsPmieducarMatricula( $this->cod_matricula ); | |
| 529 | - $det_matricula = $obj_matricula->detalhe(); | |
| 530 | - $ref_cod_serie = $det_matricula["ref_ref_cod_serie"]; | |
| 531 | - | |
| 532 | - $obj_sequencia = new clsPmieducarSequenciaSerie(); | |
| 533 | - $lst_sequencia = $obj_sequencia->lista( null,$ref_cod_serie,null,null,null,null,null,null,1 ); | |
| 534 | - // verifica se a serie da matricula cancelada eh sequencia de alguma outra serie | |
| 535 | - if ( is_array($lst_sequencia) ) | |
| 536 | - { | |
| 537 | - $det_sequencia = array_shift($lst_sequencia); | |
| 538 | - $ref_serie_origem = $det_sequencia["ref_serie_origem"]; | |
| 539 | - | |
| 540 | - $obj_matricula = new clsPmieducarMatricula(); | |
| 541 | - $lst_matricula = $obj_matricula->lista( null,null,null,$ref_serie_origem,null,null,$this->ref_cod_aluno,null,null,null,null,null,1,null,null,null,0 ); | |
| 542 | - // verifica se o aluno tem matricula na serie encontrada (sequencia) | |
| 543 | - if ( is_array($lst_matricula) ) | |
| 544 | - { | |
| 545 | - $det_matricula = array_shift($lst_matricula); | |
| 546 | - $ref_cod_matricula = $det_matricula["cod_matricula"]; | |
| 547 | - | |
| 548 | - $obj = new clsPmieducarMatricula( $ref_cod_matricula,null,null,null,$this->pessoa_logada,null,null,null,null,null,1,null,1 ); | |
| 549 | - $editou1 = $obj->edita(); | |
| 550 | - if( !$editou1 ) | |
| 551 | - { | |
| 552 | - $this->mensagem = "Não foi possível editar a Última Matrícula da Sequência.<br>"; | |
| 553 | - return false; | |
| 554 | - } | |
| 555 | - } | |
| 556 | - } | |
| 557 | - | |
| 558 | - $obj = new clsPmieducarMatricula( $this->cod_matricula,null,null,null,$this->pessoa_logada,null,null,null,null,null,0 ); | |
| 559 | - $excluiu = $obj->excluir(); | |
| 560 | - if( $excluiu ) | |
| 561 | - { | |
| 562 | - $this->mensagem .= "Exclusão efetuada com sucesso.<br>"; | |
| 563 | - header( "Location: educar_matricula_lst.php?ref_cod_aluno={$this->ref_cod_aluno}" ); | |
| 564 | - die(); | |
| 565 | - return true; | |
| 566 | - } | |
| 567 | - | |
| 568 | - $this->mensagem = "Exclusão não realizada.<br>"; | |
| 569 | - echo "<!--\nErro ao excluir clsPmieducarMatricula\nvalores obrigatorios\nif( is_numeric( $this->cod_matricula ) && is_numeric( $this->pessoa_logada ) )\n-->"; | |
| 570 | - return false; | |
| 571 | - } | |
| 572 | - | |
| 573 | - /** | |
| 574 | - * marca como zero o campo ultima_matricula | |
| 575 | - * das matriculas da sequencia | |
| 576 | - * | |
| 577 | - */ | |
| 578 | - function desativaMatriculasSequencia($ultima_matricula) | |
| 579 | - { | |
| 580 | - | |
| 581 | - $db2 = new clsBanco(); | |
| 582 | - | |
| 583 | - $db2->Consulta( " | |
| 584 | - SELECT | |
| 585 | - so.ref_cod_curso as curso_origem | |
| 586 | - , ss.ref_serie_origem as serie_origem | |
| 587 | - , sd.ref_cod_curso as curso_destino | |
| 588 | - , ss.ref_serie_destino as serie_destino | |
| 589 | - FROM | |
| 590 | - pmieducar.sequencia_serie ss | |
| 591 | - , pmieducar.serie so | |
| 592 | - , pmieducar.serie sd | |
| 593 | - WHERE | |
| 594 | - ss.ativo = 1 | |
| 595 | - AND ref_serie_origem = so.cod_serie | |
| 596 | - AND ref_serie_destino = sd.cod_serie | |
| 597 | - ORDER BY | |
| 598 | - ss.ref_serie_origem ASC | |
| 599 | - "); | |
| 600 | - | |
| 601 | - if ($db2->numLinhas()) | |
| 602 | - { | |
| 603 | - while ( $db2->ProximoRegistro() ) | |
| 604 | - { | |
| 605 | - $sequencias[] = $db2->Tupla(); | |
| 606 | - } | |
| 607 | - } | |
| 608 | - | |
| 609 | - $db2->Consulta( " | |
| 610 | - SELECT | |
| 611 | - distinct( o.ref_serie_origem ) | |
| 612 | - FROM | |
| 613 | - pmieducar.sequencia_serie o | |
| 614 | - , pmieducar.escola_serie es | |
| 615 | - WHERE NOT EXISTS | |
| 616 | - ( | |
| 617 | - SELECT | |
| 618 | - 1 | |
| 619 | - FROM | |
| 620 | - pmieducar.sequencia_serie d | |
| 621 | - WHERE | |
| 622 | - o.ref_serie_origem = d.ref_serie_destino | |
| 623 | - ) | |
| 624 | - "); | |
| 625 | - | |
| 626 | - if ($db2->numLinhas()) | |
| 627 | - { | |
| 628 | - $pertence_sequencia = false; | |
| 629 | - $achou_serie = false; | |
| 630 | - $reset = false; | |
| 631 | - | |
| 632 | - $serie_sequencia[] = $this->ref_ref_cod_serie; | |
| 633 | - | |
| 634 | - while ( $db2->ProximoRegistro() ) | |
| 635 | - { | |
| 636 | - list( $ini_sequencia ) = $db2->Tupla(); | |
| 637 | - | |
| 638 | - $ini_serie = $ini_sequencia; | |
| 639 | - reset($sequencias); | |
| 640 | - | |
| 641 | - do | |
| 642 | - { | |
| 643 | - if( $reset ) | |
| 644 | - { | |
| 645 | - reset($sequencias); | |
| 646 | - $reset = false; | |
| 647 | - } | |
| 648 | - | |
| 649 | - $sequencia = current($sequencias); | |
| 650 | - $aux_serie = $sequencia['serie_origem']; | |
| 651 | - | |
| 652 | - if ($ini_serie == $aux_serie) | |
| 653 | - { | |
| 654 | - if ($this->ref_ref_cod_serie == $aux_serie) | |
| 655 | - { | |
| 656 | - // achou serie da matricula | |
| 657 | - $achou_serie = true; | |
| 658 | - } | |
| 659 | - if ($sequencia['curso_destino'] == $this->ref_cod_curso) | |
| 660 | - { | |
| 661 | - // curso pertence a sequencia | |
| 662 | - $pertence_sequencia = true; | |
| 663 | - $serie_sequencia[] = $sequencia['serie_destino']; | |
| 664 | - $ini_serie = $sequencia['serie_destino']; | |
| 665 | - $reset = true; | |
| 666 | - } | |
| 667 | - else | |
| 668 | - { | |
| 669 | - $ini_serie = $sequencia['serie_destino']; | |
| 670 | - $reset = true; | |
| 671 | - } | |
| 672 | - } | |
| 673 | - } while ( each($sequencias) ); | |
| 674 | - | |
| 675 | - if ($achou_serie && $pertence_sequencia) | |
| 676 | - { | |
| 677 | - // curso escolhido pertence a sequencia da serie da matricula | |
| 678 | - $series = implode(",",$serie_sequencia); | |
| 679 | - $db2->Consulta("UPDATE pmieducar.matricula SET ultima_matricula = 0 WHERE ref_ref_cod_serie IN ($series) AND ref_cod_aluno = {$this->ref_cod_aluno} AND cod_matricula != $ultima_matricula "); | |
| 680 | - die("UPDATE pmieducar.matricula SET ultima_matricula = 0 WHERE ref_ref_cod_serie IN ($series) AND ref_cod_aluno = {$this->ref_cod_aluno} AND cod_matricula != $ultima_matricula "); | |
| 681 | - } | |
| 682 | - } | |
| 683 | - } | |
| 684 | - } | |
| 67 | + var $pessoa_logada; | |
| 68 | + | |
| 69 | + var $cod_matricula; | |
| 70 | + var $ref_cod_reserva_vaga; | |
| 71 | + var $ref_ref_cod_escola; | |
| 72 | + var $ref_ref_cod_serie; | |
| 73 | + var $ref_usuario_exc; | |
| 74 | + var $ref_usuario_cad; | |
| 75 | + var $ref_cod_aluno; | |
| 76 | + var $aprovado; | |
| 77 | + var $data_cadastro; | |
| 78 | + var $data_exclusao; | |
| 79 | + var $ativo; | |
| 80 | + var $ano; | |
| 81 | + | |
| 82 | + var $ref_cod_instituicao; | |
| 83 | + var $ref_cod_curso; | |
| 84 | + var $ref_cod_escola; | |
| 85 | + | |
| 86 | + var $matricula_transferencia; | |
| 87 | + var $semestre; | |
| 88 | + var $is_padrao; | |
| 89 | + | |
| 90 | + function Inicializar() | |
| 91 | + { | |
| 92 | + $retorno = 'Novo'; | |
| 93 | + | |
| 94 | + @session_start(); | |
| 95 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 96 | + @session_write_close(); | |
| 97 | + | |
| 98 | + $this->cod_matricula = $_GET['cod_matricula']; | |
| 99 | + $this->ref_cod_aluno = $_GET['ref_cod_aluno']; | |
| 100 | + | |
| 101 | + $obj_aluno = new clsPmieducarAluno($this->ref_cod_aluno); | |
| 102 | + | |
| 103 | + if (! $obj_aluno->existe()) { | |
| 104 | + header('Location: educar_matricula_lst.php'); | |
| 105 | + die; | |
| 106 | + } | |
| 107 | + | |
| 108 | + $url = 'educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno; | |
| 109 | + | |
| 110 | + $obj_permissoes = new clsPermissoes(); | |
| 111 | + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, $url); | |
| 112 | + | |
| 113 | + if (is_numeric($this->cod_matricula)) { | |
| 114 | + if ($obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7)) { | |
| 115 | + $this->Excluir(); | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + $this->url_cancelar = $url; | |
| 120 | + $this->nome_url_cancelar = 'Cancelar'; | |
| 121 | + return $retorno; | |
| 122 | + } | |
| 123 | + | |
| 124 | + function Gerar() | |
| 125 | + { | |
| 126 | + // primary keys | |
| 127 | + $this->campoOculto("cod_matricula", $this->cod_matricula); | |
| 128 | + $this->campoOculto("ref_cod_aluno", $this->ref_cod_aluno); | |
| 129 | + | |
| 130 | + $obj_aluno = new clsPmieducarAluno(); | |
| 131 | + $lst_aluno = $obj_aluno->lista($this->ref_cod_aluno, NULL, NULL, NULL, NULL, | |
| 132 | + NULL, NULL, NULL, NULL, NULL, 1); | |
| 133 | + | |
| 134 | + if (is_array($lst_aluno)) { | |
| 135 | + $det_aluno = array_shift($lst_aluno); | |
| 136 | + $this->nm_aluno = $det_aluno['nome_aluno']; | |
| 137 | + $this->campoRotulo('nm_aluno', 'Aluno', $this->nm_aluno); | |
| 138 | + } | |
| 139 | + | |
| 140 | + /* | |
| 141 | + * Verifica se existem matrículas para o aluno para apresentar o campo | |
| 142 | + * transferência, necessário para o relatório de movimentação mensal. | |
| 143 | + */ | |
| 144 | + $obj_matricula = new clsPmieducarMatricula(); | |
| 145 | + $lst_matricula = $obj_matricula->lista(NULL, NULL, NULL, NULL, NULL, NULL, | |
| 146 | + $this->ref_cod_aluno); | |
| 147 | + | |
| 148 | + // Primeira matrícula do sistema exibe campo check | |
| 149 | + if (! $lst_matricula) { | |
| 150 | + $this->campoCheck('matricula_transferencia', | |
| 151 | + 'Matrícula de Transferência', '', | |
| 152 | + 'Caso seja transfência externa por favor marque esta opção.'); | |
| 153 | + } | |
| 154 | + | |
| 155 | + // foreign keys | |
| 156 | + $instituicao_obrigatorio = TRUE; | |
| 157 | + $curso_obrigatorio = TRUE; | |
| 158 | + $escola_curso_obrigatorio = TRUE; | |
| 159 | + $get_escola = TRUE; | |
| 160 | + $get_curso = TRUE; | |
| 161 | + $get_escola_curso_serie = TRUE; | |
| 162 | + $get_matricula = TRUE; | |
| 163 | + $sem_padrao = TRUE; | |
| 164 | + | |
| 165 | + include 'include/pmieducar/educar_campo_lista.php'; | |
| 166 | + | |
| 167 | + if (is_numeric($this->ref_cod_curso)) { | |
| 168 | + $obj_curso = new clsPmieducarCurso($this->ref_cod_curso); | |
| 169 | + $det_curso = $obj_curso->detalhe(); | |
| 170 | + | |
| 171 | + if (is_numeric($det_curso['ref_cod_tipo_avaliacao'])) { | |
| 172 | + $this->campoOculto('apagar_radios', $det_curso['padrao_ano_escolar']); | |
| 173 | + $this->campoOculto('is_padrao', $det_curso['padrao_ano_escolar']); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + if ($this->ref_cod_escola) { | |
| 178 | + $this->ref_ref_cod_escola = $this->ref_cod_escola; | |
| 179 | + } | |
| 180 | + | |
| 181 | + $this->acao_enviar = 'valida()'; | |
| 182 | + } | |
| 183 | + | |
| 184 | + function Novo() | |
| 185 | + { | |
| 186 | + @session_start(); | |
| 187 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 188 | + @session_write_close(); | |
| 189 | + | |
| 190 | + $obj_permissoes = new clsPermissoes(); | |
| 191 | + $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, | |
| 192 | + 'educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno); | |
| 193 | + | |
| 194 | + $obj_escola_ano_letivo = new clsPmieducarEscolaAnoLetivo(); | |
| 195 | + $lst_escola_ano_letivo = $obj_escola_ano_letivo->lista($this->ref_cod_escola, | |
| 196 | + NULL, NULL, NULL,1, NULL, NULL, NULL, NULL, 1); | |
| 197 | + | |
| 198 | + if (is_array($lst_escola_ano_letivo)) { | |
| 199 | + $det_escola_ano_letivo = array_shift($lst_escola_ano_letivo); | |
| 200 | + $this->ano = $det_escola_ano_letivo['ano']; | |
| 201 | + | |
| 202 | + $obj_reserva_vaga = new clsPmieducarReservaVaga(); | |
| 203 | + $lst_reserva_vaga = $obj_reserva_vaga->lista(NULL, $this->ref_cod_escola, | |
| 204 | + $this->ref_ref_cod_serie, NULL, NULL,$this->ref_cod_aluno, NULL, NULL, | |
| 205 | + NULL, NULL, 1); | |
| 206 | + | |
| 207 | + // Verifica se existe reserva de vaga para o aluno | |
| 208 | + if (is_array($lst_reserva_vaga)) { | |
| 209 | + $det_reserva_vaga = array_shift($lst_reserva_vaga); | |
| 210 | + $this->ref_cod_reserva_vaga = $det_reserva_vaga['cod_reserva_vaga']; | |
| 211 | + | |
| 212 | + $obj_reserva_vaga = new clsPmieducarReservaVaga($this->ref_cod_reserva_vaga, | |
| 213 | + NULL, NULL, $this->pessoa_logada, NULL, NULL, NULL, NULL, 0); | |
| 214 | + | |
| 215 | + $editou = $obj_reserva_vaga->edita(); | |
| 216 | + if (! $editou) { | |
| 217 | + $this->mensagem = 'Edição não realizada.<br />'; | |
| 218 | + return FALSE; | |
| 219 | + } | |
| 220 | + } | |
| 221 | + | |
| 222 | + $vagas_restantes = 1; | |
| 223 | + | |
| 224 | + if (! $this->ref_cod_reserva_vaga) { | |
| 225 | + $obj_turmas = new clsPmieducarTurma(); | |
| 226 | + $lst_turmas = $obj_turmas->lista(NULL, NULL, NULL, $this->ref_ref_cod_serie, | |
| 227 | + $this->ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
| 228 | + NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | |
| 229 | + NULL, NULL, NULL, NULL, NULL, TRUE); | |
| 230 | + | |
| 231 | + if (is_array($lst_turmas)) { | |
| 232 | + $total_vagas = 0; | |
| 233 | + foreach ($lst_turmas as $turmas) { | |
| 234 | + $total_vagas += $turmas['max_aluno']; | |
| 235 | + } | |
| 236 | + } | |
| 237 | + else { | |
| 238 | + $this->mensagem = 'Série não possui turmas cadastradas.<br />'; | |
| 239 | + return FALSE; | |
| 240 | + } | |
| 241 | + | |
| 242 | + $obj_matricula = new clsPmieducarMatricula(); | |
| 243 | + $lst_matricula = $obj_matricula->lista(NULL, NULL, $this->ref_cod_escola, | |
| 244 | + $this->ref_ref_cod_serie, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL, 1, | |
| 245 | + $this->ano, $this->ref_cod_curso, $this->ref_cod_instituicao, 1); | |
| 246 | + | |
| 247 | + if (is_array($lst_matricula)) { | |
| 248 | + $matriculados = count($lst_matricula); | |
| 249 | + } | |
| 250 | + | |
| 251 | + $obj_reserva_vaga = new clsPmieducarReservaVaga(); | |
| 252 | + $lst_reserva_vaga = $obj_reserva_vaga->lista(NULL, $this->ref_cod_escola, | |
| 253 | + $this->ref_ref_cod_serie, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, | |
| 254 | + $this->ref_cod_instituicao, $this->ref_cod_curso); | |
| 255 | + | |
| 256 | + if (is_array($lst_reserva_vaga)) { | |
| 257 | + $reservados = count($lst_reserva_vaga); | |
| 258 | + } | |
| 259 | + | |
| 260 | + $vagas_restantes = $total_vagas - ($matriculados + $reservados); | |
| 261 | + } | |
| 262 | + | |
| 263 | + if ($vagas_restantes <= 0) { | |
| 264 | + echo sprintf(' | |
| 265 | + <script> | |
| 266 | + var msg = \'\'; | |
| 267 | + msg += \'Excedido o número de total de vagas para Matricula!\\n\'; | |
| 268 | + msg += \'Número total de matriculados: %d\\n\'; | |
| 269 | + msg += \'Número total de vagas reservadas: %d\\n\'; | |
| 270 | + msg += \'Número total de vagas: %d\\n\'; | |
| 271 | + msg += \'Deseja mesmo assim realizar a Matrícula?\'; | |
| 272 | + | |
| 273 | + if (! confirm(msg)) { | |
| 274 | + window.location = \'educar_matricula_lst.php?ref_cod_aluno=%d\'; | |
| 275 | + } | |
| 276 | + </script>', | |
| 277 | + $matriculados, $reservados, $total_vagas, $this->ref_cod_aluno | |
| 278 | + ); | |
| 279 | + } | |
| 280 | + | |
| 281 | + $obj_matricula_aluno = new clsPmieducarMatricula(); | |
| 282 | + $lst_matricula_aluno = $obj_matricula_aluno->lista(NULL, NULL, NULL, NULL, | |
| 283 | + NULL, NULL, $this->ref_cod_aluno); | |
| 284 | + | |
| 285 | + if (! $lst_matricula_aluno) { | |
| 286 | + // Primeira matrícula do sistema, consistência (?) | |
| 287 | + $this->matricula_transferencia = | |
| 288 | + $this->matricula_transferencia == 'on' ? TRUE : FALSE; | |
| 289 | + } | |
| 290 | + else { | |
| 291 | + $this->matricula_transferencia = FALSE; | |
| 292 | + } | |
| 293 | + | |
| 294 | + if ($this->is_padrao == 1) { | |
| 295 | + $this->semestre = NULL; | |
| 296 | + } | |
| 297 | + | |
| 298 | + $obj = new clsPmieducarMatricula(NULL, $this->ref_cod_reserva_vaga, | |
| 299 | + $this->ref_cod_escola, $this->ref_ref_cod_serie, NULL, | |
| 300 | + $this->pessoa_logada, $this->ref_cod_aluno, 3, NULL, NULL, 1, $this->ano, | |
| 301 | + 1, NULL, NULL, NULL, NULL, $this->ref_cod_curso, | |
| 302 | + $this->matricula_transferencia, $this->semestre); | |
| 303 | + | |
| 304 | + $cadastrou = $obj->cadastra(); | |
| 305 | + if ($cadastrou) { | |
| 306 | + /** | |
| 307 | + * @todo Remover | |
| 308 | + */ | |
| 309 | + if ($this->pessoa_logada == 21317) { | |
| 310 | + $this->desativaMatriculasSequencia($cadastrou); | |
| 311 | + } | |
| 312 | + | |
| 313 | + $obj_transferencia = new clsPmieducarTransferenciaSolicitacao(); | |
| 314 | + $lst_transferencia = $obj_transferencia->lista(NULL, NULL, NULL, NULL, | |
| 315 | + NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, | |
| 316 | + $this->ref_cod_aluno, FALSE, NULL, NULL, NULL, TRUE, FALSE); | |
| 317 | + | |
| 318 | + // Verifica se existe solicitação de transferência de aluno | |
| 319 | + if (is_array($lst_transferencia)) { | |
| 320 | + $det_transferencia = array_shift($lst_transferencia); | |
| 321 | + | |
| 322 | + $obj_transferencia = new clsPmieducarTransferenciaSolicitacao( | |
| 323 | + $det_transferencia['cod_transferencia_solicitacao'], NULL, | |
| 324 | + $this->pessoa_logada, NULL, NULL, NULL, NULL, NULL, NULL, 0); | |
| 325 | + | |
| 326 | + $editou2 = $obj_transferencia->edita(); | |
| 327 | + | |
| 328 | + if ($editou2) { | |
| 329 | + $obj = new clsPmieducarMatricula($det_transferencia['ref_cod_matricula_saida'], | |
| 330 | + NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, 4, NULL, NULL, 1, NULL, 0); | |
| 331 | + | |
| 332 | + $editou3 = $obj->edita(); | |
| 333 | + | |
| 334 | + if (! $editou3) { | |
| 335 | + $this->mensagem = 'Edição não realizada.<br />'; | |
| 336 | + return FALSE; | |
| 337 | + } | |
| 338 | + } | |
| 339 | + else { | |
| 340 | + $this->mensagem = 'Edição não realizada.<br />'; | |
| 341 | + return FALSE; | |
| 342 | + } | |
| 343 | + } | |
| 344 | + else { | |
| 345 | + $obj_transferencia = new clsPmieducarTransferenciaSolicitacao(); | |
| 346 | + $lst_transferencia = $obj_transferencia->lista(NULL, NULL, NULL, NULL, | |
| 347 | + NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, | |
| 348 | + $this->ref_cod_aluno, FALSE, NULL, NULL, NULL, FALSE, FALSE); | |
| 349 | + | |
| 350 | + // Verifica se existe solicitação de transferência do aluno | |
| 351 | + if (is_array($lst_transferencia)) { | |
| 352 | + // Verifica cada solicitação de transferência do aluno | |
| 353 | + foreach ($lst_transferencia as $transferencia) { | |
| 354 | + $obj_matricula = new clsPmieducarMatricula( | |
| 355 | + $transferencia['ref_cod_matricula_saida'] | |
| 356 | + ); | |
| 357 | + | |
| 358 | + $det_matricula = $obj_matricula->detalhe(); | |
| 359 | + | |
| 360 | + // Caso a solicitação seja para uma mesma série | |
| 361 | + if ($det_matricula['ref_ref_cod_serie'] == $this->ref_ref_cod_serie) { | |
| 362 | + $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao']; | |
| 363 | + break; | |
| 364 | + } | |
| 365 | + // Caso a solicitação seja para a série da sequência | |
| 366 | + else { | |
| 367 | + $obj_sequencia = new clsPmieducarSequenciaSerie( | |
| 368 | + $det_matricula['ref_ref_cod_serie'], $this->ref_ref_cod_serie, | |
| 369 | + NULL, NULL, NULL, NULL, 1 | |
| 370 | + ); | |
| 371 | + | |
| 372 | + if ($obj_sequencia->existe()) { | |
| 373 | + $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao']; | |
| 374 | + break; | |
| 375 | + } | |
| 376 | + } | |
| 377 | + | |
| 378 | + $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao']; | |
| 379 | + } | |
| 380 | + | |
| 381 | + if ($ref_cod_transferencia) { | |
| 382 | + $obj_transferencia = new clsPmieducarTransferenciaSolicitacao( | |
| 383 | + $ref_cod_transferencia, NULL, $this->pessoa_logada, NULL, | |
| 384 | + $cadastrou, NULL, NULL, NULL, NULL, 1, date('Y-m-d') | |
| 385 | + ); | |
| 386 | + | |
| 387 | + $editou2 = $obj_transferencia->edita(); | |
| 388 | + | |
| 389 | + if ($editou2) { | |
| 390 | + $obj_transferencia = new clsPmieducarTransferenciaSolicitacao( | |
| 391 | + $ref_cod_transferencia | |
| 392 | + ); | |
| 393 | + | |
| 394 | + $det_transferencia = $obj_transferencia->detalhe(); | |
| 395 | + $matricula_saida = $det_transferencia['ref_cod_matricula_saida']; | |
| 396 | + | |
| 397 | + $obj_matricula = new clsPmieducarMatricula($matricula_saida); | |
| 398 | + $det_matricula = $obj_matricula->detalhe(); | |
| 399 | + | |
| 400 | + // Caso a situação da matrícula do aluno esteja em andamento | |
| 401 | + if ($det_matricula['aprovado'] == 3) { | |
| 402 | + $obj_matricula = new clsPmieducarMatricula( | |
| 403 | + $cadastrou, NULL, NULL, NULL, $this->pessoa_logada, NULL, | |
| 404 | + NULL, NULL, NULL, NULL, 1, NULL, NULL, $det_matricula['modulo'] | |
| 405 | + ); | |
| 406 | + | |
| 407 | + $editou_mat = $obj_matricula->edita(); | |
| 408 | + | |
| 409 | + if ($editou_mat) { | |
| 410 | + $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | |
| 411 | + $lst_matricula_turma = $obj_matricula_turma->lista( | |
| 412 | + $matricula_saida, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1 | |
| 413 | + ); | |
| 414 | + | |
| 415 | + if (is_array($lst_matricula_turma)) { | |
| 416 | + $det_matricula_turma = array_shift($lst_matricula_turma); | |
| 417 | + | |
| 418 | + $obj_matricula_turma = new clsPmieducarMatriculaTurma( | |
| 419 | + $matricula_saida, $det_matricula_turma['ref_cod_turma'], | |
| 420 | + $this->pessoa_logada, NULL, NULL, NULL, 0, NULL, | |
| 421 | + $det_matricula_turma['sequencial'] | |
| 422 | + ); | |
| 423 | + | |
| 424 | + $editou_mat_turma = $obj_matricula_turma->edita(); | |
| 425 | + | |
| 426 | + if (! $editou_mat_turma) { | |
| 427 | + $this->mensagem = 'Não foi possível editar a Matrícula Turma.<br />'; | |
| 428 | + return FALSE; | |
| 429 | + } | |
| 430 | + } | |
| 431 | + | |
| 432 | + // Armazena as disciplinas utilizadas da nova escola | |
| 433 | + $obj_esd = new clsPmieducarEscolaSerieDisciplina(); | |
| 434 | + $lst_esd = $obj_esd->lista( | |
| 435 | + $this->ref_ref_cod_serie, $this->ref_cod_escola, NULL, 1 | |
| 436 | + ); | |
| 437 | + | |
| 438 | + if (is_array($lst_esd)) { | |
| 439 | + foreach ($lst_esd as $campo) { | |
| 440 | + $disciplinas[$campo['ref_cod_disciplina']] = $campo['ref_cod_disciplina']; | |
| 441 | + } | |
| 442 | + } | |
| 443 | + | |
| 444 | + // Lista as notas que o aluno já tinha | |
| 445 | + $obj_nota_aluno = new clsPmieducarNotaAluno(); | |
| 446 | + $lst_nota_aluno = $obj_nota_aluno->lista( | |
| 447 | + NULL, NULL, NULL, $this->ref_ref_cod_serie, NULL, NULL, | |
| 448 | + $matricula_saida, NULL, NULL, NULL, NULL, NULL, NULL, 1 | |
| 449 | + ); | |
| 450 | + | |
| 451 | + if (is_array($lst_nota_aluno)) { | |
| 452 | + foreach ($lst_nota_aluno as $campo) { | |
| 453 | + if ($disciplinas[$campo['ref_cod_disciplina']]) { | |
| 454 | + // Cadastra as notas existentes na nova matrícula | |
| 455 | + $obj_nota_aluno = new clsPmieducarNotaAluno( | |
| 456 | + NULL, $campo['ref_sequencial'], | |
| 457 | + $campo['ref_ref_cod_tipo_avaliacao'], $this->ref_ref_cod_serie, | |
| 458 | + $this->ref_cod_escola, $campo['ref_cod_disciplina'], | |
| 459 | + $cadastrou, NULL, $this->pessoa_logada, NULL, NULL, | |
| 460 | + 1, $campo['modulo'] | |
| 461 | + ); | |
| 462 | + | |
| 463 | + $cadastrou_nota = $obj_nota_aluno->cadastra(); | |
| 464 | + | |
| 465 | + if (! $cadastrou_nota) { | |
| 466 | + $this->mensagem = 'Cadastro não realizado.<br />'; | |
| 467 | + return FALSE; | |
| 468 | + } | |
| 469 | + } | |
| 470 | + } | |
| 471 | + } | |
| 472 | + | |
| 473 | + // Lista as faltas que o aluno já tinha | |
| 474 | + $obj_falta_aluno = new clsPmieducarFaltaAluno(); | |
| 475 | + $lst_falta_aluno = $obj_falta_aluno->lista( | |
| 476 | + NULL, NULL, NULL, $this->ref_ref_cod_serie, NULL, NULL, | |
| 477 | + $matricula_saida, NULL, NULL, NULL, NULL, NULL, 1 | |
| 478 | + ); | |
| 479 | + | |
| 480 | + if (is_array($lst_falta_aluno)) { | |
| 481 | + foreach ($lst_falta_aluno as $campo) { | |
| 482 | + if ($disciplinas[$campo['ref_cod_disciplina']]) { | |
| 483 | + // Cadastra as faltas existentes na nova matrícula | |
| 484 | + $obj_falta_aluno = new clsPmieducarFaltaAluno( | |
| 485 | + NULL, NULL, $this->pessoa_logada, | |
| 486 | + $this->ref_ref_cod_serie, $this->ref_cod_escola, | |
| 487 | + $campo['ref_cod_disciplina'], $cadastrou, | |
| 488 | + $campo['faltas'], NULL, NULL, 1, $campo['modulo'] | |
| 489 | + ); | |
| 490 | + | |
| 491 | + $cadastrou_falta = $obj_falta_aluno->cadastra(); | |
| 492 | + | |
| 493 | + if (! $cadastrou_falta) { | |
| 494 | + $this->mensagem = 'Cadastro não realizado.<br />'; | |
| 495 | + return FALSE; | |
| 496 | + } | |
| 497 | + } | |
| 498 | + } | |
| 499 | + } | |
| 500 | + | |
| 501 | + // Lista as notas que o aluno já tinha (globalizada) | |
| 502 | + $obj_faltas = new clsPmieducarFaltas(); | |
| 503 | + $lst_faltas = $obj_faltas->lista($matricula_saida); | |
| 504 | + | |
| 505 | + if (is_array($lst_faltas)) { | |
| 506 | + foreach ($lst_faltas as $campo) { | |
| 507 | + // Cadastra as faltas existentes na nova matrícula | |
| 508 | + $obj_faltas = new clsPmieducarFaltas( | |
| 509 | + $cadastrou, $campo['sequencial'], $this->pessoa_logada, | |
| 510 | + $campo['falta'] | |
| 511 | + ); | |
| 512 | + | |
| 513 | + $cadastrou_faltas = $obj_faltas->cadastra(); | |
| 514 | + | |
| 515 | + if (! $cadastrou_faltas) { | |
| 516 | + $this->mensagem = 'Cadastro não realizado.<br />'; | |
| 517 | + return FALSE; | |
| 518 | + } | |
| 519 | + } | |
| 520 | + } | |
| 521 | + } | |
| 522 | + } | |
| 523 | + | |
| 524 | + $obj = new clsPmieducarMatricula( | |
| 525 | + $matricula_saida, NULL, NULL, NULL,$this->pessoa_logada, NULL, | |
| 526 | + NULL, 4, NULL, NULL, 1, NULL, 0 | |
| 527 | + ); | |
| 528 | + | |
| 529 | + $editou3 = $obj->edita(); | |
| 530 | + | |
| 531 | + if (! $editou3) { | |
| 532 | + $this->mensagem = 'Edição não realizada.<br />'; | |
| 533 | + return FALSE; | |
| 534 | + } | |
| 535 | + } | |
| 536 | + else { | |
| 537 | + $this->mensagem = 'Edição não realizada.<br />'; | |
| 538 | + return FALSE; | |
| 539 | + } | |
| 540 | + } | |
| 541 | + } | |
| 542 | + } | |
| 543 | + | |
| 544 | + $this->mensagem .= 'Cadastro efetuado com sucesso.<br />'; | |
| 545 | + header('Location: educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno); | |
| 546 | + die(); | |
| 547 | + } | |
| 548 | + | |
| 549 | + $this->mensagem = 'Cadastro não realizado.<br />'; | |
| 550 | + return FALSE; | |
| 551 | + } | |
| 552 | + else { | |
| 553 | + $this->mensagem = 'Não foi possível encontrar o "Ano Letivo" em andamento da Escola.<br />'; | |
| 554 | + return FALSE; | |
| 555 | + } | |
| 556 | + } | |
| 557 | + | |
| 558 | + function Excluir() | |
| 559 | + { | |
| 560 | + @session_start(); | |
| 561 | + $this->pessoa_logada = $_SESSION['id_pessoa']; | |
| 562 | + @session_write_close(); | |
| 563 | + | |
| 564 | + $obj_permissoes = new clsPermissoes(); | |
| 565 | + $obj_permissoes->permissao_excluir(578, $this->pessoa_logada, 7, | |
| 566 | + 'educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno); | |
| 567 | + | |
| 568 | + $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | |
| 569 | + $lst_matricula_turma = $obj_matricula_turma->lista( | |
| 570 | + $this->cod_matricula, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1 | |
| 571 | + ); | |
| 572 | + | |
| 573 | + if (is_array($lst_matricula_turma)) { | |
| 574 | + $det_matricula_turma = array_shift($lst_matricula_turma); | |
| 575 | + $obj_matricula_turma = new clsPmieducarMatriculaTurma( | |
| 576 | + $det_matricula_turma['ref_cod_matricula'], | |
| 577 | + $det_matricula_turma['ref_cod_turma'], $this->pessoa_logada, NULL, | |
| 578 | + NULL, NULL, 0, NULL, $det_matricula_turma['sequencial'] | |
| 579 | + ); | |
| 580 | + | |
| 581 | + $editou = $obj_matricula_turma->edita(); | |
| 582 | + | |
| 583 | + if (! $editou) { | |
| 584 | + $this->mensagem = 'Edição não realizada.<br />'; | |
| 585 | + return FALSE; | |
| 586 | + } | |
| 587 | + } | |
| 588 | + | |
| 589 | + $obj_matricula = new clsPmieducarMatricula( $this->cod_matricula ); | |
| 590 | + $det_matricula = $obj_matricula->detalhe(); | |
| 591 | + $ref_cod_serie = $det_matricula['ref_ref_cod_serie']; | |
| 592 | + | |
| 593 | + $obj_sequencia = new clsPmieducarSequenciaSerie(); | |
| 594 | + $lst_sequencia = $obj_sequencia->lista( | |
| 595 | + NULL, $ref_cod_serie, NULL, NULL, NULL, NULL, NULL, NULL, 1 | |
| 596 | + ); | |
| 597 | + | |
| 598 | + // Verifica se a série da matrícula cancelada é sequência de alguma outra série | |
| 599 | + if (is_array($lst_sequencia)) { | |
| 600 | + $det_sequencia = array_shift($lst_sequencia); | |
| 601 | + $ref_serie_origem = $det_sequencia['ref_serie_origem']; | |
| 602 | + | |
| 603 | + $obj_matricula = new clsPmieducarMatricula(); | |
| 604 | + $lst_matricula = $obj_matricula->lista( | |
| 605 | + NULL, NULL, NULL, $ref_serie_origem, NULL, NULL,$this->ref_cod_aluno, | |
| 606 | + NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, 0 | |
| 607 | + ); | |
| 608 | + | |
| 609 | + // Verifica se o aluno tem matrícula na série encontrada | |
| 610 | + if (is_array($lst_matricula)) { | |
| 611 | + $det_matricula = array_shift($lst_matricula); | |
| 612 | + $ref_cod_matricula = $det_matricula['cod_matricula']; | |
| 613 | + | |
| 614 | + $obj = new clsPmieducarMatricula( | |
| 615 | + $ref_cod_matricula, NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, | |
| 616 | + NULL, NULL, NULL, 1, NULL, 1 | |
| 617 | + ); | |
| 618 | + | |
| 619 | + $editou1 = $obj->edita(); | |
| 620 | + if (! $editou1) { | |
| 621 | + $this->mensagem = 'Não foi possível editar a "Última Matrícula da Sequência".<br />'; | |
| 622 | + return FALSE; | |
| 623 | + } | |
| 624 | + } | |
| 625 | + } | |
| 626 | + | |
| 627 | + $obj = new clsPmieducarMatricula( | |
| 628 | + $this->cod_matricula, NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, | |
| 629 | + NULL, NULL, NULL, 0 | |
| 630 | + ); | |
| 631 | + | |
| 632 | + $excluiu = $obj->excluir(); | |
| 633 | + | |
| 634 | + if ($excluiu) { | |
| 635 | + $this->mensagem .= 'Exclusão efetuada com sucesso.<br />'; | |
| 636 | + header('Location: educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno); | |
| 637 | + die(); | |
| 638 | + } | |
| 639 | + | |
| 640 | + $this->mensagem = 'Exclusão não realizada.<br />'; | |
| 641 | + return FALSE; | |
| 642 | + } | |
| 643 | + | |
| 644 | + /** | |
| 645 | + * Marca como zero o campo ultima_matricula das matriculas da sequência. | |
| 646 | + * @param int $ultima_matricula | |
| 647 | + * @todo Remover, apenas um código condicional chama o método (L310). | |
| 648 | + */ | |
| 649 | + function desativaMatriculasSequencia($ultima_matricula) | |
| 650 | + { | |
| 651 | + $db2 = new clsBanco(); | |
| 652 | + | |
| 653 | + $db2->Consulta(' | |
| 654 | + SELECT | |
| 655 | + so.ref_cod_curso as curso_origem, | |
| 656 | + ss.ref_serie_origem as serie_origem, | |
| 657 | + sd.ref_cod_curso as curso_destino, | |
| 658 | + ss.ref_serie_destino as serie_destino | |
| 659 | + FROM | |
| 660 | + pmieducar.sequencia_serie ss, | |
| 661 | + pmieducar.serie so, | |
| 662 | + pmieducar.serie sd | |
| 663 | + WHERE | |
| 664 | + ss.ativo = 1 | |
| 665 | + AND ref_serie_origem = so.cod_serie | |
| 666 | + AND ref_serie_destino = sd.cod_serie | |
| 667 | + ORDER BY | |
| 668 | + ss.ref_serie_origem ASC'); | |
| 669 | + | |
| 670 | + if ($db2->numLinhas()) { | |
| 671 | + while ($db2->ProximoRegistro()) { | |
| 672 | + $sequencias[] = $db2->Tupla(); | |
| 673 | + } | |
| 674 | + } | |
| 675 | + | |
| 676 | + $db2->Consulta(' | |
| 677 | + SELECT | |
| 678 | + DISTINCT(o.ref_serie_origem) | |
| 679 | + FROM | |
| 680 | + pmieducar.sequencia_serie o, | |
| 681 | + pmieducar.escola_serie es | |
| 682 | + WHERE | |
| 683 | + NOT EXISTS ( | |
| 684 | + SELECT | |
| 685 | + 1 | |
| 686 | + FROM | |
| 687 | + pmieducar.sequencia_serie d | |
| 688 | + WHERE | |
| 689 | + o.ref_serie_origem = d.ref_serie_destino | |
| 690 | + )'); | |
| 691 | + | |
| 692 | + if ($db2->numLinhas()) | |
| 693 | + { | |
| 694 | + $pertence_sequencia = FALSE; | |
| 695 | + $achou_serie = FALSE; | |
| 696 | + $reset = FALSE; | |
| 697 | + | |
| 698 | + $serie_sequencia[] = $this->ref_ref_cod_serie; | |
| 699 | + | |
| 700 | + while ($db2->ProximoRegistro()) { | |
| 701 | + list($ini_sequencia) = $db2->Tupla(); | |
| 702 | + | |
| 703 | + $ini_serie = $ini_sequencia; | |
| 704 | + reset($sequencias); | |
| 705 | + | |
| 706 | + do { | |
| 707 | + if ($reset) { | |
| 708 | + reset($sequencias); | |
| 709 | + $reset = FALSE; | |
| 710 | + } | |
| 711 | + | |
| 712 | + $sequencia = current($sequencias); | |
| 713 | + $aux_serie = $sequencia['serie_origem']; | |
| 714 | + | |
| 715 | + if ($ini_serie == $aux_serie) { | |
| 716 | + if ($this->ref_ref_cod_serie == $aux_serie) { | |
| 717 | + // Achou série da matricula | |
| 718 | + $achou_serie = TRUE; | |
| 719 | + } | |
| 720 | + | |
| 721 | + if ($sequencia['curso_destino'] == $this->ref_cod_curso) { | |
| 722 | + // Curso pertence a sequência | |
| 723 | + $pertence_sequencia = TRUE; | |
| 724 | + $serie_sequencia[] = $sequencia['serie_destino']; | |
| 725 | + $ini_serie = $sequencia['serie_destino']; | |
| 726 | + $reset = TRUE; | |
| 727 | + } | |
| 728 | + else { | |
| 729 | + $ini_serie = $sequencia['serie_destino']; | |
| 730 | + $reset = TRUE; | |
| 731 | + } | |
| 732 | + } | |
| 733 | + } while (each($sequencias)); | |
| 734 | + | |
| 735 | + if ($achou_serie && $pertence_sequencia) { | |
| 736 | + // Curso escolhido pertence a sequência da série da matrícula | |
| 737 | + $series = implode(',', $serie_sequencia); | |
| 738 | + $db2->Consulta(sprintf(" | |
| 739 | + UPDATE | |
| 740 | + pmieducar.matricula | |
| 741 | + SET | |
| 742 | + ultima_matricula = 0 | |
| 743 | + WHERE | |
| 744 | + ref_ref_cod_serie IN (%s) | |
| 745 | + AND ref_cod_aluno = %d | |
| 746 | + AND cod_matricula != %d", | |
| 747 | + $series, $this->ref_cod_aluno, $ultima_matricula | |
| 748 | + )); | |
| 749 | + | |
| 750 | + die(); | |
| 751 | + } | |
| 752 | + } | |
| 753 | + } | |
| 754 | + } | |
| 685 | 755 | } |
| 686 | 756 | |
| 687 | -// cria uma extensao da classe base | |
| 757 | +// Instancia objeto de página | |
| 688 | 758 | $pagina = new clsIndexBase(); |
| 689 | -// cria o conteudo | |
| 759 | + | |
| 760 | +// Instancia objeto de conteúdo | |
| 690 | 761 | $miolo = new indice(); |
| 691 | -// adiciona o conteudo na clsBase | |
| 692 | -$pagina->addForm( $miolo ); | |
| 693 | -// gera o html | |
| 694 | -$pagina->MakeAll(); | |
| 695 | 762 | |
| 696 | -?> | |
| 697 | -<script> | |
| 763 | +// Atribui o conteúdo à página | |
| 764 | +$pagina->addForm($miolo); | |
| 698 | 765 | |
| 766 | +// Gera o código HTML | |
| 767 | +$pagina->MakeAll(); | |
| 768 | +?> | |
| 769 | +<script type="text/javascript"> | |
| 699 | 770 | function getCursoMatricula() |
| 700 | 771 | { |
| 701 | - var campoInstituicao = document.getElementById('ref_cod_instituicao').value; | |
| 702 | - var cod_aluno = <?=$_GET["ref_cod_aluno"]?>; | |
| 772 | + var campoInstituicao = document.getElementById('ref_cod_instituicao').value; | |
| 773 | + var cod_aluno = <?php print $_GET['ref_cod_aluno'] ?>; | |
| 774 | + var campoCurso = document.getElementById('ref_cod_curso'); | |
| 775 | + | |
| 776 | + campoCurso.length = 1; | |
| 777 | + campoCurso.disabled = true; | |
| 778 | + campoCurso.options[0].text = 'Carregando curso'; | |
| 703 | 779 | |
| 704 | - var campoCurso = document.getElementById('ref_cod_curso'); | |
| 705 | - campoCurso.length = 1; | |
| 706 | - campoCurso.disabled = true; | |
| 707 | - campoCurso.options[0].text = 'Carregando curso'; | |
| 780 | + var xml_curso_matricula = new ajax(atualizaCursoMatricula); | |
| 708 | 781 | |
| 709 | - var xml_curso_matricula = new ajax( atualizaCursoMatricula ); | |
| 710 | - xml_curso_matricula.envia( "educar_curso_matricula_xml.php?ins="+campoInstituicao+"&alu="+cod_aluno ); | |
| 782 | + var url = 'educar_curso_matricula_xml.php?ins=' + campoInstituicao + '&alu=' + cod_aluno; | |
| 783 | + xml_curso_matricula.envia(url); | |
| 711 | 784 | } |
| 712 | 785 | |
| 713 | -function atualizaCursoMatricula( xml_curso_matricula ) | |
| 786 | +function atualizaCursoMatricula(xml_curso_matricula) | |
| 714 | 787 | { |
| 715 | - var campoCurso = document.getElementById('ref_cod_curso'); | |
| 716 | - var DOM_array = xml_curso_matricula.getElementsByTagName( "curso" ); | |
| 717 | - | |
| 718 | - if(DOM_array.length) | |
| 719 | - { | |
| 720 | - campoCurso.length = 1; | |
| 721 | - campoCurso.options[0].text = 'Selecione um curso'; | |
| 722 | - campoCurso.disabled = false; | |
| 723 | - | |
| 724 | - for( var i = 0; i < DOM_array.length; i++ ) | |
| 725 | - { | |
| 726 | - campoCurso.options[campoCurso.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_curso"),false,false); | |
| 727 | - } | |
| 728 | - } | |
| 729 | - else | |
| 730 | - campoCurso.options[0].text = 'A instituição não possui nenhum curso'; | |
| 731 | - | |
| 788 | + var campoCurso = document.getElementById('ref_cod_curso'); | |
| 789 | + var DOM_array = xml_curso_matricula.getElementsByTagName('curso'); | |
| 790 | + | |
| 791 | + if (DOM_array.length) { | |
| 792 | + campoCurso.length = 1; | |
| 793 | + campoCurso.options[0].text = 'Selecione um curso'; | |
| 794 | + campoCurso.disabled = false; | |
| 795 | + | |
| 796 | + for (var i = 0; i < DOM_array.length; i++) { | |
| 797 | + campoCurso.options[campoCurso.options.length] = new Option( | |
| 798 | + DOM_array[i].firstChild.data, DOM_array[i].getAttribute('cod_curso'), | |
| 799 | + false, false | |
| 800 | + ); | |
| 801 | + } | |
| 802 | + } | |
| 803 | + else { | |
| 804 | + campoCurso.options[0].text = 'A instituição não possui nenhum curso'; | |
| 805 | + } | |
| 732 | 806 | } |
| 733 | 807 | |
| 734 | 808 | function getSerieMatricula() |
| 735 | 809 | { |
| 736 | - var campoInstituicao = document.getElementById('ref_cod_instituicao').value; | |
| 737 | - var campoEscola = document.getElementById('ref_cod_escola').value; | |
| 738 | - var campoCurso = document.getElementById('ref_cod_curso').value; | |
| 739 | - var cod_aluno = <?=$_GET["ref_cod_aluno"]?>; | |
| 740 | - | |
| 741 | - var campoSerie = document.getElementById('ref_ref_cod_serie'); | |
| 742 | - campoSerie.length = 1; | |
| 743 | - campoSerie.disabled = true; | |
| 744 | - campoSerie.options[0].text = 'Carregando série'; | |
| 745 | - | |
| 746 | - var xml_serie_matricula = new ajax( atualizaSerieMatricula ); | |
| 747 | - xml_serie_matricula.envia( "educar_serie_matricula_xml.php?ins="+campoInstituicao+"&cur="+campoCurso+"&esc="+campoEscola+"&alu="+cod_aluno ); | |
| 810 | + var campoInstituicao = document.getElementById('ref_cod_instituicao').value; | |
| 811 | + var campoEscola = document.getElementById('ref_cod_escola').value; | |
| 812 | + var campoCurso = document.getElementById('ref_cod_curso').value; | |
| 813 | + var cod_aluno = <?php print $_GET['ref_cod_aluno'] ?>; | |
| 814 | + var campoSerie = document.getElementById('ref_ref_cod_serie'); | |
| 815 | + | |
| 816 | + campoSerie.length = 1; | |
| 817 | + campoSerie.disabled = true; | |
| 818 | + campoSerie.options[0].text = 'Carregando série'; | |
| 819 | + | |
| 820 | + var xml_serie_matricula = new ajax(atualizaSerieMatricula); | |
| 821 | + | |
| 822 | + var url = 'educar_serie_matricula_xml.php?ins=' + campoInstituicao + '&cur=' + campoCurso | |
| 823 | + + '&esc=' + campoEscola + '&alu=' + cod_aluno; | |
| 824 | + | |
| 825 | + xml_serie_matricula.envia(url); | |
| 748 | 826 | } |
| 749 | 827 | |
| 750 | -function atualizaSerieMatricula( xml_serie_matricula ) | |
| 828 | +function atualizaSerieMatricula(xml_serie_matricula) | |
| 751 | 829 | { |
| 752 | - var campoSerie = document.getElementById('ref_ref_cod_serie'); | |
| 753 | - var DOM_array = xml_serie_matricula.getElementsByTagName( "serie" ); | |
| 754 | - | |
| 755 | - if(DOM_array.length) | |
| 756 | - { | |
| 757 | - campoSerie.length = 1; | |
| 758 | - campoSerie.options[0].text = 'Selecione uma série'; | |
| 759 | - campoSerie.disabled = false; | |
| 760 | - var series = new Array(); | |
| 761 | - for( var i = 0; i < DOM_array.length; i++ ) | |
| 762 | - { | |
| 763 | - if(!series[DOM_array[i].getAttribute("cod_serie") + '_']) | |
| 764 | - { | |
| 765 | - campoSerie.options[campoSerie.options.length] = new Option( DOM_array[i].firstChild.data, DOM_array[i].getAttribute("cod_serie"),false,false); | |
| 766 | - series[DOM_array[i].getAttribute("cod_serie") + '_'] = true; | |
| 767 | - } | |
| 768 | - } | |
| 769 | - } | |
| 770 | - else | |
| 771 | - campoSerie.options[0].text = 'A escola/curso não possui nenhuma série'; | |
| 830 | + var campoSerie = document.getElementById('ref_ref_cod_serie'); | |
| 831 | + var DOM_array = xml_serie_matricula.getElementsByTagName('serie'); | |
| 832 | + | |
| 833 | + if (DOM_array.length) { | |
| 834 | + campoSerie.length = 1; | |
| 835 | + campoSerie.options[0].text = 'Selecione uma série'; | |
| 836 | + campoSerie.disabled = false; | |
| 837 | + | |
| 838 | + var series = new Array(); | |
| 839 | + | |
| 840 | + for (var i = 0; i < DOM_array.length; i++) { | |
| 841 | + if (! series[DOM_array[i].getAttribute('cod_serie') + '_']) { | |
| 842 | + campoSerie.options[campoSerie.options.length] = new Option( | |
| 843 | + DOM_array[i].firstChild.data, DOM_array[i].getAttribute('cod_serie'), | |
| 844 | + false, false | |
| 845 | + ); | |
| 846 | + | |
| 847 | + series[DOM_array[i].getAttribute('cod_serie') + '_'] = true; | |
| 848 | + } | |
| 849 | + } | |
| 850 | + } | |
| 851 | + else { | |
| 852 | + campoSerie.options[0].text = 'A escola/curso não possui nenhuma série'; | |
| 853 | + } | |
| 772 | 854 | } |
| 773 | 855 | |
| 774 | 856 | document.getElementById('ref_cod_escola').onchange = function() |
| 775 | 857 | { |
| 776 | - if( document.getElementById('ref_cod_escola').value == "" ) | |
| 777 | - getCursoMatricula(); | |
| 778 | - else | |
| 779 | - getEscolaCurso(); | |
| 858 | + if (document.getElementById('ref_cod_escola').value == '') { | |
| 859 | + getCursoMatricula(); | |
| 860 | + } | |
| 861 | + else { | |
| 862 | + getEscolaCurso(); | |
| 863 | + } | |
| 780 | 864 | } |
| 781 | 865 | |
| 782 | 866 | document.getElementById('ref_cod_curso').onchange = function() |
| 783 | 867 | { |
| 784 | - getSerieMatricula(); | |
| 868 | + getSerieMatricula(); | |
| 785 | 869 | } |
| 786 | 870 | |
| 787 | 871 | function valida() |
| 788 | 872 | { |
| 789 | - if( document.getElementById('ref_cod_escola').value ) | |
| 790 | - { | |
| 791 | - if( !document.getElementById('ref_ref_cod_serie').value ) | |
| 792 | - { | |
| 793 | - alert("O campo 'Série' deve ser preenchido corretamente!"); | |
| 794 | - document.getElementById('ref_ref_cod_serie').focus(); | |
| 795 | - return false; | |
| 796 | - } | |
| 797 | - } | |
| 798 | - if( !acao() ) | |
| 799 | - return false; | |
| 800 | - | |
| 801 | - document.forms[0].submit(); | |
| 873 | + if (document.getElementById('ref_cod_escola').value) { | |
| 874 | + if (!document.getElementById('ref_ref_cod_serie').value) { | |
| 875 | + alert('O campo "Série" deve ser preenchido corretamente!'); | |
| 876 | + document.getElementById('ref_ref_cod_serie').focus(); | |
| 877 | + return false; | |
| 878 | + } | |
| 879 | + } | |
| 880 | + | |
| 881 | + if (! acao()) { | |
| 882 | + return false; | |
| 883 | + } | |
| 884 | + | |
| 885 | + document.forms[0].submit(); | |
| 802 | 886 | } |
| 803 | - | |
| 804 | 887 | </script> |
| 805 | 888 | \ No newline at end of file | ... | ... |