Commit f98f7da8917a647526054f57fda9fcfc619f185e

Authored by Caroline Salib
2 parents 57f7bbca 6185c0f5

Merge branch 'master' into 'master'

Merge request - Correção de bug na rematricula automática e modal no cadastro de alunos

See merge request !8
ieducar/intranet/atendidos_cad.php
... ... @@ -932,7 +932,7 @@ class indice extends clsCadastro
932 932 if (parentType)
933 933 window.opener.afterChangePessoa(self, parentType, $id, \$j('#nm_pessoa').val());
934 934 else
935   - window.opener.afterChangePessoa(self, $id);
  935 + window.opener.afterChangePessoa(self, null, $id, \$j('#nm_pessoa').val());
936 936 }
937 937 else
938 938 document.location = 'atendidos_lst.php';
... ...
ieducar/intranet/educar_avancar_mod_cad.php
... ... @@ -79,6 +79,7 @@ class indice extends clsCadastro
79 79 $this->inputsHelper()->dynamic('turma', array('label' => 'Selecione a turma do ano anterior'));
80 80 $this->inputsHelper()->dynamic('anoLetivo', array('label' => 'Ano destino'), $anoLetivoHelperOptions);
81 81 $this->inputsHelper()->date('data_matricula', array('label' => 'Data da matrícula', 'placeholder' => 'dd/mm/yyyy'));
  82 + $this->inputsHelper()->hidden('nao_filtrar_ano', array('value' => '1'));
