Commit cace3890b929a50871e7111e789f5f92df54c62a

Authored by Caroline Salib
Committed by Caroline Salib
1 parent 31d9dae4

Adicionado modal para cadastro de pessoa fisica dentro de aluno;

portabilis/ieducar#155
ieducar/intranet/scripts/dom.js
... ... @@ -268,7 +268,7 @@ function showExpansivel( largura, altura, conteudo )
268 268 expansivel.setAttribute("id", "div_dinamico_"+exp_id);
269 269 insertAfter(expansivel, document.getElementById("DOM_expansivel"));
270 270 DOM_divs[exp_id] = expansivel;
271   - expansivel.style.zIndex = 30+exp_id;
  271 + expansivel.style.zIndex = 1003+exp_id;
272 272 expansivel.style.position = "absolute";
273 273  
274 274 if( typeof window.innerHeight == 'number' )
... ... @@ -1539,7 +1539,7 @@ function getPDFouvidoriaEquipe()
1539 1539  
1540 1540 Obj = document.getElementById('imprimir');
1541 1541 Obj.value = 'Gerando Arquivo...';
1542   - Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
  1542 + Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
1543 1543 //document.location.href = strURL;
1544 1544 }
1545 1545  
... ... @@ -1566,7 +1566,7 @@ function getPDFouvidoriaTipoServico()
1566 1566 DOM_loadXMLDoc( strURL );
1567 1567 Obj = document.getElementById('imprimir');
1568 1568 Obj.value = 'Gerando Arquivo...';
1569   - Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
  1569 + Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
1570 1570 //document.location.href = strURL;
1571 1571 }
1572 1572  
... ... @@ -1594,7 +1594,7 @@ function getPDFouvidoriaAtendimento()
1594 1594 DOM_loadXMLDoc( strURL );
1595 1595 Obj = document.getElementById('imprimir');
1596 1596 Obj.value = 'Gerando Arquivo...';
1597   - Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
  1597 + Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
1598 1598 }
1599 1599  
1600 1600 function getPDFouvidoriaAtendimentoDone()
... ... @@ -1626,7 +1626,7 @@ function getPDFestoquesaida()
1626 1626 DOM_loadXMLDoc( strURL );
1627 1627 Obj = document.getElementById('imprimir');
1628 1628 Obj.value = 'Gerando Arquivo...';
1629   - Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
  1629 + Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
1630 1630 }
1631 1631  
1632 1632 function getPDFestoquesaidaDone()
... ... @@ -1657,7 +1657,7 @@ function getPDFouvidoriaAtendimentoSetor()
1657 1657 DOM_loadXMLDoc( strURL );
1658 1658 Obj = document.getElementById('imprimir');
1659 1659 Obj.value = 'Gerando Arquivo...';
1660   - Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
  1660 + Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
1661 1661  
1662 1662 }
1663 1663  
... ... @@ -1695,7 +1695,7 @@ function getPDFouvidoriaOrdem()
1695 1695 DOM_loadXMLDoc( strURL );
1696 1696 Obj = document.getElementById('imprimir');
1697 1697 Obj.value = 'Gerando Arquivo...';
1698   - Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
  1698 + Obj.onclick = function() { alert('O sistema está gerando o arquivo. Aguarde!')};
1699 1699 //document.location.href = strURL;
1700 1700 }
1701 1701  
... ... @@ -1707,7 +1707,7 @@ function getPDFouvidoriaOrdemDone()
1707 1707 Obj = document.getElementById('imprimir');
1708 1708 Obj.value = 'Clique para baixar arquivo!';
1709 1709 Obj.onclick = function() { document.location.href = link;};
1710   - //alert('Arquivo Concluído');
  1710 + //alert('Arquivo Conclu?o');
1711 1711 document.location.href = link;
1712 1712 }
1713 1713  
... ... @@ -1717,7 +1717,7 @@ function fecha_notificacao( id_notificacao )
1717 1717 {
1718 1718 if( DOM_itensArray[0].firstChild.data == 0 )
1719 1719 {
1720   - alert( 'Erro de permissão. A notificação não foi deletada.' );
  1720 + alert( 'Erro de permissão. A notificação não foi deletada.' );
1721 1721 document.getElementById('notificacao_' + id_notificacao).style.display='block';
1722 1722 }
1723 1723 }
... ...
ieducar/modules/Api/Views/AlunoController.php
... ... @@ -788,8 +788,9 @@ protected function createOrUpdateUniforme($id) {
788 788 $aluno = Portabilis_Array_Utils::merge($objMoradia,$aluno);
789 789 }
790 790  
791   - $sql = "select sus from cadastro.fisica where idpes = $1";
792   - $aluno['sus'] = Portabilis_String_Utils::toUtf8($this->fetchPreparedQuery($sql, $aluno['pessoa_id'], false, 'first-field'));
  791 + $sql = "select sus, idpes_mae, idpes_pai from cadastro.fisica where idpes = $1";
  792 + $camposFisica = Portabilis_String_Utils::toUtf8($this->fetchPreparedQuery($sql, $aluno['pessoa_id'], false, 'first-row'));
  793 + $aluno['sus'] = $camposFisica['sus'];
793 794  
794 795 return $aluno;
795 796 }
... ... @@ -856,6 +857,34 @@ protected function createOrUpdateUniforme($id) {
856 857 }
857 858 }
858 859  
  860 + protected function saveParents(){
  861 +
  862 + $maeId = $this->getRequest()->mae_id;
  863 + $paiId = $this->getRequest()->pai_id;
  864 + $pessoaId = $this->getRequest()->pessoa_id;
  865 +
  866 + if($maeId || $paiId){
  867 +
  868 + $sql = "UPDATE cadastro.fisica set ";
  869 +
  870 + $virgulaOuNada = '';
  871 +
  872 + if ($maeId){
  873 + $sql .= " idpes_mae = {$maeId} ";
  874 + $virgulaOuNada = ", ";
  875 + }
  876 +
  877 + if ($paiId){
  878 + $sql .= "{$virgulaOuNada} idpes_pai = {$paiId} ";
  879 + $virgulaOuNada = ", ";
  880 + }
  881 +
  882 + $sql .= " WHERE idpes = {$pessoaId}";
  883 +
  884 + Portabilis_Utils_Database::fetchPreparedQuery($sql);
  885 + }
  886 + }
  887 +
