function Novo()
    {
        $this->url_cancelar = 'educar_aluno_det.php?cod_aluno=' . $this->ref_cod_aluno;
        $this->nome_url_cancelar = 'Cancelar';
        @session_start();
        $this->pessoa_logada = $_SESSION['id_pessoa'];
        @session_write_close();
        $obj_permissoes = new clsPermissoes();
        $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, 'educar_aluno_det.php?cod_aluno=' . $this->ref_cod_aluno);
        //novas regras matricula aluno
        $this->ano = $_POST['ano'];
        $anoLetivoEmAndamentoEscola = new clsPmieducarEscolaAnoLetivo();
        $anoLetivoEmAndamentoEscola = $anoLetivoEmAndamentoEscola->lista($this->ref_cod_escola, $this->ano, null, null, 2, null, null, null, null, 1);
        if (is_array($anoLetivoEmAndamentoEscola)) {
            require_once 'include/pmieducar/clsPmieducarSerie.inc.php';
            $db = new clsBanco();
            $db->Consulta("select ref_ref_cod_serie, ref_cod_curso from pmieducar.matricula where ativo = 1 and ref_ref_cod_escola = {$this->ref_cod_escola} and ref_cod_curso = {$this->ref_cod_curso} and ref_cod_aluno = {$this->ref_cod_aluno} and aprovado not in (1,2,4,5,6,7,8,9)");
            $db->ProximoRegistro();
            $m = $db->Tupla();
            if (is_array($m) && count($m)) {
                $curso = $this->getCurso($this->ref_cod_curso);
                if ($m['ref_ref_cod_serie'] == $this->ref_cod_serie) {
                    $this->mensagem .= "Este aluno já está matriculado nesta série e curso, não é possivel matricular um aluno mais de uma vez na mesma série.<br />";
                    return false;
                } elseif ($curso['multi_seriado'] != 1) {
                    $serie = new clsPmieducarSerie($m['ref_ref_cod_serie'], null, null, $m['ref_cod_curso']);
                    $serie = $serie->detalhe();
                    if (is_array($serie) && count($serie)) {
                        $nomeSerie = $serie['nm_serie'];
                    } else {
                        $nomeSerie = '';
                    }
                    $this->mensagem .= "Este aluno já está matriculado no(a) '{$nomeSerie}' deste curso e escola. Como este curso não é multi seriado, não é possivel manter mais de uma matricula em andamento para o mesmo curso.<br />";
                    return false;
                }
            } else {
                $db->Consulta("select ref_ref_cod_escola, ref_cod_curso, ref_ref_cod_serie from pmieducar.matricula where ativo = 1 and ref_ref_cod_escola != {$this->ref_cod_escola} and ref_cod_aluno = {$this->ref_cod_aluno} and aprovado not in (1,2,4,5,6,7,8,9) and not exists (select 1 from pmieducar.transferencia_solicitacao as ts where ts.ativo = 1 and ts.ref_cod_matricula_saida = matricula.cod_matricula)");
                $db->ProximoRegistro();
                $m = $db->Tupla();
                if (is_array($m) && count($m)) {
                    if ($m['ref_cod_curso'] == $this->ref_cod_curso || $GLOBALS['coreExt']['Config']->app->matricula->multiplas_matriculas == 0) {
                        require_once 'include/pmieducar/clsPmieducarEscola.inc.php';
                        require_once 'include/pessoa/clsJuridica.inc.php';
                        $serie = new clsPmieducarSerie($m['ref_ref_cod_serie'], null, null, $m['ref_cod_curso']);
                        $serie = $serie->detalhe();
                        if (is_array($serie) && count($serie)) {
                            $serie = $serie['nm_serie'];
                        } else {
                            $serie = '';
                        }
                        $escola = new clsPmieducarEscola($m['ref_ref_cod_escola']);
                        $escola = $escola->detalhe();
                        if (is_array($escola) && count($escola)) {
                            $escola = new clsJuridica($escola['ref_idpes']);
                            $escola = $escola->detalhe();
                            if (is_array($escola) && count($escola)) {
                                $escola = $escola['fantasia'];
                            } else {
                                $escola = '';
                            }
                        } else {
                            $escola = '';
                        }
                        $curso = new clsPmieducarCurso($m['ref_cod_curso']);
                        $curso = $curso->detalhe();
                        if (is_array($curso) && count($curso)) {
                            $curso = $curso['nm_curso'];
                        } else {
                            $curso = '';
                        }
                        $this->mensagem .= "Este aluno já está matriculado no(a) '{$serie}' do curso '{$curso}' na escola '{$escola}', para matricular este aluno na sua escola solicite transferência ao secretário(a) da escola citada.<br />";
                        return false;
                    }
                }
            }
            $obj_reserva_vaga = new clsPmieducarReservaVaga();
            $lst_reserva_vaga = $obj_reserva_vaga->lista(NULL, $this->ref_cod_escola, $this->ref_cod_serie, NULL, NULL, $this->ref_cod_aluno, NULL, NULL, NULL, NULL, 1);
            // Verifica se existe reserva de vaga para o aluno
            if (is_array($lst_reserva_vaga)) {
                $det_reserva_vaga = array_shift($lst_reserva_vaga);
                $this->ref_cod_reserva_vaga = $det_reserva_vaga['cod_reserva_vaga'];
                $obj_reserva_vaga = new clsPmieducarReservaVaga($this->ref_cod_reserva_vaga, NULL, NULL, $this->pessoa_logada, NULL, NULL, NULL, NULL, 0);
                $editou = $obj_reserva_vaga->edita();
                if (!$editou) {
                    $this->mensagem = 'Edição não realizada.<br />';
                    return FALSE;
                }
            }
            $vagas_restantes = 1;
            if (!$this->ref_cod_reserva_vaga) {
                $obj_turmas = new clsPmieducarTurma();
                $lst_turmas = $obj_turmas->lista(NULL, NULL, NULL, $this->ref_cod_serie, $this->ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
                if (is_array($lst_turmas)) {
                    $total_vagas = 0;
                    foreach ($lst_turmas as $turmas) {
                        $total_vagas += $turmas['max_aluno'];
                    }
                } else {
                    $this->mensagem = 'A série selecionada não possui turmas cadastradas.<br />';
                    return FALSE;
                }
                $obj_matricula = new clsPmieducarMatricula();
                $lst_matricula = $obj_matricula->lista(NULL, NULL, $this->ref_cod_escola, $this->ref_cod_serie, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL, 1, $this->ano, $this->ref_cod_curso, $this->ref_cod_instituicao, 1);
                if (is_array($lst_matricula)) {
                    $matriculados = count($lst_matricula);
                }
                $obj_reserva_vaga = new clsPmieducarReservaVaga();
                $lst_reserva_vaga = $obj_reserva_vaga->lista(NULL, $this->ref_cod_escola, $this->ref_cod_serie, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao, $this->ref_cod_curso);
                if (is_array($lst_reserva_vaga)) {
                    $reservados = count($lst_reserva_vaga);
                }
                $vagas_restantes = $total_vagas - ($matriculados + $reservados);
            }
            if ($vagas_restantes <= 0) {
                echo sprintf('
          <script>
            var msg = \'\';
            msg += \'Excedido o número de total de vagas para Matricula!\\n\';
            msg += \'Número total de matriculados: %d\\n\';
            msg += \'Número total de vagas reservadas: %d\\n\';
            msg += \'Número total de vagas: %d\\n\';
            msg += \'Deseja mesmo assim realizar a Matrícula?\';

            if (! confirm(msg)) {
              window.location = \'educar_aluno_det.php?cod_aluno=%d\';
            }
          </script>', $matriculados, $reservados, $total_vagas, $this->ref_cod_aluno);
            }
            $obj_matricula_aluno = new clsPmieducarMatricula();
            $lst_matricula_aluno = $obj_matricula_aluno->lista(NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_aluno);
            if (!$lst_matricula_aluno) {
                // Primeira matrícula do sistema, consistência (?)
                $this->matricula_transferencia = $this->matricula_transferencia == 'on' ? TRUE : FALSE;
            } else {
                $this->matricula_transferencia = FALSE;
            }
            if ($this->is_padrao == 1) {
                $this->semestre = NULL;
            }
            if (!$this->removerFlagUltimaMatricula($this->ref_cod_aluno)) {
                return false;
            }
            $this->data_matricula = Portabilis_Date_Utils::brToPgSQL($this->data_matricula);
            $obj = new clsPmieducarMatricula(NULL, $this->ref_cod_reserva_vaga, $this->ref_cod_escola, $this->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, $this->data_matricula);
            $cadastrou = $obj->cadastra();
            // turma
            $cod_matricula = $cadastrou;
            $this->enturmacaoMatricula($cod_matricula, $this->ref_cod_turma);
            if ($cadastrou) {
                $obj_transferencia = new clsPmieducarTransferenciaSolicitacao();
                #Se encontrar solicitações de transferencia externa (com data de transferencia sem codigo de matricula de entrada), inativa estas
                /*$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);
                
                        if (is_array($lst_transferencia)) {
                          echo 'Encontrou solicitações de transferencia externa (saida) com data de transferencia';
                          $det_transferencia = array_shift($lst_transferencia);
                
                          $obj_transferencia = new clsPmieducarTransferenciaSolicitacao(
                            $det_transferencia['cod_transferencia_solicitacao'], NULL,
                            $this->pessoa_logada, NULL, NULL, NULL, NULL, NULL, NULL, 0);
                
                          $editou2 = $obj_transferencia->edita();
                
                          if ($editou2) {
                            $obj = new clsPmieducarMatricula($det_transferencia['ref_cod_matricula_saida'],
                              NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, 4, NULL, NULL, 1, NULL, 0);
                
                            $editou3 = $obj->edita();
                
                            if (! $editou3) {
                              $this->mensagem = 'Edição não realizada.<br />';
                              return FALSE;
                            }
                          }
                          else {
                            $this->mensagem = 'Edição não realizada.<br />';
                            return FALSE;
                          }
                        }
                        #senão pega as solicitacoes de transferencia internas (sem data de transferencia e sem codigo de matricula de entrada) e
                        #seta a data de transferencia e codigo de matricula de entrada, atualiza a situacao da matricula para transferido e inativa a matricula turma
                        else {
                        */
                $obj_transferencia = new clsPmieducarTransferenciaSolicitacao();
                $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);
                #TODO interna ?
                // Verifica se existe solicitação de transferência (interna) do aluno
                if (is_array($lst_transferencia)) {
                    #echo 'Encontrou solicitações de transferencia interna  (saida) com data de transferencia';
                    // Verifica cada solicitação de transferência do aluno
                    foreach ($lst_transferencia as $transferencia) {
                        $obj_matricula = new clsPmieducarMatricula($transferencia['ref_cod_matricula_saida']);
                        $det_matricula = $obj_matricula->detalhe();
                        // Se a matrícula anterior estava em andamento, copia as notas/faltas/pareceres
                        if ($det_matricula['aprovado'] == 3) {
                            $db->Consulta(" SELECT modules.copia_notas_transf({$det_matricula['cod_matricula']},{$cod_matricula})");
                        }
                        // Caso a solicitação seja para uma mesma série
                        if ($det_matricula['ref_ref_cod_serie'] == $this->ref_cod_serie) {
                            $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao'];
                            break;
                        } else {
                            $obj_sequencia = new clsPmieducarSequenciaSerie($det_matricula['ref_ref_cod_serie'], $this->ref_cod_serie, NULL, NULL, NULL, NULL, 1);
                            if ($obj_sequencia->existe()) {
                                $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao'];
                                break;
                            }
                        }
                        $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao'];
                    }
                    if ($ref_cod_transferencia) {
                        $obj_transferencia = new clsPmieducarTransferenciaSolicitacao($ref_cod_transferencia, NULL, $this->pessoa_logada, NULL, $cadastrou, NULL, NULL, NULL, NULL, 1, date('Y-m-d'));
                        $editou2 = $obj_transferencia->edita();
                        if ($editou2) {
                            $obj_transferencia = new clsPmieducarTransferenciaSolicitacao($ref_cod_transferencia);
                            $det_transferencia = $obj_transferencia->detalhe();
                            $matricula_saida = $det_transferencia['ref_cod_matricula_saida'];
                            $obj_matricula = new clsPmieducarMatricula($matricula_saida);
                            $det_matricula = $obj_matricula->detalhe();
                            // Caso a situação da matrícula do aluno esteja em andamento
                            if ($det_matricula['aprovado'] == 3) {
                                $obj_matricula = new clsPmieducarMatricula($cadastrou, NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, $det_matricula['modulo']);
                                if ($obj_matricula->edita() && !$this->desativaEnturmacoesMatricula($matricula_saida)) {
                                    return false;
                                }
                            }
                            $obj = new clsPmieducarMatricula($matricula_saida, NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, 4, NULL, NULL, 1, NULL, 0);
                            $editou3 = $obj->edita();
                            if (!$editou3) {
                                $this->mensagem = 'Edição não realizada.<br />';
                                return FALSE;
                            }
                        } else {
                            $this->mensagem = 'Edição não realizada.<br />';
                            return FALSE;
                        }
                    }
                }
                //}
                #TODO set in $_SESSION['flash'] 'Aluno matriculado com sucesso'
                $this->mensagem .= 'Cadastro efetuado com sucesso.<br />';
                header('Location: educar_aluno_det.php?cod_aluno=' . $this->ref_cod_aluno);
                #die();
                #return true;
            }
            $this->mensagem = 'Cadastro não realizado.<br />';
            return FALSE;
        } else {
            $this->mensagem = 'O ano (letivo) selecionado não esta em andamento na escola selecionada.<br />';
            return FALSE;
        }
    }
    function Novo()
    {
        @session_start();
        $this->pessoa_logada = $_SESSION['id_pessoa'];
        @session_write_close();
        $obj_permissoes = new clsPermissoes();
        $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, 'educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno);
        $obj_escola_ano_letivo = new clsPmieducarEscolaAnoLetivo();
        $lst_escola_ano_letivo = $obj_escola_ano_letivo->lista($this->ref_cod_escola, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, 1);
        if (is_array($lst_escola_ano_letivo)) {
            $det_escola_ano_letivo = array_shift($lst_escola_ano_letivo);
            $this->ano = $det_escola_ano_letivo['ano'];
            $obj_reserva_vaga = new clsPmieducarReservaVaga();
            $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);
            // Verifica se existe reserva de vaga para o aluno
            if (is_array($lst_reserva_vaga)) {
                $det_reserva_vaga = array_shift($lst_reserva_vaga);
                $this->ref_cod_reserva_vaga = $det_reserva_vaga['cod_reserva_vaga'];
                $obj_reserva_vaga = new clsPmieducarReservaVaga($this->ref_cod_reserva_vaga, NULL, NULL, $this->pessoa_logada, NULL, NULL, NULL, NULL, 0);
                $editou = $obj_reserva_vaga->edita();
                if (!$editou) {
                    $this->mensagem = 'Edição não realizada.<br />';
                    return FALSE;
                }
            }
            $vagas_restantes = 1;
            if (!$this->ref_cod_reserva_vaga) {
                $obj_turmas = new clsPmieducarTurma();
                $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);
                if (is_array($lst_turmas)) {
                    $total_vagas = 0;
                    foreach ($lst_turmas as $turmas) {
                        $total_vagas += $turmas['max_aluno'];
                    }
                } else {
                    $this->mensagem = 'Série não possui turmas cadastradas.<br />';
                    return FALSE;
                }
                $obj_matricula = new clsPmieducarMatricula();
                $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);
                if (is_array($lst_matricula)) {
                    $matriculados = count($lst_matricula);
                }
                $obj_reserva_vaga = new clsPmieducarReservaVaga();
                $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);
                if (is_array($lst_reserva_vaga)) {
                    $reservados = count($lst_reserva_vaga);
                }
                $vagas_restantes = $total_vagas - ($matriculados + $reservados);
            }
            if ($vagas_restantes <= 0) {
                echo sprintf('
          <script>
            var msg = \'\';
            msg += \'Excedido o número de total de vagas para Matricula!\\n\';
            msg += \'Número total de matriculados: %d\\n\';
            msg += \'Número total de vagas reservadas: %d\\n\';
            msg += \'Número total de vagas: %d\\n\';
            msg += \'Deseja mesmo assim realizar a Matrícula?\';

            if (! confirm(msg)) {
              window.location = \'educar_matricula_lst.php?ref_cod_aluno=%d\';
            }
          </script>', $matriculados, $reservados, $total_vagas, $this->ref_cod_aluno);
            }
            $obj_matricula_aluno = new clsPmieducarMatricula();
            $lst_matricula_aluno = $obj_matricula_aluno->lista(NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_aluno);
            if (!$lst_matricula_aluno) {
                // Primeira matrícula do sistema, consistência (?)
                $this->matricula_transferencia = $this->matricula_transferencia == 'on' ? TRUE : FALSE;
            } else {
                $this->matricula_transferencia = FALSE;
            }
            if ($this->is_padrao == 1) {
                $this->semestre = NULL;
            }
            $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);
            $cadastrou = $obj->cadastra();
            if ($cadastrou) {
                $obj_transferencia = new clsPmieducarTransferenciaSolicitacao();
                $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);
                // Verifica se existe solicitação de transferência de aluno
                if (is_array($lst_transferencia)) {
                    $det_transferencia = array_shift($lst_transferencia);
                    $obj_transferencia = new clsPmieducarTransferenciaSolicitacao($det_transferencia['cod_transferencia_solicitacao'], NULL, $this->pessoa_logada, NULL, NULL, NULL, NULL, NULL, NULL, 0);
                    $editou2 = $obj_transferencia->edita();
                    if ($editou2) {
                        $obj = new clsPmieducarMatricula($det_transferencia['ref_cod_matricula_saida'], NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, 4, NULL, NULL, 1, NULL, 0);
                        $editou3 = $obj->edita();
                        if (!$editou3) {
                            $this->mensagem = 'Edição não realizada.<br />';
                            return FALSE;
                        }
                    } else {
                        $this->mensagem = 'Edição não realizada.<br />';
                        return FALSE;
                    }
                } else {
                    $obj_transferencia = new clsPmieducarTransferenciaSolicitacao();
                    $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);
                    // Verifica se existe solicitação de transferência do aluno
                    if (is_array($lst_transferencia)) {
                        // Verifica cada solicitação de transferência do aluno
                        foreach ($lst_transferencia as $transferencia) {
                            $obj_matricula = new clsPmieducarMatricula($transferencia['ref_cod_matricula_saida']);
                            $det_matricula = $obj_matricula->detalhe();
                            // Caso a solicitação seja para uma mesma série
                            if ($det_matricula['ref_ref_cod_serie'] == $this->ref_ref_cod_serie) {
                                $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao'];
                                break;
                            } else {
                                $obj_sequencia = new clsPmieducarSequenciaSerie($det_matricula['ref_ref_cod_serie'], $this->ref_ref_cod_serie, NULL, NULL, NULL, NULL, 1);
                                if ($obj_sequencia->existe()) {
                                    $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao'];
                                    break;
                                }
                            }
                            $ref_cod_transferencia = $transferencia['cod_transferencia_solicitacao'];
                        }
                        if ($ref_cod_transferencia) {
                            $obj_transferencia = new clsPmieducarTransferenciaSolicitacao($ref_cod_transferencia, NULL, $this->pessoa_logada, NULL, $cadastrou, NULL, NULL, NULL, NULL, 1, date('Y-m-d'));
                            $editou2 = $obj_transferencia->edita();
                            if ($editou2) {
                                $obj_transferencia = new clsPmieducarTransferenciaSolicitacao($ref_cod_transferencia);
                                $det_transferencia = $obj_transferencia->detalhe();
                                $matricula_saida = $det_transferencia['ref_cod_matricula_saida'];
                                $obj_matricula = new clsPmieducarMatricula($matricula_saida);
                                $det_matricula = $obj_matricula->detalhe();
                                // Caso a situação da matrícula do aluno esteja em andamento
                                if ($det_matricula['aprovado'] == 3) {
                                    $obj_matricula = new clsPmieducarMatricula($cadastrou, NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, $det_matricula['modulo']);
                                    $editou_mat = $obj_matricula->edita();
                                    if ($editou_mat) {
                                        $obj_matricula_turma = new clsPmieducarMatriculaTurma();
                                        $lst_matricula_turma = $obj_matricula_turma->lista($matricula_saida, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
                                        if (is_array($lst_matricula_turma)) {
                                            $det_matricula_turma = array_shift($lst_matricula_turma);
                                            $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']);
                                            $editou_mat_turma = $obj_matricula_turma->edita();
                                            if (!$editou_mat_turma) {
                                                $this->mensagem = 'Não foi possível editar a Matrícula Turma.<br />';
                                                return FALSE;
                                            }
                                        }
                                    }
                                }
                                $obj = new clsPmieducarMatricula($matricula_saida, NULL, NULL, NULL, $this->pessoa_logada, NULL, NULL, 4, NULL, NULL, 1, NULL, 0);
                                $editou3 = $obj->edita();
                                if (!$editou3) {
                                    $this->mensagem = 'Edição não realizada.<br />';
                                    return FALSE;
                                }
                            } else {
                                $this->mensagem = 'Edição não realizada.<br />';
                                return FALSE;
                            }
                        }
                    }
                }
                $this->mensagem .= 'Cadastro efetuado com sucesso.<br />';
                header('Location: educar_matricula_lst.php?ref_cod_aluno=' . $this->ref_cod_aluno);
                die;
            }
            $this->mensagem = 'Cadastro não realizado.<br />';
            return FALSE;
        } else {
            $this->mensagem = 'Não foi possível encontrar o "Ano Letivo" em andamento da Escola.<br />';
            return FALSE;
        }
    }