82 83 }
83 84  
84 85 /**
... ... @@ -138,8 +139,8 @@ class indice extends clsCadastro
138 139 $mensagem .= "</br> As enturmações podem ser realizadas em: Movimentação > Enturmação.</span>";
139 140 $this->mensagem = $mensagem;
140 141 }else{
141   - $this->mensagem = "<span class='notice'>Nenhum aluno rematriculado. Certifique-se que a turma possui alunos aprovados ou reprovados não matriculados em $ano.</span>";
142   - }
  142 + $this->mensagem = "<span class='notice'>Nenhum aluno rematriculado. Certifique-se que a turma possui alunos aprovados ou reprovados não matriculados em ".($ano-1).".</span>";
  143 + }
143 144 }elseif(empty($this->mensagem))
144 145 $this->mensagem = "Ocorreu algum erro inesperado durante as rematrículas, por favor, tente novamente.";
145 146  
... ...
ieducar/intranet/include/clsGrafico.inc.php
... ... @@ -104,7 +104,7 @@
104 104  
105 105 <script type='text/javascript' src='scripts/padrao.js'></script>
106 106 <script type='text/javascript' src='scripts/novo.js'></script>
107   - <script type='text/javascript' src='scripts/dom.js'></script>
  107 + <script type='text/javascript' src='scripts/dom.js?2'></script>
108 108  
109 109 <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
110 110 <meta http-equiv=\"Pragma\" content=\"no-cache\">
... ... @@ -361,7 +361,7 @@
361 361  
362 362 <script type='text/javascript' src='scripts/padrao.js'></script>
363 363 <script type='text/javascript' src='scripts/novo.js'></script>
364   - <script type='text/javascript' src='scripts/dom.js'></script>
  364 + <script type='text/javascript' src='scripts/dom.js?2'></script>
365 365  
366 366 <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
367 367 <meta http-equiv=\"Pragma\" content=\"no-cache\">
... ...
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/intranet/templates/nvp_htmlhead.tpl
... ... @@ -23,7 +23,7 @@
23 23  
24 24 <script type="text/javascript" src="scripts/padrao.js?1"></script>
25 25 <script type="text/javascript" src="scripts/novo.js?1"></script>
26   - <script type="text/javascript" src="scripts/dom.js?1"></script>
  26 + <script type="text/javascript" src="scripts/dom.js?2"></script>
27 27 <script type="text/javascript" src="scripts/menu.js?1"></script>
28 28 <script type="text/javascript" src="scripts/ied/forms.js?1"></script>
29 29 <script type="text/javascript" src="scripts/ied/phpjs.js?1"></script>
... ...
ieducar/lib/App/Model/IedFinder.php
... ... @@ -237,7 +237,7 @@ class App_Model_IedFinder extends CoreExt_Entity
237 237  
238 238 $ret = array();
239 239 foreach ($turmas as $turma) {
240   - $ret[$turma['cod_turma']] = $turma['nm_turma'];
  240 + $ret[$turma['cod_turma']] = $turma['nm_turma'].' - '.($turma['ano'] == null ? 'Sem ano' : $turma['ano'] );
241 241 }
242 242  
243 243 return $ret;
... ...
ieducar/lib/Portabilis/View/Helper/DynamicInput/Turma.php
... ... @@ -54,6 +54,7 @@ class Portabilis_View_Helper_DynamicInput_Turma extends Portabilis_View_Helper_D
54 54 $escolaId = $this->getEscolaId($options['escolaId']);
55 55 $serieId = $this->getSerieId($options['serieId']);
56 56 $ano = $this->viewInstance->ano;
  57 + $naoFiltrarAno = $this->viewInstance->nao_filtrar_ano;
57 58  
58 59 $userId = $this->getCurrentUserId();
59 60 $isProfessor = Portabilis_Business_Professor::isProfessor($instituicaoId, $userId);
... ... @@ -69,7 +70,7 @@ class Portabilis_View_Helper_DynamicInput_Turma extends Portabilis_View_Helper_D
69 70 // caso no letivo esteja definido para filtrar turmas por ano,
70 71 // somente exibe as turmas do ano letivo.
71 72  
72   - if ($escolaId && $ano && $this->turmasPorAno($escolaId, $ano)) {
  73 + if ($escolaId && $ano && !$naoFiltrarAno && $this->turmasPorAno($escolaId, $ano)) {
73 74 foreach ($resources as $id => $nome) {
74 75 $turma = new clsPmieducarTurma();
75 76 $turma->cod_turma = $id;
... ...
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 &#39;lib/Portabilis/Controller/ApiCoreController.php&#39;;
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 = Portabilis_String_Utils::toLatin1($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(&#39;&lt;span&gt;&#39;).html(&#39;&#39;)
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');
  484 +
  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 + }
387 493  
388   - if (dataResponse.mae_id)
389   - nomeMae = dataResponse.mae_id + ' - ' + nomeMae;
  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,25 @@ 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 + }
  552 + }
431 553 }
432 554  
433 555 var getPersonDetails = function(personId) {
... ... @@ -445,7 +567,25 @@ var getPersonDetails = function(personId) {
445 567 getResource(options);
446 568 }
447 569  
  570 +var getPersonParentDetails = function(personId,parentType) {
  571 + var additionalVars = {
  572 + id : personId
  573 + };
  574 +
  575 + var options = {
  576 + url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa-parent', additionalVars),
  577 + dataType : 'json',
  578 + data : {},
  579 + success : function(data){
  580 + handleGetPersonParentDetails(data, parentType)
  581 + }
  582 + };
  583 +
  584 + getResource(options);
  585 +}
  586 +
448 587 var updatePersonDetails = function() {
  588 + canShowParentsFields();
449 589 if ($j('#pessoa_nome').val() && $j('#pessoa_id').val())
450 590 getPersonDetails($j('#pessoa_id').val());
451 591 else
... ... @@ -468,29 +608,69 @@ var simpleSearchPessoaOptions = {
468 608  
469 609 // children callbacks
470 610  
471   -function afterChangePessoa(targetWindow, pessoaId) {
472   - targetWindow.close();
  611 +function afterChangePessoa(targetWindow, parentType, parentId, parentName) {
  612 + if (targetWindow != null)
  613 + targetWindow.close();
  614 +
  615 + var $tempIdField;
  616 + var $tempNomeField;
  617 +
  618 + if(parentType){
  619 + $tempIdField = $j(buildId(parentType + '_id'));
  620 + $tempNomeField = $j(buildId(parentType + '_nome'));
  621 + }else{
  622 + $tempIdField = $j('pessoa_id');
  623 + $tempNomeField = $nomeField;
  624 + }
  625 +
473 626  
474 627 // timeout para usuario perceber mudança
475 628 window.setTimeout(function() {
476   - messageUtils.success('Pessoa alterada com sucesso', $nomeField);
  629 + messageUtils.success('Pessoa alterada com sucesso', $tempNomeField);
477 630  
478   - $j('#pessoa_id').val(pessoaId);
479   - getPersonDetails(pessoaId);
  631 + $tempIdField.val(parentId);
  632 + if(!parentType){
  633 + getPersonDetails(parentId);
  634 + }else{
  635 + $tempNomeField.val(parentId + ' - ' +parentName);
  636 + }
480 637  
481   - if ($nomeField.is(':active'))
482   - $nomeField.focus();
  638 + if ($tempNomeField.is(':active'))
  639 + $tempNomeField.focus();
  640 +
  641 + changeVisibilityOfLinksToPessoaParent(parentType);
483 642  
484 643 }, 500);
485 644 }
486 645  
  646 +function afterChangePessoaParent(pessoaId, parentType) {
  647 +
  648 + $tempField = (parentType == 'pai' ? $paiNomeField : $maeNomeField);
  649 +
  650 + messageUtils.success('Pessoa '+parentType+' alterada com sucesso', $tempField);
  651 +
  652 + getPersonParentDetails(pessoaId, parentType);
  653 +
  654 + if ($tempField.is(':active'))
  655 + $tempField.focus();
  656 +}
  657 +
  658 +function canShowParentsFields(){
  659 + if ($j('#pessoa_id').val()){
  660 + $paiNomeField.removeAttr('disabled');
  661 + $maeNomeField.removeAttr('disabled');
  662 + }else{
  663 + $paiNomeField.attr('disabled', 'true');
  664 + $maeNomeField.attr('disabled', 'true');
  665 + }
  666 +}
487 667  
488 668 // when page is ready
489 669  
490 670 (function($) {
491 671 $(document).ready(function() {
492 672  
493   - // pessoa
  673 + canShowParentsFields();
494 674  
495 675 var $pessoaActionBar = $j('<span>').html('')
496 676 .addClass('pessoa-links')
... ... @@ -499,15 +679,13 @@ function afterChangePessoa(targetWindow, pessoaId) {
499 679  
500 680 $j('<a>').hide()
501 681 .addClass('cadastrar-pessoa decorated')
502   - .attr('href', '/intranet/atendidos_cad.php')
503   - .attr('target', '_blank')
  682 + .attr('id', 'cadastrar-pessoa-link')
504 683 .html('Cadastrar pessoa')
505 684 .appendTo($pessoaActionBar);
506 685  
507 686 $j('<a>').hide()
508 687 .addClass('editar-pessoa decorated')
509   - .attr('href', '#')
510   - .attr('target', '_blank')
  688 + .attr('id', 'editar-pessoa-link')
511 689 .html('Editar pessoa')
512 690 .appendTo($pessoaActionBar);
513 691  
... ... @@ -627,7 +805,7 @@ function afterChangePessoa(targetWindow, pessoaId) {
627 805  
628 806 if (index<84 && index!=0){
629 807 row.hide();
630   - }else{
  808 + }else if(index<111){
631 809 row.show();
632 810 }
633 811 });
... ... @@ -656,5 +834,472 @@ function afterChangePessoa(targetWindow, pessoaId) {
656 834 }
657 835 });
658 836  
  837 + // MODAL pessoa-aluno
  838 +
  839 + // Esse simplesSearch é carregado no final do arquivo, então a sua linha deve ser escondida,
  840 + // é só campo será 'puxado' para a modal
  841 + $j('#municipio_pessoa-aluno').closest('tr').hide();
  842 +
  843 +
  844 + $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><p><a id="link_cadastro_detalhado" target="_blank">Cadastro detalhado</a></p></form></div>');
  845 +
  846 + var name = $j("#nome-pessoa-aluno"),
  847 + sexo = $j( "#sexo-pessoa-aluno" ),
  848 + estadocivil = $j( "#estado-civil-pessoa-aluno" ),
  849 + datanasc = $j( "#data-nasc-pessoa-aluno" ),
  850 + municipio = $j( "#naturalidade_aluno_pessoa-aluno" ),
  851 + municipio_id = $j( "#naturalidade_aluno_id" ),
  852 + complemento = $j( "#complemento" ),
  853 + numero = $j( "#numero" ),
  854 + letra = $j( "#letra" ),
  855 + apartamento = $j( "#apartamento" ),
  856 + bloco = $j( "#bloco" ),
  857 + andar = $j( "#andar" ),
  858 + allFields = $j( [] ).add( name ).add( sexo ).add( estadocivil ).add(datanasc).add(municipio).add(municipio_id)
  859 + .add(complemento).add(numero).add(letra).add(apartamento).add(bloco).add(andar);
  860 +
  861 + municipio.show().toggleClass('geral text').attr('display', 'block').appendTo('#dialog-form-pessoa-aluno tr td:first-child fieldset');
  862 +
  863 + $j('<label>').html('CEP').attr('for', 'cep_').insertBefore($j('#cep_'));
  864 + $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();
  865 + $j('<label>').html('Munic&iacute;pio').attr('for', 'municipio_municipio').insertBefore($j('#municipio_municipio'));
  866 + $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();
  867 + $j('<label>').html('Logradouro').attr('for', 'logradouro_logradouro').insertBefore($j('#logradouro_logradouro'));
  868 + $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();
  869 + $j('<label>').html('Tipo de logradouro').attr('for', 'idtlog').insertBefore($j('#idtlog'));
  870 + $j('#idtlog').toggleClass('geral text');
  871 + $j('<label>').html('Logradouro').attr('for', 'logradouro').insertBefore($j('#logradouro'));
  872 + $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();
  873 + $j('<label>').html('Bairro').attr('for', 'bairro_bairro').insertBefore($j('#bairro_bairro'));
  874 + $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();
  875 + $j('<label>').html('Zona de localiza&ccedil;&atilde;o').attr('for', 'zona_localizacao').insertBefore($j('#zona_localizacao'));
  876 + $j('#zona_localizacao').toggleClass('geral text');
  877 + $j('<label>').html('Bairro').attr('for', 'bairro').insertBefore($j('#bairro'));
  878 + $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();
  879 +
  880 + $j('<label>').html('Complemento').attr('for', 'complemento').insertBefore($j('#complemento'));
  881 + $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();
  882 + $j('<label>').html('N&uacute;mero').attr('for', 'numero').insertBefore($j('#numero'));
  883 + $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();
  884 + $j('<label>').html('Letra').attr('for', 'letra').insertBefore($j('#letra'));
  885 + $j('#letra').toggleClass('geral text');
  886 + $j('<label>').html('N&ordm; de apartamento').attr('for', 'apartamento').insertBefore($j('#apartamento'));
  887 + $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();
  888 + $j('<label>').html('Bloco').attr('for', 'bloco').insertBefore($j('#bloco'));
  889 + $j('#bloco').toggleClass('geral text');
  890 + $j('<label>').html('Andar').attr('for', 'andar').insertBefore($j('#andar'));
  891 + $j('#andar').toggleClass('geral text');
  892 +
  893 + $j('#dialog-form-pessoa-aluno').find(':input').css('display', 'block');
  894 + $j('#cep_').css('display', 'inline');
  895 +
  896 + $j( "#dialog-form-pessoa-aluno" ).dialog({
  897 + autoOpen: false,
  898 + height: 'auto',
  899 + width: 'auto',
  900 + modal: true,
  901 + resizable: false,
  902 + draggable: false,
  903 + buttons: {
  904 + "Gravar" : function() {
  905 + var bValid = true;
  906 + allFields.removeClass( "error" );
  907 +
  908 + bValid = bValid && checkLength( name, "nome", 3, 255 );
  909 + bValid = bValid && checkSelect( sexo, "sexo");
  910 + bValid = bValid && checkSelect( estadocivil, "estado civil");
  911 + 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." );
  912 + bValid = bValid && checkSimpleSearch( municipio, municipio_id, "munic\u00edpio");
  913 + bValid = bValid && ($j('#cep_').val() == '' ? true : validateEndereco());
  914 +
  915 + if ( bValid ) {
  916 + postPessoa($j('#pessoa_nome'), name.val(), sexo.val(), estadocivil.val(), datanasc.val(), municipio_id.val(), (editar_pessoa ? $j('#pessoa_id').val() : null), null);
  917 + $j( this ).dialog( "close" );
  918 + }
  919 + },
  920 + "Cancelar": function() {
  921 +
  922 + $j( this ).dialog( "close" );
  923 + }
  924 + },
  925 + close: function() {
  926 +
  927 + allFields.val( "" ).removeClass( "error" );
  928 +
  929 + },
  930 + hide: {
  931 + effect: "clip",
  932 + duration: 500
  933 + },
  934 +
  935 + show: {
  936 + effect: "clip",
  937 + duration: 500
  938 + }
  939 + });
  940 +
  941 + $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>');
  942 +
  943 + $j('#dialog-form-pessoa-parent').find(':input').css('display', 'block');
  944 +
  945 + var nameParent = $j("#nome-pessoa-parent"),
  946 + sexoParent = $j( "#sexo-pessoa-parent" ),
  947 + estadocivilParent = $j( "#estado-civil-pessoa-parent" ),
  948 + allFields = $j( [] ).add( nameParent ).add( sexoParent ).add( estadocivilParent );
  949 +
  950 + $j( "#dialog-form-pessoa-parent" ).dialog({
  951 + autoOpen: false,
  952 + height: 'auto',
  953 + width: 'auto',
  954 + modal: true,
  955 + resizable: false,
  956 + draggable: false,
  957 + buttons: {
  958 + "Gravar" : function() {
  959 + var bValid = true;
  960 + allFields.removeClass( "ui-state-error" );
  961 +
  962 + bValid = bValid && checkLength( nameParent, "nome", 3, 255 );
  963 + bValid = bValid && checkSelect( sexoParent, "sexo");
  964 + bValid = bValid && checkSelect( estadocivilParent, "estado civil");
  965 +
  966 + if ( bValid ) {
  967 + postPessoa(nameParent, nameParent.val(), sexoParent.val(), estadocivilParent.val(), null, null, (editar_pessoa ? $j('#'+pessoaPaiOuMae+'_id').val() : null), pessoaPaiOuMae);
  968 + $j( this ).dialog( "close" );
  969 + }
  970 + },
  971 + "Cancelar": function() {
  972 +
  973 + $j( this ).dialog( "close" );
  974 + }
  975 + },
  976 + close: function() {
  977 +
  978 + allFields.val( "" ).removeClass( "error" );
  979 +
  980 + },
  981 + hide: {
  982 + effect: "clip",
  983 + duration: 500
  984 + },
  985 +
  986 + show: {
  987 + effect: "clip",
  988 + duration: 500
  989 + }
  990 + });
  991 +
  992 + $j('#link_cadastro_detalhado').click(function(){
  993 + $j( "#dialog-form-pessoa-aluno" ).dialog( "close" );
  994 + });
  995 +
  996 + $j('#link_cadastro_detalhado_parent').click(function(){
  997 + $j( "#dialog-form-pessoa-parent" ).dialog( "close" );
  998 + });
  999 +
  1000 + $j("#cadastrar-pessoa-link").click(function() {
  1001 +
  1002 + $j('#link_cadastro_detalhado').attr('href','/intranet/atendidos_cad.php');
  1003 +
  1004 + $j( "#dialog-form-pessoa-aluno" ).dialog( "open" );
  1005 +
  1006 + $j('#cep_').val('');
  1007 + clearEnderecoFields();
  1008 + hideEnderecoFields();
  1009 +
  1010 + $j(".ui-widget-overlay").click(function(){
  1011 + $j(".ui-dialog-titlebar-close").trigger('click');
  1012 + });
  1013 +
  1014 + $j('#nome-pessoa-aluno').focus();
  1015 +
  1016 + $j('#dialog-form-pessoa-aluno form p:first-child').html('Cadastrar pessoa aluno').css('margin-left', '0.75em');
  1017 +
  1018 + editar_pessoa = false;
  1019 +
  1020 + });
  1021 +
  1022 + $j("#editar-pessoa-link").click(function() {
  1023 +
  1024 + $j('#link_cadastro_detalhado').attr('href','/intranet/atendidos_cad.php?cod_pessoa_fj=' + person_details.id);
  1025 + clearEnderecoFields();
  1026 +
  1027 + name.val(person_details.nome);
  1028 + datanasc.val(person_details.data_nascimento);
  1029 + estadocivil.val(person_details.estadocivil);
  1030 + sexo.val(person_details.sexo);
  1031 +
  1032 + if (person_details.idmun_nascimento){
  1033 +
  1034 + $j('#naturalidade_aluno_id').val(person_details.idmun_nascimento);
  1035 + $j('#naturalidade_aluno_pessoa-aluno').val(person_details.idmun_nascimento+' - '+person_details.municipio_nascimento+' ('+person_details.sigla_uf_nascimento+')');
  1036 +
  1037 + }
  1038 +
  1039 + $j('#cep_').val(person_details.cep);
  1040 +
  1041 + if ($j('#cep_').val()){
  1042 +
  1043 + $j('#municipio_municipio').removeAttr('disabled');
  1044 + $j('#bairro_bairro').removeAttr('disabled');
  1045 + $j('#logradouro_logradouro').removeAttr('disabled');
  1046 + $j('#bairro').removeAttr('disabled');
  1047 + $j('#zona_localizacao').removeAttr('disabled');
  1048 + $j('#idtlog').removeAttr('disabled');
  1049 + $j('#logradouro').removeAttr('disabled');
  1050 +
  1051 + $j('#complemento').val(person_details.complemento);
  1052 + $j('#numero').val(person_details.numero);
  1053 + $j('#letra').val(person_details.letra);
  1054 + $j('#apartamento').val(person_details.apartamento);
  1055 + $j('#bloco').val(person_details.bloco);
  1056 + $j('#andar').val(person_details.andar);
  1057 +
  1058 + $j('#municipio_id').val(person_details.idmun);
  1059 +
  1060 + $j('#municipio_municipio').val(person_details.idmun+' - '+person_details.municipio+' ('+person_details.sigla_uf+')');
  1061 +
  1062 + if (person_details.idbai && person_details.idlog){
  1063 +
  1064 + $j('#bairro_id').val(person_details.idbai);
  1065 + $j('#logradouro_id').val(person_details.idlog);
  1066 + $j('#bairro_bairro').val(person_details.bairro + ' / Zona '+(person_details.zona_localizacao == "1" ? "Urbana" : "Rural"));
  1067 + $j('#logradouro_logradouro').val($j("#idtlog option[value='"+person_details.idtlog+"']").text() + ' '+person_details.logradouro);
  1068 +
  1069 + }else{
  1070 +
  1071 + $j('#bairro').val(person_details.bairro);
  1072 + $j('#logradouro').val(person_details.logradouro);
  1073 + $j('#idtlog').val(person_details.idtlog);
  1074 + $j('#zona_localizacao').val(person_details.zona_localizacao);
  1075 +
  1076 + }
  1077 + }
  1078 +
  1079 + hideEnderecoFields();
  1080 +
  1081 + $j( "#dialog-form-pessoa-aluno" ).dialog("open");
  1082 +
  1083 + $j(".ui-widget-overlay").click(function(){
  1084 + $j(".ui-dialog-titlebar-close").trigger('click');
  1085 + });
  1086 +
  1087 + $j('#nome-pessoa-aluno').focus();
  1088 +
  1089 + $j('#dialog-form-pessoa-aluno form p:first-child').html('Editar pessoa aluno').css('margin-left', '0.75em');
  1090 +
  1091 + editar_pessoa = true;
  1092 +
  1093 + });
  1094 +
  1095 + $j("#cadastrar-pessoa-pai-link").click(function() {
  1096 +
  1097 + if($j('#pessoa_id').val()){
  1098 +
  1099 + openModalParent('pai');
  1100 +
  1101 + }else{
  1102 +
  1103 + alertSelecionarPessoaAluno();
  1104 + }
  1105 +
  1106 + });
  1107 +
  1108 +
  1109 + $j("#cadastrar-pessoa-mae-link").click(function() {
  1110 +
  1111 + if($j('#pessoa_id').val()){
  1112 +
  1113 + openModalParent('mae');
  1114 +
  1115 + }else{
  1116 + alertSelecionarPessoaAluno();
  1117 + }
  1118 +
  1119 + });
  1120 +
  1121 + $j("#editar-pessoa-pai-link").click(function() {
  1122 +
  1123 + if($j('#pessoa_id').val()){
  1124 +
  1125 + openEditModalParent('pai');
  1126 +
  1127 + }
  1128 +
  1129 + });
  1130 +
  1131 +
  1132 + $j("#editar-pessoa-mae-link").click(function() {
  1133 +
  1134 + if($j('#pessoa_id').val()){
  1135 +
  1136 + openEditModalParent('mae');
  1137 +
  1138 + }
  1139 +
  1140 + });
  1141 +
  1142 + function alertSelecionarPessoaAluno(){
  1143 + messageUtils.error('Primeiro cadastre/selecione uma pessoa para o aluno. ');
  1144 + }
  1145 +
  1146 + function openModalParent(parentType){
  1147 +
  1148 + $j('#link_cadastro_detalhado_parent').attr('href','/intranet/atendidos_cad.php?parent_type='+parentType);
  1149 +
  1150 + $j( "#dialog-form-pessoa-parent" ).dialog( "open" );
  1151 +
  1152 + $j(".ui-widget-overlay").click(function(){
  1153 + $j(".ui-dialog-titlebar-close").trigger('click');
  1154 + });
  1155 +
  1156 + $j('#nome-pessoa-parent').focus();
  1157 +
  1158 + $j('#dialog-form-pessoa-parent form p:first-child').html('Cadastrar pessoa '+(parentType == 'mae' ? 'm&atilde;e' : parentType)).css('margin-left', '0.75em');
  1159 + pessoaPaiOuMae = parentType;
  1160 +
  1161 + editar_pessoa = false;
  1162 +
  1163 + }
  1164 +
  1165 + function openEditModalParent(parentType){
  1166 +
  1167 + $j('#link_cadastro_detalhado_parent').attr('href','/intranet/atendidos_cad.php?cod_pessoa_fj='+ $j('#'+parentType+'_id').val() +'&parent_type='+parentType);
  1168 +
  1169 + $j( "#dialog-form-pessoa-parent" ).dialog( "open" );
  1170 +
  1171 + $j(".ui-widget-overlay").click(function(){
  1172 + $j(".ui-dialog-titlebar-close").trigger('click');
  1173 + });
  1174 +
  1175 + $j('#nome-pessoa-parent').focus();
  1176 +
  1177 + nameParent.val(window[parentType+'_details'].nome);
  1178 + estadocivilParent.val(window[parentType+'_details'].estadocivil);
  1179 + sexoParent.val(window[parentType+'_details'].sexo);
  1180 +
  1181 + $j('#dialog-form-pessoa-parent form p:first-child').html('Editar pessoa '+(parentType == 'mae' ? 'm&atilde;e' : parentType)).css('margin-left', '0.75em');
  1182 +
  1183 + pessoaPaiOuMae = parentType;
  1184 +
  1185 + editar_pessoa = true;
  1186 + }
  1187 +
  1188 + function checkLength( o, n, min, max ) {
  1189 + if ( o.val().length > max || o.val().length < min ) {
  1190 + o.addClass( "error" );
  1191 + messageUtils.error( "Tamanho do " + n + " deve ter entre " +
  1192 + min + " e " + max + " caracteres." );
  1193 + return false;
  1194 + } else {
  1195 + return true;
  1196 + }
  1197 + }
  1198 +
  1199 + function checkRegexp( o, regexp, n ) {
  1200 + if ( !( regexp.test( o.val() ) ) ) {
  1201 + o.addClass( "error" );
  1202 + messageUtils.error( n );
  1203 + return false;
  1204 + } else {
  1205 + return true;
  1206 + }
  1207 + }
  1208 +
  1209 + function checkSelect(comp, name) {
  1210 +
  1211 + if ( comp.val() == '') {
  1212 + comp.addClass( "error" );
  1213 + messageUtils.error( "Selecione um "+name+"." );
  1214 + return false;
  1215 + } else {
  1216 + return true;
  1217 + }
  1218 +
  1219 + }
  1220 +
  1221 + function checkSimpleSearch(comp, hiddenComp, name) {
  1222 +
  1223 + if ( hiddenComp.val() == '') {
  1224 + comp.addClass( "error" );
  1225 + messageUtils.error( "Selecione um "+name+"." );
  1226 + return false;
  1227 + } else {
  1228 + return true;
  1229 + }
  1230 +
  1231 + }
  1232 +
  1233 + $j('#pai_id').change( function(){ getPersonParentDetails($j(this).val(), 'pai') });
  1234 + $j('#mae_id').change( function(){ getPersonParentDetails($j(this).val(), 'mae' ) });
659 1235 }); // ready
  1236 +
  1237 + function postPessoa($pessoaField, nome, sexo, estadocivil, datanasc, naturalidade, pessoa_id, parentType) {
  1238 +
  1239 + var data = {
  1240 + nome : nome,
  1241 + sexo : sexo,
  1242 + estadocivil : estadocivil,
  1243 + datanasc : datanasc,
  1244 + naturalidade : naturalidade,
  1245 + pessoa_id : pessoa_id
  1246 + };
  1247 +
  1248 + var options = {
  1249 + url : postResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa', {}),
  1250 + dataType : 'json',
  1251 + data : data,
  1252 + success : function(dataResponse) {
  1253 + if(parentType=='mae')
  1254 + afterChangePessoaParent(dataResponse.pessoa_id, 'mae');
  1255 + else if(parentType=='pai')
  1256 + afterChangePessoaParent(dataResponse.pessoa_id, 'pai');
  1257 + else
  1258 + postEnderecoPessoa(dataResponse.pessoa_id);
  1259 + }
  1260 + };
  1261 +
  1262 + postResource(options);
  1263 +
  1264 + }
  1265 +
  1266 + function postEnderecoPessoa(pessoa_id) {
  1267 +
  1268 + if (checkCepFields($j('#cep_').val())){
  1269 +
  1270 + var data = {
  1271 + pessoa_id : pessoa_id,
  1272 + cep : $j('#cep_').val(),
  1273 + municipio_id : $j('#municipio_id').val(),
  1274 + bairro : $j('#bairro').val(),
  1275 + bairro_id : $j('#bairro_id').val(),
  1276 + zona_localizacao : $j('#zona_localizacao').val(),
  1277 + logradouro : $j('#logradouro').val(),
  1278 + idtlog : $j('#idtlog').val(),
  1279 + logradouro_id : $j('#logradouro_id').val(),
  1280 + apartamento : $j('#apartamento').val(),
  1281 + complemento : $j('#complemento').val(),
  1282 + numero : $j('#numero').val(),
  1283 + letra : $j('#letra').val(),
  1284 + bloco : $j('#bloco').val(),
  1285 + andar : $j('#andar').val()
  1286 + };
  1287 +
  1288 + var options = {
  1289 + url : postResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa-endereco', {}),
  1290 + dataType : 'json',
  1291 + data : data,
  1292 + success : function(dataResponse) {
  1293 + afterChangePessoa(null,null,pessoa_id);
  1294 + }
  1295 + };
  1296 +
  1297 + postResource(options);
  1298 +
  1299 + }else{
  1300 + afterChangePessoa(null,null,pessoa_id);
  1301 + }
  1302 +
  1303 + }
  1304 +
660 1305 })(jQuery);
661 1306 \ 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
... ... @@ -11,26 +11,9 @@
11 11 */
12 12  
13 13 margin-right: 5px;
  14 + cursor: pointer;