859 888 protected function getOcorrenciasDisciplinares() {
860 889 if ($this->canGetOcorrenciasDisciplinares())
861 890 return $this->loadOcorrenciasDisciplinares();
... ... @@ -866,6 +895,8 @@ protected function createOrUpdateUniforme($id) {
866 895 $id = $this->createOrUpdateAluno();
867 896 $pessoaId = $this->getRequest()->pessoa_id;
868 897  
  898 + $this->saveParents();
  899 +
869 900 if (is_numeric($id)) {
870 901 $this->updateResponsavel();
871 902 $this->saveSus($pessoaId);
... ... @@ -889,6 +920,8 @@ protected function createOrUpdateUniforme($id) {
889 920 $id = $this->getRequest()->id;
890 921 $pessoaId = $this->getRequest()->pessoa_id;
891 922  
  923 + $this->saveParents();
  924 +
892 925 if ($this->canPut() && $this->createOrUpdateAluno($id)) {
893 926 $this->updateResponsavel();
894 927 $this->saveSus($pessoaId);
... ...
ieducar/modules/Api/Views/PessoaController.php
... ... @@ -36,6 +36,9 @@ 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 38 require_once 'lib/Portabilis/Date/Utils.php';
  39 +require_once 'include/pessoa/clsPessoa_.inc.php';
  40 +require_once 'include/pessoa/clsFisica.inc.php';
  41 +require_once 'intranet/include/funcoes.inc.php';
39 42  
40 43 class PessoaController extends ApiCoreController
41 44 {
... ... @@ -108,29 +111,148 @@ class PessoaController extends ApiCoreController
108 111  
109 112 $sql = "select cpf, data_nasc as data_nascimento, idpes_pai as pai_id,
110 113 idpes_mae as mae_id, idpes_responsavel as responsavel_id,
  114 + ideciv as estadocivil, sexo,
111 115 coalesce((select nome from cadastro.pessoa where idpes = fisica.idpes_pai),
112 116 (select nm_pai from pmieducar.aluno where cod_aluno = $1)) as nome_pai,
113 117 coalesce((select nome from cadastro.pessoa where idpes = fisica.idpes_mae),
114 118 (select nm_mae from pmieducar.aluno where cod_aluno = $1)) as nome_mae,
115 119 (select nome from cadastro.pessoa where idpes = fisica.idpes_responsavel) as nome_responsavel,
116   - (select rg from cadastro.documento where documento.idpes = fisica.idpes) as rg
  120 + (select rg from cadastro.documento where documento.idpes = fisica.idpes) as rg,
  121 + (SELECT COALESCE((SELECT cep FROM cadastro.endereco_pessoa WHERE idpes = $2),
  122 + (SELECT cep FROM cadastro.endereco_externo WHERE idpes = $2))) as cep,
  123 +
  124 + (SELECT COALESCE((SELECT l.nome FROM public.logradouro l, cadastro.endereco_pessoa ep WHERE l.idlog = ep.idlog and ep.idpes = $2),
  125 + (SELECT logradouro FROM cadastro.endereco_externo WHERE idpes = $2))) as logradouro,
  126 +
  127 + (SELECT COALESCE((SELECT l.idtlog FROM public.logradouro l, cadastro.endereco_pessoa ep WHERE l.idlog = ep.idlog and ep.idpes = $2),
  128 + (SELECT idtlog FROM cadastro.endereco_externo WHERE idpes = $2))) as idtlog,
  129 +
  130 + (SELECT COALESCE((SELECT b.nome FROM public.bairro b, cadastro.endereco_pessoa ep WHERE b.idbai = ep.idbai and ep.idpes = $2),
  131 + (SELECT bairro FROM cadastro.endereco_externo WHERE idpes = $2))) as bairro,
  132 +
  133 + (SELECT COALESCE((SELECT b.zona_localizacao FROM public.bairro b, cadastro.endereco_pessoa ep WHERE b.idbai = ep.idbai and ep.idpes = $2),
  134 + (SELECT zona_localizacao FROM cadastro.endereco_externo WHERE idpes = $2))) as zona_localizacao,
  135 +
  136 + (SELECT COALESCE((SELECT l.idmun FROM public.logradouro l, cadastro.endereco_pessoa ep WHERE l.idlog = ep.idlog and ep.idpes = $2),
  137 + (SELECT idmun FROM public.logradouro l, urbano.cep_logradouro cl, cadastro.endereco_externo ee
  138 + WHERE cl.idlog = l.idlog AND cl.cep = ee.cep and ee.idpes = $2 order by 1 desc limit 1))) as idmun,
  139 +
  140 + idmun_nascimento,
  141 +
  142 +
  143 + (SELECT COALESCE((SELECT numero FROM cadastro.endereco_pessoa WHERE idpes = $2),
  144 + (SELECT numero FROM cadastro.endereco_externo WHERE idpes = $2))) as numero,
  145 +
  146 + (SELECT COALESCE((SELECT letra FROM cadastro.endereco_pessoa WHERE idpes = $2),
  147 + (SELECT letra FROM cadastro.endereco_externo WHERE idpes = $2))) as letra,
  148 +
  149 + (SELECT COALESCE((SELECT complemento FROM cadastro.endereco_pessoa WHERE idpes = $2),
  150 + (SELECT complemento FROM cadastro.endereco_externo WHERE idpes = $2))) as complemento,
  151 +
  152 + (SELECT COALESCE((SELECT andar FROM cadastro.endereco_pessoa WHERE idpes = $2),
  153 + (SELECT andar FROM cadastro.endereco_externo WHERE idpes = $2))) as andar,
  154 +
  155 + (SELECT COALESCE((SELECT bloco FROM cadastro.endereco_pessoa WHERE idpes = $2),
  156 + (SELECT bloco FROM cadastro.endereco_externo WHERE idpes = $2))) as bloco,
  157 +
  158 + (SELECT COALESCE((SELECT apartamento FROM cadastro.endereco_pessoa WHERE idpes = $2),
  159 + (SELECT apartamento FROM cadastro.endereco_externo WHERE idpes = $2))) as apartamento,
  160 +
  161 + (SELECT idbai FROM cadastro.endereco_pessoa WHERE idpes = $2) as idbai,
  162 +
  163 + (SELECT idlog FROM cadastro.endereco_pessoa WHERE idpes = $2) as idlog
117 164 from cadastro.fisica where idpes = $2";
118 165  
119 166 $details = $this->fetchPreparedQuery($sql, array($alunoId, $pessoaId), false, 'first-row');
120 167  
121   - $attrs = array('cpf', 'rg', 'data_nascimento', 'pai_id', 'mae_id', 'responsavel_id', 'nome_pai', 'nome_mae', 'nome_responsavel');
  168 + $attrs = array('cpf', 'rg', 'data_nascimento', 'pai_id', 'mae_id', 'responsavel_id', 'nome_pai', 'nome_mae',
  169 + 'nome_responsavel','sexo','estadocivil', 'cep', 'logradouro', 'idtlog', 'bairro',
  170 + 'zona_localizacao', 'idbai', 'idlog', 'idmun', 'idmun_nascimento', 'complemento',
  171 + 'apartamento', 'andar', 'bloco', 'numero' , 'letra');
122 172 $details = Portabilis_Array_Utils::filter($details, $attrs);
123 173  
124 174 $details['aluno_id'] = $alunoId;
125 175 $details['nome_mae'] = $this->toUtf8($details['nome_mae'], array('transform' => true));
126 176 $details['nome_pai'] = $this->toUtf8($details['nome_pai'], array('transform' => true));
127 177 $details['nome_responsavel'] = $this->toUtf8($details['nome_responsavel'], array('transform' => true));
  178 + $details['cep'] = int2CEP($details['cep']);
  179 +
  180 + $details['bairro'] = $this->toUtf8($details['bairro']);
  181 + $details['logradouro'] = $this->toUtf8($details['logradouro']);
  182 + $detaihandleGetPersonls['complemento'] = $this->toUtf8($details['complemento']);
  183 + $details['letra'] = $this->toUtf8($details['letra']);
  184 + $details['bloco'] = $this->toUtf8($details['bloco']);
  185 +
  186 + if($details['idmun']){
  187 +
  188 + $_sql = " SELECT nome, sigla_uf FROM public.municipio WHERE idmun = $1; ";
  189 +
  190 + $mun = $this->fetchPreparedQuery($_sql, $details['idmun'], false, 'first-row');
  191 +
  192 + $details['municipio'] = $this->toUtf8($mun['nome']);
  193 +
  194 + $details['sigla_uf'] = $mun['sigla_uf'];
  195 +
  196 + }
  197 +
  198 + if ($details['idmun_nascimento']){
  199 +
  200 + $_sql = " SELECT nome, sigla_uf FROM public.municipio WHERE idmun = $1; ";
  201 +
  202 + $mun = $this->fetchPreparedQuery($_sql, $details['idmun_nascimento'], false, 'first-row');
  203 +
  204 + $details['municipio_nascimento'] = $this->toUtf8($mun['nome']);
  205 +
  206 + $details['sigla_uf_nascimento'] = $mun['sigla_uf'];
  207 +
  208 + }
  209 +
  210 + if ($details['pai_id']){
  211 +
  212 + $_sql = " SELECT ideciv as estadocivil, sexo FROM cadastro.fisica WHERE idpes = $1; ";
  213 +
  214 + $pai = $this->fetchPreparedQuery($_sql, $details['pai_id'], false, 'first-row');
  215 +
  216 + $paiDetails['estadocivil'] = $pai['estadocivil'];
  217 +
  218 + $paiDetails['sexo'] = $pai['sexo'];
  219 +
  220 + $details['pai_details'] = $paiDetails;
  221 +
  222 + }
  223 +
  224 + if ($details['mae_id']){
  225 +
  226 + $_sql = " SELECT ideciv as estadocivil, sexo FROM cadastro.fisica WHERE idpes = $1; ";
  227 +
  228 + $mae = $this->fetchPreparedQuery($_sql, $details['mae_id'], false, 'first-row');
  229 +
  230 + $maeDetails['estadocivil'] = $mae['estadocivil'];
  231 +
  232 + $maeDetails['sexo'] = $mae['sexo'];
  233 +
  234 + $details['mae_details'] = $maeDetails;
  235 +
  236 + }
128 237  
129 238 $details['data_nascimento'] = Portabilis_Date_Utils::pgSQLToBr($details['data_nascimento']);
130 239  
131 240 return $details;
132 241 }
133 242  
  243 + protected function loadPessoaParent(){
  244 +
  245 + $_sql = " SELECT (select nome from cadastro.pessoa where pessoa.idpes = fisica.idpes) as nome ,ideciv as estadocivil, sexo FROM cadastro.fisica WHERE idpes = $1; ";
  246 +
  247 + $details = $this->fetchPreparedQuery($_sql, $this->getRequest()->id, false, 'first-row');
  248 +
  249 + $details['nome'] = Portabilis_String_Utils::toUtf8($details['nome']);
  250 +
  251 + $details['id'] = $this->getRequest()->id;
  252 +
  253 + return $details;;
  254 + }
  255 +
134 256 protected function loadDeficiencias($pessoaId) {
135 257 $sql = "select cod_deficiencia as id, nm_deficiencia as nome from cadastro.fisica_deficiencia,
136 258 cadastro.deficiencia where cod_deficiencia = ref_cod_deficiencia and ref_idpes = $1";
... ... @@ -239,6 +361,150 @@ class PessoaController extends ApiCoreController
239 361 return $pessoa;
240 362 }
241 363  
  364 + protected function post(){
  365 +
  366 + $pessoaId = $this->getRequest()->pessoa_id;
  367 +
  368 + $pessoaId = $this->createOrUpdatePessoa($pessoaId);
  369 + $this->createOrUpdatePessoaFisica($pessoaId);
  370 +
  371 + $this->appendResponse('pessoa_id', $pessoaId);
  372 + }
  373 +
  374 + protected function createOrUpdatePessoa($pessoaId = null) {
  375 + $pessoa = new clsPessoa_();
  376 + $pessoa->idpes = $pessoaId;
  377 + $pessoa->nome = addslashes(urldecode($this->getRequest()->nome));
  378 +
  379 + $sql = "select 1 from cadastro.pessoa WHERE idpes = $1 limit 1";
  380 +
  381 + if (! $pessoaId || Portabilis_Utils_Database::selectField($sql, $pessoaId) != 1) {
  382 + $pessoa->tipo = 'F';
  383 + $pessoa->idpes_cad = $this->currentUserId();
  384 + $pessoaId = $pessoa->cadastra();
  385 + }
  386 + else {
  387 + $pessoa->idpes_rev = $this->currentUserId();
  388 + $pessoa->data_rev = date('Y-m-d H:i:s', time());
  389 + $pessoa->edita();
  390 + }
  391 +
  392 + return $pessoaId;
  393 + }
  394 +
  395 + protected function createOrUpdatePessoaFisica($pessoaId) {
  396 +
  397 + $fisica = new clsFisica();
  398 + $fisica->idpes = $pessoaId;
  399 + $fisica->data_nasc = Portabilis_Date_Utils::brToPgSQL($this->getRequest()->datanasc);
  400 + $fisica->sexo = $this->getRequest()->sexo;
  401 + $fisica->ref_cod_sistema = 'NULL';
  402 + $fisica->ideciv = $this->getRequest()->estadocivil;
  403 + $fisica->idpes_pai = "NULL";
  404 + $fisica->idpes_mae = "NULL";
  405 + $fisica->idmun_nascimento = $this->getRequest()->naturalidade;
  406 +
  407 + $sql = "select 1 from cadastro.fisica WHERE idpes = $1 limit 1";
  408 +
  409 + if (Portabilis_Utils_Database::selectField($sql, $pessoaId) != 1)
  410 + $fisica->cadastra();
  411 + else
  412 + $fisica->edita();
  413 +
  414 + }
  415 +
  416 + protected function _createOrUpdatePessoaEndereco($pessoaId) {
  417 +
  418 + $cep = idFederal2Int($this->getRequest()->cep);
  419 +
  420 + $objCepLogradouro = new ClsCepLogradouro($cep, $this->getRequest()->logradouro_id);
  421 +
  422 + if (! $objCepLogradouro->existe())
  423 + $objCepLogradouro->cadastra();
  424 +
  425 + $objCepLogradouroBairro = new ClsCepLogradouroBairro();
  426 + $objCepLogradouroBairro->cep = $cep;
  427 + $objCepLogradouroBairro->idbai = $this->getRequest()->bairro_id;
  428 + $objCepLogradouroBairro->idlog = $this->getRequest()->logradouro_id;
  429 +
  430 + if (! $objCepLogradouroBairro->existe())
  431 + $objCepLogradouroBairro->cadastra();
  432 +
  433 + $endereco = new clsPessoaEndereco(
  434 + $this->getRequest()->pessoa_id,
  435 + $cep,
  436 + $this->getRequest()->logradouro_id,
  437 + $this->getRequest()->bairro_id,
  438 + $this->getRequest()->numero,
  439 + Portabilis_String_Utils::toLatin1($this->getRequest()->complemento),
  440 + FALSE,
  441 + Portabilis_String_Utils::toLatin1($this->getRequest()->letra),
  442 + Portabilis_String_Utils::toLatin1($this->getRequest()->bloco),
  443 + $this->getRequest()->apartamento,
  444 + $this->getRequest()->andar
  445 + );
  446 +
  447 + // forçado exclusão, assim ao cadastrar endereco_pessoa novamente,
  448 + // será excluido endereco_externo (por meio da trigger fcn_aft_ins_endereco_pessoa).
  449 + $endereco->exclui();
  450 + $endereco->cadastra();
  451 + }
  452 +
  453 + protected function createOrUpdateEndereco() {
  454 +
  455 + $pessoaId = $this->getRequest()->pessoa_id;
  456 +
  457 + if ($this->getRequest()->cep && is_numeric($this->getRequest()->bairro_id) && is_numeric($this->getRequest()->logradouro_id))
  458 + $this->_createOrUpdatePessoaEndereco($pessoaId);
  459 + else if($this->getRequest()->cep && is_numeric($this->getRequest()->municipio_id)){
  460 +
  461 + if (!is_numeric($this->bairro_id)){
  462 +
  463 + if ($this->canCreateBairro())
  464 + $this->getRequest()->bairro_id = $this->createBairro();
  465 + else
  466 + return;
  467 + }
  468 +
  469 + if (!is_numeric($this->logradouro_id)){
  470 + if($this->canCreateLogradouro())
  471 + $this->getRequest()->logradouro_id = $this->createLogradouro();
  472 + else
  473 + return;
  474 + }
  475 +
  476 + $this->_createOrUpdatePessoaEndereco($pessoaId);
  477 +
  478 + }else{
  479 + $endereco = new clsPessoaEndereco($pessoaId);
  480 + $endereco->exclui();
  481 + }
  482 +
  483 + }
  484 +
  485 +
  486 + protected function canCreateBairro(){
  487 + return !empty($this->getRequest()->bairro) && !empty($this->getRequest()->zona_localizacao);
  488 + }
  489 +
  490 + protected function canCreateLogradouro(){
  491 + return !empty($this->getRequest()->logradouro) && !empty($this->getRequest()->idtlog);
  492 + }
  493 +
  494 + protected function createBairro(){
  495 +
  496 + $objBairro = new clsBairro(null,$this->getRequest()->municipio_id,null,Portabilis_String_Utils::toLatin1($this->getRequest()->bairro), $this->currentUserId());
  497 + $objBairro->zona_localizacao = $this->getRequest()->zona_localizacao;
  498 +
  499 + return $objBairro->cadastra();
  500 + }
  501 +
  502 + protected function createLogradouro(){
  503 + $objLogradouro = new clsLogradouro(null,$this->getRequest()->idtlog, Portabilis_String_Utils::toLatin1($this->getRequest()->logradouro), $this->getRequest()->municipio_id,
  504 + null, 'S', $this->currentUserId());
  505 + return $objLogradouro->cadastra();
  506 + }
  507 +
242 508  
243 509 public function Gerar() {
244 510 if ($this->isRequestFor('get', 'pessoa-search'))
... ... @@ -246,6 +512,12 @@ class PessoaController extends ApiCoreController
246 512  
247 513 elseif ($this->isRequestFor('get', 'pessoa'))
248 514 $this->appendResponse($this->get());
  515 + elseif ($this->isRequestFor('post', 'pessoa'))
  516 + $this->appendResponse($this->post());
  517 + elseif ($this->isRequestFor('post', 'pessoa-endereco'))
  518 + $this->appendResponse($this->createOrUpdateEndereco());
  519 + elseif ($this->isRequestFor('get', 'pessoa-parent'))
  520 + $this->appendResponse($this->loadPessoaParent());
249 521 else
250 522 $this->notImplementedOperationError();
251 523 }
... ...
ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js
1   -// before page is ready
  1 +var editar_pessoa = false;
  2 +var person_details;
  3 +var pai_details;
  4 +var mae_details;
  5 +var pessoaPaiOuMae;
  6 +
  7 + // before page is ready
2 8  
3 9 var $idField = $j('#id');
4 10 var $nomeField = $j('#pessoa_nome');
... ... @@ -12,6 +18,48 @@ var $resourceNotice = $j('<span>').html('')
12 18 var $pessoaNotice = $resourceNotice.clone()
13 19 .appendTo($nomeField.parent());
14 20  
  21 +var $paiNomeField = $j('#pai_nome');
  22 +var $paiIdField = $j('#pai_id');
  23 +
  24 +var $maeNomeField = $j('#mae_nome');
  25 +var $maeIdField = $j('#mae_id');
  26 +
  27 +var $pessoaPaiActionBar = $j('<span>').html('')
  28 + .addClass('pessoa-links pessoa-pai-links')
  29 + .width($paiNomeField.outerWidth() - 12)
  30 + .appendTo($paiNomeField.parent());
  31 +
  32 +var $pessoaMaeActionBar = $pessoaPaiActionBar.clone()
  33 + .removeClass('pessoa-pai-links')
  34 + .addClass('pessoa-mae-links')
  35 + .appendTo($maeNomeField.parent());
  36 +
  37 +var $linkToCreatePessoaPai = $j('<a>').addClass('cadastrar-pessoa-pai decorated')
  38 + .attr('id', 'cadastrar-pessoa-pai-link')
  39 + .html('Cadastrar pessoa')
  40 + .appendTo($pessoaPaiActionBar);
  41 +
  42 +var $linkToEditPessoaPai = $j('<a>').hide()
  43 + .addClass('editar-pessoa-pai decorated')
  44 + .attr('id', 'editar-pessoa-pai-link')
  45 + .html('Editar pessoa')
  46 + .appendTo($pessoaPaiActionBar);
  47 +
  48 +var $linkToCreatePessoaMae = $linkToCreatePessoaPai.clone()
  49 + .removeClass('cadastrar-pessoa-pai')
  50 + .attr('id', 'cadastrar-pessoa-mae-link')
  51 + .addClass('cadastrar-pessoa-mae')
  52 + .appendTo($pessoaMaeActionBar);
  53 +
  54 +var $linkToEditPessoaMae = $linkToEditPessoaPai.clone()
  55 + .removeClass('editar-pessoa-pai')
  56 + .addClass('editar-pessoa-mae')
  57 + .attr('id', 'editar-pessoa-mae-link')
  58 + .appendTo($pessoaMaeActionBar);
  59 +
  60 +
  61 +
  62 +
15 63 // adiciona id 'stop' na linha separadora
16 64 $j('.tableDetalheLinhaSeparador').closest('tr').attr('id','stop');
17 65 // Adiciona abas na página
... ... @@ -349,9 +397,51 @@ resourceOptions.handleGet = function(dataResponse) {
349 397  
350 398 };
351 399  
  400 +// pessoa links callbacks
  401 +
  402 +var changeVisibilityOfLinksToPessoaParent = function(parentType) {
  403 + var $nomeField = $j(buildId(parentType + '_nome'));
  404 + var $idField = $j(buildId(parentType + '_id'));
  405 + var $linkToEdit = $j('.pessoa-' + parentType + '-links .editar-pessoa-' + parentType);
  406 +
  407 + if($nomeField.val() && $idField.val()) {
  408 + $linkToEdit.show().css('display', 'inline');
  409 + }
  410 + else {
  411 + $nomeField.val('')
  412 + $idField.val('');
  413 +
  414 + $linkToEdit.hide();
  415 + }
  416 +}
  417 +
  418 +var changeVisibilityOfLinksToPessoaPai = function() {
  419 + changeVisibilityOfLinksToPessoaParent('pai');
  420 +}
  421 +
  422 +var changeVisibilityOfLinksToPessoaMae = function() {
  423 + changeVisibilityOfLinksToPessoaParent('mae');
  424 +}
  425 +
  426 +var simpleSearchPaiOptions = {
  427 + autocompleteOptions : { close : changeVisibilityOfLinksToPessoaPai }
  428 +};
  429 +
  430 +var simpleSearchMaeOptions = {
  431 + autocompleteOptions : { close : changeVisibilityOfLinksToPessoaMae }
  432 +};
  433 +
  434 +$paiIdField.change(changeVisibilityOfLinksToPessoaPai);
  435 +$maeIdField.change(changeVisibilityOfLinksToPessoaMae);
  436 +
352 437 var handleGetPersonDetails = function(dataResponse) {
353 438 handleMessages(dataResponse.msgs);
354 439 $pessoaNotice.hide();
  440 + person_details = dataResponse;
  441 +
  442 + mae_details = dataResponse.mae_details;
  443 +
  444 + pai_details = dataResponse.pai_details;
355 445  
356 446 var alunoId = dataResponse.aluno_id;
357 447  
... ... @@ -369,8 +459,7 @@ var handleGetPersonDetails = function(dataResponse) {
369 459 }
370 460  
371 461 else {
372   - $j('.pessoa-links .editar-pessoa').attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + dataResponse.id)
373   - .show().css('display', 'inline');
  462 + $j('.pessoa-links .editar-pessoa').show().css('display', 'inline');
374 463  
375 464 $submitButton.removeAttr('disabled').show();
376 465 }
... ... @@ -382,11 +471,27 @@ var handleGetPersonDetails = function(dataResponse) {
382 471 var nomeMae = dataResponse.nome_mae;
383 472 var nomeResponsavel = dataResponse.nome_responsavel;
384 473  
385   - if (dataResponse.pai_id)
386   - nomePai = dataResponse.pai_id + ' - ' + nomePai;
  474 + if (dataResponse.pai_id){
  475 + pai_details.nome = nomePai;
  476 + $j('#pai_nome').val(dataResponse.pai_id + ' - ' + nomePai);
  477 + $j('#pai_id').val(dataResponse.pai_id);
  478 + }else{
  479 + $j('#pai_nome').val('');
  480 + $j('#pai_id').val('');
  481 + }
  482 +
  483 + $j('#pai_id').trigger('change');
387 484  
388   - if (dataResponse.mae_id)
389   - nomeMae = dataResponse.mae_id + ' - ' + nomeMae;
  485 + if (dataResponse.mae_id){
  486 + mae_details.nome = nomeMae;
  487 + $j('#mae_nome').val(dataResponse.mae_id + ' - ' + nomeMae);
  488 + $j('#mae_id').val(dataResponse.mae_id);
  489 + }else{
  490 + $j('#mae_nome').val('');
  491 + $j('#mae_id').val('');
  492 + }
  493 +
  494 + $j('#mae_id').trigger('change');
390 495  
391 496 if (dataResponse.responsavel_id)
392 497 nomeResponsavel = dataResponse.responsavel_id + ' - ' + nomeResponsavel;
... ... @@ -394,8 +499,6 @@ var handleGetPersonDetails = function(dataResponse) {
394 499 $j('#data_nascimento').val(dataResponse.data_nascimento);
395 500 $j('#rg').val(dataResponse.rg);
396 501  
397   - $j('#pai').val(nomePai);
398   - $j('#mae').val(nomeMae);
399 502 $j('#responsavel_nome').val(nomeResponsavel);
400 503 $j('#responsavel_id').val(dataResponse.responsavel_id);
401 504  
... ... @@ -428,6 +531,24 @@ var handleGetPersonDetails = function(dataResponse) {
428 531  
429 532 // # TODO show aluno photo
430 533 //$j('#aluno_foto').val(dataResponse.url_foto);
  534 + canShowParentsFields();
  535 +}
  536 +
  537 +var handleGetPersonParentDetails = function(dataResponse, parentType) {
  538 +
  539 + window[parentType+'_details'] = dataResponse;
  540 +
  541 + if(dataResponse.id){
  542 +
  543 + if(parentType=='mae'){
  544 + $maeNomeField.val(dataResponse.id + ' - '+ dataResponse.nome);
  545 + $maeIdField.val(dataResponse.id);
  546 + changeVisibilityOfLinksToPessoaMae();
  547 + }else
  548 + $paiNomeField.val(dataResponse.id + ' - '+ dataResponse.nome);
  549 + $paiIdField.val(dataResponse.id);
  550 + changeVisibilityOfLinksToPessoaPai();
  551 + }
431 552 }
432 553  
433 554 var getPersonDetails = function(personId) {
... ... @@ -445,7 +566,25 @@ var getPersonDetails = function(personId) {
445 566 getResource(options);
446 567 }
447 568  
  569 +var getPersonParentDetails = function(personId,parentType) {
  570 + var additionalVars = {
  571 + id : personId
  572 + };
  573 +
  574 + var options = {
  575 + url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa-parent', additionalVars),
  576 + dataType : 'json',
  577 + data : {},
  578 + success : function(data){
  579 + handleGetPersonParentDetails(data, parentType)
  580 + }
  581 + };
  582 +
  583 + getResource(options);
  584 +}
  585 +
448 586 var updatePersonDetails = function() {
  587 + canShowParentsFields();
449 588 if ($j('#pessoa_nome').val() && $j('#pessoa_id').val())
450 589 getPersonDetails($j('#pessoa_id').val());
451 590 else
... ... @@ -469,7 +608,8 @@ var simpleSearchPessoaOptions = {
469 608 // children callbacks
470 609  
471 610 function afterChangePessoa(targetWindow, pessoaId) {
472   - targetWindow.close();
  611 + if (targetWindow != null)
  612 + targetWindow.close();
473 613  
474 614 // timeout para usuario perceber mudança
475 615 window.setTimeout(function() {
... ... @@ -484,13 +624,34 @@ function afterChangePessoa(targetWindow, pessoaId) {
484 624 }, 500);
485 625 }
486 626  
  627 +function afterChangePessoaParent(pessoaId, parentType) {
  628 +
  629 + $tempField = (parentType == 'pai' ? $paiNomeField : $maeNomeField);
  630 +
  631 + messageUtils.success('Pessoa '+parentType+' alterada com sucesso', $tempField);
  632 +
  633 + getPersonParentDetails(pessoaId, parentType);
  634 +
  635 + if ($tempField.is(':active'))
  636 + $tempField.focus();
  637 +}
  638 +
  639 +function canShowParentsFields(){
  640 + if ($j('#pessoa_id').val()){
  641 + $paiNomeField.removeAttr('disabled');
  642 + $maeNomeField.removeAttr('disabled');
  643 + }else{
  644 + $paiNomeField.attr('disabled', 'true');
  645 + $maeNomeField.attr('disabled', 'true');
  646 + }
  647 +}
487 648  
488 649 // when page is ready
489 650  
490 651 (function($) {
491 652 $(document).ready(function() {
492 653  
493   - // pessoa
  654 + canShowParentsFields();
494 655  
495 656 var $pessoaActionBar = $j('<span>').html('')
496 657 .addClass('pessoa-links')
... ... @@ -499,15 +660,13 @@ function afterChangePessoa(targetWindow, pessoaId) {
499 660  
500 661 $j('<a>').hide()
501 662 .addClass('cadastrar-pessoa decorated')
502   - .attr('href', '/intranet/atendidos_cad.php')
503   - .attr('target', '_blank')
  663 + .attr('id', 'cadastrar-pessoa-link')
504 664 .html('Cadastrar pessoa')
505 665 .appendTo($pessoaActionBar);
506 666  
507 667 $j('<a>').hide()
508 668 .addClass('editar-pessoa decorated')
509   - .attr('href', '#')
510   - .attr('target', '_blank')
  669 + .attr('id', 'editar-pessoa-link')
511 670 .html('Editar pessoa')
512 671 .appendTo($pessoaActionBar);
513 672  
... ... @@ -627,7 +786,7 @@ function afterChangePessoa(targetWindow, pessoaId) {
627 786  
628 787 if (index<84 && index!=0){
629 788 row.hide();
630   - }else{
  789 + }else if(index<111){
631 790 row.show();
632 791 }
633 792 });
... ... @@ -656,5 +815,469 @@ function afterChangePessoa(targetWindow, pessoaId) {
656 815 }
657 816 });
658 817  
  818 + // MODAL pessoa-aluno
  819 +
  820 + // Esse simplesSearch é carregado no final do arquivo, então a sua linha deve ser escondida,
  821 + // é só campo será 'puxado' para a modal
  822 + $j('#municipio_pessoa-aluno').closest('tr').hide();
  823 +
  824 +
  825 + $j('body').append('<div id="dialog-form-pessoa-aluno" ><form><p></p><table><tr><td valign="top"><fieldset><legend>Dados b&aacute;sicos</legend><label for="nome-pessoa-aluno">Nome</label> <input type="text " name="nome-pessoa-aluno" id="nome-pessoa-aluno" size="58" maxlength="255" class="text"> <label for="sexo-pessoa-aluno">Sexo</label> <select class="select ui-widget-content ui-corner-all" name="sexo-pessoa-aluno" id="sexo-pessoa-aluno" ><option value="" selected>Sexo</option><option value="M">Masculino</option><option value="F">Feminino</option></select> <label for="estado-civil-pessoa-aluno">Estado civil</label> <select class="select ui-widget-content ui-corner-all" name="estado-civil-pessoa-aluno" id="estado-civil-pessoa-aluno" ><option id="estado-civil-pessoa-aluno_" value="" selected>Estado civil</option><option id="estado-civil-pessoa-aluno_2" value="2">Casado(a)</option><option id="estado-civil-pessoa-aluno_6" value="6">Companheiro(a)</option><option id="estado-civil-pessoa-aluno_3" value="3">Divorciado(a)</option><option id="estado-civil-pessoa-aluno_4" value="4">Separado(a)</option><option id="estado-civil-pessoa-aluno_1" value="1">Solteiro(a)</option><option id="estado-civil-pessoa-aluno_5" value="5">Vi&uacute;vo(a)</option></select> <label for="data-nasc-pessoa-aluno"> Data de nascimento </label> <input onKeyPress="formataData(this, event);" class="" placeholder="dd/mm/yyyy" type="text" name="data-nasc-pessoa-aluno" id="data-nasc-pessoa-aluno" value="" size="11" maxlength="10" > <label for="naturalidade_pessoa-aluno"> Naturalidade </label> </fieldset> </td><td><fieldset valign="top"> <legend>Dados do endere&ccedil;o</legend> <table></table></fieldset></td><td><fieldset ><table></table></fieldset></td></tr></table></form></div>');
  826 +
  827 + var name = $j("#nome-pessoa-aluno"),
  828 + sexo = $j( "#sexo-pessoa-aluno" ),
  829 + estadocivil = $j( "#estado-civil-pessoa-aluno" ),
  830 + datanasc = $j( "#data-nasc-pessoa-aluno" ),
  831 + municipio = $j( "#naturalidade_aluno_pessoa-aluno" ),
  832 + municipio_id = $j( "#naturalidade_aluno_id" ),
  833 + complemento = $j( "#complemento" ),
  834 + numero = $j( "#numero" ),
  835 + letra = $j( "#letra" ),
  836 + apartamento = $j( "#apartamento" ),
  837 + bloco = $j( "#bloco" ),
  838 + andar = $j( "#andar" ),
  839 + allFields = $j( [] ).add( name ).add( sexo ).add( estadocivil ).add(datanasc).add(municipio).add(municipio_id)
  840 + .add(complemento).add(numero).add(letra).add(apartamento).add(bloco).add(andar);
  841 +
  842 + municipio.show().toggleClass('geral text').attr('display', 'block').appendTo('#dialog-form-pessoa-aluno tr td:first-child fieldset');
  843 +
  844 + $j('<label>').html('CEP').attr('for', 'cep_').insertBefore($j('#cep_'));
  845 + $j('#cep_').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  846 + $j('<label>').html('Munic&iacute;pio').attr('for', 'municipio_municipio').insertBefore($j('#municipio_municipio'));
  847 + $j('#municipio_municipio').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  848 + $j('<label>').html('Logradouro').attr('for', 'logradouro_logradouro').insertBefore($j('#logradouro_logradouro'));
  849 + $j('#logradouro_logradouro').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  850 + $j('<label>').html('Tipo de logradouro').attr('for', 'idtlog').insertBefore($j('#idtlog'));
  851 + $j('#idtlog').toggleClass('geral text');
  852 + $j('<label>').html('Logradouro').attr('for', 'logradouro').insertBefore($j('#logradouro'));
  853 + $j('#logradouro').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  854 + $j('<label>').html('Bairro').attr('for', 'bairro_bairro').insertBefore($j('#bairro_bairro'));
  855 + $j('#bairro_bairro').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  856 + $j('<label>').html('Zona de localiza&ccedil;&atilde;o').attr('for', 'zona_localizacao').insertBefore($j('#zona_localizacao'));
  857 + $j('#zona_localizacao').toggleClass('geral text');
  858 + $j('<label>').html('Bairro').attr('for', 'bairro').insertBefore($j('#bairro'));
  859 + $j('#bairro').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  860 +
  861 + $j('<label>').html('Complemento').attr('for', 'complemento').insertBefore($j('#complemento'));
  862 + $j('#complemento').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(2) fieldset table').find('td').removeClass();
  863 + $j('<label>').html('N&uacute;mero').attr('for', 'numero').insertBefore($j('#numero'));
  864 + $j('#numero').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(3) fieldset table').find('td').removeClass();
  865 + $j('<label>').html('Letra').attr('for', 'letra').insertBefore($j('#letra'));
  866 + $j('#letra').toggleClass('geral text');
  867 + $j('<label>').html('N&ordm; de apartamento').attr('for', 'apartamento').insertBefore($j('#apartamento'));
  868 + $j('#apartamento').toggleClass('geral text').closest('tr').show().find('td:first-child').hide().closest('tr').removeClass().appendTo('#dialog-form-pessoa-aluno tr td:nth-child(3) fieldset table').find('td').removeClass();
  869 + $j('<label>').html('Bloco').attr('for', 'bloco').insertBefore($j('#bloco'));
  870 + $j('#bloco').toggleClass('geral text');
  871 + $j('<label>').html('Andar').attr('for', 'andar').insertBefore($j('#andar'));
  872 + $j('#andar').toggleClass('geral text');
  873 +
  874 + $j('#dialog-form-pessoa-aluno').find(':input').css('display', 'block');
  875 + $j('#cep_').css('display', 'inline');
  876 +
  877 + $j( "#dialog-form-pessoa-aluno" ).dialog({
  878 + autoOpen: false,
  879 + height: 'auto',
  880 + width: 'auto',
  881 + modal: true,
  882 + resizable: false,
  883 + draggable: false,
  884 + buttons: {
  885 + "Gravar" : function() {
  886 + var bValid = true;
  887 + allFields.removeClass( "error" );
  888 +
  889 + bValid = bValid && checkLength( name, "nome", 3, 255 );
  890 + bValid = bValid && checkSelect( sexo, "sexo");
  891 + bValid = bValid && checkSelect( estadocivil, "estado civil");
  892 + bValid = bValid && checkRegexp( datanasc, /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/[12][0-9]{3}$/i, "O campo data de nascimento deve ser preenchido no formato dd/mm/yyyy." );
  893 + bValid = bValid && checkSimpleSearch( municipio, municipio_id, "munic\u00edpio");
  894 + bValid = bValid && ($j('#cep_').val() == '' ? true : validateEndereco());
  895 +
  896 + if ( bValid ) {
  897 + postPessoa($j('#pessoa_nome'), name.val(), sexo.val(), estadocivil.val(), datanasc.val(), municipio_id.val(), (editar_pessoa ? $j('#pessoa_id').val() : null), null);
  898 + $j( this ).dialog( "close" );
  899 + }
  900 + },
  901 + "Cancelar": function() {
  902 +
  903 + $j( this ).dialog( "close" );
  904 + }
  905 + },
  906 + close: function() {
  907 +
  908 + allFields.val( "" ).removeClass( "error" );
  909 +
  910 + },
  911 + hide: {
  912 + effect: "clip",
  913 + duration: 500
  914 + },
  915 +
  916 + show: {
  917 + effect: "clip",
  918 + duration: 500
  919 + }
  920 + });
  921 +
  922 + $j('body').append('<div id="dialog-form-pessoa-parent"><form><p></p><table><tr><td valign="top"><fieldset><label for="nome-pessoa-parent">Nome</label> <input type="text " name="nome-pessoa-parent" id="nome-pessoa-parent" size="58" maxlength="255" class="text"> <label for="sexo-pessoa-parent">Sexo</label> <select class="select ui-widget-content ui-corner-all" name="sexo-pessoa-parent" id="sexo-pessoa-parent" ><option value="" selected>Sexo</option><option value="M">Masculino</option><option value="F">Feminino</option></select> <label for="estado-civil-pessoa-parent">Estado civil</label> <select class="select ui-widget-content ui-corner-all" name="estado-civil-pessoa-parent" id="estado-civil-pessoa-parent" ><option id="estado-civil-pessoa-parent_" value="" selected>Estado civil</option><option id="estado-civil-pessoa-parent_2" value="2">Casado(a)</option><option id="estado-civil-pessoa-parent_6" value="6">Companheiro(a)</option><option id="estado-civil-pessoa-parent_3" value="3">Divorciado(a)</option><option id="estado-civil-pessoa-parent_4" value="4">Separado(a)</option><option id="estado-civil-pessoa-parent_1" value="1">Solteiro(a)</option><option id="estado-civil-pessoa-parent_5" value="5">Vi&uacute;vo(a)</option></select></fieldset><p><a id="link_cadastro_detalhado_parent" target="_blank">Cadastro detalhado</a></p></form></div>');
  923 +
  924 + $j('#dialog-form-pessoa-parent').find(':input').css('display', 'block');
  925 +
  926 + var nameParent = $j("#nome-pessoa-parent"),
  927 + sexoParent = $j( "#sexo-pessoa-parent" ),
  928 + estadocivilParent = $j( "#estado-civil-pessoa-parent" ),
  929 + allFields = $j( [] ).add( nameParent ).add( sexoParent ).add( estadocivilParent );
  930 +
  931 + $j( "#dialog-form-pessoa-parent" ).dialog({
  932 + autoOpen: false,
  933 + height: 'auto',
  934 + width: 'auto',
  935 + modal: true,
  936 + resizable: false,
  937 + draggable: false,
  938 + buttons: {
  939 + "Gravar" : function() {
  940 + var bValid = true;
  941 + allFields.removeClass( "ui-state-error" );
  942 +
  943 + bValid = bValid && checkLength( nameParent, "nome", 3, 255 );
  944 + bValid = bValid && checkSelect( sexoParent, "sexo");
  945 + bValid = bValid && checkSelect( estadocivilParent, "estado civil");
  946 +
  947 + if ( bValid ) {
  948 + postPessoa(nameParent, nameParent.val(), sexoParent.val(), estadocivilParent.val(), null, null, (editar_pessoa ? $j('#'+pessoaPaiOuMae+'_id').val() : null), pessoaPaiOuMae);
  949 + $j( this ).dialog( "close" );
  950 + }
  951 + },
  952 + "Cancelar": function() {
  953 +
  954 + $j( this ).dialog( "close" );
  955 + }
  956 + },
  957 + close: function() {
  958 +
  959 + allFields.val( "" ).removeClass( "error" );
  960 +
  961 + },
  962 + hide: {
  963 + effect: "clip",
  964 + duration: 500
  965 + },
  966 +
  967 + show: {
  968 + effect: "clip",
  969 + duration: 500
  970 + }
  971 + });
  972 +
  973 + $j('#link_cadastro_detalhado').click(function(){
  974 + $j( "#dialog-form-pessoa-aluno" ).dialog( "close" );
  975 + });
  976 +
  977 + $j("#cadastrar-pessoa-link").click(function() {
  978 +
  979 + $j('#link_cadastro_detalhado').attr('href','/intranet/atendidos_cad.php');
  980 +
  981 + $j( "#dialog-form-pessoa-aluno" ).dialog( "open" );
  982 +
  983 + $j('#cep_').val('');
  984 + clearEnderecoFields();
  985 + hideEnderecoFields();
  986 +
  987 + $j(".ui-widget-overlay").click(function(){
  988 + $j(".ui-dialog-titlebar-close").trigger('click');
  989 + });
  990 +
  991 + $j('#nome-pessoa-aluno').focus();
  992 +
  993 + $j('#dialog-form-pessoa-aluno form p:first-child').html('Cadastrar pessoa aluno');
  994 +
  995 + editar_pessoa = false;
  996 +
  997 + });
  998 +
  999 + $j("#editar-pessoa-link").click(function() {
  1000 +
  1001 + $j('#link_cadastro_detalhado').attr('href','/intranet/atendidos_cad.php?cod_pessoa_fj=' + person_details.id);
  1002 + clearEnderecoFields();
  1003 +
  1004 + name.val(person_details.nome);
  1005 + datanasc.val(person_details.data_nascimento);
  1006 + estadocivil.val(person_details.estadocivil);
  1007 + sexo.val(person_details.sexo);
  1008 +
  1009 + if (person_details.idmun_nascimento){
  1010 +
  1011 + $j('#naturalidade_aluno_id').val(person_details.idmun_nascimento);
  1012 + $j('#naturalidade_aluno_pessoa-aluno').val(person_details.idmun_nascimento+' - '+person_details.municipio_nascimento+' ('+person_details.sigla_uf_nascimento+')');
  1013 +
  1014 + }
  1015 +
  1016 + $j('#cep_').val(person_details.cep);
  1017 +
  1018 + if ($j('#cep_').val()){
  1019 +
  1020 + $j('#municipio_municipio').removeAttr('disabled');
  1021 + $j('#bairro_bairro').removeAttr('disabled');
  1022 + $j('#logradouro_logradouro').removeAttr('disabled');
  1023 + $j('#bairro').removeAttr('disabled');
  1024 + $j('#zona_localizacao').removeAttr('disabled');
  1025 + $j('#idtlog').removeAttr('disabled');
  1026 + $j('#logradouro').removeAttr('disabled');
  1027 +
  1028 + $j('#complemento').val(person_details.complemento);
  1029 + $j('#numero').val(person_details.numero);
  1030 + $j('#letra').val(person_details.letra);
  1031 + $j('#apartamento').val(person_details.apartamento);
  1032 + $j('#bloco').val(person_details.bloco);
  1033 + $j('#andar').val(person_details.andar);
  1034 +
  1035 + $j('#municipio_id').val(person_details.idmun);
  1036 +
  1037 + $j('#municipio_municipio').val(person_details.idmun+' - '+person_details.municipio+' ('+person_details.sigla_uf+')');
  1038 +
  1039 + if (person_details.idbai && person_details.idlog){
  1040 +
  1041 + $j('#bairro_id').val(person_details.idbai);
  1042 + $j('#logradouro_id').val(person_details.idlog);
  1043 + $j('#bairro_bairro').val(person_details.bairro + ' / Zona '+(person_details.zona_localizacao == "1" ? "Urbana" : "Rural"));
  1044 + $j('#logradouro_logradouro').val($j("#idtlog option[value='"+person_details.idtlog+"']").text() + ' '+person_details.logradouro);
  1045 +
  1046 + }else{
  1047 +
  1048 + $j('#bairro').val(person_details.bairro);
  1049 + $j('#logradouro').val(person_details.logradouro);
  1050 + $j('#idtlog').val(person_details.idtlog);
  1051 + $j('#zona_localizacao').val(person_details.zona_localizacao);
  1052 +
  1053 + }
  1054 + }
  1055 +
  1056 + hideEnderecoFields();
  1057 +
  1058 + $j( "#dialog-form-pessoa-aluno" ).dialog("open");
  1059 +
  1060 + $j(".ui-widget-overlay").click(function(){
  1061 + $j(".ui-dialog-titlebar-close").trigger('click');
  1062 + });
  1063 +
  1064 + $j('#nome-pessoa-aluno').focus();
  1065 +
  1066 + $j('#dialog-form-pessoa-aluno form p:first-child').html('Editar pessoa aluno');
  1067 +
  1068 + editar_pessoa = true;
  1069 +
  1070 + });
  1071 +
  1072 + $j("#cadastrar-pessoa-pai-link").click(function() {
  1073 +
  1074 + if($j('#pessoa_id').val()){
  1075 +
  1076 + openModalParent('pai');
  1077 +
  1078 + }else{
  1079 +
  1080 + alertSelecionarPessoaAluno();
  1081 + }
  1082 +
  1083 + });
  1084 +
  1085 +
  1086 + $j("#cadastrar-pessoa-mae-link").click(function() {
  1087 +
  1088 + if($j('#pessoa_id').val()){
  1089 +
  1090 + openModalParent('mae');
  1091 +
  1092 + }else{
  1093 + alertSelecionarPessoaAluno();
  1094 + }
  1095 +
  1096 + });
  1097 +
  1098 + $j("#editar-pessoa-pai-link").click(function() {
  1099 +
  1100 + if($j('#pessoa_id').val()){
  1101 +
  1102 + openEditModalParent('pai');
  1103 +
  1104 + }
  1105 +
  1106 + });
  1107 +
  1108 +
  1109 + $j("#editar-pessoa-mae-link").click(function() {
  1110 +
  1111 + if($j('#pessoa_id').val()){
  1112 +
  1113 + openEditModalParent('mae');
  1114 +
  1115 + }
  1116 +
  1117 + });
  1118 +
  1119 + function alertSelecionarPessoaAluno(){
  1120 + messageUtils.error('Primeiro cadastre/selecione uma pessoa para o aluno. ');
  1121 + }
  1122 +
  1123 + function openModalParent(parentType){
  1124 +
  1125 + $j('#link_cadastro_detalhado_parent').attr('href','/intranet/atendidos_cad.php?parent_type='+parentType);
  1126 +
  1127 + $j( "#dialog-form-pessoa-parent" ).dialog( "open" );
  1128 +
  1129 + $j(".ui-widget-overlay").click(function(){
  1130 + $j(".ui-dialog-titlebar-close").trigger('click');
  1131 + });
  1132 +
  1133 + $j('#nome-pessoa-parent').focus();
  1134 +
  1135 + $j('#dialog-form-pessoa-parent form p:first-child').html('Cadastrar pessoa '+(parentType == 'mae' ? 'm&atilde;e' : parentType));
  1136 +
  1137 + pessoaPaiOuMae = parentType;
  1138 +
  1139 + editar_pessoa = false;
  1140 +
  1141 + }
  1142 +
  1143 + function openEditModalParent(parentType){
  1144 +
  1145 + $j('#link_cadastro_detalhado_parent').attr('href','/intranet/atendidos_cad.php?cod_pessoa_fj='+ $j('#'+parentType+'_id').val() +'parent_type='+parentType);
  1146 +
  1147 + $j( "#dialog-form-pessoa-parent" ).dialog( "open" );
  1148 +
  1149 + $j(".ui-widget-overlay").click(function(){
  1150 + $j(".ui-dialog-titlebar-close").trigger('click');
  1151 + });
  1152 +
  1153 + $j('#nome-pessoa-parent').focus();
  1154 +
  1155 + nameParent.val(window[parentType+'_details'].nome);
  1156 + estadocivilParent.val(window[parentType+'_details'].estadocivil);
  1157 + sexoParent.val(window[parentType+'_details'].sexo);
  1158 +
  1159 + $j('#dialog-form-pessoa-parent form p:first-child').html('Editar pessoa '+(parentType == 'mae' ? 'm&atilde;e' : parentType));
  1160 +
  1161 + pessoaPaiOuMae = parentType;
  1162 +
  1163 + editar_pessoa = true;
  1164 + }
  1165 +
  1166 + function checkLength( o, n, min, max ) {
  1167 + if ( o.val().length > max || o.val().length < min ) {
  1168 + o.addClass( "error" );
  1169 + messageUtils.error( "Tamanho do " + n + " deve ter entre " +
  1170 + min + " e " + max + " caracteres." );
  1171 + return false;
  1172 + } else {
  1173 + return true;
  1174 + }
  1175 + }
  1176 +
  1177 + function checkRegexp( o, regexp, n ) {
  1178 + if ( !( regexp.test( o.val() ) ) ) {
  1179 + o.addClass( "error" );
  1180 + messageUtils.error( n );
  1181 + return false;
  1182 + } else {
  1183 + return true;
  1184 + }
  1185 + }
  1186 +
  1187 + function checkSelect(comp, name) {
  1188 +
  1189 + if ( comp.val() == '') {
  1190 + comp.addClass( "error" );
  1191 + messageUtils.error( "Selecione um "+name+"." );
  1192 + return false;
  1193 + } else {
  1194 + return true;
  1195 + }
  1196 +
  1197 + }
  1198 +
  1199 + function checkSimpleSearch(comp, hiddenComp, name) {
  1200 +
  1201 + if ( hiddenComp.val() == '') {
  1202 + comp.addClass( "error" );
  1203 + messageUtils.error( "Selecione um "+name+"." );
  1204 + return false;
  1205 + } else {
  1206 + return true;
  1207 + }
  1208 +
  1209 + }
  1210 +
  1211 + $j('#pai_id').change( function(){ getPersonParentDetails($j(this).val(), 'pai') });
  1212 + $j('#mae_id').change( function(){ getPersonParentDetails($j(this).val(), 'mae' ) });
659 1213 }); // ready
  1214 +
  1215 + function postPessoa($pessoaField, nome, sexo, estadocivil, datanasc, naturalidade, pessoa_id, parentType) {
  1216 +
  1217 + var data = {
  1218 + nome : nome,
  1219 + sexo : sexo,
  1220 + estadocivil : estadocivil,
  1221 + datanasc : datanasc,
  1222 + naturalidade : naturalidade,
  1223 + pessoa_id : pessoa_id
  1224 + };
  1225 +
  1226 + var options = {
  1227 + url : postResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa', {}),
  1228 + dataType : 'json',
  1229 + data : data,
  1230 + success : function(dataResponse) {
  1231 + if(parentType=='mae')
  1232 + afterChangePessoaParent(dataResponse.pessoa_id, 'mae');
  1233 + else if(parentType=='pai')
  1234 + afterChangePessoaParent(dataResponse.pessoa_id, 'pai');
  1235 + else
  1236 + postEnderecoPessoa(dataResponse.pessoa_id);
  1237 + }
  1238 + };
  1239 +
  1240 + postResource(options);
  1241 +
  1242 + }
  1243 +
  1244 + function postEnderecoPessoa(pessoa_id) {
  1245 +
  1246 + if (checkCepFields($j('#cep_').val())){
  1247 +
  1248 + var data = {
  1249 + pessoa_id : pessoa_id,
  1250 + cep : $j('#cep_').val(),
  1251 + municipio_id : $j('#municipio_id').val(),
  1252 + bairro : $j('#bairro').val(),
  1253 + bairro_id : $j('#bairro_id').val(),
  1254 + zona_localizacao : $j('#zona_localizacao').val(),
  1255 + logradouro : $j('#logradouro').val(),
  1256 + idtlog : $j('#idtlog').val(),
  1257 + logradouro_id : $j('#logradouro_id').val(),
  1258 + apartamento : $j('#apartamento').val(),
  1259 + complemento : $j('#complemento').val(),
  1260 + numero : $j('#numero').val(),
  1261 + letra : $j('#letra').val(),
  1262 + bloco : $j('#bloco').val(),
  1263 + andar : $j('#andar').val()
  1264 + };
  1265 +
  1266 + var options = {
  1267 + url : postResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa-endereco', {}),
  1268 + dataType : 'json',
  1269 + data : data,
  1270 + success : function(dataResponse) {
  1271 + afterChangePessoa(null,pessoa_id);
  1272 + }
  1273 + };
  1274 +
  1275 + postResource(options);
  1276 +
  1277 + }else{
  1278 + afterChangePessoa(null,pessoa_id);
  1279 + }
  1280 +
  1281 + }
  1282 +
660 1283 })(jQuery);
661 1284 \ No newline at end of file
... ...
ieducar/modules/Cadastro/Assets/Javascripts/Endereco.js
... ... @@ -29,6 +29,7 @@ function hideEnderecoFields(){
29 29  
30 30 function preenchaCampoCepPrimeiro(){
31 31 messageUtils.error('Digite um CEP primeiro...');
  32 + $j('#cep_').focus();
32 33 }
33 34  
34 35  
... ... @@ -131,7 +132,7 @@ function bloqueiaBuscaBairro(){
131 132 if (checkCepFields($j('#cep_').val())){
132 133 $j('#bairro_bairro').closest('tr').hide();
133 134 $j('#bairro').closest('tr').show();
134   - $j('#bairro').val($j('#bairro_bairro').val());
  135 + $j('#bairro').val($j('#bairro').val() ? $j('#bairro').val() :$j('#bairro_bairro').val());
135 136 $j('#bairro_bairro').val('');
136 137 $j('#bairro_id').val('');
137 138 }
... ... @@ -153,7 +154,7 @@ function bloqueiaBuscaLogradouro(){
153 154 if (checkCepFields($j('#cep_').val())){
154 155 $j('#logradouro_logradouro').closest('tr').hide();
155 156 $j('#idtlog').closest('tr').show();
156   - $j('#logradouro').val($j('#logradouro_logradouro').val());
  157 + $j('#logradouro').val($j('#logradouro').val() ? $j('#logradouro').val() :$j('#logradouro_logradouro').val());
157 158 $j('#logradouro_logradouro').val('');
158 159 $j('#logradouro_id').val('');
159 160 }else{
... ... @@ -273,10 +274,19 @@ function validateEndereco(){
273 274  
274 275 var err = false;
275 276  
  277 + if (!checkCepFields($j('#cep_').val())){
  278 +
  279 + $j('#municipio_municipio').addClass('error');
  280 + $j('#municipio_id').addClass('error');
  281 + messageUtils.error('Informe um CEP no formato NNNNN-NNN.');
  282 + err = true;
  283 +
  284 + }
  285 +
276 286 if (!$j('#municipio_id').val()){
277 287 $j('#municipio_municipio').addClass('error');
278 288 $j('#municipio_id').addClass('error');
279   - messageUtils.error('Selecione um município corretamente');
  289 + messageUtils.error('Selecione um município corretamente.');
280 290 err = true;
281 291 }
282 292  
... ...
ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css
... ... @@ -116,7 +116,7 @@
116 116 height: 25px;
117 117 background-color: #e4e9ed;
118 118 text-align: center;
119   - font-weight: bold;
  119 + font-weight: bold;
120 120 }
121 121  
122 122 .alunoTab-active2{
... ... @@ -140,19 +140,78 @@
140 140 height: 25px;
141 141 background-color: white;
142 142 text-align: center;
143   - font-weight: bold;
  143 + font-weight: bold;
144 144 }
145 145  
146 146 .tabText{
147 147 position: relative;
148   - top: 6px;
  148 + top: 6px;
149 149 }
150 150  
151 151 #tr_tit_dados_hospital, #tr_tit_dados_responsavel,
152   -#tit_dados_hospital, #tit_dados_responsavel, #tr_label_calca,
153   -#tr_label_calcado, #tr_label_saia, #tr_label_camiseta,
  152 +#tit_dados_hospital, #tit_dados_responsavel, #tr_label_calca,
  153 +#tr_label_calcado, #tr_label_saia, #tr_label_camiseta,
154 154 #tr_label_meia, #tr_label_bermuda, #tr_label_blusa_jaqueta,
155 155 .tit_uniforme{
156 156 font-weight: bold;
157 157 font-size: 11px;
  158 +}
  159 +
  160 +/* MODAL TESTE :p
  161 +
  162 +#dialog-form-pessoa-aluno { font-size: 62.5%; }
  163 +#dialog-form-pessoa-aluno label, dialog-form-pessoa-aluno input { display:block; }
  164 +#dialog-form-pessoa-aluno > input { margin-bottom:12px; width:95%; padding: .4em; }
  165 +#dialog-form-pessoa-aluno > fieldset { padding:0; border:0; margin-top:25px; }
  166 +#dialog-form-pessoa-aluno > h1 { font-size: 1.2em; margin: .6em 0; }*/
  167 +
  168 +.ui-dialog .ui-state-error { padding: .3em; }
  169 +.validateTips-pessoa-aluno { border: 1px solid transparent; padding: 0.3em; }
  170 +
  171 +.ui-widget-overlay{
  172 + background:black;
  173 +}
  174 +
  175 +.ui-dialog-titlebar {display:none}
  176 +
  177 +.ui-state-error {
  178 + background: white !important;
  179 + color: black !important;
  180 +}
  181 +
  182 +.ui-button span{
  183 +
  184 + color: #495C67 !important;
  185 + border: 1px solid #495C67 !important;
  186 +
  187 +}
  188 +
  189 +.ui-state-hover, .ui-state-focus{
  190 + border: 0px !important;
  191 +}
  192 +
  193 +fieldset {
  194 + border: 0px;
  195 +}
  196 +
  197 +fieldset legend{
  198 + font-weight: bold;
  199 +
  200 +}
  201 +
  202 +tr td:first-child legend{
  203 + margin-left: -3px;
  204 +}
  205 +
  206 +#feedback-messages{
  207 + z-index: 1050;
  208 +}
  209 +
  210 +.ui-button-text {
  211 + font-size: 12px !important;
  212 +}
  213 +
  214 +div p a{
  215 + color: blue !important;
  216 + cursor: pointer;
158 217 }
159 218 \ No newline at end of file
... ...
ieducar/modules/Cadastro/Views/AlunoController.php
... ... @@ -31,6 +31,7 @@
31 31 * @version $Id$
32 32 */
33 33  
  34 +require_once 'App/Model/ZonaLocalizacao.php';
34 35 require_once 'lib/Portabilis/Controller/Page/EditController.php';
35 36 require_once 'Usuario/Model/FuncionarioDataMapper.php';
36 37  
... ... @@ -356,14 +357,17 @@ class AlunoController extends Portabilis_Controller_Page_EditController
356 357 $options = array('label' => $this->_getLabel('rg'), 'disabled' => true, 'required' => false, 'size' => 25);
357 358 $this->inputsHelper()->integer('rg', $options);
358 359  
359   - // pai
  360 + $this->inputPai();
  361 + $this->inputMae();
  362 +
  363 +/* // pai
360 364 $options = array('label' => $this->_getLabel('pai'), 'disabled' => true, 'required' => false, 'size' => 68);
361 365 $this->inputsHelper()->text('pai', $options);
362 366  
363 367  
364 368 // mãe
365 369 $options = array('label' => $this->_getLabel('mae'), 'disabled' => true, 'required' => false, 'size' => 68);
366   - $this->inputsHelper()->text('mae', $options);
  370 + $this->inputsHelper()->text('mae', $options);*/
367 371  
368 372  
369 373 // responsável
... ... @@ -805,7 +809,217 @@ class AlunoController extends Portabilis_Controller_Page_EditController
805 809 $options = array('label' => Portabilis_String_Utils::toLatin1($this->_getLabel('lixo') ), 'required' => false, 'placeholder' => '');
806 810 $this->inputsHelper()->checkbox('lixo',$options);
807 811  
  812 + $this->inputsHelper()->simpleSearchMunicipio('pessoa-aluno', array('required' => false, 'size' => 57), array('objectName' => 'naturalidade_aluno'));
  813 +
  814 + $enderecamentoObrigatorio = false;
  815 + $desativarCamposDefinidosViaCep = true;
  816 +
  817 + $this->campoCep(
  818 + 'cep_',
  819 + 'CEP',
  820 + '',
  821 + $enderecamentoObrigatorio,
  822 + '-',
  823 + "&nbsp;<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=\'/intranet/educar_pesquisa_cep_log_bairro.php?campo1=bairro_bairro&campo2=bairro_id&campo3=cep&campo4=logradouro_logradouro&campo5=logradouro_id&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=municipio_municipio&campo12=idtlog&campo13=municipio_id&campo14=zona_localizacao\'></iframe>');\">",
  824 + false
  825 + );
  826 +
  827 + $options = array('label' => Portabilis_String_Utils::toLatin1('Município'), 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
  828 +
  829 + $helperOptions = array('objectName' => 'municipio',
  830 + 'hiddenInputOptions' => array('options' => array('value' => $this->municipio_id)));
  831 +
  832 + $this->inputsHelper()->simpleSearchMunicipio('municipio', $options, $helperOptions);
  833 +
  834 + $helperOptions = array('hiddenInputOptions' => array('options' => array('value' => $this->bairro_id)));
  835 +
  836 + $options = array( 'label' => Portabilis_String_Utils::toLatin1('Bairro / Zona de Localização - <b>Buscar</b>'), 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
  837 +
  838 +
  839 + $this->inputsHelper()->simpleSearchBairro('bairro', $options, $helperOptions);
  840 +
  841 + $options = array(
  842 + 'label' => 'Bairro / Zona de Localização - <b>Cadastrar</b>',
  843 + 'placeholder' => 'Bairro',
  844 + 'value' => $this->bairro,
  845 + 'max_length' => 40,
  846 + 'disabled' => $desativarCamposDefinidosViaCep,
  847 + 'inline' => true,
  848 + 'required' => $enderecamentoObrigatorio
  849 + );
  850 +
  851 + $this->inputsHelper()->text('bairro', $options);
  852 +
  853 + // zona localização
  854 +
  855 + $zonas = App_Model_ZonaLocalizacao::getInstance();
  856 + $zonas = $zonas->getEnums();
  857 + $zonas = Portabilis_Array_Utils::insertIn(null, 'Zona localiza&ccedil;&atilde;o', $zonas);
  858 +
  859 + $options = array(
  860 + 'label' => '',
  861 + 'placeholder' => 'Zona localização',
  862 + 'value' => $this->zona_localizacao,
  863 + 'disabled' => $desativarCamposDefinidosViaCep,
  864 + 'resources' => $zonas,
  865 + 'required' => $enderecamentoObrigatorio
  866 + );
  867 +
  868 + $this->inputsHelper()->select('zona_localizacao', $options);
  869 +
  870 + $helperOptions = array('hiddenInputOptions' => array('options' => array('value' => $this->logradouro_id)));
  871 +
  872 + $options = array('label' => 'Tipo / Logradouro - <b>Buscar</b>', 'required' => $enderecamentoObrigatorio, 'disabled' => $desativarCamposDefinidosViaCep);
  873 +
  874 + $this->inputsHelper()->simpleSearchLogradouro('logradouro', $options, $helperOptions);
  875 +
  876 + // tipo logradouro
  877 +
  878 + $options = array(
  879 + 'label' => 'Tipo / Logradouro - <b>Cadastrar</b>',
  880 + 'value' => $this->idtlog,
  881 + 'disabled' => $desativarCamposDefinidosViaCep,
  882 + 'inline' => true,
  883 + 'required' => $enderecamentoObrigatorio
  884 + );
  885 +
  886 + $helperOptions = array(
  887 + 'attrName' => 'idtlog'
  888 + );
  889 +
  890 + $this->inputsHelper()->tipoLogradouro($options, $helperOptions);
  891 +
  892 +
  893 + // logradouro
  894 +
  895 + $options = array(
  896 + 'label' => '',
  897 + 'placeholder' => 'Logradouro',
  898 + 'value' => '',
  899 + 'max_length' => 150,
  900 + 'disabled' => $desativarCamposDefinidosViaCep,
  901 + 'required' => $enderecamentoObrigatorio
  902 + );
  903 +
  904 + $this->inputsHelper()->text('logradouro', $options);
  905 +
  906 + // complemento
  907 +
  908 + $options = array(
  909 + 'required' => false,
  910 + 'value' => '',
  911 + 'max_length' => 20
  912 + );
  913 +
  914 + $this->inputsHelper()->text('complemento', $options);
  915 +
  916 +
  917 + // numero
  918 +
  919 + $options = array(
  920 + 'required' => false,
  921 + 'label' => 'Número / Letra',
  922 + 'placeholder' => Portabilis_String_Utils::toLatin1('Número'),
  923 + 'value' => '',
  924 + 'max_length' => 6,
  925 + 'inline' => true
  926 + );
  927 +
  928 + $this->inputsHelper()->integer('numero', $options);
  929 +
  930 +
  931 + // letra
  932 +
  933 + $options = array(
  934 + 'required' => false,
  935 + 'label' => '',
  936 + 'placeholder' => 'Letra',
  937 + 'value' => $this->letra,
  938 + 'max_length' => 1,
  939 + 'size' => 15
  940 + );
  941 +
  942 + $this->inputsHelper()->text('letra', $options);
  943 +
  944 +
  945 + // apartamento
  946 +
  947 + $options = array(
  948 + 'required' => false,
  949 + 'label' => 'Nº apartamento / Bloco / Andar',
  950 + 'placeholder' => 'Apartamento',
  951 + 'value' => $this->apartamento,
  952 + 'max_length' => 6,
  953 + 'inline' => true
  954 + );
  955 +
  956 + $this->inputsHelper()->integer('apartamento', $options);
  957 +
  958 +
  959 + // bloco
  960 +
  961 + $options = array(
  962 + 'required' => false,
  963 + 'label' => '',
  964 + 'placeholder' => 'Bloco',
  965 + 'value' => $this->bloco,
  966 + 'max_length' => 20,
  967 + 'size' => 15,
  968 + 'inline' => true
  969 + );
  970 +
  971 + $this->inputsHelper()->text('bloco', $options);
  972 +
  973 +
  974 + // andar
  975 +
  976 + $options = array(
  977 + 'required' => false,
  978 + 'label' => '',
  979 + 'placeholder' => 'Andar',
  980 + 'value' => $this->andar,
  981 + 'max_length' => 2
  982 + );
  983 +
  984 + $this->inputsHelper()->integer('andar', $options);
  985 +
  986 + $script = '/modules/Cadastro/Assets/Javascripts/Endereco.js';
  987 +
  988 + Portabilis_View_Helper_Application::loadJavascript($this, $script);
  989 +
808 990 $this->loadResourceAssets($this->getDispatcher());
  991 +
  992 + }
  993 +
  994 + protected function addParentsInput($parentType, $parentTypeLabel = '') {
  995 + if (! $parentTypeLabel)
  996 + $parentTypeLabel = $parentType;
  997 +
  998 +
  999 + $parentId = $this->{$parentType . '_id'};
  1000 +
  1001 +
  1002 + // mostra uma dica nos casos em que foi informado apenas o nome dos pais,
  1003 + //pela antiga interface do cadastro de alunos.
  1004 +
  1005 +
  1006 +
  1007 + $hiddenInputOptions = array('options' => array('value' => $parentId));
  1008 + $helperOptions = array('objectName' => $parentType, 'hiddenInputOptions' => $hiddenInputOptions);
  1009 +
  1010 + $options = array('label' => 'Pessoa ' . $parentTypeLabel,
  1011 + 'size' => 69,
  1012 + 'required' => false);
  1013 +
  1014 + $this->inputsHelper()->simpleSearchPessoa('nome', $options, $helperOptions);
  1015 + }
  1016 +
  1017 + protected function inputPai() {
  1018 + $this->addParentsInput('pai');
  1019 + }
  1020 +
  1021 + protected function inputMae() {
  1022 + $this->addParentsInput('mae', 'mãe');
809 1023 }
810 1024 }
811 1025 ?>
812 1026 \ No newline at end of file
... ...
ieducar/modules/Portabilis/Assets/Version.php
... ... @@ -5,7 +5,7 @@
5 5  
6 6 class Portabilis_Assets_Version {
7 7  
8   - const VERSION = '13';
  8 + const VERSION = '14';
9 9  
10 10 }
11 11 ?>
... ...