Commit 8b7a1c0ea96b3e47ff24ea9e37c6c82ed7279762
1 parent
1e9b08f8
Exists in
master
Alterado simple search pessoa, para quando informado, exibir após o nome da pess…
…oa a data de nascimento e o RG. Alterado cadastro de pessoa fisica, para obrigar informar o RG dos pais do aluno. Incluido no cadastro de aluno campo RG e Data nascimento.
Showing
7 changed files
with
136 additions
and
53 deletions
Show diff stats
ieducar/intranet/atendidos_cad.php
... | ... | @@ -170,11 +170,27 @@ class indice extends clsCadastro |
170 | 170 | $this->campoOculto('cod_pessoa_fj', $this->cod_pessoa_fj); |
171 | 171 | $this->campoTexto('nm_pessoa', 'Nome', $this->nm_pessoa, '50', '255', TRUE); |
172 | 172 | |
173 | + | |
174 | + // ao cadastrar pessoa do pai ou mãe apartir do cadastro de outra pessoa, | |
175 | + // é enviado o tipo de cadastro (pai ou mae). | |
176 | + $parentType = isset($_REQUEST['parent_type']) ? $_REQUEST['parent_type'] : ''; | |
177 | + | |
178 | + | |
173 | 179 | // sexo |
174 | 180 | |
181 | + $sexo = $this->sexo; | |
182 | + | |
183 | + // sugere sexo quando cadastrando o pai ou mãe | |
184 | + | |
185 | + if (! $sexo && $parentType == 'pai') | |
186 | + $sexo = 'M'; | |
187 | + elseif (! $sexo && $parentType == 'mae') | |
188 | + $sexo = 'F'; | |
189 | + | |
190 | + | |
175 | 191 | $options = array( |
176 | 192 | 'label' => 'Sexo / Estado civil', |
177 | - 'value' => $this->sexo, | |
193 | + 'value' => $sexo, | |
178 | 194 | 'resources' => array( |
179 | 195 | '' => 'Sexo', |
180 | 196 | 'M' => 'Masculino', |
... | ... | @@ -187,14 +203,15 @@ class indice extends clsCadastro |
187 | 203 | |
188 | 204 | // estado civil |
189 | 205 | |
190 | - $this->inputsHelper()->estadoCivil(array('label' => '')); | |
206 | + $this->inputsHelper()->estadoCivil(array('label' => '', 'required' => empty($parentType))); | |
191 | 207 | |
192 | 208 | |
193 | 209 | // data nascimento |
194 | 210 | |
195 | 211 | $options = array( |
196 | 212 | 'label' => 'Data nascimento', |
197 | - 'value' => $this->data_nasc | |
213 | + 'value' => $this->data_nasc, | |
214 | + 'required' => empty($parentType) | |
198 | 215 | ); |
199 | 216 | |
200 | 217 | $this->inputsHelper()->date('data_nasc', $options); |
... | ... | @@ -214,14 +231,22 @@ class indice extends clsCadastro |
214 | 231 | |
215 | 232 | // rg |
216 | 233 | |
234 | + // o rg é obrigatorio ao cadastrar pai ou mãe, exceto se configurado como opcional. | |
235 | + | |
236 | + $required = (! empty($parentType)); | |
237 | + | |
238 | + if ($required && $GLOBALS['coreExt']['Config']->app->rg_pessoa_fisica_pais_opcional) { | |
239 | + $required = false; | |
240 | + } | |
241 | + | |
217 | 242 | $options = array( |
218 | - 'required' => false, | |
219 | - 'label' => 'RG / Data emissão', | |
243 | + 'required' => $required, | |
244 | + 'label' => 'RG / Data emissão', | |
220 | 245 | 'placeholder' => 'Documento identidade', |
221 | - 'value' => $documentos['rg'], | |
222 | - 'max_length' => 20, | |
223 | - 'size' => 27, | |
224 | - 'inline' => true | |
246 | + 'value' => $documentos['rg'], | |
247 | + 'max_length' => 20, | |
248 | + 'size' => 27, | |
249 | + 'inline' => true | |
225 | 250 | ); |
226 | 251 | |
227 | 252 | $this->inputsHelper()->integer('rg', $options); |
... | ... | @@ -570,6 +595,10 @@ class indice extends clsCadastro |
570 | 595 | $this->campoOculto('id_cidade', $this->cidade); |
571 | 596 | |
572 | 597 | |
598 | + // o endereçamento é opcional ao cadastrar pai ou mãe. | |
599 | + $enderecamentoObrigatorio = empty($parentType); | |
600 | + | |
601 | + | |
573 | 602 | // considera como endereço localizado por CEP quando alguma das variaveis de instancia |
574 | 603 | // idbai (bairro) ou idlog (logradouro) estão definidas, neste caso desabilita a edição |
575 | 604 | // dos campos definidos via CEP. |
... | ... | @@ -579,7 +608,7 @@ class indice extends clsCadastro |
579 | 608 | 'cep_', |
580 | 609 | 'CEP', |
581 | 610 | $this->cep, |
582 | - TRUE, | |
611 | + $enderecamentoObrigatorio, | |
583 | 612 | '-', |
584 | 613 | " <img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel(500, 550, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade&campo14=zona_localizacao\'></iframe>');\">", |
585 | 614 | $desativarCamposDefinidosViaCep |
... | ... | @@ -592,7 +621,8 @@ class indice extends clsCadastro |
592 | 621 | 'label' => 'Estado / Cidade', |
593 | 622 | 'value' => $this->sigla_uf, |
594 | 623 | 'disabled' => $desativarCamposDefinidosViaCep, |
595 | - 'inline' => true | |
624 | + 'inline' => true, | |
625 | + 'required' => $enderecamentoObrigatorio | |
596 | 626 | ); |
597 | 627 | |
598 | 628 | $helperOptions = array( |
... | ... | @@ -609,7 +639,8 @@ class indice extends clsCadastro |
609 | 639 | 'placeholder' => 'Cidade', |
610 | 640 | 'value' => $this->cidade, |
611 | 641 | 'max_length' => 60, |
612 | - 'disabled' => $desativarCamposDefinidosViaCep | |
642 | + 'disabled' => $desativarCamposDefinidosViaCep, | |
643 | + 'required' => $enderecamentoObrigatorio | |
613 | 644 | ); |
614 | 645 | |
615 | 646 | $this->inputsHelper()->text('cidade', $options); |
... | ... | @@ -623,7 +654,8 @@ class indice extends clsCadastro |
623 | 654 | 'value' => $this->bairro, |
624 | 655 | 'max_length' => 40, |
625 | 656 | 'disabled' => $desativarCamposDefinidosViaCep, |
626 | - 'inline' => true | |
657 | + 'inline' => true, | |
658 | + 'required' => $enderecamentoObrigatorio | |
627 | 659 | ); |
628 | 660 | |
629 | 661 | $this->inputsHelper()->text('bairro', $options); |
... | ... | @@ -640,7 +672,8 @@ class indice extends clsCadastro |
640 | 672 | 'placeholder' => 'Zona localização', |
641 | 673 | 'value' => $this->zona_localizacao, |
642 | 674 | 'disabled' => $desativarCamposDefinidosViaCep, |
643 | - 'resources' => $zonas | |
675 | + 'resources' => $zonas, | |
676 | + 'required' => $enderecamentoObrigatorio | |
644 | 677 | ); |
645 | 678 | |
646 | 679 | $this->inputsHelper()->select('zona_localizacao', $options); |
... | ... | @@ -652,7 +685,8 @@ class indice extends clsCadastro |
652 | 685 | 'label' => 'Tipo / Logradouro', |
653 | 686 | 'value' => $this->idtlog, |
654 | 687 | 'disabled' => $desativarCamposDefinidosViaCep, |
655 | - 'inline' => true | |
688 | + 'inline' => true, | |
689 | + 'required' => $enderecamentoObrigatorio | |
656 | 690 | ); |
657 | 691 | |
658 | 692 | $helperOptions = array( |
... | ... | @@ -669,7 +703,8 @@ class indice extends clsCadastro |
669 | 703 | 'placeholder' => 'Logradouro', |
670 | 704 | 'value' => $this->logradouro, |
671 | 705 | 'max_length' => 150, |
672 | - 'disabled' => $desativarCamposDefinidosViaCep | |
706 | + 'disabled' => $desativarCamposDefinidosViaCep, | |
707 | + 'required' => $enderecamentoObrigatorio | |
673 | 708 | ); |
674 | 709 | |
675 | 710 | $this->inputsHelper()->text('logradouro', $options); |
... | ... | @@ -777,8 +812,8 @@ class indice extends clsCadastro |
777 | 812 | |
778 | 813 | // after change pessoa pai / mae |
779 | 814 | |
780 | - if (isset($_REQUEST['parent_type'])) | |
781 | - $this->inputsHelper()->hidden('parent_type', array('value' => $_REQUEST['parent_type'])); | |
815 | + if ($parentType) | |
816 | + $this->inputsHelper()->hidden('parent_type', array('value' => $parentType)); | |
782 | 817 | |
783 | 818 | |
784 | 819 | $styles = array( | ... | ... |
ieducar/lib/Portabilis/View/Helper/Input/Date.php
... | ... | @@ -59,7 +59,10 @@ class Portabilis_View_Helper_Input_Date extends Portabilis_View_Helper_Input_Cor |
59 | 59 | 'label_hint' => '', |
60 | 60 | 'inline' => false, |
61 | 61 | 'callback' => false, |
62 | - 'disabled' => false); | |
62 | + 'disabled' => false, | |
63 | + | |
64 | + // opcoes suportadas pelo elemento, mas não pelo helper ieducar | |
65 | + 'size' => 9); | |
63 | 66 | |
64 | 67 | $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); |
65 | 68 | |
... | ... | @@ -70,5 +73,23 @@ class Portabilis_View_Helper_Input_Date extends Portabilis_View_Helper_Input_Cor |
70 | 73 | |
71 | 74 | call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions); |
72 | 75 | $this->fixupPlaceholder($inputOptions); |
76 | + | |
77 | + // implementado fixup via js, pois algumas opções não estão sendo verificadas pelo helper ieducar. | |
78 | + $this->fixupOptions($inputOptions); | |
79 | + } | |
80 | + | |
81 | + protected function fixupOptions($inputOptions) { | |
82 | + $id = $inputOptions['id']; | |
83 | + | |
84 | + $sizeFixup = "\$input.attr('size', " . $inputOptions['size'] . ");"; | |
85 | + $disableFixup = $inputOptions['disabled'] ? "\$input.attr('disabled', 'disabled');" : ''; | |
86 | + | |
87 | + $script = " | |
88 | + var \$input = \$j('#" . $id . "'); | |
89 | + $sizeFixup | |
90 | + $disableFixup | |
91 | + "; | |
92 | + | |
93 | + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true); | |
73 | 94 | } |
74 | 95 | } | ... | ... |
ieducar/modules/Api/Views/PessoaController.php
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | require_once 'lib/Portabilis/Controller/ApiCoreController.php'; |
36 | 36 | require_once 'lib/Portabilis/Array/Utils.php'; |
37 | 37 | require_once 'lib/Portabilis/String/Utils.php'; |
38 | +require_once 'lib/Portabilis/Date/Utils.php'; | |
38 | 39 | |
39 | 40 | class PessoaController extends ApiCoreController |
40 | 41 | { |
... | ... | @@ -70,7 +71,8 @@ class PessoaController extends ApiCoreController |
70 | 71 | $sql = "select cod_aluno as id from pmieducar.aluno where ref_idpes = $1"; |
71 | 72 | $id = $this->fetchPreparedQuery($sql, $pessoaId, false, 'first-field'); |
72 | 73 | |
73 | - // when not exists, returns an empty array that causes error on loadDetails | |
74 | + // caso um array vazio seja retornado, seta resultado como null, | |
75 | + // evitando erro em loadDetails | |
74 | 76 | if (empty($id)) |
75 | 77 | $id = null; |
76 | 78 | |
... | ... | @@ -104,7 +106,8 @@ class PessoaController extends ApiCoreController |
104 | 106 | protected function loadDetails($pessoaId = null) { |
105 | 107 | $alunoId = $this->tryLoadAlunoId($pessoaId); |
106 | 108 | |
107 | - $sql = "select cpf, idpes_pai as pai_id, idpes_mae as mae_id, idpes_responsavel as responsavel_id, | |
109 | + $sql = "select cpf, data_nasc as data_nascimento, idpes_pai as pai_id, | |
110 | + idpes_mae as mae_id, idpes_responsavel as responsavel_id, | |
108 | 111 | coalesce((select nome from cadastro.pessoa where idpes = fisica.idpes_pai), |
109 | 112 | (select nm_pai from pmieducar.aluno where cod_aluno = $1)) as nome_pai, |
110 | 113 | coalesce((select nome from cadastro.pessoa where idpes = fisica.idpes_mae), |
... | ... | @@ -115,7 +118,7 @@ class PessoaController extends ApiCoreController |
115 | 118 | |
116 | 119 | $details = $this->fetchPreparedQuery($sql, array($alunoId, $pessoaId), false, 'first-row'); |
117 | 120 | |
118 | - $attrs = array('cpf', 'rg', 'pai_id', 'mae_id', 'responsavel_id', 'nome_pai', 'nome_mae', 'nome_responsavel'); | |
121 | + $attrs = array('cpf', 'rg', 'data_nascimento', 'pai_id', 'mae_id', 'responsavel_id', 'nome_pai', 'nome_mae', 'nome_responsavel'); | |
119 | 122 | $details = Portabilis_Array_Utils::filter($details, $attrs); |
120 | 123 | |
121 | 124 | $details['aluno_id'] = $alunoId; |
... | ... | @@ -123,6 +126,8 @@ class PessoaController extends ApiCoreController |
123 | 126 | $details['nome_pai'] = $this->toUtf8($details['nome_pai'], array('transform' => true)); |
124 | 127 | $details['nome_responsavel'] = $this->toUtf8($details['nome_responsavel'], array('transform' => true)); |
125 | 128 | |
129 | + $details['data_nascimento'] = Portabilis_Date_Utils::pgSQLToBr($details['data_nascimento']); | |
130 | + | |
126 | 131 | return $details; |
127 | 132 | } |
128 | 133 | |
... | ... | @@ -143,6 +148,28 @@ class PessoaController extends ApiCoreController |
143 | 148 | return $_deficiencias; |
144 | 149 | } |
145 | 150 | |
151 | + protected function loadRg($pessoaId) { | |
152 | + $sql = "select rg from cadastro.documento where idpes = $1"; | |
153 | + $rg = $this->fetchPreparedQuery($sql, $pessoaId, false, 'first-field'); | |
154 | + | |
155 | + // caso um array vazio seja retornado, seta resultado como null | |
156 | + if (empty($rg)) | |
157 | + $rg = null; | |
158 | + | |
159 | + return $rg; | |
160 | + } | |
161 | + | |
162 | + protected function loadDataNascimento($pessoaId) { | |
163 | + $sql = "select data_nasc from cadastro.fisica where idpes = $1"; | |
164 | + $nascimento = $this->fetchPreparedQuery($sql, $pessoaId, false, 'first-field'); | |
165 | + | |
166 | + // caso um array vazio seja retornado, seta resultado como null | |
167 | + if (empty($nascimento)) | |
168 | + $nascimento = null; | |
169 | + | |
170 | + return $nascimento; | |
171 | + } | |
172 | + | |
146 | 173 | |
147 | 174 | // search |
148 | 175 | |
... | ... | @@ -167,6 +194,27 @@ class PessoaController extends ApiCoreController |
167 | 194 | return $sqls; |
168 | 195 | } |
169 | 196 | |
197 | + // subscreve formatResourceValue para adicionar o rg da pessoa, ao final do valor, | |
198 | + // "<id_pessoa> - <nome_pessoa> (RG: <rg>)", ex: "1 - Lucas D'Avila (RG: 1234567)" | |
199 | + protected function formatResourceValue($resource) { | |
200 | + $nome = $this->toUtf8($resource['name'], array('transform' => true)); | |
201 | + $rg = $this->loadRg($resource['id']); | |
202 | + $nascimento = $this->loadDataNascimento($resource['id']); | |
203 | + | |
204 | + // Quando informado, inclui detalhes extra sobre a pessoa, como RG e Data nascimento. | |
205 | + $details = array(); | |
206 | + | |
207 | + if ($nascimento) | |
208 | + $details[] = 'Nascimento: ' . Portabilis_Date_Utils::pgSQLToBr($nascimento); | |
209 | + | |
210 | + if ($rg) | |
211 | + $details[] = "RG: $rg"; | |
212 | + | |
213 | + $details = $details ? ' (' . implode(', ', $details) . ')' : ''; | |
214 | + | |
215 | + return $resource['id'] . " - $nome$details"; | |
216 | + } | |
217 | + | |
170 | 218 | // api responders |
171 | 219 | |
172 | 220 | protected function get() { | ... | ... |
ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js
... | ... | @@ -104,8 +104,8 @@ var handleGetPersonDetails = function(dataResponse) { |
104 | 104 | if (dataResponse.responsavel_id) |
105 | 105 | nomeResponsavel = dataResponse.responsavel_id + ' - ' + nomeResponsavel; |
106 | 106 | |
107 | - //$j('#rg').val(dataResponse.rg); | |
108 | - //$j('#cpf').val(dataResponse.cpf); | |
107 | + $j('#data_nascimento').val(dataResponse.data_nascimento); | |
108 | + $j('#rg').val(dataResponse.rg); | |
109 | 109 | |
110 | 110 | $j('#pai').val(nomePai); |
111 | 111 | $j('#mae').val(nomeMae); | ... | ... |
ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js
... | ... | @@ -190,22 +190,6 @@ $j(document).ready(function() { |
190 | 190 | $j('#tr_uf_emissao_certidao_civil td').removeClass('formmdtd'); |
191 | 191 | $j('#tr_carteira_trabalho td').removeClass('formlttd').addClass('formmdtd'); |
192 | 192 | |
193 | - | |
194 | - // remove obrigatoriedade de determinados campos, ao criar pessoa pai ou mãe | |
195 | - // para agilizar o cadastro do filho; | |
196 | - | |
197 | - if ($j.inArray($j('#parent_type').val(), ['pai', 'mae']) > -1) { | |
198 | - var $elements = $j('#sexo, #estado_civil_id, #data_nasc, #cep_, #sigla_uf, #cidade, #bairro,\ | |
199 | - #zona_localizacao, #idtlog, #logradouro').filter('[value=]'); | |
200 | - | |
201 | - $elements.addClass('skip-presence-validation'); | |
202 | - | |
203 | - // remove '*' obrigatório ao lado do label. | |
204 | - $elements.each(function(index, element) { | |
205 | - $j(element).closest('tr').find('.campo_obrigatorio').hide(); | |
206 | - }); | |
207 | - } | |
208 | - | |
209 | 193 | // bind events |
210 | 194 | |
211 | 195 | checkTipoNacionalidade(); | ... | ... |
ieducar/modules/Cadastro/Views/AlunoController.php
... | ... | @@ -50,12 +50,7 @@ class AlunoController extends Portabilis_Controller_Page_EditController |
50 | 50 | ), |
51 | 51 | |
52 | 52 | 'rg' => array( |
53 | - 'label' => 'Documento de identidade (rg)', | |
54 | - 'help' => '', | |
55 | - ), | |
56 | - | |
57 | - 'cpf' => array( | |
58 | - 'label' => 'CPF', | |
53 | + 'label' => 'Documento de identidade (RG)', | |
59 | 54 | 'help' => '', |
60 | 55 | ), |
61 | 56 | |
... | ... | @@ -143,13 +138,13 @@ class AlunoController extends Portabilis_Controller_Page_EditController |
143 | 138 | $options = array('label' => $this->_getLabel('pessoa'), 'size' => 68); |
144 | 139 | $this->inputsHelper()->simpleSearchPessoa('nome', $options); |
145 | 140 | |
146 | - // rg | |
147 | - //$options = array('label' => $this->_getLabel('rg'), 'disabled' => true, 'required' => false); | |
148 | - //$this->inputsHelper()->text('aluno', 'rg', $options); | |
141 | + // data nascimento | |
142 | + $options = array('label' => 'Data nascimento', 'disabled' => true, 'required' => false, 'size' => 25, 'placeholder' => ''); | |
143 | + $this->inputsHelper()->date('data_nascimento', $options); | |
149 | 144 | |
150 | - // cpf | |
151 | - //$options = array('label' => $this->_getLabel('cpf'), 'disabled' => true, 'required' => false); | |
152 | - //$this->inputsHelper()->text('aluno', 'cpf', $options); | |
145 | + // rg | |
146 | + $options = array('label' => $this->_getLabel('rg'), 'disabled' => true, 'required' => false, 'size' => 25); | |
147 | + $this->inputsHelper()->integer('rg', $options); | |
153 | 148 | |
154 | 149 | // pai |
155 | 150 | $options = array('label' => $this->_getLabel('pai'), 'disabled' => true, 'required' => false, 'size' => 68); | ... | ... |
ieducar/modules/Portabilis/Assets/Version.php