14 15 }
15 16  
16   -#deficiencias_chzn ul {
17   - width: 307px;
18   -}
19   -
20   -.pessoa-links {
21   - display: block;
22   - padding: 5px;
23   - margin: 2px;
24   -}
25   -
26   -.pessoa-links a {
27   - /*
28   - obs: no firefox, ao mostrar o elemento (.show, jquery), é setado display como block,
29   - para reparar isto, após chamar .show(), chamar .css('display', 'inline');
30   - */
31   -
32   - margin-right: 5px;
33   -}
34 17  
35 18 #deficiencias_chzn ul {
36 19 width: 307px;
... ... @@ -116,7 +99,7 @@
116 99 height: 25px;
117 100 background-color: #e4e9ed;
118 101 text-align: center;
119   - font-weight: bold;
  102 + font-weight: bold;
120 103 }
121 104  
122 105 .alunoTab-active2{
... ... @@ -140,19 +123,92 @@
140 123 height: 25px;
141 124 background-color: white;
142 125 text-align: center;
143   - font-weight: bold;
  126 + font-weight: bold;
144 127 }
145 128  
146 129 .tabText{
147 130 position: relative;
148   - top: 6px;
  131 + top: 6px;
149 132 }
150 133  
151 134 #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,
  135 +#tit_dados_hospital, #tit_dados_responsavel, #tr_label_calca,
  136 +#tr_label_calcado, #tr_label_saia, #tr_label_camiseta,
