Example #1
0
 function Novo()
 {
     $this->cnpj = idFederal2int(urldecode($this->cnpj));
     $objJuridica = new clsJuridica(false, $this->cnpj);
     $detalhJuridica = $objJuridica->detalhe();
     if (!$detalhJuridica) {
         $this->insc_est = idFederal2int($this->insc_est);
         $this->idpes_cad = $_SESSION["id_pessoa"];
         $objPessoa = new clsPessoa_(false, $this->razao_social, $this->idpes_cad, $this->url, "J", false, false, $this->email);
         $this->cod_pessoa_fj = $objPessoa->cadastra();
         $objJuridica = new clsJuridica($this->cod_pessoa_fj, $this->cnpj, $this->fantasia, $this->insc_est, $this->capital_social);
         $objJuridica->cadastra();
         if ($this->telefone_1) {
             $this->telefone_1 = str_replace("-", "", $this->telefone_1);
             if (is_numeric($this->telefone_1)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
                 $objTelefone->cadastra();
             }
         }
         if ($this->telefone_2) {
             $this->telefone_2 = str_replace("-", "", $this->telefone_2);
             if (is_numeric($this->telefone_2)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
                 $objTelefone->cadastra();
             }
         }
         if ($this->telefone_mov) {
             $this->telefone_mov = str_replace("-", "", $this->telefone_mov);
             if (is_numeric($this->telefone_mov)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
                 $objTelefone->cadastra();
             }
         }
         if ($this->telefone_fax) {
             $this->telefone_fax = str_replace("-", "", $this->telefone_fax);
             if (is_numeric($this->telefone_fax)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
                 $objTelefone->cadastra();
             }
         }
         if ($this->cep && $this->idbai && $this->idlog) {
             $this->cep = idFederal2Int($this->cep);
             $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, $this->letra);
             $objEndereco->cadastra();
         } else {
             $this->cep_ = idFederal2int($this->cep_);
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj, "1", $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep_, $this->cidade, $this->sigla_uf, false);
             $objEnderecoExterno->cadastra();
         }
         header("Location: empresas_lst.php");
         return true;
     }
     $this->mensagem = "Ja existe uma empresa cadastrada com este CNPJ. ";
     return false;
 }
