コード例 #1
0
 function Editar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     @session_write_close();
     $obj_permissoes = new clsPermissoes();
     $obj_permissoes->permissao_cadastra(561, $this->pessoa_logada, 3, "educar_escola_lst.php");
     //
     //		echo "<br>cep: ".$this->cep;
     //		echo "<br>cep_: ".$this->cep_;die;
     if ($this->cod_escola) {
         $obj = new clsPmieducarEscola($this->cod_escola, null, $this->pessoa_logada, $this->ref_cod_instituicao, $this->ref_cod_escola_localizacao, $this->ref_cod_escola_rede_ensino, $this->ref_idpes, $this->sigla, null, null, 1);
         $editou = $obj->edita();
     } else {
         $obj = new clsPmieducarEscola(null, $this->pessoa_logada, null, $this->ref_cod_instituicao, $this->ref_cod_escola_localizacao, $this->ref_cod_escola_rede_ensino, $this->ref_idpes, $this->sigla, null, null, 1);
         $editou = $obj->cadastra();
         $this->cod_escola = $editou;
     }
     if ($editou) {
         if ($this->com_cnpj) {
             $objPessoa = new clsPessoa_($this->ref_idpes, null, false, $this->p_http, false, $this->pessoa_logada, date("Y-m-d H:i:s", time()), $this->p_email);
             $editou1 = $objPessoa->edita();
             if ($editou1) {
                 $obj_pes_juridica = new clsJuridica($this->ref_idpes, $this->cnpj, $this->fantasia, false, false, false, $this->pessoa_logada);
                 $editou2 = $obj_pes_juridica->edita();
                 if ($editou2) {
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes);
                     $objTelefone->excluiTodos();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 1, str_replace("-", "", $this->p_telefone_1), $this->p_ddd_telefone_1);
                     $objTelefone->cadastra();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 2, str_replace("-", "", $this->p_telefone_2), $this->p_ddd_telefone_2);
                     $objTelefone->cadastra();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 3, str_replace("-", "", $this->p_telefone_mov), $this->p_ddd_telefone_mov);
                     $objTelefone->cadastra();
                     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 4, str_replace("-", "", $this->p_telefone_fax), $this->p_ddd_telefone_fax);
                     $objTelefone->cadastra();
                     $objEndereco = new clsPessoaEndereco($this->ref_idpes);
                     $detEndereco = $objEndereco->detalhe();
                     if ($this->cep) {
                         $this->cep_ = idFederal2int($this->cep);
                     }
                     $this->cep = $this->cep;
                     //echo "$this->ref_idpes, $this->cep_, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, false, false, false, $this->andar ";die;
                     //echo "<pre>";print_r($this);die;
                     /*					$objEndereco2 = new clsPessoaEndereco( $this->ref_idpes, $this->cep_, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, false, false, false, $this->andar );
                     						if ( $detEndereco && $this->cep_ && $this->idlog && $this->idbai )
                     							$objEndereco2->edita();
                     						elseif ( $this->cep_ && $this->idlog && $this->idbai )
                     							$objEndereco2->cadastra();
                     
                     						elseif ( $detEndereco )
                     						{
                     							$objEndereco2->exclui();
                     							//$this->cep = $this->cep;
                     							$objEnderecoExterno = new clsEnderecoExterno( $this->ref_idpes );
                     							$detEnderecoExterno = $objEnderecoExterno->detalhe();
                     
                     							//$this->cep = idFederal2int($this->cep) ;
                     							$objEnderecoExterno2 = new clsEnderecoExterno( $this->ref_idpes, "1", $this->idtlog, $this->logradouro, $this->numero, false, $this->complemento, $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, false, false, false, $this->andar );
                     							if( $detEnderecoExterno )
                     							{
                     								$objEnderecoExterno2->edita();
                     								if ( $detEndereco )
                     									$objEndereco->exclui();
                     							}
                     							else
                     							{
                     								$objEnderecoExterno2->cadastra();
                     								if ( $detEndereco )
                     									$objEndereco->exclui();
                     							}
                     						}
                     						else
                     						{
                     							$objEnderecoExterno = new clsEnderecoExterno( $this->ref_idpes );
                     							$detEnderecoExterno = $objEnderecoExterno->detalhe();
                     
                     							$objEnderecoExterno2 = new clsEnderecoExterno( $this->ref_idpes, "1", $this->idtlog, $this->logradouro, $this->numero, false, $this->complemento, $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, false, false, false, $this->andar );
                     							if( $detEnderecoExterno )
                     							{
                     								$objEnderecoExterno2->edita();
                     							}
                     							else
                     							{
                     								$objEnderecoExterno2->cadastra();
                     							}
                     						}*/
                     if (!$this->isEnderecoExterno) {
                         //							die("Interno");
                         //							echo "<br>cep: ".$this->cep_;
                         //							$this->cep = idFederal2Int( $this->cep );
                         $this->cep = $this->cep_;
                         //							echo "<br>cep: ".$this->cep;
                         //							echo "<br>clsPessoaEndereco( $this->ref_idpes, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false )";die;
                         $objEndereco = new clsPessoaEndereco($this->ref_idpes, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false);
                         if ($objEndereco->detalhe()) {
                             $objEndereco->edita();
                         } else {
                             $objEndereco->cadastra();
                         }
                     } else {
                         //							echo "<br>Externo";
                         //							echo "<br>cep_: ".$this->cep_;
                         $this->cep = idFederal2int($this->cep);
                         //							echo "<br>cep: ".$this->cep;
                         //							echo "<br>clsEnderecoExterno( $this->ref_idpes, 1, $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep, $this->cidade, $this->sigla_uf, false )";
                         $objEnderecoExterno = new clsEnderecoExterno($this->ref_idpes, "1", $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep, $this->cidade, $this->sigla_uf, false);
                         if ($objEnderecoExterno->existe()) {
                             //								echo "<br>editar";
                             $objEnderecoExterno->edita();
                         } else {
                             //								echo "<br>cadastra";
                             $objEnderecoExterno->cadastra();
                         }
                     }
                     //-----------------------EDITA CURSO------------------------//
                     $this->escola_curso = unserialize(urldecode($this->escola_curso));
                     $obj = new clsPmieducarEscolaCurso($this->cod_escola);
                     $excluiu = $obj->excluirTodos();
                     if ($excluiu) {
                         if ($this->escola_curso) {
                             //								die("com cnpj");
                             foreach ($this->escola_curso as $campo) {
                                 $obj = new clsPmieducarEscolaCurso($this->cod_escola, $campo, null, $this->pessoa_logada, null, null, 1);
                                 $cadastrou_ = $obj->cadastra();
                                 if (!$cadastrou_) {
                                     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
                                     echo "<!--\nErro ao editar clsPmieducarEscolaCurso\nvalores obrigat&oacute;rios\nis_numeric( {$this->cod_serie} ) && is_numeric( {$campo} ) && is_numeric( {$this->pessoa_logada} )\n-->";
                                     return false;
                                 }
                             }
                         }
                     }
                     //-----------------------FIM EDITA CURSO------------------------//
                     $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
                     header("Location: educar_escola_lst.php");
                     die;
                     return true;
                 }
                 /*if($this->cep && $this->idbai && $this->idlog)
                 		{
                 			$objEndereco = new clsPessoaEndereco( $this->ref_idpes );
                 			$objEndereco2 = new clsPessoaEndereco($this->ref_idpes,$this->cep,$this->idlog,$this->idbai,$this->numero,$this->complemento, false,false, false, false, $this->andar);
                 			if( $objEndereco->detalhe() )
                 			{
                 				$objEndereco2->edita();
                 			}
                 			else
                 			{
                 				$objEndereco2->cadastra();
                 			}
                 			$objPessoa = new clsPessoaFj();
                 			list( $this->cidade, $this->bairro, $this->logradouro, $this->cep, $this->idtlog, $this->sigla_uf, $this->bloco, $this->apartamento, $this->andar ) = $objPessoa->queryRapida($this->ref_idpes, "cidade", "bairro", "logradouro", "cep", "idtlog", "sigla_uf", "bloco", "apartamento", "andar" );
                 		}
                 		else
                 		{
                 			$this->cep_ = idFederal2int($this->cep_);
                 			$objEnderecoExterno = new clsEnderecoExterno( $this->ref_idpes );
                 			$objEnderecoExterno2 = new clsEnderecoExterno( $this->ref_idpes,"1",$this->idtlog,$this->logradouro,$this->numero,false,$this->complemento,$this->bairro,$this->cep_,$this->cidade,$this->sigla_uf,false,false,false, $this->andar);
                 			if( $objEnderecoExterno->detalhe() )
                 			{
                 				$objEnderecoExterno2->edita();
                 			}
                 			else
                 			{
                 				$objEnderecoExterno2->cadastra();
                 			}
                 		}*/
             }
         } else {
             if ($this->sem_cnpj) {
                 $objComplemento = new clsPmieducarEscolaComplemento($this->cod_escola, $this->pessoa_logada, null, idFederal2int($this->cep_), $this->numero, $this->complemento, $this->p_email, $this->fantasia, $this->cidade, $this->bairro, $this->logradouro, $this->p_ddd_telefone_1, $this->p_telefone_1, $this->p_ddd_telefone_fax, $this->p_telefone_fax);
                 $editou1 = $objComplemento->edita();
                 if ($editou1) {
                     //-----------------------EDITA CURSO------------------------//
                     $this->escola_curso = unserialize(urldecode($this->escola_curso));
                     $obj = new clsPmieducarEscolaCurso($this->cod_escola);
                     $excluiu = $obj->excluirTodos();
                     if ($excluiu) {
                         if ($this->escola_curso) {
                             //							die("sem cnpj");
                             foreach ($this->escola_curso as $campo) {
                                 $obj = new clsPmieducarEscolaCurso($this->cod_escola, $campo, null, $this->pessoa_logada, null, null, 1);
                                 $cadastrou_ = $obj->cadastra();
                                 if (!$cadastrou_) {
                                     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
                                     echo "<!--\nErro ao editar clsPmieducarEscolaCurso\nvalores obrigat&oacute;rios\nis_numeric( {$this->cod_serie} ) && is_numeric( {$campo[$i]} ) && is_numeric( {$this->pessoa_logada} )\n-->";
                                     return false;
                                 }
                             }
                         }
                     }
                     //-----------------------FIM EDITA CURSO------------------------//
                     $this->mensagem .= "Edi&ccedil;&atilde;o efetuada com sucesso.<br>";
                     header("Location: educar_escola_lst.php");
                     die;
                     return true;
                 } else {
                     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada (clsPmieducarEscolaComplemento).<br>";
                     //					echo "<!--\nErro ao editar clsPmieducarEscola\nvalores obrigatorios\nif( is_numeric( $this->cod_escola ) && is_numeric( $this->pessoa_logada ) )\n-->";
                     return false;
                 }
             }
         }
     }
     $this->mensagem = "Edi&ccedil;&atilde;o n&atilde;o realizada.<br>";
     echo "<!--\nErro ao editar clsPmieducarEscola\nvalores obrigatorios\nif( is_numeric( {$this->cod_escola} ) && is_numeric( {$this->pessoa_logada} ) )\n-->";
     return false;
 }
