Commit 787d0d4558aa6498c5b0f14f6e82099aa34f76df

Authored by Lucas D'Avila
1 parent e3697e39
Exists in master

Adicionado campos referentes a pessoa fisica antes presentes no cadastro de alun…

…os, para o cadastro de pessoas fisicas.
ieducar/intranet/adicionar_documentos_cad.php
... ... @@ -97,9 +97,7 @@ class indice extends clsCadastro
97 97 $this->zona_tit_eleitor = $detalheDocumento['zona_tit_eleitor'];
98 98 $this->secao_tit_eleitor = $detalheDocumento['secao_tit_eleitor'];
99 99 $this->idorg_exp_rg = $detalheDocumento['idorg_exp_rg'];
100   -
101   -
102   -
  100 + $this->certidao_nascimento = $detalheDocumento['certidao_nascimento'];
103 101  
104 102 $ObjDocumento = new clsDocumento($this->idpes);
105 103  
... ... @@ -155,6 +153,8 @@ class indice extends clsCadastro
155 153 $this->campoTexto("num_termo", "Termo", $this->num_termo, "8", "8", false);
156 154 $this->campoTexto("num_livro", "Livro", $this->num_livro, "8", "8", false);
157 155 $this->campoTexto("num_folha", "Folha", $this->num_folha, "4", "4", false);
  156 + $this->campoTexto('certidao_nascimento', 'Certidão nascimento', $this->certidao_nascimento, '37', '40', FALSE);
  157 +
