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ção não realizada.<br>"; echo "<!--\nErro ao editar clsPmieducarEscolaCurso\nvalores obrigatórios\nis_numeric( {$this->cod_serie} ) && is_numeric( {$campo} ) && is_numeric( {$this->pessoa_logada} )\n-->"; return false; } } } } //-----------------------FIM EDITA CURSO------------------------// $this->mensagem .= "Ediçã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ção não realizada.<br>"; echo "<!--\nErro ao editar clsPmieducarEscolaCurso\nvalores obrigatórios\nis_numeric( {$this->cod_serie} ) && is_numeric( {$campo[$i]} ) && is_numeric( {$this->pessoa_logada} )\n-->"; return false; } } } } //-----------------------FIM EDITA CURSO------------------------// $this->mensagem .= "Edição efetuada com sucesso.<br>"; header("Location: educar_escola_lst.php"); die; return true; } else { $this->mensagem = "Edição nã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ção não realizada.<br>"; echo "<!--\nErro ao editar clsPmieducarEscola\nvalores obrigatorios\nif( is_numeric( {$this->cod_escola} ) && is_numeric( {$this->pessoa_logada} ) )\n-->"; return false; }
public function Editar() { session_start(); $pessoaFj = $_SESSION['id_pessoa']; session_write_close(); $objPessoa = new clsPessoa_($pessoaFj, FALSE, FALSE, $this->p_http, FALSE, $pessoaFj, date("Y-m-d H:i:s", time()), $this->p_email); $objPessoa->edita(); $objFisica = new clsFisica($pessoaFj, FALSE, $this->p_sexo); $objFisica->edita(); $objTelefone = new clsPessoaTelefone($pessoaFj); $objTelefone->excluiTodos(); $objTelefone = new clsPessoaTelefone($pessoaFj, 1, str_replace("-", "", $this->p_telefone_1), $this->p_ddd_telefone_1); $objTelefone->cadastra(); $objTelefone = new clsPessoaTelefone($pessoaFj, 2, str_replace("-", "", $this->p_telefone_2), $this->p_ddd_telefone_2); $objTelefone->cadastra(); $objTelefone = new clsPessoaTelefone($pessoaFj, 3, str_replace("-", "", $this->p_telefone_mov), $this->p_ddd_telefone_mov); $objTelefone->cadastra(); $objTelefone = new clsPessoaTelefone($pessoaFj, 4, str_replace("-", "", $this->p_telefone_fax), $this->p_ddd_telefone_fax); $objTelefone->cadastra(); if ($this->cep && $this->idbai && $this->idlog) { $objEndereco = new clsPessoaEndereco($pessoaFj); $objEndereco2 = new clsPessoaEndereco($pessoaFj, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, FALSE, $this->letra, $this->bloco, $this->apartamento, $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($pessoaFj, "cidade", "bairro", "logradouro", "cep", "idtlog", "sigla_uf", "bloco", "apartamento", "andar"); } else { $this->cep_ = idFederal2int($this->cep_); $objEnderecoExterno = new clsEnderecoExterno($pessoaFj); $objEnderecoExterno2 = new clsEnderecoExterno($pessoaFj, "1", $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, FALSE, $this->bloco, $this->apartamento, $this->andar); if ($objEnderecoExterno->detalhe()) { $objEnderecoExterno2->edita(); } else { $objEnderecoExterno2->cadastra(); } } // Verifica o maior setor selecionado for ($i = 0; $i < 5; $i++) { $varNm = "setor_{$i}"; if ($this->{$varNm}) { $setor = $this->{$varNm}; } } if ($setor) { $sql = " ref_cod_setor_new = '{$setor}', "; } if ($this->f_senha != $this->confere_senha) { $sql_funcionario = "UPDATE funcionario SET senha=md5('{$this->f_senha}'), data_troca_senha = NOW(), ref_cod_funcionario_vinculo='{$this->ref_cod_funcionario_vinculo}', {$sql} ramal='{$this->f_ramal}', ref_ref_cod_pessoa_fj='{$pessoaFj}', tempo_expira_senha = 30 WHERE ref_cod_pessoa_fj={$this->p_cod_pessoa_fj}"; } else { if (empty($_SESSION['convidado'])) { $sql_funcionario = "UPDATE funcionario SET {$sql} ramal='{$this->f_ramal}', ref_cod_funcionario_vinculo='{$this->ref_cod_funcionario_vinculo}', ref_ref_cod_pessoa_fj='{$pessoaFj}' WHERE ref_cod_pessoa_fj={$this->p_cod_pessoa_fj}"; } else { $sql_funcionario = "UPDATE funcionario SET {$sql} ramal='{$this->f_ramal}', ref_ref_cod_pessoa_fj='{$pessoaFj}' WHERE ref_cod_pessoa_fj={$this->p_cod_pessoa_fj}"; } } $db = new clsBanco(); $db->Consulta($sql_funcionario); if (empty($_SESSION['convidado'])) { if (!$_POST["reloading"]) { } } else { if ($_SESSION['motivo_visita'] == 'atualizar_cadastro_e_email') { echo "<script>document.location='solicita_email.php';</script>"; } else { echo "<script>document.location='insmess_cad.php';</script>"; } } header('Location: index.php'); return TRUE; }