コード例 #2
0
 function Novo()
 {
     session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     if (!$this->cpf && $this->cpf_2) {
         $cpf = idFederal2int($this->cpf_2);
         $obj_pessoa_fisica = new clsPessoaFisica();
         $lst_pessoa_fisica = $obj_pessoa_fisica->lista(NULL, $cpf);
         if ($lst_pessoa_fisica) {
             $this->mensagem = 'CPF Já Cadastrado';
             return FALSE;
         } else {
             die('CPF Não Existente');
         }
     }
     $obj_pessoa = new clsPessoa_($this->ref_idpes);
     if ($obj_pessoa->detalhe()) {
         $obj_pessoa = new clsPessoa_($this->ref_idpes, $this->nome, NULL, $this->url, NULL, $this->pessoa_logada, NULL, $this->email);
         if (!$obj_pessoa->edita()) {
             return false;
         }
     } else {
         $obj_pessoa = new clsPessoa_($this->ref_idpes, $this->nome, NULL, $this->url, 'F', $this->pessoa_logada, NULL, $this->email);
         if (!($this->ref_idpes = $obj_pessoa->cadastra())) {
             return FALSE;
         }
     }
     if (!$this->cpf) {
         $this->ref_cod_sistema = 1;
     } else {
         $this->ref_cod_sistema = 'NULL';
     }
     if (is_string($this->cpf_pai) && $this->cpf_pai != '') {
         $this->cpf_pai = idFederal2int($this->cpf_pai);
         $obj_cpf = new clsFisica(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->cpf_pai);
         $detalhe_cpf = $obj_cpf->detalheCPF();
         if ($detalhe_cpf) {
             $this->idpes_pai = $detalhe_cpf['idpes'];
             $obj_pessoa = new clsPessoa_($this->idpes_pai);
             $det_pessoa = $obj_pessoa->detalhe();
             if ($det_pessoa) {
                 if ($this->nm_pai) {
                     $obj_pessoa = new clsPessoa_($this->idpes_pai, $this->nm_pai);
                     $obj_pessoa->edita();
                 } else {
                     $this->nm_pai = $det_pessoa['nome'];
                 }
             }
         } else {
             // cria uma pessoa para o pai
             $obj_pessoa = new clsPessoa_(FALSE, $this->nm_pai, $this->pessoa_logada, FALSE, 'F');
             $idpes = $obj_pessoa->cadastra();
             if ($idpes) {
                 $this->idpes_pai = $idpes;
                 //cadastra como pesso Fisica
                 $obj_fisica = new clsFisica($idpes, FALSE, 'M', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->pessoa_logada, NULL, NULL, $this->cpf_pai);
                 $obj_fisica->cadastra();
             }
         }
     } else {
         $this->idpes_pai = "NULL";
     }
     if (is_string($this->cpf_mae) && $this->cpf_mae != "") {
         $this->cpf_mae = idFederal2int($this->cpf_mae);
         $obj_cpf = new clsFisica(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->cpf_mae);
         $detalhe_cpf = $obj_cpf->detalheCPF();
         if ($detalhe_cpf) {
             $this->idpes_mae = $detalhe_cpf['idpes'];
             $obj_pessoa = new clsPessoa_($this->idpes_mae);
             $det_pessoa = $obj_pessoa->detalhe();
             if ($det_pessoa) {
                 if ($this->nm_mae) {
                     $obj_pessoa = new clsPessoa_($this->idpes_mae, $this->nm_mae);
                     $obj_pessoa->edita();
                 } else {
                     $this->nm_mae = $det_pessoa['nome'];
                 }
             }
         } else {
             // cria uma pessoa para a mae
             $obj_pessoa = new clsPessoa_(FALSE, $this->nm_mae, $this->pessoa_logada, FALSE, 'F');
             $idpes = $obj_pessoa->cadastra();
             if ($idpes) {
                 $this->idpes_mae = $idpes;
                 //cadastra como pesso Fisica
                 $obj_fisica = new clsFisica($idpes, FALSE, 'F', FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $this->pessoa_logada, NULL, NULL, $this->cpf_mae);
                 $obj_fisica->cadastra();
             }
         }
     } else {
         $this->idpes_mae = "NULL";
     }
     $obj_fisica = new clsFisica($this->ref_idpes, dataToBanco($this->data_nascimento), $this->sexo, $this->idpes_mae, $this->idpes_pai, $this->ref_idpes_responsavel, NULL, $this->ideciv, NULL, NULL, NULL, $this->nacionalidade, $this->pais_origem, NULL, $this->idmun_nascimento, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->pessoa_logada, $this->ref_cod_sistema, $this->cpf);
     if ($obj_fisica->detalhe()) {
         if (!$this->ref_idpes_responsavel) {
             $this->ref_idpes_responsavel = "NULL";
         }
         $obj_fisica = new clsFisica($this->ref_idpes, dataToBanco($this->data_nascimento), $this->sexo, $this->idpes_mae, $this->idpes_pai, $this->ref_idpes_responsavel, NULL, $this->ideciv, NULL, NULL, NULL, $this->nacionalidade, $this->pais_origem, NULL, $this->idmun_nascimento, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->pessoa_logada, $this->ref_cod_sistema);
         if (!$obj_fisica->edita()) {
             return FALSE;
         }
     } else {
         $obj_fisica = new clsFisica($this->ref_idpes, dataToBanco($this->data_nascimento), $this->sexo, $this->idpes_mae, $this->idpes_pai, $this->ref_idpes_responsavel, NULL, $this->ideciv, NULL, NULL, NULL, $this->nacionalidade, $this->pais_origem, NULL, $this->idmun_nascimento, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, $this->pessoa_logada, $this->ref_cod_sistema, $this->cpf);
         if (!$obj_fisica->cadastra()) {
             return FALSE;
         }
     }
     if (is_numeric($this->ref_cod_raca)) {
         $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes);
         if ($obj_fisica_raca->existe()) {
             $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes, $this->ref_cod_raca);
             $obj_fisica_raca->edita();
         } else {
             $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes, $this->ref_cod_raca);
             $obj_fisica_raca->cadastra();
         }
     } else {
         $obj_fisica_raca = new clsCadastroFisicaRaca($this->ref_idpes, $this->ref_cod_raca);
         $obj_fisica_raca->excluir();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 1, $this->fone_1, $this->ddd_fone_1);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 2, $this->fone_2, $this->ddd_fone_2);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 3, $this->fone_mov, $this->ddd_mov);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     $objTelefone = new clsPessoaTelefone($this->ref_idpes, 4, $this->fone_fax, $this->ddd_fax);
     if ($objTelefone->detalhe()) {
         $objTelefone->edita();
     } else {
         $objTelefone->cadastra();
     }
     if ($this->isEnderecoExterno) {
         $this->cep_ = str_replace('-', '', $this->cep_);
         $obj_endereco = new clsEnderecoExterno($this->ref_idpes, 1, $this->ref_idtlog, $this->nm_logradouro, $this->numero, $this->letra, $this->complemento, $this->nm_bairro, $this->cep_, $this->cidade, $this->ref_sigla_uf_, NULL, $this->bloco, $this->apartamento, $this->andar, NULL, $this->pessoa_logada, $this->zona_localizacao);
         if ($obj_endereco->existe()) {
             if (!$obj_endereco->edita()) {
                 return FALSE;
             }
         } else {
             if (!$obj_endereco->cadastra()) {
                 return FALSE;
             }
         }
         if ($this->endereco_original_is_externo != $this->isEnderecoExterno) {
             $obj_endereco = new clsPessoaEndereco($this->ref_idpes);
             $obj_endereco->exclui();
         }
     } else {
         $obj_endereco = new clsPessoaEndereco($this->ref_idpes, $this->id_cep, $this->id_logradouro, $this->id_bairro, $this->numero, $this->complemento, NULL, $this->letra, $this->bloco, $this->apartamento, $this->andar, null, $this->pessoa_logada);
         if ($obj_endereco->existe()) {
             if (!$obj_endereco->edita()) {
                 return FALSE;
             }
         } else {
             if (!$obj_endereco->cadastra()) {
                 return FALSE;
             }
         }
         if ($this->endereco_original_is_externo != $this->isEnderecoExterno) {
             $obj_endereco = new clsEnderecoExterno($this->ref_idpes);
             $obj_endereco->exclui();
         }
     }
     $this->deficiencia_exc = $_POST['oc_defic_exc'];
     if ($this->deficiencia_exc) {
         foreach ($this->deficiencia_exc as $key => $deficiencia) {
             $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia($this->ref_idpes, $deficiencia);
             if ($obj_deficiencia_pessoa->detalhe()) {
                 $obj_deficiencia_pessoa->excluir();
             }
         }
     }
     $this->deficiencia = $_POST['oc_defic'];
     if ($this->deficiencia) {
         foreach ($this->deficiencia as $key => $deficiencia) {
             $obj_deficiencia_pessoa = new clsCadastroFisicaDeficiencia($this->ref_idpes, $key);
             if (!$obj_deficiencia_pessoa->detalhe()) {
                 $obj_deficiencia_pessoa->cadastra();
             }
         }
     }
     if ($this->data_emissao_cart_trabalho) {
         $this->data_emissao_cart_trabalho = explode('/', $this->data_emissao_cart_trabalho);
         $this->data_emissao_cart_trabalho = "{$this->data_emissao_cart_trabalho[2]}/{$this->data_emissao_cart_trabalho[1]}/{$this->data_emissao_cart_trabalho[0]}";
     }
     if ($this->data_emissao_cert_civil) {
         $this->data_emissao_cert_civil = explode('/', $this->data_emissao_cert_civil);
         $this->data_emissao_cert_civil = "{$this->data_emissao_cert_civil[2]}/{$this->data_emissao_cert_civil[1]}/{$this->data_emissao_cert_civil[0]}";
     }
     if ($this->data_exp_rg) {
         $this->data_exp_rg = explode('/', $this->data_exp_rg);
         $this->data_exp_rg = "{$this->data_exp_rg[2]}/{$this->data_exp_rg[1]}/{$this->data_exp_rg[0]}";
     }
     $ObjDocumento = new clsDocumento($this->ref_idpes, $this->rg, $this->data_exp_rg, $this->sigla_uf_exp_rg, $this->tipo_cert_civil, $this->num_termo, $this->num_livro, $this->num_folha, $this->data_emissao_cert_civil, $this->sigla_uf_cert_civil, $this->cartorio_cert_civil, $this->num_cart_trabalho, $this->serie_cart_trabalho, $this->data_emissao_cart_trabalho, $this->sigla_uf_cart_trabalho, $this->num_tit_eleitor, $this->zona_tit_eleitor, $this->secao_tit_eleitor, $this->idorg_exp_rg);
     if ($ObjDocumento->detalhe()) {
         $ObjDocumento = new clsDocumento($this->ref_idpes, $this->rg, $this->data_exp_rg, $this->sigla_uf_exp_rg, $this->tipo_cert_civil, $this->num_termo, $this->num_livro, $this->num_folha, $this->data_emissao_cert_civil, $this->sigla_uf_cert_civil, $this->cartorio_cert_civil, $this->num_cart_trabalho, $this->serie_cart_trabalho, $this->data_emissao_cart_trabalho, $this->sigla_uf_cart_trabalho, $this->num_tit_eleitor, $this->zona_tit_eleitor, $this->secao_tit_eleitor, $this->idorg_exp_rg);
         if (!$ObjDocumento->edita()) {
             return FALSE;
         }
     } else {
         $ObjDocumento = new clsDocumento($this->ref_idpes, $this->rg, $this->data_exp_rg, $this->sigla_uf_exp_rg, $this->tipo_cert_civil, $this->num_termo, $this->num_livro, $this->num_folha, $this->data_emissao_cert_civil, $this->sigla_uf_cert_civil, $this->cartorio_cert_civil, $this->num_cart_trabalho, $this->serie_cart_trabalho, $this->data_emissao_cart_trabalho, $this->sigla_uf_cart_trabalho, $this->num_tit_eleitor, $this->zona_tit_eleitor, $this->secao_tit_eleitor, $this->idorg_exp_rg);
         if (!$ObjDocumento->cadastra()) {
             return FALSE;
         }
     }
     if ($this->foto && $this->foto['error'] == 0) {
         $this->foto = $this->geraFotos($this->foto['tmp_name']);
         $obj = new clsPmieducarAluno(NULL, $this->ref_cod_aluno_beneficio, $this->ref_cod_religiao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_idpes, NULL, NULL, 1, $this->foto, $this->analfabeto, $this->nm_pai, $this->nm_mae);
         $obj_det = $obj->detalhe();
         if ($obj_det) {
             if ($obj_det['caminho_foto']) {
                 $this->caminho_foto = $obj_det['caminho_foto'];
             }
             $this->foto_excluida = 1;
         }
     } elseif ($this->foto_excluida == 1) {
         $this->foto = 'NULL';
     } elseif (!$this->foto_excluida) {
         $this->foto = $this->foto_antiga;
     }
     if ($this->foto_excluida) {
         if (file_exists('arquivos/educar/aluno/big/' . $this->caminho_foto)) {
             unlink('arquivos/educar/aluno/big/' . $this->caminho_foto);
         }
         if (file_exists('arquivos/educar/aluno/small/' . $this->caminho_foto)) {
             unlink('arquivos/educar/aluno/small/' . $this->caminho_foto);
         }
         if (file_exists('arquivos/educar/aluno/original/' . $this->caminho_foto)) {
             unlink('arquivos/educar/aluno/original/' . $this->caminho_foto);
         }
     }
     if (is_numeric($this->idpes_mae) && $this->idpes_mae != 'NULL') {
         $this->nm_mae = 'NULL';
     }
     if (is_numeric($this->idpes_pai) && $this->idpes_pai != 'NULL') {
         $this->nm_pai = 'NULL';
     }
     if (!$this->cod_aluno) {
         $obj = new clsPmieducarAluno(NULL, $this->ref_cod_aluno_beneficio, $this->ref_cod_religiao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_idpes, NULL, NULL, 1, $this->foto, $this->analfabeto, $this->nm_pai, $this->nm_mae, $this->tipo_responsavel);
         if ($this->ref_idpes) {
             if ($obj->existePessoa()) {
                 $aluno = $obj->edita();
                 $this->cod_aluno = $aluno['cod_aluno'];
             } else {
                 $this->cod_aluno = $obj->cadastra();
             }
         }
     } else {
         $obj = new clsPmieducarAluno($this->cod_aluno, $this->ref_cod_aluno_beneficio, $this->ref_cod_religiao, $this->pessoa_logada, $this->pessoa_logada, $this->ref_idpes, NULL, NULL, 1, $this->foto, $this->analfabeto, $this->nm_pai, $this->nm_mae, $this->tipo_responsavel);
         if ($this->ref_idpes) {
             if ($obj->existePessoa()) {
                 $obj->edita();
             } else {
                 $obj->cadastra();
             }
         }
     }
     // Atualiza a informação de uso de transporte escolar.
     $this->_cadastraTransporte($this->cod_aluno, $this->transporte_aluno, $this->transporte_responsavel, $this->pessoa_logada);
     header('Location: educar_aluno_det.php?cod_aluno=' . $this->cod_aluno);
     die;
 }