function Inicializar() { $retorno = "Novo"; @session_start(); $this->pessoa_logada = $_SESSION['id_pessoa']; @session_write_close(); if (!$_POST) { header('Location: educar_matricula_lst.php'); die; } foreach ($_POST as $key => $value) { $this->{$key} = $value; } $obj_permissoes = new clsPermissoes(); $obj_permissoes->permissao_cadastra(578, $this->pessoa_logada, 7, 'educar_matricula_lst.php'); if (is_numeric($this->ref_cod_matricula)) { if (is_numeric($this->ref_cod_turma_origem)) { $obj_matricula_turma = new clsPmieducarMatriculaTurma(); $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); if ($lst_matricula_turma) { foreach ($lst_matricula_turma as $matricula) { $obj = new clsPmieducarMatriculaTurma($this->ref_cod_matricula, $matricula['ref_cod_turma'], $this->pessoa_logada, NULL, NULL, NULL, 0, NULL, $matricula['sequencial']); $registro = $obj->detalhe(); if ($registro) { if (!$obj->edita()) { echo "erro ao cadastrar"; die; } } } } $obj = new clsPmieducarMatriculaTurma($this->ref_cod_matricula, $this->ref_cod_turma_destino, $this->pessoa_logada, $this->pessoa_logada, NULL, NULL, 1); $cadastrou = $obj->cadastra(); if ($cadastrou) { $this->mensagem .= 'Cadastro efetuado com sucesso.<br>'; header('Location: educar_matricula_det.php?cod_matricula=' . $this->ref_cod_matricula); die; } } else { $obj = new clsPmieducarMatriculaTurma($this->ref_cod_matricula, $this->ref_cod_turma_destino, $this->pessoa_logada, $this->pessoa_logada, NULL, NULL, 1); $cadastrou = $obj->cadastra(); if ($cadastrou) { $this->mensagem .= 'Cadastro efetuado com sucesso.<br>'; header('Location: educar_matricula_det.php?cod_matricula=' . $this->ref_cod_matricula); die; } } } header('Location: educar_matricula_lst.php'); die; }