Example #2
0
 function Novo()
 {
     @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");
     if ($this->com_cnpj) {
         //			echo "clsPessoa_( false, $this->fantasia, $this->pessoa_logada, $this->p_http, "J", false, false, $this->p_email )";
         $objPessoa = new clsPessoa_(false, $this->fantasia, $this->pessoa_logada, $this->p_http, "J", false, false, $this->p_email);
         $this->ref_idpes = $objPessoa->cadastra();
         if ($this->ref_idpes) {
             //				echo "clsJuridica( $this->ref_idpes,$this->cnpj,$this->fantasia,false,false,$this->pessoa_logada )";
             $obj_pes_juridica = new clsJuridica($this->ref_idpes, $this->cnpj, $this->fantasia, false, false, $this->pessoa_logada);
             $cadastrou = $obj_pes_juridica->cadastra();
             if ($cadastrou) {
                 $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);
                 $cadastrou1 = $obj->cadastra();
                 if ($cadastrou1) {
                     $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();
                     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();
                         }
                     }
                     //-----------------------CADASTRA CURSO------------------------//
                     $this->escola_curso = unserialize(urldecode($this->escola_curso));
                     if ($this->escola_curso) {
                         //							echo "<pre>";print_r($this->escola_curso);die;
                         foreach ($this->escola_curso as $campo) {
                             $curso_escola = new clsPmieducarEscolaCurso($cadastrou1, $campo, null, $this->pessoa_logada, null, null, 1);
                             $cadastrou_ = $curso_escola->cadastra();
                             if (!$cadastrou_) {
                                 $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
                                 echo "<!--\nErro ao cadastrar clsPmieducarEscolaCurso\nvalores obrigat&oacute;rios\nis_numeric( {$cadastrou} ) && is_numeric( {$campo} ) \n-->";
                                 return false;
                             }
                         }
                     }
                     //-----------------------FIM CADASTRA CURSO------------------------//
                 } else {
                     $this->mensagem = "Cadastro n&atilde;o realizado (clsPmieducarEscola).<br>";
                     //						echo "<!--\nErro ao cadastrar clsPmieducarEscola\nvalores obrigat&oacute;rios\nis_numeric( $this->pessoa_logada ) && is_numeric( {$campo[$i]} ) \n-->";
                     return false;
                 }
             } else {
                 $this->mensagem = "Cadastro n&atilde;o realizado (clsJuridica).<br>";
                 //						echo "<!--\nErro ao cadastrar clsPmieducarEscola\nvalores obrigat&oacute;rios\nis_numeric( $this->pessoa_logada ) && is_numeric( {$campo[$i]} ) \n-->";
                 return false;
             }
             $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
             header("Location: educar_escola_lst.php");
             die;
             return true;
         } else {
             $this->mensagem = "Cadastro n&atilde;o realizado (clsPessoa_).<br>";
             return false;
         }
     } else {
         if ($this->sem_cnpj) {
             $obj = new clsPmieducarEscola(null, $this->pessoa_logada, null, $this->ref_cod_instituicao, $this->ref_cod_escola_localizacao, $this->ref_cod_escola_rede_ensino, null, $this->sigla, null, null, 1);
             $cadastrou = $obj->cadastra();
             if ($cadastrou) {
                 $obj2 = new clsPmieducarEscolaComplemento($cadastrou, null, $this->pessoa_logada, 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, null, null, 1);
                 $cadastrou2 = $obj2->cadastra();
                 if ($cadastrou2) {
                     //-----------------------CADASTRA CURSO------------------------//
                     $this->escola_curso = unserialize(urldecode($this->escola_curso));
                     if ($this->escola_curso) {
                         foreach ($this->escola_curso as $campo) {
                             $curso_escola = new clsPmieducarEscolaCurso($cadastrou, $campo, null, $this->pessoa_logada, null, null, 1);
                             $cadastrou_ = $curso_escola->cadastra();
                             if (!$cadastrou_) {
                                 $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
                                 echo "<!--\nErro ao cadastrar clsPmieducarEscolaCurso\nvalores obrigat&oacute;rios\nis_numeric( {$cadastrou} ) && is_numeric( {$campo} ) \n-->";
                                 return false;
                             }
                         }
                     }
                     //-----------------------FIM CADASTRA CURSO------------------------//
                     $this->mensagem .= "Cadastro efetuado com sucesso.<br>";
                     header("Location: educar_escola_lst.php");
                     die;
                     return true;
                 } else {
                     $this->mensagem = "Cadastro n&atilde;o realizado.<br>";
                     echo "<!--\nErro ao cadastrar clsPmieducarEscolaComplemento\nvalores obrigat&oacute;rios\nis_numeric( {$cadastrou} ) && is_numeric( {$this->pessoa_logada} ) && is_numeric( {$this->numero} ) && is_string( {$this->complemento} ) && is_string( {$this->p_email} ) && is_string( {$this->fantasia} ) && is_string( {$this->cidade} ) && is_string( {$this->bairro} )\n-->";
                     return false;
                 }
             } else {
                 $this->mensagem = "Cadastro n&atilde;o realizado (clsPmieducarEscola).<br>";
                 //				echo "<!--\nErro ao cadastrar clsPmieducarEscolaComplemento\nvalores obrigat&oacute;rios\nis_numeric( $cadastrou ) && is_numeric( $this->pessoa_logada ) && is_numeric( $this->numero ) && is_string( $this->complemento ) && is_string( $this->p_email ) && is_string( $this->fantasia ) && is_string( $this->cidade ) && is_string( $this->bairro )\n-->";
                 return false;
             }
         }
     }
 }
 function Novo()
 {
     @session_start();
     $pessoa_logada = $_SESSION['id_pessoa'];
     $parametros = new clsParametrosPesquisas();
     if ($_SESSION["campos"]) {
         $parametros->preencheAtributosComArray($_SESSION['campos']);
     }
     if (is_numeric(idFederal2int($this->cep_))) {
         $this->cep = idFederal2int($this->cep_);
     } else {
         $this->cep = idFederal2int($this->cep);
     }
     @session_write_close();
     if ($this->pessoa == "F") {
         if ($this->id_federal) {
             $this->id_federal = idFederal2int($this->id_federal);
             $objCPF = 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->id_federal);
             if ($objCPF->detalhe()) {
                 $this->erros['id_federal'] = "CPF j&aacute; cadastrado.";
                 return false;
             }
         }
         $objPessoa = new clsPessoa_(false, $this->nm_pessoa, $pessoaFj, $this->http, "F", false, false, $this->email);
         $idpes = $objPessoa->cadastra();
         $this->data_nasc = dataToBanco($this->data_nasc);
         if (is_numeric($this->id_federal)) {
             $this->id_federal = idFederal2Int($this->id_federal);
             $objFisica = new clsFisica($idpes, $this->data_nasc, $this->sexo, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, $this->id_federal);
             $objFisica->cadastra();
         } else {
             $objFisica = new clsFisica($idpes, $this->data_nasc, $this->sexo, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, $this->ref_cod_sistema);
             $objFisica->cadastra();
         }
         $objTelefone = new clsPessoaTelefone($idpes, 1, $this->telefone_1, $this->ddd_telefone_1);
         $objTelefone->cadastra();
         $objTelefone = new clsPessoaTelefone($idpes, 2, $this->telefone_2, $this->ddd_telefone_2);
         $objTelefone->cadastra();
         $objTelefone = new clsPessoaTelefone($idpes, 3, $this->telefone_mov, $this->ddd_telefone_mov);
         $objTelefone->cadastra();
         $objTelefone = new clsPessoaTelefone($idpes, 4, $this->telefone_fax, $this->ddd_telefone_fax);
         $objTelefone->cadastra();
         $this->cod_pessoa_fj = $idpes;
         $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj);
         $this->cep = $this->cep;
         $objEndereco2 = new clsPessoaEndereco($this->cod_pessoa_fj, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, $this->letra, $this->bloco, $this->apartamento, $this->andar);
         if ($objEndereco->detalhe() && $this->cep && $this->idlog && $this->idbai) {
             $objEndereco2->edita();
         } elseif ($this->cep && $this->idlog && $this->idbai) {
             $objEndereco2->cadastra();
         } elseif ($objEndereco->detalhe()) {
             $objEndereco2->exclui();
         } else {
             $this->cep = idFederal2int($this->cep);
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj);
             $objEnderecoExterno2 = new clsEnderecoExterno($this->cod_pessoa_fj, "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();
             }
         }
         if (is_numeric($idpes)) {
             $obj_pessoa = new clsPessoaFj($idpes);
             $pessoa = $obj_pessoa->detalhe();
         }
         if (is_numeric($idpes)) {
             $obj_pessoa = new clsPessoaFj($idpes);
             $pessoa = $obj_pessoa->lista_rapida($idpes);
             $pessoa = $pessoa[0];
             $funcao = " set_campo_pesquisa(";
             $virgula = "";
             $cont = 0;
             foreach ($parametros->getCampoNome() as $campo) {
                 if ($parametros->getCampoTipo($cont) == "text") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 } elseif ($parametros->getCampoTipo($cont) == "select") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 }
                 $cont++;
             }
             if ($parametros->getSubmit()) {
                 $funcao .= "{$virgula} 'submit' )";
             } else {
                 $funcao .= " )";
             }
             $this->executa_script = $funcao;
             /**
              * alteracao para executar script
              * em tabela dinamica
              * procon
              */
             if ($_GET['tab_dinamica'] == 'procon') {
                 $script = "function passaPraTraz(nome, id)\n\t\t\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\t\t\t// reclamada\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada[{$_GET['tab_dinamica_id']}]').value = nome;\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada_id[{$_GET['tab_dinamica_id']}]').value = id;\n\n\t\t\t\t\t\t\t\t\twindow.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));\n\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpassaPraTraz('{$pessoa['nome']}',{$idpes});";
                 $this->executa_script = $script;
             }
             return true;
         }
     } elseif ($this->pessoa == "J") {
         if ($this->id_federal) {
             $this->id_federal = idFederal2int($this->id_federal);
             $objCNPJ = new clsJuridica(false, $this->id_federal);
             if ($objCNPJ->detalhe()) {
                 $this->erros['id_federal'] = "CNPJ j&aacute; cadastrado.";
                 return false;
             }
         }
         $this->insc_est = idFederal2int($this->insc_est);
         $this->idpes_cad = $_SESSION["id_pessoa"];
         $objPessoa = new clsPessoa_(false, $this->razao_social, $this->idpes_cad, $this->url, "J", false, false, $this->email);
         $this->cod_pessoa_fj = $objPessoa->cadastra();
         $objJuridica = new clsJuridica($this->cod_pessoa_fj, $this->id_federal, $this->fantasia, $this->insc_est, $this->capital_social);
         $objJuridica->cadastra();
         if ($this->telefone_1) {
             $this->telefone_1 = str_replace("-", "", $this->telefone_1);
             if (is_numeric($this->telefone_1)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 1, $this->telefone_1, $this->ddd_telefone_1);
                 $objTelefone->cadastra();
             }
         }
         if ($this->telefone_2) {
             $this->telefone_2 = str_replace("-", "", $this->telefone_2);
             if (is_numeric($this->telefone_2)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 2, $this->telefone_2, $this->ddd_telefone_2);
                 $objTelefone->cadastra();
             }
         }
         if ($this->telefone_mov) {
             $this->telefone_mov = str_replace("-", "", $this->telefone_mov);
             if (is_numeric($this->telefone_mov)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 3, $this->telefone_mov, $this->ddd_telefone_mov);
                 $objTelefone->cadastra();
             }
         }
         if ($this->telefone_fax) {
             $this->telefone_fax = str_replace("-", "", $this->telefone_fax);
             if (is_numeric($this->telefone_fax)) {
                 $objTelefone = new clsPessoaTelefone($this->cod_pessoa_fj, 4, $this->telefone_fax, $this->ddd_telefone_fax);
                 $objTelefone->cadastra();
             }
         }
         if ($this->cep && $this->idbai && $this->idlog) {
             $this->cep = idFederal2Int($this->cep);
             $objEndereco = new clsPessoaEndereco($this->cod_pessoa_fj, $this->cep, $this->idlog, $this->idbai, $this->numero, $this->complemento, false, $this->letra);
             $objEndereco->cadastra();
         } else {
             $this->cep = idFederal2int($this->cep);
             $objEnderecoExterno = new clsEnderecoExterno($this->cod_pessoa_fj, "1", $this->idtlog, $this->logradouro, $this->numero, $this->letra, $this->complemento, $this->bairro, $this->cep, $this->cidade, $this->sigla_uf, false);
             $objEnderecoExterno->cadastra();
         }
         if (is_numeric($this->cod_pessoa_fj)) {
             $obj_pessoa = new clsPessoaFj($this->cod_pessoa_fj);
             $pessoa = $obj_pessoa->lista_rapida($this->cod_pessoa_fj);
             $pessoa = $pessoa[0];
             $funcao = " set_campo_pesquisa(";
             $virgula = "";
             $cont = 0;
             foreach ($parametros->getCampoNome() as $campo) {
                 if ($parametros->getCampoTipo($cont) == "text") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 } elseif ($parametros->getCampoTipo($cont) == "select") {
                     $funcao .= "{$virgula} '{$campo}', '{$pessoa[$parametros->getCampoIndice($cont)]}', '{$pessoa[$parametros->getCampoValor($cont)]}'";
                     $virgula = ",";
                 }
                 $cont++;
             }
             if ($parametros->getSubmit()) {
                 $funcao .= "{$virgula} 'submit' )";
             } else {
                 $funcao .= " )";
             }
             $this->executa_script = $funcao;
             /**
              * alteracao para executar script
              * em tabela dinamica
              * procon
              */
             if ($_GET['tab_dinamica'] == 'procon') {
                 $script = "function passaPraTraz(nome, id)\n\t\t\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\t\t\t// reclamada\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada[{$_GET['tab_dinamica_id']}]').value = nome;\n\t\t\t\t\t\t\t\t\twindow.parent.document.getElementById('reclamada_id[{$_GET['tab_dinamica_id']}]').value = id;\n\n\t\t\t\t\t\t\t\t\twindow.parent.fechaExpansivel('div_dinamico_'+(parent.DOM_divs.length*1-1));\n\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpassaPraTraz('{$pessoa['nome']}',{$this->cod_pessoa_fj});";
                 $this->executa_script = $script;
             }
             return true;
         }
     }
     return false;
 }