158 158 $this->campoData("data_emissao_cert_civil", "Emissão Certidão Civil", $this->data_emissao_cert_civil, false);
159 159 $this->campoLista("sigla_uf_cert_civil", "Sigla Certidão Civil", $listaEstado, $this->sigla_uf_cert_civil, false, false, false, false, false);
160 160 $this->campoMemo("cartorio_cert_civil", "Cartório", $this->cartorio_cert_civil, "35", "4", false);
... ... @@ -169,27 +169,28 @@ class indice extends clsCadastro
169 169  
170 170 }
171 171  
172   - function Novo()
173   - {
174   - if($this->data_emissao_cart_trabalho)
175   - {
  172 + function Novo() {
  173 + if($this->data_emissao_cart_trabalho) {
176 174 $this->data_emissao_cart_trabalho = explode("/",$this->data_emissao_cart_trabalho);
177 175 $this->data_emissao_cart_trabalho = "{$this->data_emissao_cart_trabalho[2]}/{$this->data_emissao_cart_trabalho[1]}/{$this->data_emissao_cart_trabalho[0]}";
178 176 }
179   - if($this->data_emissao_cert_civil)
180   - {
  177 +
  178 + if($this->data_emissao_cert_civil) {
181 179 $this->data_emissao_cert_civil = explode("/",$this->data_emissao_cert_civil);
182 180 $this->data_emissao_cert_civil = "{$this->data_emissao_cert_civil[2]}/{$this->data_emissao_cert_civil[1]}/{$this->data_emissao_cert_civil[0]}";
183 181 }
184   - if($this->data_exp_rg)
185   - {
  182 +
  183 + if($this->data_exp_rg) {
186 184 $this->data_exp_rg = explode("/",$this->data_exp_rg);
187 185 $this->data_exp_rg = "{$this->data_exp_rg[2]}/{$this->data_exp_rg[1]}/{$this->data_exp_rg[0]}";
188   -
189 186 }
190   - $ObjDocumento = new clsDocumento($this->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 );
191   - if( $ObjDocumento->cadastra() )
192   - {
  187 +
  188 + // remove caracteres não numericos
  189 + $this->rg = preg_replace("/[^0-9]/", "", $this->rg);
  190 +
  191 + $ObjDocumento = new clsDocumento($this->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, $this->certidao_nascimento );
  192 +
  193 + if( $ObjDocumento->cadastra() ) {
193 194 echo "<script>window.close()</script>";
194 195 return true;
195 196 }
... ... @@ -197,25 +198,26 @@ class indice extends clsCadastro
197 198 return false;
198 199 }
199 200  
200   - function Editar()
201   - {
202   - if($this->data_emissao_cart_trabalho)
203   - {
  201 + function Editar() {
  202 + if($this->data_emissao_cart_trabalho) {
204 203 $this->data_emissao_cart_trabalho = explode("/",$this->data_emissao_cart_trabalho);
205 204 $this->data_emissao_cart_trabalho = "{$this->data_emissao_cart_trabalho[2]}/{$this->data_emissao_cart_trabalho[1]}/{$this->data_emissao_cart_trabalho[0]}";
206 205 }
207   - if($this->data_emissao_cert_civil)
208   - {
  206 +
  207 + if($this->data_emissao_cert_civil) {
209 208 $this->data_emissao_cert_civil = explode("/",$this->data_emissao_cert_civil);
210 209 $this->data_emissao_cert_civil = "{$this->data_emissao_cert_civil[2]}/{$this->data_emissao_cert_civil[1]}/{$this->data_emissao_cert_civil[0]}";
211 210 }
212   - if($this->data_exp_rg)
213   - {
  211 +
  212 + if($this->data_exp_rg) {
214 213 $this->data_exp_rg = explode("/",$this->data_exp_rg);
215 214 $this->data_exp_rg = "{$this->data_exp_rg[2]}/{$this->data_exp_rg[1]}/{$this->data_exp_rg[0]}";
216   -
217 215 }
218   - $ObjDocumento = new clsDocumento($this->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 );
  216 +
  217 + // remove caracteres não numericos
  218 + $this->rg = preg_replace("/[^0-9]/", "", $this->rg);
  219 +
  220 + $ObjDocumento = new clsDocumento($this->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, $this->certidao_nascimento );
219 221  
220 222 if ($ObjDocumento->edita()) {
221 223 echo '<script>window.close()</script>';
... ...
ieducar/intranet/atendidos_cad.php
... ... @@ -33,9 +33,13 @@ require_once &#39;include/clsBanco.inc.php&#39;;
33 33 require_once 'include/clsCadastro.inc.php';
34 34 require_once 'include/pessoa/clsCadastroRaca.inc.php';
35 35 require_once 'include/pessoa/clsCadastroFisicaRaca.inc.php';
  36 +require_once 'include/pmieducar/clsPmieducarAluno.inc.php';
36 37  
37 38 require_once 'App/Model/ZonaLocalizacao.php';
38 39  
  40 +require_once 'lib/Portabilis/String/Utils.php';
  41 +require_once 'lib/Portabilis/View/Helper/Application.php';
  42 +
39 43 /**
40 44 * clsIndex class.
41 45 *
... ... @@ -143,16 +147,23 @@ class indice extends clsCadastro
143 147 $this->http, $this->tipo_pessoa, $this->sexo, $this->cidade,
144 148 $this->bairro, $this->logradouro, $this->cep, $this->idlog, $this->idbai,
145 149 $this->idtlog, $this->sigla_uf, $this->complemento, $this->numero,
146   - $this->bloco, $this->apartamento, $this->andar, $this->zona_localizacao
  150 + $this->bloco, $this->apartamento, $this->andar, $this->zona_localizacao, $this->estado_civil,
  151 + $this->pai_id, $this->mae_id, $this->tipo_nacionalidade, $this->pais_origem, $this->naturalidade
147 152 ) =
  153 +
148 154 $objPessoa->queryRapida(
149 155 $this->cod_pessoa_fj, 'nome', 'cpf', 'data_nasc', 'ddd_1', 'fone_1',
150 156 'ddd_2', 'fone_2', 'ddd_mov', 'fone_mov', 'ddd_fax', 'fone_fax', 'email',
151 157 'url', 'tipo', 'sexo', 'cidade', 'bairro', 'logradouro', 'cep', 'idlog',
152 158 'idbai', 'idtlog', 'sigla_uf', 'complemento', 'numero', 'bloco', 'apartamento',
153   - 'andar', 'zona_localizacao'
  159 + 'andar', 'zona_localizacao', 'ideciv', 'idpes_pai', 'idpes_mae', 'nacionalidade',
  160 + 'idpais_estrangeiro', 'idmun_nascimento'
154 161 );
155 162  
  163 + $this->estado_civil_id = $this->estado_civil->ideciv;
  164 + $this->pais_origem_id = $this->pais_origem->idpais;
  165 + $this->naturalidade_id = $this->naturalidade->idmun;
  166 +
156 167 // Cor/Raça.
157 168 $raca = new clsCadastroFisicaRaca($this->cod_pessoa_fj);
158 169 $raca = $raca->detalhe();
... ... @@ -224,6 +235,13 @@ class indice extends clsCadastro
224 235 $lista_sexos['F'] = 'Feminino';
225 236 $this->campoLista('sexo', 'Sexo', $lista_sexos, $this->sexo);
226 237  
  238 + $this->inputsHelper()->estadoCivil(array('required' => false));
  239 +
  240 + // pai, mãe
  241 +
  242 + $this->addPaiInput();
  243 + $this->addMaeInput();
  244 +
227 245 // Cor/raça.
228 246 $opcoes_raca = array('' => 'Selecione');
229 247 $obj_raca = new clsCadastroRaca();
... ... @@ -238,7 +256,42 @@ class indice extends clsCadastro
238 256 $this->campoLista('cor_raca', 'Raça', $opcoes_raca,
239 257 $this->cod_raca, '', FALSE, '', '', '', FALSE);
240 258  
  259 + // nacionalidade
  260 +
  261 + // tipos
  262 + $tiposNacionalidade = array(null => 'Selecione',
  263 + '1' => 'Brasileiro',
  264 + '2' => 'Naturalizado brasileiro',
  265 + '3' => 'Estrangeiro');
  266 +
  267 + $options = array('label' => 'Nacionalidade',
  268 + 'resources' => $tiposNacionalidade,
  269 + 'required' => false,
  270 + 'inline' => true,
  271 + 'value' => $this->tipo_nacionalidade);
  272 +
  273 + $this->inputsHelper()->select('tipo_nacionalidade', $options);
  274 +
  275 + // pais origem
  276 +
  277 + $options = array('label' => '', 'required' => true);
  278 + $helperOptions = array('objectName' => 'pais_origem',
  279 + 'hiddenInputOptions' => array('options' => array('value' => $this->pais_origem_id)));
  280 +
  281 + $this->inputsHelper()->simpleSearchPais('nome', $options, $helperOptions);
  282 +
  283 +
  284 + // naturalidade
  285 +
  286 + $options = array('label' => 'Naturalidade', 'required' => false);
  287 + $helperOptions = array('objectName' => 'naturalidade',
  288 + 'hiddenInputOptions' => array('options' => array('value' => $this->naturalidade_id)));
  289 +
  290 + $this->inputsHelper()->simpleSearchMunicipio('nome', $options, $helperOptions);
  291 +
  292 +
241 293 // Detalhes do Endereço
  294 +
242 295 $objTipoLog = new clsTipoLogradouro();
243 296 $listaTipoLog = $objTipoLog->lista();
244 297 $listaTLog = array('0' => 'Selecione');
... ... @@ -400,11 +453,17 @@ class indice extends clsCadastro
400 453  
401 454 if ($this->cod_pessoa_fj) {
402 455 $this->campoRotulo('documentos', '<b><i>Documentos</i></b>',
403   - "<a href='#' onclick=\"openPage('adicionar_documentos_cad.php?id_pessoa={$this->cod_pessoa_fj}', '400', '400', 'yes', '10', '10'); \"><img src='imagens/nvp_bot_ad_doc.png' border='0'></a>");
  456 + "<a href='#' onclick=\"windowUtils.open('adicionar_documentos_cad.php?id_pessoa={$this->cod_pessoa_fj}'); \"><img src='imagens/nvp_bot_ad_doc.png' border='0'></a>");
404 457  
405 458 $this->campoCheck('alterado', 'Alterado', $this->alterado);
406 459 }
407 460 }
  461 +
  462 + $styles = array('/modules/Portabilis/Assets/Stylesheets/Frontend.css');
  463 + Portabilis_View_Helper_Application::loadStylesheet($this, $styles);
  464 +
  465 + $script = "/modules/Cadastro/Assets/Javascripts/PessoaFisica.js";
  466 + Portabilis_View_Helper_Application::loadJavascript($this, $script);
408 467 }
409 468  
410 469 function Novo()
... ... @@ -432,27 +491,31 @@ class indice extends clsCadastro
432 491 }
433 492 }
434 493  
  494 + // pessoa
  495 +
435 496 $objPessoa = new clsPessoa_(FALSE, $this->nm_pessoa, $pessoaFj, $this->http,
436 497 'F', FALSE, FALSE, $this->email);
437 498  
438 499 $idpes = $objPessoa->cadastra();
439 500  
440   - $this->data_nasc = dataToBanco($this->data_nasc);
441 501  
442   - if ($this->id_federal) {
443   - $objFisica = new clsFisica($idpes, $this->data_nasc, $this->sexo, FALSE,
444   - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
445   - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
446   - $ref_cod_sistema, $this->id_federal);
447   - }
448   - else {
449   - $objFisica = new clsFisica($idpes, $this->data_nasc, $this->sexo, FALSE,
450   - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
451   - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
452   - $ref_cod_sistema);
453   - }
  502 + // pessoa fisica
  503 +
  504 + $fisica = new clsFisica();
454 505  
455   - $objFisica->cadastra();
  506 + $fisica->idpes = $idpes;
  507 + $fisica->data_nasc = dataToBanco($this->data_nasc);
  508 + $fisica->sexo = $this->sexo;
  509 + $fisica->ref_cod_sistema = 'NULL';
  510 + $fisica->cpf = $this->id_federal;
  511 + $fisica->ideciv = $this->estado_civil_id;
  512 + $fisica->idpes_pai = $this->pai_id;
  513 + $fisica->idpes_mae = $this->mae_id;
  514 + $fisica->nacionalidade = $_REQUEST['tipo_nacionalidade'];
  515 + $fisica->idpais_estrangeiro = $_REQUEST['pais_origem_id'];
  516 + $fisica->idmun_nascimento = $_REQUEST['naturalidade_id'];
  517 +
  518 + $fisica->cadastra();
456 519  
457 520 $objTelefone = new clsPessoaTelefone($idpes, 1, $this->telefone_1, $this->ddd_telefone_1);
458 521 $objTelefone->cadastra();
... ... @@ -501,7 +564,7 @@ class indice extends clsCadastro
501 564 // Cadastra raça.
502 565 $this->_cadastraRaca($idpes, $this->cor_raca);
503 566  
504   - echo '<script>document.location="atendidos_lst.php";</script>';
  567 + $this->afterChangePessoa($idpes);
505 568 return TRUE;
506 569 }
507 570  
... ... @@ -512,7 +575,6 @@ class indice extends clsCadastro
512 575 session_write_close();
513 576  
514 577 if ($this->id_federal) {
515   - $ref_cod_sistema = 'null';
516 578 $this->id_federal = idFederal2int($this->id_federal);
517 579  
518 580 $objFisicaCpf = new clsFisica($this->cod_pessoa_fj);
... ... @@ -530,28 +592,31 @@ class indice extends clsCadastro
530 592 }
531 593 }
532 594  
  595 + // pessoa
  596 +
533 597 $objPessoa = new clsPessoa_($this->cod_pessoa_fj, $this->nm_pessoa, FALSE,
534 598 $this->p_http, FALSE, $pessoaFj, date('Y-m-d H:i:s', time()), $this->email);
535 599  
536 600 $objPessoa->edita();
537 601  
538   - $this->data_nasc = dataToBanco($this->data_nasc);
  602 + // pessoa fisica
539 603  
540   - if ($this->id_federal) {
541   - $this->id_federal = idFederal2Int($this->id_federal);
542   - $objFisica = new clsFisica($this->cod_pessoa_fj, $this->data_nasc,
543   - $this->sexo, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
544   - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
545   - FALSE, FALSE, FALSE, $ref_cod_sistema, $this->id_federal);
546   - }
547   - else {
548   - $objFisica = new clsFisica($this->cod_pessoa_fj, $this->data_nasc,
549   - $this->sexo, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
550   - FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
551   - FALSE, FALSE, FALSE, $ref_cod_sistema);
552   - }
  604 + $fisica = new clsFisica();
  605 +
  606 + $fisica->idpes = $this->cod_pessoa_fj;
  607 + $fisica->data_nasc = dataToBanco($this->data_nasc);
  608 + $fisica->sexo = $this->sexo;
  609 + $fisica->ref_cod_sistema = 'NULL';
  610 + $fisica->cpf = $this->id_federal;
  611 + $fisica->ideciv = $this->estado_civil_id;
553 612  
554   - $objFisica->edita();
  613 + $fisica->idpes_pai = $this->pai_id;
  614 + $fisica->idpes_mae = $this->mae_id;
  615 + $fisica->nacionalidade = $_REQUEST['tipo_nacionalidade'];
  616 + $fisica->idpais_estrangeiro = $_REQUEST['pais_origem_id'];
  617 + $fisica->idmun_nascimento = $_REQUEST['naturalidade_id'];
  618 +
  619 + $fisica->edita();
555 620  
556 621 if ($this->alterado) {
557 622 $db = new clsBanco();
... ... @@ -612,7 +677,8 @@ class indice extends clsCadastro
612 677 // Atualizada raça.
613 678 $this->_cadastraRaca($this->cod_pessoa_fj, $this->cor_raca);
614 679  
615   - echo '<script>document.location="atendidos_lst.php";</script>';
  680 + $this->afterChangePessoa($this->cod_pessoa_fj);
  681 +
616 682 return TRUE;
617 683 }
618 684  
... ... @@ -622,6 +688,15 @@ class indice extends clsCadastro
622 688 return TRUE;
623 689 }
624 690  
  691 + function afterChangePessoa($id) {
  692 + Portabilis_View_Helper_Application::embedJavascript($this, "
  693 + if(window.opener && window.opener.afterChangePessoa)
  694 + window.opener.afterChangePessoa(self, $id);
  695 + else
  696 + document.location = 'atendidos_lst.php';
  697 + ");
  698 + }
  699 +
625 700 /**
626 701 * Cadastra ou atualiza a raça de uma pessoa.
627 702 *
... ... @@ -643,6 +718,47 @@ class indice extends clsCadastro
643 718  
644 719 return $raca->cadastra();
645 720 }
  721 +
  722 + protected function loadAlunoByPessoaId($id) {
  723 + $aluno = new clsPmieducarAluno();
  724 + $aluno->ref_idpes = $id;
  725 +
  726 + return $aluno->detalhe();
  727 + }
  728 +
  729 + protected function addPaiInput() {
  730 + $this->addParentsInput('pai');
  731 + }
  732 +
  733 + protected function addMaeInput() {
  734 + $this->addParentsInput('mae', 'mãe');
  735 + }
  736 +
  737 + protected function addParentsInput($parentType, $parentTypeLabel = '') {
  738 + if (! $parentTypeLabel)
  739 + $parentTypeLabel = $parentType;
  740 +
  741 + if (! isset($this->_aluno))
  742 + $this->_aluno = $this->loadAlunoByPessoaId($this->cod_pessoa_fj);
  743 +
  744 + $parentId = $this->{$parentType . '_id'};
  745 +
  746 + // mostra uma dica nos casos em que foi informado apenas o nome dos pais, pela antiga interface do cadastro de alunos.
  747 + if (! $parentId && $this->_aluno['nm_' . $parentType]) {
  748 + $nome = Portabilis_String_Utils::toLatin1($this->_aluno['nm_' . $parentType], array('transform' => true, 'escape' => false));
  749 + $inputHint = '<b>Dica:</b> Foi informado o nome "' . $nome . '" no cadastro de aluno, tente pesquisar esta pessoa pelo CPF ou RG.';
  750 + }
  751 +
  752 + $hiddenInputOptions = array('options' => array('value' => $parentId));
  753 + $helperOptions = array('objectName' => $parentType, 'hiddenInputOptions' => $hiddenInputOptions);
  754 +
  755 + $options = array('label' => 'Pessoa ' . $parentTypeLabel,
  756 + 'size' => 50,
  757 + 'required' => false,
  758 + 'input_hint' => $inputHint);
  759 +
  760 + $this->inputsHelper()->simpleSearchPessoa('nome', $options, $helperOptions);
  761 + }
646 762 }
647 763  
648 764 // Instancia objeto de página
... ...