function Novo() { @session_start(); $this->pessoa_logada = $_SESSION['id_pessoa']; @session_write_close(); /* * Se houve erro na primeira tentativa de cadastro, irá considerar apenas * os valores enviados de forma oculta. */ if (isset($this->ref_cod_instituicao_)) { $this->ref_cod_instituicao = $this->ref_cod_instituicao_; $this->ref_cod_escola = $this->ref_cod_escola_; $this->ref_cod_curso = $this->ref_cod_curso_; $this->ref_cod_serie = $this->ref_cod_serie_; } $anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper(); $componenteAno = $anoEscolar->findComponentePorSerie($this->ref_cod_serie); /* * Se $disciplinas não for informado e o ano escolar tem componentes * curriculares cadastrados, retorna erro. */ if (!is_array($this->disciplinas) && (is_array($componenteAno) && 0 < count($componenteAno))) { echo "<script> alert('É necessário adicionar pelo menos um componente curricular.') </script>"; $this->mensagem = 'Cadastro não realizado.<br>'; return FALSE; } $obj = new clsPmieducarEscolaSerie($this->ref_cod_escola, $this->ref_cod_serie, $this->pessoa_logada, $this->pessoa_logada, $this->hora_inicial, $this->hora_final, NULL, NULL, 1, $this->hora_inicio_intervalo, $this->hora_fim_intervalo); if ($obj->existe()) { $cadastrou = $obj->edita(); } else { $cadastrou = $obj->cadastra(); } if ($cadastrou) { if ($this->disciplinas) { foreach ($this->disciplinas as $key => $campo) { $obj = new clsPmieducarEscolaSerieDisciplina($this->ref_cod_serie, $this->ref_cod_escola, $campo, 1, $this->carga_horaria[$key]); if ($obj->existe()) { $cadastrou1 = $obj->edita(); } else { $cadastrou1 = $obj->cadastra(); } if (!$cadastrou1) { $this->mensagem = 'Cadastro não realizado.<br>'; echo "<!--\nErro ao cadastrar clsPmieducarEscolaSerieDisciplina\nvalores obrigatórios\nis_numeric( {$this->ref_cod_serie} ) && is_numeric( {$this->ref_cod_escola} ) && is_numeric( {$campo[$i]} ) \n-->"; return FALSE; } } } $this->mensagem .= 'Cadastro efetuado com sucesso.<br>'; header('Location: educar_escola_serie_lst.php'); die; } $this->mensagem = 'Cadastro não realizado.<br>'; echo "<!--\nErro ao cadastrar clsPmieducarEscolaSerie\nvalores obrigatorios\nis_numeric( {$this->ref_cod_escola} ) && is_numeric( {$this->ref_cod_serie} ) && is_numeric( {$this->pessoa_logada} ) && ( {$this->hora_inicial} ) && ( {$this->hora_final} ) && ( {$this->hora_inicio_intervalo} ) && ( {$this->hora_fim_intervalo} )\n-->"; return FALSE; }