154 137 #tr_label_meia, #tr_label_bermuda, #tr_label_blusa_jaqueta,
155 138 .tit_uniforme{
156 139 font-weight: bold;
157 140 font-size: 11px;
  141 +}
  142 +
  143 +/* MODAL TESTE :p
  144 +
  145 +#dialog-form-pessoa-aluno { font-size: 62.5%; }
  146 +#dialog-form-pessoa-aluno label, dialog-form-pessoa-aluno input { display:block; }
  147 +#dialog-form-pessoa-aluno > input { margin-bottom:12px; width:95%; padding: .4em; }
  148 +#dialog-form-pessoa-aluno > fieldset { padding:0; border:0; margin-top:25px; }
  149 +#dialog-form-pessoa-aluno > h1 { font-size: 1.2em; margin: .6em 0; }*/
  150 +
  151 +.ui-dialog .ui-state-error { padding: .3em; }
  152 +.validateTips-pessoa-aluno { border: 1px solid transparent; padding: 0.3em; }
  153 +
  154 +.ui-widget-overlay{
  155 + background:black;
  156 +}
  157 +
  158 +.ui-dialog-titlebar {display:none}
  159 +
  160 +.ui-state-error {
  161 + background: white !important;
  162 + color: black !important;
  163 +}
  164 +
  165 +.ui-button span{
  166 +
  167 + color: #495C67 !important;
  168 + border: 1px solid #495C67 !important;
  169 +
  170 +}
  171 +
  172 +.ui-state-hover, .ui-state-focus{
  173 + border: 0px !important;
  174 +}
  175 +
  176 +fieldset {
  177 + border: 0px;
  178 +}
  179 +
  180 +fieldset legend{
  181 + font-weight: bold;
  182 +
  183 +}
  184 +
  185 +tr td:first-child legend{
  186 + margin-left: -3px;
  187 +}
  188 +
  189 +#feedback-messages{
  190 + z-index: 1050;
  191 +}
  192 +
  193 +.ui-button-text {
  194 + font-size: 12px !important;
  195 +}
  196 +
  197 +div p a{
  198 + color: blue !important;
  199 + cursor: pointer;
  200 +}
  201 +
  202 +#link_cadastro_detalhado{
  203 + font-family: arial, verdana, sans-serif, "Times New Roman";
  204 + font-size: 12px;
  205 +
  206 +}
  207 +
  208 +#link_cadastro_detalhado, #link_cadastro_detalhado_parent{
  209 + margin-left: 1.2em;
  210 +}
  211 +
  212 +.ui-dialog-content, .ui-widget-content{
  213 + padding: 0px !important;
158 214 }
159 215 \ 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/DynamicInput/Assets/Javascripts/Turma.js
... ... @@ -9,6 +9,8 @@
9 9 var $turmaField = getElementFor('turma');
10 10 var $ano = getElementFor('ano');
11 11  
  12 + var $naoFiltrarAno = getElementFor('nao_filtrar_ano') || null;
  13 +
12 14 var handleGetTurmas = function(response) {
13 15 var selectOptions = jsonResourcesToSelectOptions(response['options']);
14 16 updateSelect($turmaField, selectOptions, "Selecione uma turma");
... ... @@ -24,7 +26,8 @@
24 26 instituicao_id : $instituicaoField.val(),
25 27 escola_id : $escolaField.val(),
26 28 serie_id : $serieField.val(),
27   - ano : $ano.val()
  29 + ano : $naoFiltrarAno ? null : $ano.val(),
  30 + nao_filtrar_ano : $naoFiltrarAno ? 1 : null
28 31 });
29 32  
30 33 var options = {
... ...
ieducar/modules/Portabilis/Assets/Version.php
... ... @@ -5,7 +5,7 @@
5 5  
6 6 class Portabilis_Assets_Version {
7 7  
8   - const VERSION = '12';
  8 + const VERSION = '14';
9 9  
10 10 }
11 11 ?>
... ...