Commit e3e0b786e9ee6795b8e728d72439278d562ade7c

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

Facilitado preenchimento dos documentos, ao cadastrar nova pessoa fisica closes #6

Showing 38 changed files with 1622 additions and 410 deletions   Show diff stats
ieducar/intranet/atendidos_cad.php
1 <?php 1 <?php
2 2
  3 +#error_reporting(E_ALL);
  4 +#ini_set("display_errors", 1);
  5 +
3 /** 6 /**
4 * i-Educar - Sistema de gestão escolar 7 * i-Educar - Sistema de gestão escolar
5 * 8 *
@@ -40,6 +43,7 @@ require_once &#39;App/Model/ZonaLocalizacao.php&#39;; @@ -40,6 +43,7 @@ require_once &#39;App/Model/ZonaLocalizacao.php&#39;;
40 require_once 'Portabilis/String/Utils.php'; 43 require_once 'Portabilis/String/Utils.php';
41 require_once 'Portabilis/View/Helper/Application.php'; 44 require_once 'Portabilis/View/Helper/Application.php';
42 require_once 'Portabilis/Utils/Validation.php'; 45 require_once 'Portabilis/Utils/Validation.php';
  46 +require_once 'Portabilis/Date/Utils.php';
43 47
44 /** 48 /**
45 * clsIndex class. 49 * clsIndex class.
@@ -125,7 +129,8 @@ class indice extends clsCadastro @@ -125,7 +129,8 @@ class indice extends clsCadastro
125 $this->bairro, $this->logradouro, $this->cep, $this->idlog, $this->idbai, 129 $this->bairro, $this->logradouro, $this->cep, $this->idlog, $this->idbai,
126 $this->idtlog, $this->sigla_uf, $this->complemento, $this->numero, 130 $this->idtlog, $this->sigla_uf, $this->complemento, $this->numero,
127 $this->bloco, $this->apartamento, $this->andar, $this->zona_localizacao, $this->estado_civil, 131 $this->bloco, $this->apartamento, $this->andar, $this->zona_localizacao, $this->estado_civil,
128 - $this->pai_id, $this->mae_id, $this->tipo_nacionalidade, $this->pais_origem, $this->naturalidade 132 + $this->pai_id, $this->mae_id, $this->tipo_nacionalidade, $this->pais_origem, $this->naturalidade,
  133 + $this->letra
129 ) = 134 ) =
130 135
131 $objPessoa->queryRapida( 136 $objPessoa->queryRapida(
@@ -134,7 +139,7 @@ class indice extends clsCadastro @@ -134,7 +139,7 @@ class indice extends clsCadastro
134 'url', 'tipo', 'sexo', 'cidade', 'bairro', 'logradouro', 'cep', 'idlog', 139 'url', 'tipo', 'sexo', 'cidade', 'bairro', 'logradouro', 'cep', 'idlog',
135 'idbai', 'idtlog', 'sigla_uf', 'complemento', 'numero', 'bloco', 'apartamento', 140 'idbai', 'idtlog', 'sigla_uf', 'complemento', 'numero', 'bloco', 'apartamento',
136 'andar', 'zona_localizacao', 'ideciv', 'idpes_pai', 'idpes_mae', 'nacionalidade', 141 'andar', 'zona_localizacao', 'ideciv', 'idpes_pai', 'idpes_mae', 'nacionalidade',
137 - 'idpais_estrangeiro', 'idmun_nascimento' 142 + 'idpais_estrangeiro', 'idmun_nascimento', 'letra'
138 ); 143 );
139 144
140 $this->id_federal = is_numeric($this->id_federal) ? int2CPF($this->id_federal) : ''; 145 $this->id_federal = is_numeric($this->id_federal) ? int2CPF($this->id_federal) : '';
@@ -160,39 +165,353 @@ class indice extends clsCadastro @@ -160,39 +165,353 @@ class indice extends clsCadastro
160 $this->url_cancelar = $this->retorno == 'Editar' ? 165 $this->url_cancelar = $this->retorno == 'Editar' ?
161 'atendidos_det.php?cod_pessoa=' . $this->cod_pessoa_fj : 'atendidos_lst.php'; 166 'atendidos_det.php?cod_pessoa=' . $this->cod_pessoa_fj : 'atendidos_lst.php';
162 167
  168 + $this->campoCpf('id_federal', 'CPF', $this->id_federal, FALSE);
  169 +
163 $this->campoOculto('cod_pessoa_fj', $this->cod_pessoa_fj); 170 $this->campoOculto('cod_pessoa_fj', $this->cod_pessoa_fj);
164 $this->campoTexto('nm_pessoa', 'Nome', $this->nm_pessoa, '50', '255', TRUE); 171 $this->campoTexto('nm_pessoa', 'Nome', $this->nm_pessoa, '50', '255', TRUE);
165 172
166 - $this->campoCpf('id_federal', 'CPF', $this->id_federal, FALSE); 173 + // sexo
  174 +
  175 + $options = array(
  176 + 'label' => 'Sexo / Estado civil',
  177 + 'value' => $this->sexo,
  178 + 'resources' => array(
  179 + '' => 'Sexo',
  180 + 'M' => 'Masculino',
  181 + 'F' => 'Feminino'
  182 + ),
  183 + 'inline' => true
  184 + );
  185 +
  186 + $this->inputsHelper()->select('sexo', $options);
167 187
168 - $this->campoData('data_nasc', 'Data de Nascimento', $this->data_nasc); 188 + // estado civil
169 189
170 - $lista_sexos = array();  
171 - $lista_sexos[''] = 'Escolha uma opção...';  
172 - $lista_sexos['M'] = 'Masculino';  
173 - $lista_sexos['F'] = 'Feminino';  
174 - $this->campoLista('sexo', 'Sexo', $lista_sexos, $this->sexo); 190 + $this->inputsHelper()->estadoCivil(array('label' => ''));
  191 +
  192 +
  193 + // data nascimento
  194 +
  195 + $options = array(
  196 + 'label' => 'Data nascimento',
  197 + 'value' => $this->data_nasc
  198 + );
  199 +
  200 + $this->inputsHelper()->date('data_nasc', $options);
175 201
176 - $this->inputsHelper()->estadoCivil(array('required' => false));  
177 202
178 // pai, mãe 203 // pai, mãe
179 204
180 - $this->addPaiInput();  
181 - $this->addMaeInput(); 205 + $this->inputPai();
  206 + $this->inputMae();
  207 +
  208 +
  209 + // documentos
  210 +
  211 + $documentos = new clsDocumento();
  212 + $documentos->idpes = $this->cod_pessoa_fj;
  213 + $documentos = $documentos->detalhe();
  214 +
  215 + // rg
  216 +
  217 + $options = array(
  218 + 'required' => false,
  219 + 'label' => 'RG / Data emissão',
  220 + 'placeholder' => 'Documento identidade',
  221 + 'value' => $documentos['rg'],
  222 + 'max_length' => 20,
  223 + 'size' => 27,
  224 + 'inline' => true
  225 + );
  226 +
  227 + $this->inputsHelper()->integer('rg', $options);
  228 +
  229 +
  230 + // data emissão rg
  231 +
  232 + $options = array(
  233 + 'required' => false,
  234 + 'label' => '',
  235 + 'placeholder' => 'Data emissão',
  236 + 'value' => $documentos['data_exp_rg'],
  237 + 'size' => 19
  238 + );
  239 +
  240 + $this->inputsHelper()->date('data_emissao_rg', $options);
  241 +
  242 +
  243 + // orgão emissão rg
  244 +
  245 + $selectOptions = array( null => 'Orgão emissor' );
  246 + $orgaos = new clsOrgaoEmissorRg();
  247 + $orgaos = $orgaos->lista();
  248 +
  249 + foreach ($orgaos as $orgao)
  250 + $selectOptions[$orgao['idorg_rg']] = $orgao['sigla'];
  251 +
  252 + $selectOptions = Portabilis_Array_Utils::sortByValue($selectOptions);
  253 +
  254 + $options = array(
  255 + 'required' => false,
  256 + 'label' => '',
  257 + 'value' => $documentos['idorg_exp_rg'],
  258 + 'resources' => $selectOptions,
  259 + 'inline' => true
  260 + );
  261 +
  262 + $this->inputsHelper()->select('orgao_emissao_rg', $options);
  263 +
  264 +
  265 + // uf emissão rg
  266 +
  267 + $options = array(
  268 + 'required' => false,
  269 + 'label' => '',
  270 + 'value' => $documentos['sigla_uf_exp_rg']
  271 + );
  272 +
  273 + $helperOptions = array(
  274 + 'attrName' => 'uf_emissao_rg'
  275 + );
  276 +
  277 + $this->inputsHelper()->uf($options, $helperOptions);
  278 +
  279 +
  280 + // tipo de certidao civil
  281 +
  282 + $selectOptions = array(
  283 + null => 'Tipo certidão civil',
  284 + 'certidao_nascimento_novo_formato' => 'Nascimento (novo formato)',
  285 + 91 => 'Nascimento (antigo formato)',
  286 + 92 => 'Casamento'
  287 + );
  288 +
  289 +
  290 + // caso certidao nascimento novo formato tenha sido informado,
  291 + // considera este o tipo da certidão
  292 + if (! empty($documentos['certidao_nascimento']))
  293 + $tipoCertidaoCivil = 'certidao_nascimento_novo_formato';
  294 + else
  295 + $tipoCertidaoCivil = $documentos['tipo_cert_civil'];
  296 +
  297 + $options = array(
  298 + 'required' => false,
  299 + 'label' => 'Tipo certidão civil',
  300 + 'value' => $tipoCertidaoCivil,
  301 + 'resources' => $selectOptions,
  302 + 'inline' => true
  303 + );
  304 +
  305 + $this->inputsHelper()->select('tipo_certidao_civil', $options);
  306 +
  307 +
  308 + // termo certidao civil
  309 +
  310 + $options = array(
  311 + 'required' => false,
  312 + 'label' => '',
  313 + 'placeholder' => 'Termo',
  314 + 'value' => $documentos['num_termo'],
  315 + 'max_length' => 8,
  316 + 'inline' => true
  317 + );
  318 +
  319 + $this->inputsHelper()->integer('termo_certidao_civil', $options);
  320 +
  321 +
  322 + // livro certidao civil
  323 +
  324 + $options = array(
  325 + 'required' => false,
  326 + 'label' => '',
  327 + 'placeholder' => 'Livro',
  328 + 'value' => $documentos['num_livro'],
  329 + 'max_length' => 8,
  330 + 'size' => 15,
  331 + 'inline' => true
  332 + );
  333 +
  334 + $this->inputsHelper()->text('livro_certidao_civil', $options);
  335 +
  336 +
  337 + // folha certidao civil
  338 +
  339 + $options = array(
  340 + 'required' => false,
  341 + 'label' => '',
  342 + 'placeholder' => 'Folha',
  343 + 'value' => $documentos['num_folha'],
  344 + 'max_length' => 4,
  345 + 'inline' => true
  346 + );
  347 +
  348 + $this->inputsHelper()->integer('folha_certidao_civil', $options);
  349 +
  350 +
  351 + // certidao nascimento (novo padrão)
  352 +
  353 + $options = array(
  354 + 'required' => false,
  355 + 'label' => '',
  356 + 'placeholder' => 'Certidão nascimento',
  357 + 'value' => $documentos['certidao_nascimento'],
  358 + 'max_length' => 50,
  359 + 'size' => 50
  360 + );
  361 +
  362 + $this->inputsHelper()->text('certidao_nascimento', $options);
  363 +
  364 +
  365 + // uf emissão certidão civil
  366 +
  367 + $options = array(
  368 + 'required' => false,
  369 + 'label' => 'Estado emissão / Data emissão',
  370 + 'value' => $documentos['sigla_uf_cert_civil'],
  371 + 'inline' => true
  372 + );
  373 +
  374 + $helperOptions = array(
  375 + 'attrName' => 'uf_emissao_certidao_civil'
  376 + );
  377 +
  378 + $this->inputsHelper()->uf($options, $helperOptions);
  379 +
  380 +
  381 + // data emissão certidão civil
  382 +
  383 + $options = array(
  384 + 'required' => false,
  385 + 'label' => '',
  386 + 'placeholder' => 'Data emissão',
  387 + 'value' => $documentos['data_emissao_cert_civil']
  388 + );
  389 +
  390 + $this->inputsHelper()->date('data_emissao_certidao_civil', $options);
  391 +
  392 +
  393 + // cartório emissão certidão civil
  394 +
  395 + $options = array(
  396 + 'required' => false,
  397 + 'label' => 'Cartório emissão',
  398 + 'value' => $documentos['cartorio_cert_civil'],
  399 + 'cols' => 45,
  400 + 'max_length' => 150
  401 + );
  402 +
  403 + $this->inputsHelper()->textArea('cartorio_emissao_certidao_civil', $options);
  404 +
  405 +
  406 + // carteira de trabalho
  407 +
  408 + $options = array(
  409 + 'required' => false,
  410 + 'label' => 'Carteira de trabalho / Série',
  411 + 'placeholder' => 'Carteira de trabalho',
  412 + 'value' => $documentos['num_cart_trabalho'],
  413 + 'max_length' => 7,
  414 + 'inline' => true
  415 +
  416 + );
  417 +
  418 + $this->inputsHelper()->integer('carteira_trabalho', $options);
  419 +
  420 + // serie carteira de trabalho
  421 +
  422 + $options = array(
  423 + 'required' => false,
  424 + 'label' => '',
  425 + 'placeholder' => 'Série',
  426 + 'value' => $documentos['serie_cart_trabalho'],
  427 + 'max_length' => 5
  428 + );
  429 +
  430 + $this->inputsHelper()->integer('serie_carteira_trabalho', $options);
  431 +
  432 +
  433 + // uf emissão carteira de trabalho
  434 +
  435 + $options = array(
  436 + 'required' => false,
  437 + 'label' => 'Estado emissão / Data emissão',
  438 + 'value' => $documentos['sigla_uf_cart_trabalho'],
  439 + 'inline' => true
  440 + );
  441 +
  442 + $helperOptions = array(
  443 + 'attrName' => 'uf_emissao_carteira_trabalho'
  444 + );
  445 +
  446 + $this->inputsHelper()->uf($options, $helperOptions);
  447 +
  448 +
  449 + // data emissão carteira de trabalho
  450 +
  451 + $options = array(
  452 + 'required' => false,
  453 + 'label' => '',
  454 + 'placeholder' => 'Data emissão',
  455 + 'value' => $documentos['data_emissao_cart_trabalho']
  456 + );
  457 +
  458 + $this->inputsHelper()->date('data_emissao_carteira_trabalho', $options);
  459 +
  460 +
  461 + // titulo eleitor
  462 +
  463 + $options = array(
  464 + 'required' => false,
  465 + 'label' => 'Titulo eleitor / Zona / Seção',
  466 + 'placeholder' => 'Titulo eleitor',
  467 + 'value' => $documentos['num_tit_eleitor'],
  468 + 'max_length' => 13,
  469 + 'inline' => true
  470 + );
  471 +
  472 + $this->inputsHelper()->integer('titulo_eleitor', $options);
  473 +
  474 +
  475 + // zona titulo eleitor
  476 +
  477 + $options = array(
  478 + 'required' => false,
  479 + 'label' => '',
  480 + 'placeholder' => 'Zona',
  481 + 'value' => $documentos['zona_tit_eleitor'],
  482 + 'max_length' => 4,
  483 + 'inline' => true
  484 + );
  485 +
  486 + $this->inputsHelper()->integer('zona_titulo_eleitor', $options);
  487 +
  488 +
  489 + // seção titulo eleitor
  490 +
  491 + $options = array(
  492 + 'required' => false,
  493 + 'label' => '',
  494 + 'placeholder' => 'Seção',
  495 + 'value' => $documentos['secao_tit_eleitor'],
  496 + 'max_length' => 4
  497 + );
  498 +
  499 + $this->inputsHelper()->integer('secao_titulo_eleitor', $options);
  500 +
182 501
183 // Cor/raça. 502 // Cor/raça.
184 - $opcoes_raca = array('' => 'Selecione');  
185 - $obj_raca = new clsCadastroRaca();  
186 - $lst_raca = $obj_raca->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);  
187 503
188 - if ($lst_raca) {  
189 - foreach ($lst_raca as $raca) {  
190 - $opcoes_raca[$raca['cod_raca']] = $raca['nm_raca'];  
191 - }  
192 - } 504 + $racas = new clsCadastroRaca();
  505 + $racas = $racas->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE);
  506 + $selectOptions = array('' => 'Raça');
  507 +
  508 + foreach ($racas as $raca)
  509 + $selectOptions[$raca['cod_raca']] = $raca['nm_raca'];
  510 +
  511 + $selectOptions = Portabilis_Array_Utils::sortByValue($selectOptions);
  512 +
  513 + $this->campoLista('cor_raca', 'Raça', $selectOptions, $this->cod_raca, '', FALSE, '', '', '', FALSE);
193 514
194 - $this->campoLista('cor_raca', 'Raça', $opcoes_raca,  
195 - $this->cod_raca, '', FALSE, '', '', '', FALSE);  
196 515
197 // nacionalidade 516 // nacionalidade
198 517
@@ -202,19 +521,31 @@ class indice extends clsCadastro @@ -202,19 +521,31 @@ class indice extends clsCadastro
202 '2' => 'Naturalizado brasileiro', 521 '2' => 'Naturalizado brasileiro',
203 '3' => 'Estrangeiro'); 522 '3' => 'Estrangeiro');
204 523
205 - $options = array('label' => 'Nacionalidade',  
206 - 'resources' => $tiposNacionalidade,  
207 - 'required' => false,  
208 - 'inline' => true,  
209 - 'value' => $this->tipo_nacionalidade); 524 + $options = array('label' => 'Nacionalidade',
  525 + 'resources' => $tiposNacionalidade,
  526 + 'required' => false,
  527 + 'inline' => true,
  528 + 'value' => $this->tipo_nacionalidade);
210 529
211 $this->inputsHelper()->select('tipo_nacionalidade', $options); 530 $this->inputsHelper()->select('tipo_nacionalidade', $options);
212 531
  532 +
213 // pais origem 533 // pais origem
214 534
215 - $options = array('label' => '', 'required' => true);  
216 - $helperOptions = array('objectName' => 'pais_origem',  
217 - 'hiddenInputOptions' => array('options' => array('value' => $this->pais_origem_id))); 535 + $options = array(
  536 + 'label' => '',
  537 + 'placeholder' => 'Informe o nome do pais',
  538 + 'required' => true
  539 + );
  540 +
  541 + $hiddenInputOptions = array(
  542 + 'options' => array('value' => $this->pais_origem_id)
  543 + );
  544 +
  545 + $helperOptions = array(
  546 + 'objectName' => 'pais_origem',
  547 + 'hiddenInputOptions' => $hiddenInputOptions
  548 + );
218 549
219 $this->inputsHelper()->simpleSearchPais('nome', $options, $helperOptions); 550 $this->inputsHelper()->simpleSearchPais('nome', $options, $helperOptions);
220 551
@@ -222,6 +553,7 @@ class indice extends clsCadastro @@ -222,6 +553,7 @@ class indice extends clsCadastro
222 // naturalidade 553 // naturalidade
223 554
224 $options = array('label' => 'Naturalidade', 'required' => false); 555 $options = array('label' => 'Naturalidade', 'required' => false);
  556 +
225 $helperOptions = array('objectName' => 'naturalidade', 557 $helperOptions = array('objectName' => 'naturalidade',
226 'hiddenInputOptions' => array('options' => array('value' => $this->naturalidade_id))); 558 'hiddenInputOptions' => array('options' => array('value' => $this->naturalidade_id)));
227 559
@@ -230,26 +562,6 @@ class indice extends clsCadastro @@ -230,26 +562,6 @@ class indice extends clsCadastro
230 562
231 // Detalhes do Endereço 563 // Detalhes do Endereço
232 564
233 - $objTipoLog = new clsTipoLogradouro();  
234 - $listaTipoLog = $objTipoLog->lista();  
235 - $listaTLog = array('0' => 'Selecione');  
236 -  
237 - if ($listaTipoLog) {  
238 - foreach ($listaTipoLog as $tipoLog) {  
239 - $listaTLog[$tipoLog['idtlog']] = $tipoLog['descricao'];  
240 - }  
241 - }  
242 -  
243 - $objUf = new clsUf();  
244 - $listauf = $objUf->lista();  
245 - $listaEstado = array('0' => 'Selecione');  
246 -  
247 - if ($listauf) {  
248 - foreach ($listauf as $uf) {  
249 - $listaEstado[$uf['sigla_uf']] = $uf['sigla_uf'];  
250 - }  
251 - }  
252 -  
253 $this->campoOculto('idbai', $this->idbai); 565 $this->campoOculto('idbai', $this->idbai);
254 $this->campoOculto('idlog', $this->idlog); 566 $this->campoOculto('idlog', $this->idlog);
255 $this->campoOculto('cep', $this->cep); 567 $this->campoOculto('cep', $this->cep);
@@ -257,153 +569,227 @@ class indice extends clsCadastro @@ -257,153 +569,227 @@ class indice extends clsCadastro
257 $this->campoOculto('ref_idtlog', $this->idtlog); 569 $this->campoOculto('ref_idtlog', $this->idtlog);
258 $this->campoOculto('id_cidade', $this->cidade); 570 $this->campoOculto('id_cidade', $this->cidade);
259 571
260 - $zona = App_Model_ZonaLocalizacao::getInstance();  
261 572
262 - if ($this->idlog && $this->idbai && $this->cep && $this->cod_pessoa_fj) {  
263 - $this->campoCep('cep_', 'CEP', $this->cep, true, '-',  
264 - "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">",  
265 - TRUE); 573 + // considera como endereço localizado por CEP quando alguma das variaveis de instancia
  574 + // idbai (bairro) ou idlog (logradouro) estão definidas, neste caso desabilita a edição
  575 + // dos campos definidos via CEP.
  576 + $desativarCamposDefinidosViaCep = ($this->idbai || $this->idlog);
266 577
267 - $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog,  
268 - FALSE, FALSE, FALSE, FALSE, TRUE); 578 + $this->campoCep(
  579 + 'cep_',
  580 + 'CEP',
  581 + $this->cep,
  582 + TRUE,
  583 + '-',
  584 + "&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=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade&campo14=zona_localizacao\'></iframe>');\">",
  585 + $desativarCamposDefinidosViaCep
  586 + );
269 587
270 - $this->campoTextoInv('logradouro', 'Logradouro', $this->logradouro,  
271 - '50', '255', FALSE);  
272 588
273 - $this->campoTextoInv('cidade', 'Cidade', $this->cidade, '50', '255',  
274 - FALSE); 589 + // estado
275 590
276 - $this->campoTextoInv('bairro', 'Bairro', $this->bairro, '50', '255', FALSE); 591 + $options = array(
  592 + 'label' => 'Estado / Cidade',
  593 + 'value' => $this->sigla_uf,
  594 + 'disabled' => $desativarCamposDefinidosViaCep,
  595 + 'inline' => true
  596 + );
277 597
278 - $this->campoTexto('complemento', 'Complemento', $this->complemento, '50', '255',  
279 - FALSE); 598 + $helperOptions = array(
  599 + 'attrName' => 'sigla_uf'
  600 + );
280 601
281 - $this->campoTexto('numero', 'Número', $this->numero, '10', '10'); 602 + $this->inputsHelper()->uf($options, $helperOptions);
282 603
283 - $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE);  
284 604
285 - $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento, '6', '6',  
286 - FALSE); 605 + // cidade
287 606
288 - $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE);  
289 - $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE); 607 + $options = array(
  608 + 'label' => '',
  609 + 'placeholder' => 'Cidade',
  610 + 'value' => $this->cidade,
  611 + 'max_length' => 60,
  612 + 'disabled' => $desativarCamposDefinidosViaCep
  613 + );
290 614
291 - $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf,  
292 - FALSE, FALSE, FALSE, FALSE, TRUE);  
293 - }  
294 - elseif($this->cod_pessoa_fj && $this->cep) {  
295 - $this->campoCep('cep_', 'CEP', $this->cep, true, '-',  
296 - "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\" onclick=\"showExpansivel( 500,500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade\'></iframe>');\">",  
297 - $disabled); 615 + $this->inputsHelper()->text('cidade', $options);
  616 +
  617 +
  618 + // bairro
298 619
299 - $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog); 620 + $options = array(
  621 + 'label' => 'Bairro / Zona localização',
  622 + 'placeholder' => 'Bairro',
  623 + 'value' => $this->bairro,
  624 + 'max_length' => 40,
  625 + 'disabled' => $desativarCamposDefinidosViaCep,
  626 + 'inline' => true
  627 + );
300 628
301 - $this->campoTexto('logradouro', 'Logradouro', $this->logradouro, '50',  
302 - '255', FALSE); 629 + $this->inputsHelper()->text('bairro', $options);
303 630
304 - $this->campoTexto('cidade', 'Cidade', $this->cidade, '50', '255', FALSE);  
305 631
306 - $this->campoTexto('bairro', 'Bairro', $this->bairro, '50', '255', FALSE); 632 + // zona localização
307 633
308 - $this->campoTexto('complemento', 'Complemento', $this->complemento, '50',  
309 - '255', FALSE); 634 + $zonas = App_Model_ZonaLocalizacao::getInstance();
  635 + $zonas = $zonas->getEnums();
  636 + $zonas = Portabilis_Array_Utils::insertIn(null, 'Zona localização', $zonas);
310 637
311 - $this->campoTexto('numero', 'Número', $this->numero, '10', '10'); 638 + $options = array(
  639 + 'label' => '',
  640 + 'placeholder' => 'Zona localização',
  641 + 'value' => $this->zona_localizacao,
  642 + 'disabled' => $desativarCamposDefinidosViaCep,
  643 + 'resources' => $zonas
  644 + );
312 645
313 - $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE); 646 + $this->inputsHelper()->select('zona_localizacao', $options);
314 647
315 - $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento,  
316 - '6', '6', FALSE);  
317 648
318 - $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE); 649 + // tipo logradouro
319 650
320 - $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE); 651 + $options = array(
  652 + 'label' => 'Tipo / Logradouro',
  653 + 'value' => $this->idtlog,
  654 + 'disabled' => $desativarCamposDefinidosViaCep,
  655 + 'inline' => true
  656 + );
321 657
322 - $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf);  
323 - }  
324 - else {  
325 - $this->campoCep('cep_', 'CEP', $this->cep, TRUE, '-',  
326 - "&nbsp;<img id='lupa' src=\"imagens/lupa.png\" border=\"0\"  
327 - onclick=\"showExpansivel(500, 500, '<iframe name=\'miolo\' id=\'miolo\' frameborder=\'0\' height=\'100%\' width=\'500\' marginheight=\'0\' marginwidth=\'0\' src=\'educar_pesquisa_cep_log_bairro.php?campo1=bairro&campo2=idbai&campo3=cep&campo4=logradouro&campo5=idlog&campo6=ref_sigla_uf&campo7=cidade&campo8=ref_idtlog&campo9=isEnderecoExterno&campo10=cep_&campo11=sigla_uf&campo12=idtlog&campo13=id_cidade&campo14=zona_localizacao\'></iframe>');\">",  
328 - false  
329 - ); 658 + $helperOptions = array(
  659 + 'attrName' => 'idtlog'
  660 + );
330 661
331 - $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog,  
332 - FALSE, FALSE, FALSE, FALSE, FALSE); 662 + $this->inputsHelper()->tipoLogradouro($options, $helperOptions);
333 663
334 - $this->campoTexto('logradouro', 'Logradouro', $this->logradouro,  
335 - '50', '255');  
336 664
337 - $this->campoTexto('cidade', 'Cidade', $this->cidade, '50', '255'); 665 + // logradouro
338 666
339 - $this->campoTexto('bairro', 'Bairro', $this->bairro, '50', '255'); 667 + $options = array(
  668 + 'label' => '',
  669 + 'placeholder' => 'Logradouro',
  670 + 'value' => $this->logradouro,
  671 + 'max_length' => 150,
  672 + 'disabled' => $desativarCamposDefinidosViaCep
  673 + );
340 674
341 - $this->campoTexto('complemento', 'Complemento', $this->complemento,  
342 - '50', '255', FALSE); 675 + $this->inputsHelper()->text('logradouro', $options);
343 676
344 - $this->campoTexto('numero', 'Número', $this->numero, '10', '10');  
345 677
346 - $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE); 678 + // complemento
347 679
348 - $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento,  
349 - '6', '6', FALSE); 680 + $options = array(
  681 + 'required' => false,
  682 + 'value' => $this->complemento,
  683 + 'max_length' => 20
  684 + );
350 685
351 - $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE); 686 + $this->inputsHelper()->text('complemento', $options);
352 687
353 - $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE);  
354 688
355 - $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf,  
356 - FALSE, FALSE, FALSE, FALSE, FALSE);  
357 - } 689 + // numero
  690 +
  691 + $options = array(
  692 + 'required' => false,
  693 + 'label' => 'Número / Letra',
  694 + 'placeholder' => 'Número',
  695 + 'value' => $this->numero,
  696 + 'max_length' => 6,
  697 + 'inline' => true
  698 + );
  699 +
  700 + $this->inputsHelper()->integer('numero', $options);
  701 +
  702 +
  703 + // letra
358 704
359 - $this->campoLista('zona_localizacao', 'Zona Localização', $zona->getEnums(),  
360 - $this->zona_localizacao, FALSE, FALSE, FALSE, FALSE,  
361 - ($this->idbai ? TRUE : FALSE) 705 + $options = array(
  706 + 'required' => false,
  707 + 'label' => '',
  708 + 'placeholder' => 'Letra',
  709 + 'value' => $this->letra,
  710 + 'max_length' => 1,
  711 + 'size' => 15
362 ); 712 );
363 713
364 - $this->campoTexto('ddd_telefone_1', 'DDD Telefone 1', $this->ddd_telefone_1,  
365 - '3', '2', FALSE); 714 + $this->inputsHelper()->text('letra', $options);
366 715
367 - $this->campoTexto('telefone_1', 'Telefone 1', $this->telefone_1, '10',  
368 - '15', FALSE);  
369 716
370 - $this->campoTexto('ddd_telefone_2', 'DDD Telefone 2', $this->ddd_telefone_2,  
371 - '3', '2', FALSE); 717 + // apartamento
372 718
373 - $this->campoTexto('telefone_2', 'Telefone 2', $this->telefone_2, '10',  
374 - '15', FALSE); 719 + $options = array(
  720 + 'required' => false,
  721 + 'label' => 'Nº apartamento / Bloco / Andar',
  722 + 'placeholder' => 'Nº apartamento',
  723 + 'value' => $this->apartamento,
  724 + 'max_length' => 6,
  725 + 'inline' => true
  726 + );
  727 +
  728 + $this->inputsHelper()->integer('apartamento', $options);
  729 +
  730 +
  731 + // bloco
375 732
376 - $this->campoTexto('ddd_telefone_mov', 'DDD Celular',  
377 - $this->ddd_telefone_mov, '3', '2', FALSE); 733 + $options = array(
  734 + 'required' => false,
  735 + 'label' => '',
  736 + 'placeholder' => 'Bloco',
  737 + 'value' => $this->bloco,
  738 + 'max_length' => 20,
  739 + 'size' => 15,
  740 + 'inline' => true
  741 + );
  742 +
  743 + $this->inputsHelper()->text('bloco', $options);
378 744
379 - $this->campoTexto('telefone_mov', 'Celular', $this->telefone_mov, '10',  
380 - '15', FALSE);  
381 745
382 - $this->campoTexto('ddd_telefone_fax', 'DDD Fax', $this->ddd_telefone_fax,  
383 - '3', '2', FALSE); 746 + // andar
  747 +
  748 + $options = array(
  749 + 'required' => false,
  750 + 'label' => '',
  751 + 'placeholder' => 'Andar',
  752 + 'value' => $this->andar,
  753 + 'max_length' => 2
  754 + );
384 755
385 - $this->campoTexto('telefone_fax', 'Fax', $this->telefone_fax, '10', '15',  
386 - FALSE); 756 + $this->inputsHelper()->integer('andar', $options);
  757 +
  758 +
  759 + // contato
  760 +
  761 + $this->inputTelefone('1', 'Telefone residencial');
  762 + $this->inputTelefone('mov', 'Celular');
  763 + $this->inputTelefone('2', 'Telefone adicional');
  764 + $this->inputTelefone('fax', 'Fax');
387 765
388 $this->campoTexto('http', 'Site', $this->http, '50', '255', FALSE); 766 $this->campoTexto('http', 'Site', $this->http, '50', '255', FALSE);
389 767
390 $this->campoTexto('email', 'E-mail', $this->email, '50', '255', FALSE); 768 $this->campoTexto('email', 'E-mail', $this->email, '50', '255', FALSE);
391 769
392 - if ($this->cod_pessoa_fj) { 770 + /*if ($this->cod_pessoa_fj) {
393 $this->campoRotulo('documentos', '<b><i>Documentos</i></b>', 771 $this->campoRotulo('documentos', '<b><i>Documentos</i></b>',
394 "<a href='#' onclick=\"windowUtils.open('adicionar_documentos_cad.php?id_pessoa={$this->cod_pessoa_fj}'); \"><img src='imagens/nvp_bot_ad_doc.png' border='0'></a>"); 772 "<a href='#' onclick=\"windowUtils.open('adicionar_documentos_cad.php?id_pessoa={$this->cod_pessoa_fj}'); \"><img src='imagens/nvp_bot_ad_doc.png' border='0'></a>");
395 773
396 $this->campoCheck('alterado', 'Alterado', $this->alterado); 774 $this->campoCheck('alterado', 'Alterado', $this->alterado);
397 - } 775 + }*/
  776 +
  777 +
  778 + // after change pessoa pai / mae
  779 +
  780 + if (isset($_REQUEST['parent_type']))
  781 + $this->inputsHelper()->hidden('parent_type', array('value' => $_REQUEST['parent_type']));
  782 +
398 783
399 $styles = array( 784 $styles = array(
400 '/modules/Portabilis/Assets/Stylesheets/Frontend.css', 785 '/modules/Portabilis/Assets/Stylesheets/Frontend.css',
401 - '/modules/Portabilis/Assets/Stylesheets/Frontend/Resource.css' 786 + '/modules/Portabilis/Assets/Stylesheets/Frontend/Resource.css',
  787 + '/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css'
402 ); 788 );
403 789
404 Portabilis_View_Helper_Application::loadStylesheet($this, $styles); 790 Portabilis_View_Helper_Application::loadStylesheet($this, $styles);
405 791
406 - $script = "/modules/Cadastro/Assets/Javascripts/PessoaFisica.js"; 792 + $script = '/modules/Cadastro/Assets/Javascripts/PessoaFisica.js';
407 Portabilis_View_Helper_Application::loadJavascript($this, $script); 793 Portabilis_View_Helper_Application::loadJavascript($this, $script);
408 } 794 }
409 795
@@ -425,7 +811,7 @@ class indice extends clsCadastro @@ -425,7 +811,7 @@ class indice extends clsCadastro
425 $fisica = new clsFisica(); 811 $fisica = new clsFisica();
426 812
427 $fisica->idpes = $idpes; 813 $fisica->idpes = $idpes;
428 - $fisica->data_nasc = dataToBanco($this->data_nasc); 814 + $fisica->data_nasc = Portabilis_Date_Utils::brToPgSQL($this->data_nasc);
429 $fisica->sexo = $this->sexo; 815 $fisica->sexo = $this->sexo;
430 $fisica->ref_cod_sistema = 'NULL'; 816 $fisica->ref_cod_sistema = 'NULL';
431 $fisica->cpf = idFederal2int($this->id_federal); 817 $fisica->cpf = idFederal2int($this->id_federal);
@@ -438,6 +824,8 @@ class indice extends clsCadastro @@ -438,6 +824,8 @@ class indice extends clsCadastro
438 824
439 $fisica->cadastra(); 825 $fisica->cadastra();
440 826
  827 + $this->createOrUpdateDocumentos($idpes);
  828 +
441 $objTelefone = new clsPessoaTelefone($idpes, 1, $this->telefone_1, $this->ddd_telefone_1); 829 $objTelefone = new clsPessoaTelefone($idpes, 1, $this->telefone_1, $this->ddd_telefone_1);
442 $objTelefone->cadastra(); 830 $objTelefone->cadastra();
443 831
@@ -507,20 +895,21 @@ class indice extends clsCadastro @@ -507,20 +895,21 @@ class indice extends clsCadastro
507 $fisica = new clsFisica(); 895 $fisica = new clsFisica();
508 896
509 $fisica->idpes = $this->cod_pessoa_fj; 897 $fisica->idpes = $this->cod_pessoa_fj;
510 - $fisica->data_nasc = dataToBanco($this->data_nasc); 898 + $fisica->data_nasc = Portabilis_Date_Utils::brToPgSQL($this->data_nasc);
511 $fisica->sexo = $this->sexo; 899 $fisica->sexo = $this->sexo;
512 $fisica->ref_cod_sistema = 'NULL'; 900 $fisica->ref_cod_sistema = 'NULL';
513 $fisica->cpf = $this->id_federal ? idFederal2int($this->id_federal) : 'NULL'; 901 $fisica->cpf = $this->id_federal ? idFederal2int($this->id_federal) : 'NULL';
514 $fisica->ideciv = $this->estado_civil_id; 902 $fisica->ideciv = $this->estado_civil_id;
515 -  
516 - $fisica->idpes_pai = $this->pai_id;  
517 - $fisica->idpes_mae = $this->mae_id; 903 + $fisica->idpes_pai = $this->pai_id ? $this->pai_id : "NULL";
  904 + $fisica->idpes_mae = $this->mae_id ? $this->mae_id : "NULL";
518 $fisica->nacionalidade = $_REQUEST['tipo_nacionalidade']; 905 $fisica->nacionalidade = $_REQUEST['tipo_nacionalidade'];
519 $fisica->idpais_estrangeiro = $_REQUEST['pais_origem_id']; 906 $fisica->idpais_estrangeiro = $_REQUEST['pais_origem_id'];
520 $fisica->idmun_nascimento = $_REQUEST['naturalidade_id']; 907 $fisica->idmun_nascimento = $_REQUEST['naturalidade_id'];
521 908
522 $fisica->edita(); 909 $fisica->edita();
523 910
  911 + $this->createOrUpdateDocumentos($this->cod_pessoa_fj);
  912 +
524 if ($this->alterado) { 913 if ($this->alterado) {
525 $db = new clsBanco(); 914 $db = new clsBanco();
526 $db->Consulta("UPDATE cadastro.fisica SET alterado = 'TRUE' WHERE idpes = '$this->cod_pessoa_fj'"); 915 $db->Consulta("UPDATE cadastro.fisica SET alterado = 'TRUE' WHERE idpes = '$this->cod_pessoa_fj'");
@@ -593,11 +982,19 @@ class indice extends clsCadastro @@ -593,11 +982,19 @@ class indice extends clsCadastro
593 982
594 function afterChangePessoa($id) { 983 function afterChangePessoa($id) {
595 Portabilis_View_Helper_Application::embedJavascript($this, " 984 Portabilis_View_Helper_Application::embedJavascript($this, "
596 - if(window.opener && window.opener.afterChangePessoa)  
597 - window.opener.afterChangePessoa(self, $id); 985 +
  986 + if(window.opener && window.opener.afterChangePessoa) {
  987 + var parentType = \$j('#parent_type').val();
  988 +
  989 + if (parentType)
  990 + window.opener.afterChangePessoa(self, parentType, $id, \$j('#nm_pessoa').val());
  991 + else
  992 + window.opener.afterChangePessoa(self, $id);
  993 + }
598 else 994 else
599 document.location = 'atendidos_lst.php'; 995 document.location = 'atendidos_lst.php';
600 - "); 996 +
  997 + ", $afterReady = true);
601 } 998 }
602 999
603 /** 1000 /**
@@ -629,11 +1026,11 @@ class indice extends clsCadastro @@ -629,11 +1026,11 @@ class indice extends clsCadastro
629 return $aluno->detalhe(); 1026 return $aluno->detalhe();
630 } 1027 }
631 1028
632 - protected function addPaiInput() { 1029 + protected function inputPai() {
633 $this->addParentsInput('pai'); 1030 $this->addParentsInput('pai');
634 } 1031 }
635 1032
636 - protected function addMaeInput() { 1033 + protected function inputMae() {
637 $this->addParentsInput('mae', 'mãe'); 1034 $this->addParentsInput('mae', 'mãe');
638 } 1035 }
639 1036
@@ -646,12 +1043,20 @@ class indice extends clsCadastro @@ -646,12 +1043,20 @@ class indice extends clsCadastro
646 1043
647 $parentId = $this->{$parentType . '_id'}; 1044 $parentId = $this->{$parentType . '_id'};
648 1045
649 - // mostra uma dica nos casos em que foi informado apenas o nome dos pais, pela antiga interface do cadastro de alunos. 1046 +
  1047 + // mostra uma dica nos casos em que foi informado apenas o nome dos pais,
  1048 + //pela antiga interface do cadastro de alunos.
  1049 +
650 if (! $parentId && $this->_aluno['nm_' . $parentType]) { 1050 if (! $parentId && $this->_aluno['nm_' . $parentType]) {
651 - $nome = Portabilis_String_Utils::toLatin1($this->_aluno['nm_' . $parentType], array('transform' => true, 'escape' => false));  
652 - $inputHint = '<b>Dica:</b> Foi informado o nome "' . $nome . '" no cadastro de aluno, tente pesquisar esta pessoa pelo CPF ou RG.'; 1051 + $nome = Portabilis_String_Utils::toLatin1($this->_aluno['nm_' . $parentType],
  1052 + array('transform' => true, 'escape' => false));
  1053 +
  1054 + $inputHint = '<br /><b>Dica:</b> Foi informado o nome "' . $nome .
  1055 + '" no cadastro de aluno,<br />tente pesquisar esta pessoa ' .
  1056 + 'pelo CPF ou RG, caso não encontre, cadastre uma nova pessoa.';
653 } 1057 }
654 1058
  1059 +
655 $hiddenInputOptions = array('options' => array('value' => $parentId)); 1060 $hiddenInputOptions = array('options' => array('value' => $parentId));
656 $helperOptions = array('objectName' => $parentType, 'hiddenInputOptions' => $hiddenInputOptions); 1061 $helperOptions = array('objectName' => $parentType, 'hiddenInputOptions' => $hiddenInputOptions);
657 1062
@@ -686,6 +1091,122 @@ class indice extends clsCadastro @@ -686,6 +1091,122 @@ class indice extends clsCadastro
686 1091
687 return $isValid; 1092 return $isValid;
688 } 1093 }
  1094 +
  1095 + protected function createOrUpdateDocumentos($pessoaId) {
  1096 + $documentos = new clsDocumento();
  1097 + $documentos->idpes = $pessoaId;
  1098 +
  1099 +
  1100 + // rg
  1101 +
  1102 + $documentos->rg = $_REQUEST['rg'];
  1103 +
  1104 + $documentos->data_exp_rg = Portabilis_Date_Utils::brToPgSQL(
  1105 + $_REQUEST['data_emissao_rg']
  1106 + );
  1107 +
  1108 + $documentos->idorg_exp_rg = $_REQUEST['orgao_emissao_rg'];
  1109 + $documentos->sigla_uf_exp_rg = $_REQUEST['uf_emissao_rg'];
  1110 +
  1111 +
  1112 + // certidão civil
  1113 +
  1114 +
  1115 + // o tipo certidão novo padrão é apenas para exibição ao usuário,
  1116 + // não precisa ser gravado no banco
  1117 + //
  1118 + // quando selecionado um tipo diferente do novo formato,
  1119 + // é removido o valor de certidao_nascimento.
  1120 + //
  1121 + if ($_REQUEST['tipo_certidao_civil'] == 'certidao_nascimento_novo_formato') {
  1122 + $documentos->tipo_cert_civil = null;
  1123 + $documentos->certidao_nascimento = $_REQUEST['certidao_nascimento'];
  1124 + }
  1125 + else {
  1126 + $documentos->tipo_cert_civil = $_REQUEST['tipo_certidao_civil'];
  1127 + $documentos->certidao_nascimento = '';
  1128 + }
  1129 +
  1130 + $documentos->num_termo = $_REQUEST['termo_certidao_civil'];
  1131 + $documentos->num_livro = $_REQUEST['livro_certidao_civil'];
  1132 + $documentos->num_folha = $_REQUEST['folha_certidao_civil'];
  1133 +
  1134 + $documentos->data_emissao_cert_civil = Portabilis_Date_Utils::brToPgSQL(
  1135 + $_REQUEST['data_emissao_certidao_civil']
  1136 + );
  1137 +
  1138 + $documentos->sigla_uf_cert_civil = $_REQUEST['uf_emissao_certidao_civil'];
  1139 + $documentos->cartorio_cert_civil = $_REQUEST['cartorio_emissao_certidao_civil'];
  1140 +
  1141 +
  1142 +
  1143 + // carteira de trabalho
  1144 +
  1145 + $documentos->num_cart_trabalho = $_REQUEST['carteira_trabalho'];
  1146 + $documentos->serie_cart_trabalho = $_REQUEST['serie_carteira_trabalho'];
  1147 +
  1148 + $documentos->data_emissao_cart_trabalho = Portabilis_Date_Utils::brToPgSQL(
  1149 + $_REQUEST['data_emissao_carteira_trabalho']
  1150 + );
  1151 +
  1152 + $documentos->sigla_uf_cart_trabalho = $_REQUEST['uf_emissao_carteira_trabalho'];
  1153 +
  1154 +
  1155 + // titulo de eleitor
  1156 +
  1157 + $documentos->num_tit_eleitor = $_REQUEST['titulo_eleitor'];
  1158 + $documentos->zona_tit_eleitor = $_REQUEST['zona_titulo_eleitor'];
  1159 + $documentos->secao_tit_eleitor = $_REQUEST['secao_titulo_eleitor'];
  1160 +
  1161 +
  1162 + // Alteração de documentos compativel com a versão anterior do cadastro,
  1163 + // onde era possivel criar uma pessoa, não informando os documentos,
  1164 + // o que não criaria o registro do documento, sendo assim, ao editar uma pessoa,
  1165 + // o registro do documento será criado, caso não exista.
  1166 +
  1167 + $sql = "select 1 from cadastro.documento WHERE idpes = $1 limit 1";
  1168 +
  1169 + if (Portabilis_Utils_Database::selectField($sql, $pessoaId) != 1)
  1170 + $documentos->cadastra();
  1171 + else
  1172 + $documentos->edita();
  1173 + }
  1174 +
  1175 + // inputs usados em Gerar,
  1176 + // implementado estes metodos para não duplicar código
  1177 + // uma vez que estes campos são usados várias vezes em Gerar.
  1178 +
  1179 + protected function inputTelefone($type, $typeLabel = '') {
  1180 + if (! $typeLabel)
  1181 + $typeLabel = "Telefone {$type}";
  1182 +
  1183 + // ddd
  1184 +
  1185 + $options = array(
  1186 + 'required' => false,
  1187 + 'label' => "(ddd) / {$typeLabel}",
  1188 + 'placeholder' => 'ddd',
  1189 + 'value' => $this->{"ddd_telefone_{$type}"},
  1190 + 'max_length' => 3,
  1191 + 'size' => 3,
  1192 + 'inline' => true
  1193 + );
  1194 +
  1195 + $this->inputsHelper()->integer("ddd_telefone_{$type}", $options);
  1196 +
  1197 +
  1198 + // telefone
  1199 +
  1200 + $options = array(
  1201 + 'required' => false,
  1202 + 'label' => '',
  1203 + 'placeholder' => $typeLabel,
  1204 + 'value' => $this->{"telefone_{$type}"},
  1205 + 'max_length' => 11
  1206 + );
  1207 +
  1208 + $this->inputsHelper()->integer("telefone_{$type}", $options);
  1209 + }
689 } 1210 }
690 1211
691 // Instancia objeto de página 1212 // Instancia objeto de página
ieducar/intranet/educar_escola_cad.php
@@ -402,7 +402,7 @@ class indice extends clsCadastro @@ -402,7 +402,7 @@ class indice extends clsCadastro
402 } 402 }
403 else 403 else
404 { 404 {
405 - $this->inputsHelper()->numeric('escola_inep_id', array('label' => 'Código inep', 'required' => false)); 405 + $this->inputsHelper()->integer('escola_inep_id', array('label' => 'Código inep', 'required' => false));
406 406
407 if( $_POST ) 407 if( $_POST )
408 foreach( $_POST AS $campo => $val ) 408 foreach( $_POST AS $campo => $val )
ieducar/intranet/include/pessoa/clsDocumento.inc.php
@@ -67,7 +67,7 @@ class clsDocumento @@ -67,7 +67,7 @@ class clsDocumento
67 * @return Object:clsDocumento 67 * @return Object:clsDocumento
68 */ 68 */
69 function clsDocumento( $int_idpes = false, $int_rg = false, $str_data_exp_rg = false, $str_sigla_uf_exp_rg = false, $int_tipo_cert_civil = false, $int_num_termo = false, $int_num_livro = false, $int_num_folha = false, $str_data_emissao_cert_civil = false, $str_sigla_uf_cert_civil = false, $str_cartorio_cert_civil = false, $int_num_cart_trabalho = false, $int_serie_cart_trabalho = false, $str_data_emissao_cart_trabalho = false, $str_sigla_uf_cart_trabalho = false, $int_num_tit_eleitor = false, $int_zona_tit_eleitor = false, $int_secao_tit_eleitor = false, $int_idorg_exp_rg = false, $str_certidao_nascimento = null) 69 function clsDocumento( $int_idpes = false, $int_rg = false, $str_data_exp_rg = false, $str_sigla_uf_exp_rg = false, $int_tipo_cert_civil = false, $int_num_termo = false, $int_num_livro = false, $int_num_folha = false, $str_data_emissao_cert_civil = false, $str_sigla_uf_cert_civil = false, $str_cartorio_cert_civil = false, $int_num_cart_trabalho = false, $int_serie_cart_trabalho = false, $str_data_emissao_cart_trabalho = false, $str_sigla_uf_cart_trabalho = false, $int_num_tit_eleitor = false, $int_zona_tit_eleitor = false, $int_secao_tit_eleitor = false, $int_idorg_exp_rg = false, $str_certidao_nascimento = null)
70 - { 70 + {
71 $objPessoa = new clsFisica($int_idpes); 71 $objPessoa = new clsFisica($int_idpes);
72 if($objPessoa->detalhe()) 72 if($objPessoa->detalhe())
73 { 73 {
@@ -448,16 +448,10 @@ class clsDocumento @@ -448,16 +448,10 @@ class clsDocumento
448 $set .= $gruda."certidao_nascimento = '{$this->certidao_nascimento}'"; 448 $set .= $gruda."certidao_nascimento = '{$this->certidao_nascimento}'";
449 $gruda = ", "; 449 $gruda = ", ";
450 } 450 }
451 - #else  
452 - #{  
453 - # $set .= $gruda."certidao_nascimento = NULL";  
454 - # $gruda = ", ";  
455 - #}  
456 451
457 if($set) 452 if($set)
458 { 453 {
459 $db = new clsBanco(); 454 $db = new clsBanco();
460 -// ECHO "UPDATE {$this->schema}.{$this->tabela} $set WHERE idpes = '$this->idpes'" ;DIE;  
461 $db->Consulta( "UPDATE {$this->schema}.{$this->tabela} $set WHERE idpes = '$this->idpes'" ); 455 $db->Consulta( "UPDATE {$this->schema}.{$this->tabela} $set WHERE idpes = '$this->idpes'" );
462 return true; 456 return true;
463 } 457 }
ieducar/intranet/include/pessoa/clsFisica.inc.php
@@ -193,16 +193,28 @@ class clsFisica @@ -193,16 +193,28 @@ class clsFisica
193 { 193 {
194 $campos = ""; 194 $campos = "";
195 $valores = ""; 195 $valores = "";
196 - if(is_string($this->data_nasc))  
197 - {  
198 - $campos .= ", data_nasc"; 196 +
  197 +
  198 + // data_nasc
  199 +
  200 + $campos .= ", data_nasc";
  201 +
  202 + if($this->data_nasc)
199 $valores .= ", '{$this->data_nasc}'"; 203 $valores .= ", '{$this->data_nasc}'";
200 - }  
201 - if(is_string($this->sexo))  
202 - {  
203 - $campos .= ", sexo"; 204 + else
  205 + $valores .= ", NULL";
  206 +
  207 +
  208 + // sexo
  209 +
  210 + $campos .= ", sexo";
  211 +
  212 + if($this->sexo)
204 $valores .= ", '$this->sexo' "; 213 $valores .= ", '$this->sexo' ";
205 - } 214 + else
  215 + $valores .= ", NULL";
  216 +
  217 +
206 if(is_numeric($this->idpes_mae)) 218 if(is_numeric($this->idpes_mae))
207 { 219 {
208 $campos .= ", idpes_mae"; 220 $campos .= ", idpes_mae";
ieducar/intranet/scripts/padrao.js
@@ -791,6 +791,9 @@ function cv_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4, @@ -791,6 +791,9 @@ function cv_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4,
791 } 791 }
792 792
793 window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1)); 793 window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1));
  794 +
  795 + if(parent.afterSetSearchFields)
  796 + parent.afterSetSearchFields(self);
794 } 797 }
795 798
796 function cv_libera_campos(campo1, campo2, campo3, campo4, campo5, campo6, campo7, campo8) 799 function cv_libera_campos(campo1, campo2, campo3, campo4, campo5, campo6, campo7, campo8)
@@ -819,6 +822,9 @@ function cv_libera_campos(campo1, campo2, campo3, campo4, campo5, campo6, campo7 @@ -819,6 +822,9 @@ function cv_libera_campos(campo1, campo2, campo3, campo4, campo5, campo6, campo7
819 parent.document.getElementById(campo8).disabled = false; 822 parent.document.getElementById(campo8).disabled = false;
820 parent.document.getElementById(campo8).value = '1'; 823 parent.document.getElementById(campo8).value = '1';
821 } 824 }
  825 +
  826 + if(parent.afterUnsetSearchFields)
  827 + parent.afterUnsetSearchFields(self);
822 } 828 }
823 829
824 // Função a ser executada antes de fechar a janela. 830 // Função a ser executada antes de fechar a janela.
ieducar/lib/Portabilis/Array/Utils.php
@@ -128,8 +128,12 @@ class Portabilis_Array_Utils { @@ -128,8 +128,12 @@ class Portabilis_Array_Utils {
128 128
129 /* transforma um conjunto de arrays "chave => valor, chave => valor" em um array "id => value", 129 /* transforma um conjunto de arrays "chave => valor, chave => valor" em um array "id => value",
130 ex: (('id' => 1, 'nome' => 'lucas'), ('id' => 2, 'nome' => 'davila')) 130 ex: (('id' => 1, 'nome' => 'lucas'), ('id' => 2, 'nome' => 'davila'))
131 - é transformado em (1 => 'lucas', 2 => davila), caso uma mesma chave se repita em mais de um array, 131 + é transformado em (1 => 'lucas', 2 => davila),
  132 +
  133 + caso uma mesma chave se repita em mais de um array,
132 será mantido a chave => valor do ultimo array que a contem. 134 será mantido a chave => valor do ultimo array que a contem.
  135 +
  136 + o array retornado, será ordenado por valor.
133 */ 137 */
134 public static function setAsIdValue($arrays, $keyAttr, $valueAtt) { 138 public static function setAsIdValue($arrays, $keyAttr, $valueAtt) {
135 if (empty($arrays)) 139 if (empty($arrays))
@@ -143,7 +147,7 @@ class Portabilis_Array_Utils { @@ -143,7 +147,7 @@ class Portabilis_Array_Utils {
143 foreach ($arrays as $array) 147 foreach ($arrays as $array)
144 $idValueArray = self::merge($idValueArray, self::asIdValue($array, $keyAttr, $valueAtt)); 148 $idValueArray = self::merge($idValueArray, self::asIdValue($array, $keyAttr, $valueAtt));
145 149
146 - return $idValueArray; 150 + return Portabilis_Array_Utils::sortByValue($idValueArray);
147 } 151 }
148 152
149 153
@@ -164,6 +168,14 @@ class Portabilis_Array_Utils { @@ -164,6 +168,14 @@ class Portabilis_Array_Utils {
164 return $array; 168 return $array;
165 } 169 }
166 170
  171 + /* ordena array por valor mantendo as chaves associativas, usando função php uasort. */
  172 + public static function sortByValue($array) {
  173 + uasort($array, function ($a, $b) {
  174 + return Portabilis_Array_Utils::_valueSorter($a, $b);
  175 + });
  176 +
  177 + return $array;
  178 + }
167 179
168 public static function _keySorter($key, $array, $otherArray) { 180 public static function _keySorter($key, $array, $otherArray) {
169 $a = $array[$key]; 181 $a = $array[$key];
@@ -175,6 +187,18 @@ class Portabilis_Array_Utils { @@ -175,6 +187,18 @@ class Portabilis_Array_Utils {
175 return ($a < $b) ? -1 : 1; 187 return ($a < $b) ? -1 : 1;
176 } 188 }
177 189
  190 + public static function _valueSorter($a, $b) {
  191 + if (is_string($a))
  192 + $a = Portabilis_String_Utils::unaccent($a);
  193 +
  194 + if (is_string($b))
  195 + $b = Portabilis_String_Utils::unaccent($b);
  196 +
  197 + if ($a == $b)
  198 + return 0;
  199 +
  200 + return ($a < $b) ? -1 : 1;
  201 + }
178 202
179 /* trim values for a given array */ 203 /* trim values for a given array */
180 public static function trim($array) { 204 public static function trim($array) {
ieducar/lib/Portabilis/Date/Utils.php
@@ -48,6 +48,9 @@ class Portabilis_Date_Utils @@ -48,6 +48,9 @@ class Portabilis_Date_Utils
48 * @param string $date 48 * @param string $date
49 */ 49 */
50 public static function brToPgSQL($date) { 50 public static function brToPgSQL($date) {
  51 + if (! $date)
  52 + return $date;
  53 +
51 // #TODO usar classe nativa datetime http://www.phptherightway.com/#date_and_time ? 54 // #TODO usar classe nativa datetime http://www.phptherightway.com/#date_and_time ?
52 list($dia, $mes, $ano) = explode("/", $date); 55 list($dia, $mes, $ano) = explode("/", $date);
53 return "$ano-$mes-$dia"; 56 return "$ano-$mes-$dia";
@@ -58,13 +61,23 @@ class Portabilis_Date_Utils @@ -58,13 +61,23 @@ class Portabilis_Date_Utils
58 * @param string $timestamp 61 * @param string $timestamp
59 */ 62 */
60 public static function pgSQLToBr($timestamp) { 63 public static function pgSQLToBr($timestamp) {
61 - $format = 'Y-m-d H:i:s';  
62 - $hasMicroseconds = strpos($timestamp, '.') > -1; 64 + $pgFormat = 'Y-m-d';
  65 + $brFormat = 'd/m/Y';
  66 +
  67 + $hasTime = strpos($timestamp, ':') > -1;
  68 +
  69 + if ($hasTime) {
  70 + $pgFormat .= ' H:i:s';
  71 + $brFormat .= ' H:i:s';
  72 +
  73 + $hasMicroseconds = strpos($timestamp, '.') > -1;
  74 +
  75 + if ($hasMicroseconds)
  76 + $pgFormat .= '.u';
  77 + }
63 78
64 - if ($hasMicroseconds)  
65 - $format .= '.u'; 79 + $d = DateTime::createFromFormat($pgFormat, $timestamp);
66 80
67 - $d = DateTime::createFromFormat($format, $timestamp);  
68 - return ($d ? $d->format('d/m/Y H:i:s') : null); 81 + return ($d ? $d->format($brFormat) : null);
69 } 82 }
70 } 83 }
ieducar/lib/Portabilis/String/Utils.php
@@ -47,6 +47,7 @@ class Portabilis_String_Utils { @@ -47,6 +47,7 @@ class Portabilis_String_Utils {
47 return Portabilis_Array_Utils::merge($options, $defaultOptions); 47 return Portabilis_Array_Utils::merge($options, $defaultOptions);
48 } 48 }
49 49
  50 +
50 /* splits a string in a array, eg: 51 /* splits a string in a array, eg:
51 52
52 $divisors = array('-', ' '); // or $divisors = '-'; 53 $divisors = array('-', ' '); // or $divisors = '-';
@@ -77,12 +78,14 @@ class Portabilis_String_Utils { @@ -77,12 +78,14 @@ class Portabilis_String_Utils {
77 return $result; 78 return $result;
78 } 79 }
79 80
  81 +
80 /* scapes a string, adding backslashes before characters that need to be quoted, 82 /* scapes a string, adding backslashes before characters that need to be quoted,
81 this method is useful to scape values to be inserted via database queries. */ 83 this method is useful to scape values to be inserted via database queries. */
82 public static function escape($str) { 84 public static function escape($str) {
83 return addslashes($str); 85 return addslashes($str);
84 } 86 }
85 87
  88 +
86 /* encodes latin1 strings to utf-8, 89 /* encodes latin1 strings to utf-8,
87 this method is useful to return latin1 strings (with accents) stored in db, in json api's. 90 this method is useful to return latin1 strings (with accents) stored in db, in json api's.
88 */ 91 */
@@ -96,6 +99,7 @@ class Portabilis_String_Utils { @@ -96,6 +99,7 @@ class Portabilis_String_Utils {
96 if ($options['transform']) 99 if ($options['transform'])
97 $str = ucwords(mb_strtolower($str)); 100 $str = ucwords(mb_strtolower($str));
98 101
  102 +
99 $str = utf8_encode($str); 103 $str = utf8_encode($str);
100 104
101 if ($options['convert_html_special_chars']) 105 if ($options['convert_html_special_chars'])
@@ -104,6 +108,7 @@ class Portabilis_String_Utils { @@ -104,6 +108,7 @@ class Portabilis_String_Utils {
104 return $str; 108 return $str;
105 } 109 }
106 110
  111 +
107 /* encodes utf-8 strings to latin1, 112 /* encodes utf-8 strings to latin1,
108 this method is useful to store utf-8 string (with accents) get from json api's, in latin1 db's. 113 this method is useful to store utf-8 string (with accents) get from json api's, in latin1 db's.
109 */ 114 */
@@ -117,7 +122,11 @@ class Portabilis_String_Utils { @@ -117,7 +122,11 @@ class Portabilis_String_Utils {
117 if ($options['transform']) 122 if ($options['transform'])
118 $str = ucwords(mb_strtolower($str)); 123 $str = ucwords(mb_strtolower($str));
119 124
120 - if (mb_detect_encoding($str, 'utf-8, iso-8859-1') == 'UTF-8') 125 +
  126 + // apenas converte para latin1, strings utf-8
  127 + // impedindo assim, converter para latin1 strings que já sejam latin1
  128 +
  129 + if (Portabilis_String_Utils::encoding($str) == 'UTF-8')
121 $str = utf8_decode($str); 130 $str = utf8_decode($str);
122 131
123 if ($options['convert_html_special_chars']) 132 if ($options['convert_html_special_chars'])
@@ -126,15 +135,27 @@ class Portabilis_String_Utils { @@ -126,15 +135,27 @@ class Portabilis_String_Utils {
126 return $str; 135 return $str;
127 } 136 }
128 137
  138 + public static function unaccent($str) {
  139 + $fromEncoding = Portabilis_String_Utils::encoding($str);
  140 + return iconv($fromEncoding, 'US-ASCII//TRANSLIT', $str);
  141 + }
  142 +
  143 +
  144 + public static function encoding($str) {
  145 + return mb_detect_encoding($str, 'UTF-8, ISO-8859-1', $strict = true);
  146 + }
  147 +
129 public static function camelize($str) { 148 public static function camelize($str) {
130 return str_replace(' ', '', ucwords(str_replace('_', ' ', $str))); 149 return str_replace(' ', '', ucwords(str_replace('_', ' ', $str)));
131 } 150 }
132 151
  152 +
133 public static function underscore($str) { 153 public static function underscore($str) {
134 $words = preg_split('/(?=[A-Z])/', $str, -1, PREG_SPLIT_NO_EMPTY); 154 $words = preg_split('/(?=[A-Z])/', $str, -1, PREG_SPLIT_NO_EMPTY);
135 return strtolower(implode('_', $words)); 155 return strtolower(implode('_', $words));
136 } 156 }
137 157
  158 +
138 public static function humanize($str) { 159 public static function humanize($str) {
139 $robotWords = array('_id', 'ref_cod_', 'ref_ref_cod_'); 160 $robotWords = array('_id', 'ref_cod_', 'ref_ref_cod_');
140 161
ieducar/lib/Portabilis/View/Helper/Input/Core.php
@@ -80,8 +80,31 @@ class Portabilis_View_Helper_Input_Core { @@ -80,8 +80,31 @@ class Portabilis_View_Helper_Input_Core {
80 return $value; 80 return $value;
81 } 81 }
82 82
  83 + protected function inputPlaceholder($inputOptions) {
  84 + return isset($inputOptions['placeholder']) ? $inputOptions['placeholder'] : $inputOptions['label'];
  85 + }
  86 +
  87 + protected function fixupPlaceholder($inputOptions) {
  88 + $id = $inputOptions['id'];
  89 + $placeholder = $this->inputPlaceholder($inputOptions);
  90 +
  91 + $script = "
  92 + var \$input = \$j('#" . $id . "');
  93 + if (\$input.is(':enabled'))
  94 + \$input.attr('placeholder', '" . $placeholder . "');
  95 + ";
  96 + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true);
  97 + }
  98 +
83 99
84 protected function loadCoreAssets() { 100 protected function loadCoreAssets() {
  101 + // carrega estilo para feedback messages, devido algumas validações de inuts
  102 + // adicionarem mensagens
  103 +
  104 + $style = "/modules/Portabilis/Assets/Stylesheets/Frontend.css";
  105 + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style);
  106 +
  107 +
85 Portabilis_View_Helper_Application::loadJQueryLib($this->viewInstance); 108 Portabilis_View_Helper_Application::loadJQueryLib($this->viewInstance);
86 Portabilis_View_Helper_Application::loadJQueryUiLib($this->viewInstance); 109 Portabilis_View_Helper_Application::loadJQueryUiLib($this->viewInstance);
87 110
ieducar/lib/Portabilis/View/Helper/Input/Date.php 0 → 100644
@@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
  1 +<?php
  2 +
  3 +/**
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package Portabilis
  27 + * @since Arquivo disponível desde a versão 1.1.0
  28 + * @version $Id$
  29 + */
  30 +
  31 +require_once 'Portabilis/View/Helper/Input/Core.php';
  32 +require_once 'Portabilis/Date/Utils.php';
  33 +
  34 +/**
  35 + * Portabilis_View_Helper_Input_Date class.
  36 + *
  37 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  38 + * @category i-Educar
  39 + * @license @@license@@
  40 + * @package Portabilis
  41 + * @since Classe disponível desde a versão 1.1.0
  42 + * @version @@package_version@@
  43 + */
  44 +class Portabilis_View_Helper_Input_Date extends Portabilis_View_Helper_Input_Core {
  45 +
  46 + public function date($attrName, $options = array()) {
  47 + $defaultOptions = array('options' => array(), 'objectName' => '');
  48 +
  49 + $options = $this->mergeOptions($options, $defaultOptions);
  50 + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : '';
  51 +
  52 + $label = ! empty($attrName) ? $attrName : $options['objectName'];
  53 + $label = str_replace('_id', '', $label);
  54 +
  55 + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName,
  56 + 'label' => ucwords($label),
  57 + 'value' => null,
  58 + 'required' => true,
  59 + 'label_hint' => '',
  60 + 'inline' => false,
  61 + 'callback' => false,
  62 + 'disabled' => false);
  63 +
  64 + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
  65 +
  66 + $isDbFormated = strrpos($inputOptions['value'], '-') > -1;
  67 +
  68 + if ($isDbFormated)
  69 + $inputOptions['value'] = Portabilis_Date_Utils::pgSQLToBr($inputOptions['value']);
  70 +
  71 + call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions);
  72 + $this->fixupPlaceholder($inputOptions);
  73 + }
  74 +}
ieducar/lib/Portabilis/View/Helper/Input/Integer.php 0 → 100644
@@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
  1 +<?php
  2 +
  3 +/**
  4 + * i-Educar - Sistema de gestão escolar
  5 + *
  6 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  7 + * <ctima@itajai.sc.gov.br>
  8 + *
  9 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  10 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  11 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  12 + * qualquer versão posterior.
  13 + *
  14 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  15 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  16 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  17 + * do GNU para mais detalhes.
  18 + *
  19 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  20 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  21 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  22 + *
  23 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  24 + * @category i-Educar
  25 + * @license @@license@@
  26 + * @package Portabilis
  27 + * @since Arquivo disponível desde a versão 1.1.0
  28 + * @version $Id$
  29 + */
  30 +
  31 +require_once 'lib/Portabilis/View/Helper/Input/Numeric.php';
  32 +
  33 +
  34 +/**
  35 + * Portabilis_View_Helper_Input_Integer class.
  36 + *
  37 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  38 + * @category i-Educar
  39 + * @license @@license@@
  40 + * @package Portabilis
  41 + * @since Classe disponível desde a versão 1.1.0
  42 + * @version @@package_version@@
  43 + */
  44 +class Portabilis_View_Helper_Input_Integer extends Portabilis_View_Helper_Input_Numeric {
  45 +
  46 + protected function fixupValidation($inputOptions) {
  47 + // fixup para remover caracteres não numericos
  48 + // inclusive pontos '.', não removidos pela super classe
  49 + $js = " \$j('#" . $inputOptions['id'] . "').keyup(function(){
  50 + var oldValue = this.value;
  51 +
  52 + this.value = this.value.replace(/[^0-9\.]/g, '');
  53 + this.value = this.value.replace('.', '');
  54 +
  55 + if (oldValue != this.value)
  56 + messageUtils.error('Informe apenas números.', this);
  57 +
  58 + });";
  59 +
  60 + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false);
  61 + }
  62 +
  63 + public function integer($attrName, $options = array()) {
  64 + parent::numeric($attrName, $options);
  65 + }
  66 +}
ieducar/lib/Portabilis/View/Helper/Input/Numeric.php
@@ -44,6 +44,20 @@ require_once &#39;lib/Portabilis/View/Helper/Input/Core.php&#39;; @@ -44,6 +44,20 @@ require_once &#39;lib/Portabilis/View/Helper/Input/Core.php&#39;;
44 */ 44 */
45 class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_Core { 45 class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_Core {
46 46
  47 + protected function fixupValidation($inputOptions) {
  48 + // fixup para remover caracteres não numericos
  49 + $js = " \$j(#'" . $inputOptions['id'] . "').keyup(function(){
  50 + var oldValue = this.value;
  51 + this.value = this.value.replace(/[^0-9\.]/g, '');
  52 +
  53 + if (oldValue != this.value)
  54 + messageUtils.error('Informe apenas números.', this);
  55 +
  56 + });";
  57 +
  58 + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false);
  59 + }
  60 +
47 public function numeric($attrName, $options = array()) { 61 public function numeric($attrName, $options = array()) {
48 $defaultOptions = array('options' => array(), 'objectName' => ''); 62 $defaultOptions = array('options' => array(), 'objectName' => '');
49 63
@@ -59,7 +73,7 @@ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_ @@ -59,7 +73,7 @@ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_
59 'size' => 15, 73 'size' => 15,
60 'max_length' => 15, 74 'max_length' => 15,
61 'required' => true, 75 'required' => true,
62 - 'label_hint' => '', 76 + 'label_hint' => ' ',
63 'input_hint' => '', 77 'input_hint' => '',
64 'script' => false, 78 'script' => false,
65 'event' => 'onKeyUp', 79 'event' => 'onKeyUp',
@@ -67,7 +81,10 @@ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_ @@ -67,7 +81,10 @@ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_
67 'disabled' => false); 81 'disabled' => false);
68 82
69 $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); 83 $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
  84 + $inputOptions['label'] = Portabilis_String_Utils::toLatin1($inputOptions['label'], array('escape' => false));
70 85
71 call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions); 86 call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions);
  87 + $this->fixupPlaceholder($inputOptions);
  88 + $this->fixupValidation($inputOptions);
72 } 89 }
73 } 90 }
ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php
@@ -53,7 +53,7 @@ class Portabilis_View_Helper_Input_Resource_Beneficio extends Portabilis_View_He @@ -53,7 +53,7 @@ class Portabilis_View_Helper_Input_Resource_Beneficio extends Portabilis_View_He
53 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_aluno_beneficio', 'nm_beneficio'); 53 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_aluno_beneficio', 'nm_beneficio');
54 } 54 }
55 55
56 - return $this->insertOption(null, "Selecione", $resources); 56 + return $this->insertOption(null, "Beneficio", $resources);
57 } 57 }
58 58
59 public function beneficio($options = array()) { 59 public function beneficio($options = array()) {
ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php
@@ -53,7 +53,7 @@ class Portabilis_View_Helper_Input_Resource_EstadoCivil extends Portabilis_View_ @@ -53,7 +53,7 @@ class Portabilis_View_Helper_Input_Resource_EstadoCivil extends Portabilis_View_
53 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'ideciv', 'descricao'); 53 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'ideciv', 'descricao');
54 } 54 }
55 55
56 - return $this->insertOption(null, "Selecione", $resources); 56 + return $this->insertOption(null, "Estado civil", $resources);
57 } 57 }
58 58
59 public function estadoCivil($options = array()) { 59 public function estadoCivil($options = array()) {
ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php
@@ -54,7 +54,7 @@ class Portabilis_View_Helper_Input_Resource_Religiao extends Portabilis_View_Hel @@ -54,7 +54,7 @@ class Portabilis_View_Helper_Input_Resource_Religiao extends Portabilis_View_Hel
54 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_religiao', 'nm_religiao'); 54 $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_religiao', 'nm_religiao');
55 } 55 }
56 56
57 - return $this->insertOption(null, "Selecione", $resources); 57 + return $this->insertOption(null, Portabilis_String_Utils::toLatin1("Religião"), $resources);
58 } 58 }
59 59
60 60
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php
@@ -50,17 +50,11 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchAluno extends Portabilis @@ -50,17 +50,11 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchAluno extends Portabilis
50 50
51 $options = $this->mergeOptions($options, $defaultOptions); 51 $options = $this->mergeOptions($options, $defaultOptions);
52 52
53 - $this->placeholderJs($options);  
54 -  
55 parent::simpleSearch($options['objectName'], $attrName, $options); 53 parent::simpleSearch($options['objectName'], $attrName, $options);
56 } 54 }
57 55
58 - protected function placeholderJs($options) {  
59 - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options";  
60 - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} };  
61 - $optionsVarName.placeholder = stringUtils.toUtf8('Informe o nome do aluno ou código');";  
62 -  
63 - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); 56 + protected function inputPlaceholder($inputOptions) {
  57 + return 'Informe o código ou nome do aluno';
64 } 58 }
65 59
66 protected function loadAssets() { 60 protected function loadAssets() {
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php
@@ -50,17 +50,11 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchMatricula extends Portab @@ -50,17 +50,11 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchMatricula extends Portab
50 50
51 $options = $this->mergeOptions($options, $defaultOptions); 51 $options = $this->mergeOptions($options, $defaultOptions);
52 52
53 - $this->placeholderJs($options);  
54 -  
55 parent::simpleSearch($options['objectName'], $attrName, $options); 53 parent::simpleSearch($options['objectName'], $attrName, $options);
56 } 54 }
57 55
58 - protected function placeholderJs($options) {  
59 - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options";  
60 - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} };  
61 - $optionsVarName.placeholder = stringUtils.toUtf8('Informe o nome do aluno, código ou código matricula');";  
62 -  
63 - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); 56 + protected function inputPlaceholder($inputOptions) {
  57 + return 'Informe o nome do aluno, código ou código da matricula';
64 } 58 }
65 59
66 protected function loadAssets() { 60 protected function loadAssets() {
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php
@@ -64,16 +64,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchMunicipio extends Portab @@ -64,16 +64,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchMunicipio extends Portab
64 64
65 $options = $this->mergeOptions($options, $defaultOptions); 65 $options = $this->mergeOptions($options, $defaultOptions);
66 66
67 - $this->placeholderJs($options);  
68 -  
69 parent::simpleSearch($options['objectName'], $attrName, $options); 67 parent::simpleSearch($options['objectName'], $attrName, $options);
70 } 68 }
71 69
72 - protected function placeholderJs($options) {  
73 - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options";  
74 - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} };  
75 - $optionsVarName.placeholder = safeUtf8Decode('Informe o código ou nome da cidade');";  
76 -  
77 - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); 70 + protected function inputPlaceholder($inputOptions) {
  71 + return 'Informe o código ou nome da cidade';
78 } 72 }
79 } 73 }
80 \ No newline at end of file 74 \ No newline at end of file
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php
@@ -62,16 +62,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchPais extends Portabilis_ @@ -62,16 +62,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchPais extends Portabilis_
62 62
63 $options = $this->mergeOptions($options, $defaultOptions); 63 $options = $this->mergeOptions($options, $defaultOptions);
64 64
65 - $this->placeholderJs($options);  
66 -  
67 parent::simpleSearch($options['objectName'], $attrName, $options); 65 parent::simpleSearch($options['objectName'], $attrName, $options);
68 } 66 }
69 67
70 - protected function placeholderJs($options) {  
71 - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options";  
72 - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} };  
73 - $optionsVarName.placeholder = safeUtf8Decode('Informe o código ou nome do pais de origem');";  
74 -  
75 - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); 68 + protected function inputPlaceholder($inputOptions) {
  69 + return 'Informe o código ou nome do pais de origem';
76 } 70 }
77 } 71 }
78 \ No newline at end of file 72 \ No newline at end of file
ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php
@@ -62,16 +62,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchPessoa extends Portabili @@ -62,16 +62,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchPessoa extends Portabili
62 62
63 $options = $this->mergeOptions($options, $defaultOptions); 63 $options = $this->mergeOptions($options, $defaultOptions);
64 64
65 - $this->placeholderJs($options);  
66 -  
67 parent::simpleSearch($options['objectName'], $attrName, $options); 65 parent::simpleSearch($options['objectName'], $attrName, $options);
68 } 66 }
69 67
70 - protected function placeholderJs($options) {  
71 - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options";  
72 - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} };  
73 - $optionsVarName.placeholder = safeUtf8Decode('Informe o nome, código, CPF ou RG da pessoa');";  
74 -  
75 - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); 68 + protected function inputPlaceholder($inputOptions) {
  69 + return 'Informe o nome, código, CPF ou RG da pessoa';
76 } 70 }
77 } 71 }
78 \ No newline at end of file 72 \ No newline at end of file
ieducar/lib/Portabilis/View/Helper/Input/Resource/TipoLogradouro.php 0 → 100644
@@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
  1 +<?php
  2 +#error_reporting(E_ALL);
  3 +#ini_set("display_errors", 1);
  4 +/**
  5 + * i-Educar - Sistema de gestão escolar
  6 + *
  7 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  8 + * <ctima@itajai.sc.gov.br>
  9 + *
  10 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  11 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  12 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  13 + * qualquer versão posterior.
  14 + *
  15 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  16 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  17 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  18 + * do GNU para mais detalhes.
  19 + *
  20 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  21 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  22 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  23 + *
  24 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  25 + * @category i-Educar
  26 + * @license @@license@@
  27 + * @package Portabilis
  28 + * @since Arquivo disponível desde a versão 1.1.0
  29 + * @version $Id$
  30 + */
  31 +
  32 +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php';
  33 +
  34 +
  35 +/**
  36 + * Portabilis_View_Helper_Input_Resource_TipoLogradouro class.
  37 + *
  38 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  39 + * @category i-Educar
  40 + * @license @@license@@
  41 + * @package Portabilis
  42 + * @since Classe disponível desde a versão 1.1.0
  43 + * @version @@package_version@@
  44 + */
  45 +
  46 +class Portabilis_View_Helper_Input_Resource_TipoLogradouro extends Portabilis_View_Helper_Input_CoreSelect {
  47 +
  48 + protected function inputOptions($options) {
  49 + $resources = $options['resources'];
  50 +
  51 + if (empty($options['resources'])) {
  52 + $resources = new clsTipoLogradouro();
  53 + $resources = $resources->lista();
  54 + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'idtlog', 'descricao');
  55 + }
  56 +
  57 + return $this->insertOption(null, "Tipo logradouro", $resources);
  58 + }
  59 +
  60 +
  61 + public function tipoLogradouro($options = array()) {
  62 + parent::select($options);
  63 + }
  64 +}
0 \ No newline at end of file 65 \ No newline at end of file
ieducar/lib/Portabilis/View/Helper/Input/Resource/Uf.php 0 → 100644
@@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
  1 +<?php
  2 +#error_reporting(E_ALL);
  3 +#ini_set("display_errors", 1);
  4 +/**
  5 + * i-Educar - Sistema de gestão escolar
  6 + *
  7 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  8 + * <ctima@itajai.sc.gov.br>
  9 + *
  10 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  11 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  12 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  13 + * qualquer versão posterior.
  14 + *
  15 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  16 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  17 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  18 + * do GNU para mais detalhes.
  19 + *
  20 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  21 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  22 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  23 + *
  24 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  25 + * @category i-Educar
  26 + * @license @@license@@
  27 + * @package Portabilis
  28 + * @since Arquivo disponível desde a versão 1.1.0
  29 + * @version $Id$
  30 + */
  31 +
  32 +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php';
  33 +
  34 +
  35 +/**
  36 + * Portabilis_View_Helper_Input_Resource_Uf class.
  37 + *
  38 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  39 + * @category i-Educar
  40 + * @license @@license@@
  41 + * @package Portabilis
  42 + * @since Classe disponível desde a versão 1.1.0
  43 + * @version @@package_version@@
  44 + */
  45 +
  46 +class Portabilis_View_Helper_Input_Resource_Uf extends Portabilis_View_Helper_Input_CoreSelect {
  47 +
  48 + protected function inputOptions($options) {
  49 + $resources = $options['resources'];
  50 +
  51 + if (empty($options['resources'])) {
  52 + $resources = new clsUf();
  53 + $resources = $resources->lista();
  54 + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'sigla_uf', 'sigla_uf');
  55 + }
  56 +
  57 + return $this->insertOption(null, "Estado", $resources);
  58 + }
  59 +
  60 +
  61 + public function uf($options = array()) {
  62 + parent::select($options);
  63 + }
  64 +}
0 \ No newline at end of file 65 \ No newline at end of file
ieducar/lib/Portabilis/View/Helper/Input/Select.php
@@ -61,7 +61,9 @@ class Portabilis_View_Helper_Input_Select extends Portabilis_View_Helper_Input_C @@ -61,7 +61,9 @@ class Portabilis_View_Helper_Input_Select extends Portabilis_View_Helper_Input_C
61 'required' => true, 61 'required' => true,
62 'multiple' => false); 62 'multiple' => false);
63 63
64 - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); 64 + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
  65 + $inputOptions['label'] = Portabilis_String_Utils::toLatin1($inputOptions['label'], array('escape' => false));
  66 +
65 call_user_func_array(array($this->viewInstance, 'campoLista'), $inputOptions); 67 call_user_func_array(array($this->viewInstance, 'campoLista'), $inputOptions);
66 } 68 }
67 } 69 }
68 \ No newline at end of file 70 \ No newline at end of file
ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php
@@ -95,6 +95,11 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I @@ -95,6 +95,11 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I
95 protected function textInput($objectName, $attrName, $options) { 95 protected function textInput($objectName, $attrName, $options) {
96 $textHelperOptions = array('objectName' => $objectName); 96 $textHelperOptions = array('objectName' => $objectName);
97 97
  98 + $options['options']['placeholder'] = Portabilis_String_Utils::toLatin1(
  99 + $this->inputPlaceholder(),
  100 + array('escape' => false)
  101 + );
  102 +
98 $this->inputsHelper()->text($attrName, $options['options'], $textHelperOptions); 103 $this->inputsHelper()->text($attrName, $options['options'], $textHelperOptions);
99 } 104 }
100 105
@@ -110,7 +115,7 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I @@ -110,7 +115,7 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I
110 115
111 /* 116 /*
112 all search options (including the option autocompleteOptions, that is passed for jquery autocomplete plugin), 117 all search options (including the option autocompleteOptions, that is passed for jquery autocomplete plugin),
113 - can be overwritten adding "var = simpleSearch<ObjectName>Options = { placeholder : '...', optionName : '...' };" 118 + can be overwritten adding "var = simpleSearch<ObjectName>Options = { option : '...', optionName : '...' };"
114 in the script file for the resource controller. 119 in the script file for the resource controller.
115 */ 120 */
116 121
ieducar/lib/Portabilis/View/Helper/Input/Text.php
@@ -51,7 +51,7 @@ class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Cor @@ -51,7 +51,7 @@ class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Cor
51 $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; 51 $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : '';
52 52
53 $label = ! empty($attrName) ? $attrName : $options['objectName']; 53 $label = ! empty($attrName) ? $attrName : $options['objectName'];
54 - $label = str_replace('_id', '', $label); 54 + $label = str_replace('_id', '', $label);
55 55
56 $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, 56 $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName,
57 'label' => ucwords($label), 57 'label' => ucwords($label),
@@ -67,8 +67,10 @@ class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Cor @@ -67,8 +67,10 @@ class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Cor
67 'event' => 'onKeyUp', 67 'event' => 'onKeyUp',
68 'disabled' => false); 68 'disabled' => false);
69 69
70 - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); 70 + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
  71 + $inputOptions['label'] = Portabilis_String_Utils::toLatin1($inputOptions['label'], array('escape' => false));
71 72
72 call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions); 73 call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions);
  74 + $this->fixupPlaceholder($inputOptions);
73 } 75 }
74 } 76 }
ieducar/lib/Portabilis/View/Helper/Input/TextArea.php 0 → 100644
@@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
  1 +<?php
  2 +#error_reporting(E_ALL);
  3 +#ini_set("display_errors", 1);
  4 +/**
  5 + * i-Educar - Sistema de gestão escolar
  6 + *
  7 + * Copyright (C) 2006 Prefeitura Municipal de Itajaí
  8 + * <ctima@itajai.sc.gov.br>
  9 + *
  10 + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo
  11 + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free
  12 + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério)
  13 + * qualquer versão posterior.
  14 + *
  15 + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM
  16 + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU
  17 + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral
  18 + * do GNU para mais detalhes.
  19 + *
  20 + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto
  21 + * com este programa; se não, escreva para a Free Software Foundation, Inc., no
  22 + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
  23 + *
  24 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  25 + * @category i-Educar
  26 + * @license @@license@@
  27 + * @package Portabilis
  28 + * @since Arquivo disponível desde a versão 1.1.0
  29 + * @version $Id$
  30 + */
  31 +
  32 +require_once 'lib/Portabilis/View/Helper/Input/Core.php';
  33 +
  34 +
  35 +/**
  36 + * Portabilis_View_Helper_Input_TextArea class.
  37 + *
  38 + * @author Lucas D'Avila <lucasdavila@portabilis.com.br>
  39 + * @category i-Educar
  40 + * @license @@license@@
  41 + * @package Portabilis
  42 + * @since Classe disponível desde a versão 1.1.0
  43 + * @version @@package_version@@
  44 + */
  45 +class Portabilis_View_Helper_Input_TextArea extends Portabilis_View_Helper_Input_Core {
  46 +
  47 + public function textArea($attrName, $options = array()) {
  48 + $defaultOptions = array('options' => array(), 'objectName' => '');
  49 +
  50 + $options = $this->mergeOptions($options, $defaultOptions);
  51 + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : '';
  52 +
  53 + $label = ! empty($attrName) ? $attrName : $options['objectName'];
  54 + $label = str_replace('_id', '', $label);
  55 +
  56 + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName,
  57 + 'label' => ucwords($label),
  58 + 'value' => null,
  59 + 'cols' => 49,
  60 + 'rows' => 5,
  61 + 'required' => true,
  62 + 'label_hint' => '',
  63 + 'max_length' => '',
  64 + 'inline' => false,
  65 + 'script' => false,
  66 + 'event' => 'onClick',
  67 + 'disabled' => false);
  68 +
  69 + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions);
  70 +
  71 + call_user_func_array(array($this->viewInstance, 'campoMemo'), $inputOptions);
  72 + $this->fixupPlaceholder($inputOptions);
  73 + }
  74 +}
ieducar/lib/Portabilis/View/Helper/Inputs.php
@@ -84,6 +84,14 @@ class Portabilis_View_Helper_Inputs { @@ -84,6 +84,14 @@ class Portabilis_View_Helper_Inputs {
84 84
85 // input helpers 85 // input helpers
86 86
  87 + public function input($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) {
  88 + $helperClassName = "Portabilis_View_Helper_Input_" . ucfirst($helperName);
  89 +
  90 + $this->includeHelper($helperClassName);
  91 + $helper = new $helperClassName($this->viewInstance, $this);
  92 + $helper->$helperName($attrName, $this->mergeInputOptions($inputOptions, $helperOptions));
  93 + }
  94 +
87 public function text($attrNames, $inputOptions = array(), $helperOptions = array()) { 95 public function text($attrNames, $inputOptions = array(), $helperOptions = array()) {
88 if (! is_array($attrNames)) 96 if (! is_array($attrNames))
89 $attrNames = array($attrNames); 97 $attrNames = array($attrNames);
@@ -93,42 +101,36 @@ class Portabilis_View_Helper_Inputs { @@ -93,42 +101,36 @@ class Portabilis_View_Helper_Inputs {
93 } 101 }
94 } 102 }
95 103
96 - public function numeric($attrNames, $inputOptions = array(), $helperOptions = array()) {  
97 - if (! is_array($attrNames))  
98 - $attrNames = array($attrNames);  
99 -  
100 - foreach($attrNames as $attrName) {  
101 - $this->input('numeric', $attrName, $inputOptions, $helperOptions);  
102 - } 104 + public function numeric($attrName, $inputOptions = array(), $helperOptions = array()) {
  105 + $this->input('numeric', $attrName, $inputOptions, $helperOptions);
103 } 106 }
104 107
  108 + public function integer($attrName, $inputOptions = array(), $helperOptions = array()) {
  109 + $this->input('integer', $attrName, $inputOptions, $helperOptions);
  110 + }
105 111
106 public function select($attrName, $inputOptions = array(), $helperOptions = array()) { 112 public function select($attrName, $inputOptions = array(), $helperOptions = array()) {
107 $this->input('select', $attrName, $inputOptions, $helperOptions); 113 $this->input('select', $attrName, $inputOptions, $helperOptions);
108 } 114 }
109 115
110 -  
111 public function search($attrName, $inputOptions = array(), $helperOptions = array()) { 116 public function search($attrName, $inputOptions = array(), $helperOptions = array()) {
112 $this->input('search', $attrName, $inputOptions, $helperOptions); 117 $this->input('search', $attrName, $inputOptions, $helperOptions);
113 } 118 }
114 119
115 -  
116 public function hidden($attrName, $inputOptions = array(), $helperOptions = array()) { 120 public function hidden($attrName, $inputOptions = array(), $helperOptions = array()) {
117 $this->input('hidden', $attrName, $inputOptions, $helperOptions); 121 $this->input('hidden', $attrName, $inputOptions, $helperOptions);
118 } 122 }
119 123
120 -  
121 public function checkbox($attrName, $inputOptions = array(), $helperOptions = array()) { 124 public function checkbox($attrName, $inputOptions = array(), $helperOptions = array()) {
122 $this->input('checkbox', $attrName, $inputOptions, $helperOptions); 125 $this->input('checkbox', $attrName, $inputOptions, $helperOptions);
123 } 126 }
124 127
  128 + public function date($attrName, $inputOptions = array(), $helperOptions = array()) {
  129 + $this->input('date', $attrName, $inputOptions, $helperOptions);
  130 + }
125 131
126 - public function input($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) {  
127 - $helperClassName = "Portabilis_View_Helper_Input_" . ucfirst($helperName);  
128 -  
129 - $this->includeHelper($helperClassName);  
130 - $helper = new $helperClassName($this->viewInstance, $this);  
131 - $helper->$helperName($attrName, $this->mergeInputOptions($inputOptions, $helperOptions)); 132 + public function textArea($attrName, $inputOptions = array(), $helperOptions = array()) {
  133 + $this->input('textArea', $attrName, $inputOptions, $helperOptions);
132 } 134 }
133 135
134 136
@@ -196,6 +198,14 @@ class Portabilis_View_Helper_Inputs { @@ -196,6 +198,14 @@ class Portabilis_View_Helper_Inputs {
196 $this->resourceInput('turmaTurno', $this->mergeInputOptions($inputOptions, $helperOptions)); 198 $this->resourceInput('turmaTurno', $this->mergeInputOptions($inputOptions, $helperOptions));
197 } 199 }
198 200
  201 + public function uf($inputOptions = array(), $helperOptions = array()) {
  202 + $this->resourceInput('uf', $this->mergeInputOptions($inputOptions, $helperOptions));
  203 + }
  204 +
  205 + public function tipoLogradouro($inputOptions = array(), $helperOptions = array()) {
  206 + $this->resourceInput('tipoLogradouro', $this->mergeInputOptions($inputOptions, $helperOptions));
  207 + }
  208 +
199 // protected methods 209 // protected methods
200 210
201 protected function resourceInput($helperName, $options = array()) { 211 protected function resourceInput($helperName, $options = array()) {
ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js
@@ -83,7 +83,7 @@ var handleGetPersonDetails = function(dataResponse) { @@ -83,7 +83,7 @@ var handleGetPersonDetails = function(dataResponse) {
83 83
84 else { 84 else {
85 $j('.pessoa-links .editar-pessoa').attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + dataResponse.id) 85 $j('.pessoa-links .editar-pessoa').attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + dataResponse.id)
86 - .show(); 86 + .show().css('display', 'inline');
87 87
88 $submitButton.removeAttr('disabled').show(); 88 $submitButton.removeAttr('disabled').show();
89 } 89 }
@@ -174,8 +174,8 @@ function afterChangePessoa(targetWindow, pessoaId) { @@ -174,8 +174,8 @@ function afterChangePessoa(targetWindow, pessoaId) {
174 $j('#pessoa_id').val(pessoaId); 174 $j('#pessoa_id').val(pessoaId);
175 getPersonDetails(pessoaId); 175 getPersonDetails(pessoaId);
176 176
177 - window.setTimeout(function() { $nomeField.removeClass('success'); }, 10000);  
178 - $nomeField.focus(); 177 + if ($nomeField.is(':active'))
  178 + $nomeField.focus();
179 179
180 }, 500); 180 }, 500);
181 } 181 }
@@ -209,7 +209,7 @@ function afterChangePessoa(targetWindow, pessoaId) { @@ -209,7 +209,7 @@ function afterChangePessoa(targetWindow, pessoaId) {
209 209
210 if (resource.isNew()) { 210 if (resource.isNew()) {
211 $nomeField.focus(); 211 $nomeField.focus();
212 - $j('.pessoa-links .cadastrar-pessoa').show(); 212 + $j('.pessoa-links .cadastrar-pessoa').show().css('display', 'inline');
213 } 213 }
214 else 214 else
215 $nomeField.attr('disabled', 'disabled'); 215 $nomeField.attr('disabled', 'disabled');
ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js
@@ -87,7 +87,7 @@ var handleGetMatriculas = function(dataResponse) { @@ -87,7 +87,7 @@ var handleGetMatriculas = function(dataResponse) {
87 } 87 }
88 88
89 $matriculasTable.fadeIn('slow'); 89 $matriculasTable.fadeIn('slow');
90 - $j('body').animate({scrollTop: $j('#matriculas').offset().top }, 900); 90 + $j('body,html').animate({scrollTop: $j('#matriculas').offset().top }, 900);
91 91
92 $matriculasTable.find('tr:even').addClass('even'); 92 $matriculasTable.find('tr:even').addClass('even');
93 } 93 }
ieducar/modules/Cadastro/Assets/Javascripts/Escola.js
1 var $submitButton = $j('#btn_enviar'); 1 var $submitButton = $j('#btn_enviar');
2 2
3 var submitForm = function(){ 3 var submitForm = function(){
4 - putEscola(); 4 + if (validationUtils.validatesFields())
  5 + putEscola();
5 } 6 }
6 7
7 var handleGetEscola = function(dataResponse) { 8 var handleGetEscola = function(dataResponse) {
ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js
1 -(function($) {  
2 - $(document).ready(function() {  
3 1
4 - var $form = $j('#formcadastro');  
5 - var $submitButton = $j('#btn_enviar');  
6 - var $cpfField = $j('#id_federal');  
7 - var $cpfNotice = $j('<span>').html('')  
8 - .addClass('error resource-notice')  
9 - .hide()  
10 - .width($j('#nm_pessoa').outerWidth() - 12)  
11 - .appendTo($cpfField.parent()); 2 +// before page is ready
12 3
  4 +function hrefToCreateParent(parentType) {
  5 + return '/intranet/atendidos_cad.php?parent_type=' + parentType;
  6 +}
  7 +
  8 +function hrefToEditParent(parentType) {
  9 + var id = $j(buildId(parentType + '_id')).val();
  10 + return hrefToCreateParent(parentType) + '&cod_pessoa_fj=' + id;
  11 +}
  12 +
  13 +var pessoaId = $j('#cod_pessoa_fj').val();
  14 +var $form = $j('#formcadastro');
  15 +var $submitButton = $j('#btn_enviar');
  16 +var $cpfField = $j('#id_federal');
  17 +var $cpfNotice = $j('<span>').html('')
  18 + .addClass('error resource-notice')
  19 + .hide()
  20 + .width($j('#nm_pessoa').outerWidth() - 12)
  21 + .appendTo($cpfField.parent());
13 22
14 - var handleGetPersonByCpf = function(dataResponse) {  
15 - handleMessages(dataResponse.msgs);  
16 - $cpfNotice.hide();  
17 23
18 - var pessoaId = dataResponse.id; 24 +// links pessoa pai, mãe
  25 +
  26 +var $paiNomeField = $j('#pai_nome');
  27 +var $paiIdField = $j('#pai_id');
  28 +
  29 +var $maeNomeField = $j('#mae_nome');
  30 +var $maeIdField = $j('#mae_id');
  31 +
  32 +
  33 +var $pessoaPaiActionBar = $j('<span>').html('')
  34 + .addClass('pessoa-links pessoa-pai-links')
  35 + .width($paiNomeField.outerWidth() - 12)
  36 + .appendTo($paiNomeField.parent());
  37 +
  38 +var $pessoaMaeActionBar = $pessoaPaiActionBar.clone()
  39 + .removeClass('pessoa-pai-links')
  40 + .addClass('pessoa-mae-links')
  41 + .appendTo($maeNomeField.parent());
19 42
20 - if (pessoaId && pessoaId != $j('#cod_pessoa_fj').val()) {  
21 - $cpfNotice.html(stringUtils.toUtf8('CPF já utilizado pela pessoa código ' + pessoaId + ', ')).slideDown('fast'); 43 +var $linkToCreatePessoaPai = $j('<a>').addClass('cadastrar-pessoa-pai decorated')
  44 + .attr('href', hrefToCreateParent('pai'))
  45 + .attr('target', '_blank')
  46 + .html('Cadastrar pessoa')
  47 + .appendTo($pessoaPaiActionBar);
22 48
23 - $j('<a>').addClass('decorated')  
24 - .attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + pessoaId)  
25 - .attr('target', '_blank')  
26 - .html('acessar cadastro.')  
27 - .appendTo($cpfNotice); 49 +var $linkToEditPessoaPai = $j('<a>').hide()
  50 + .addClass('editar-pessoa-pai decorated')
  51 + .attr('href', hrefToEditParent('pai'))
  52 + .attr('target', '_blank')
  53 + .html('Editar pessoa')
  54 + .appendTo($pessoaPaiActionBar);
28 55
29 - $j('body').animate({ scrollTop: $j('body').offset().top }, 'fast');  
30 - } 56 +var $linkToCreatePessoaMae = $linkToCreatePessoaPai.clone()
  57 + .removeClass('cadastrar-pessoa-pai')
  58 + .addClass('cadastrar-pessoa-mae')
  59 + .attr('href', hrefToCreateParent('mae'))
  60 + .appendTo($pessoaMaeActionBar);
31 61
32 - else if ($j(document).data('submit_form_after_ajax_validation'))  
33 - formUtils.submit();  
34 - } 62 +var $linkToEditPessoaMae = $linkToEditPessoaPai.clone()
  63 + .removeClass('editar-pessoa-pai')
  64 + .addClass('editar-pessoa-mae')
  65 + .attr('href', hrefToEditParent('mae'))
  66 + .appendTo($pessoaMaeActionBar);
35 67
  68 +var handleGetPersonByCpf = function(dataResponse) {
  69 + handleMessages(dataResponse.msgs);
  70 + $cpfNotice.hide();
36 71
37 - var getPersonByCpf = function(cpf) {  
38 - var options = {  
39 - url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa'),  
40 - dataType : 'json',  
41 - data : { cpf : cpf },  
42 - success : handleGetPersonByCpf, 72 + var pessoaId = dataResponse.id;
43 73
44 - // forçado requisições sincronas, evitando erro com requisições ainda não concluidas,  
45 - // como no caso, onde o usuário pressiona cancelar por exemplo.  
46 - async : false  
47 - }; 74 + if (pessoaId && pessoaId != $j('#cod_pessoa_fj').val()) {
  75 + $cpfNotice.html(stringUtils.toUtf8('CPF já utilizado pela pessoa código ' + pessoaId + ', ')).slideDown('fast');
48 76
49 - getResource(options);  
50 - } 77 + $j('<a>').addClass('decorated')
  78 + .attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + pessoaId)
  79 + .attr('target', '_blank')
  80 + .html('acessar cadastro.')
  81 + .appendTo($cpfNotice);
51 82
  83 + $j('body,html').animate({ scrollTop: $j('body').offset().top }, 'fast');
  84 + }
52 85
53 - // hide or show #pais_origem_nome by #tipo_nacionalidade  
54 - var checkTipoNacionalidade = function() {  
55 - if ($j.inArray($j('#tipo_nacionalidade').val(), ['2', '3']) > -1)  
56 - $j('#pais_origem_nome').show();  
57 - else  
58 - $j('#pais_origem_nome').hide();  
59 - } 86 + else if ($j(document).data('submit_form_after_ajax_validation'))
  87 + formUtils.submit();
  88 +}
60 89
61 90
62 - var validatesCpf = function() {  
63 - var valid = true;  
64 - var cpf = $cpfField.val(); 91 +var getPersonByCpf = function(cpf) {
  92 + var options = {
  93 + url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa'),
  94 + dataType : 'json',
  95 + data : { cpf : cpf },
  96 + success : handleGetPersonByCpf,
65 97
66 - $cpfNotice.hide(); 98 + // forçado requisições sincronas, evitando erro com requisições ainda não concluidas,
  99 + // como no caso, onde o usuário pressiona cancelar por exemplo.
  100 + async : false
  101 + };
67 102
68 - if (cpf && ! validationUtils.validatesCpf(cpf)) {  
69 - $cpfNotice.html(stringUtils.toUtf8('O CPF informado é inválido')).slideDown('fast'); 103 + getResource(options);
  104 +}
70 105
71 - // não usado $cpfField.focus(), pois isto prenderia o usuário a página,  
72 - // caso o mesmo tenha informado um cpf invalido e clique em cancelar  
73 - $j('body').animate({ scrollTop: $j('body').offset().top }, 'fast');  
74 106
75 - valid = false;  
76 - } 107 +// hide or show #pais_origem_nome by #tipo_nacionalidade
  108 +var checkTipoNacionalidade = function() {
  109 + if ($j.inArray($j('#tipo_nacionalidade').val(), ['2', '3']) > -1)
  110 + $j('#pais_origem_nome').show();
  111 + else
  112 + $j('#pais_origem_nome').hide();
  113 +}
77 114
78 - return valid;  
79 - } 115 +// hide or show *certidao* fields, by #tipo_certidao_civil
  116 +var checkTipoCertidaoCivil = function() {
  117 + var $certidaoCivilFields = $j('#termo_certidao_civil, #livro_certidao_civil, #folha_certidao_civil');
  118 + var $certidaoNascimentoField = $j('#certidao_nascimento');
  119 + var tipoCertidaoCivil = $j('#tipo_certidao_civil').val();
80 120
  121 + $certidaoCivilFields.hide();
  122 + $certidaoNascimentoField.hide();
81 123
82 - var validatesUniquenessOfCpf = function() {  
83 - var cpf = $cpfField.val(); 124 + if ($j.inArray(tipoCertidaoCivil, ['91', '92']) > -1) {
  125 + $certidaoCivilFields.show();
  126 + $j('#tr_tipo_certidao_civil td:first span').html(stringUtils.toUtf8('Tipo certidão civil / Termo / Livro / Folha'));
  127 + }
84 128
85 - if(cpf && validatesCpf())  
86 - getPersonByCpf(cpf);  
87 - } 129 + else if (tipoCertidaoCivil == 'certidao_nascimento_novo_formato') {
  130 + $certidaoNascimentoField.show();
  131 + $j('#tr_tipo_certidao_civil td:first span').html(stringUtils.toUtf8('Tipo certidão civil / Certidão nascimento'));
  132 + }
88 133
  134 +}
89 135
90 - var submitForm = function(event) { 136 +var validatesCpf = function() {
  137 + var valid = true;
  138 + var cpf = $cpfField.val();
91 139
92 - if ($cpfField.val()) {  
93 - $j(document).data('submit_form_after_ajax_validation', true);  
94 - validatesUniquenessOfCpf();  
95 - } 140 + $cpfNotice.hide();
96 141
97 - else  
98 - formUtils.submit();  
99 - } 142 + if (cpf && ! validationUtils.validatesCpf(cpf)) {
  143 + $cpfNotice.html(stringUtils.toUtf8('O CPF informado é inválido')).slideDown('fast');
100 144
  145 + // não usado $cpfField.focus(), pois isto prenderia o usuário a página,
  146 + // caso o mesmo tenha informado um cpf invalido e clique em cancelar
  147 + $j('body,html').animate({ scrollTop: $j('body').offset().top }, 'fast');
101 148
102 - // style fixup 149 + valid = false;
  150 + }
103 151
104 - $('#pais_origem_nome').css('width', '150px'); 152 + return valid;
  153 +}
105 154
106 155
107 - // bind events 156 +var validatesUniquenessOfCpf = function() {
  157 + var cpf = $cpfField.val();
108 158
109 - checkTipoNacionalidade();  
110 - $j('#tipo_nacionalidade').change(checkTipoNacionalidade); 159 + $cpfNotice.hide();
111 160
112 - $cpfField.focusout(function() {  
113 - $j(document).removeData('submit_form_after_ajax_validation');  
114 - validatesUniquenessOfCpf(); 161 + if(cpf && validatesCpf())
  162 + getPersonByCpf(cpf);
  163 +}
  164 +
  165 +
  166 +var submitForm = function(event) {
  167 + if ($cpfField.val()) {
  168 + $j(document).data('submit_form_after_ajax_validation', true);
  169 + validatesUniquenessOfCpf();
  170 + }
  171 +
  172 + else
  173 + formUtils.submit();
  174 +}
  175 +
  176 +// when page is ready
  177 +
  178 +$j(document).ready(function() {
  179 + $cpfField.focus();
  180 +
  181 + changeVisibilityOfLinksToPessoaPai();
  182 + changeVisibilityOfLinksToPessoaMae();
  183 +
  184 + // style fixup
  185 +
  186 + $j('#pais_origem_nome').css('width', '150px');
  187 +
  188 + // agrupado zebra por tipo documento, branco => .formlttd, colorido => .formmdtd
  189 +
  190 + $j('#tr_uf_emissao_certidao_civil td').removeClass('formmdtd');
  191 + $j('#tr_carteira_trabalho td').removeClass('formlttd').addClass('formmdtd');
  192 +
  193 +
  194 + // remove obrigatoriedade de determinados campos, ao criar pessoa pai ou mãe
  195 + // para agilizar o cadastro do filho;
  196 +
  197 + if ($j.inArray($j('#parent_type').val(), ['pai', 'mae']) > -1) {
  198 + var $elements = $j('#sexo, #estado_civil_id, #data_nasc, #cep_, #sigla_uf, #cidade, #bairro,\
  199 + #zona_localizacao, #idtlog, #logradouro').filter('[value=]');
  200 +
  201 + $elements.addClass('skip-presence-validation');
  202 +
  203 + // remove '*' obrigatório ao lado do label.
  204 + $elements.each(function(index, element) {
  205 + $j(element).closest('tr').find('.campo_obrigatorio').hide();
  206 + });
  207 + }
  208 +
  209 + // bind events
  210 +
  211 + checkTipoNacionalidade();
  212 + $j('#tipo_nacionalidade').change(checkTipoNacionalidade);
  213 +
  214 + checkTipoCertidaoCivil();
  215 + $j('#tipo_certidao_civil').change(checkTipoCertidaoCivil);
  216 +
  217 + $cpfField.focusout(function() {
  218 + $j(document).removeData('submit_form_after_ajax_validation');
  219 + validatesUniquenessOfCpf();
  220 + });
  221 +
  222 +
  223 + // ao clicar na lupa de pesquisa de cep, move página para cima,
  224 + // pois (exceto no ie), a popup de pesquisa é exibida no topo da página.
  225 + if (! $j.browser.msie) {
  226 + $j('#cep_').siblings('img').click(function(){
  227 + $j('body,html').animate({ scrollTop: $j('body').offset().top }, 'fast');
115 }); 228 });
  229 + }
  230 +
  231 + $submitButton.removeAttr('onclick');
  232 + $submitButton.click(submitForm);
  233 +
  234 +}); // ready
  235 +
  236 +
  237 +// pessoa links callbacks
  238 +
  239 +var changeVisibilityOfLinksToPessoaParent = function(parentType) {
  240 + var $nomeField = $j(buildId(parentType + '_nome'));
  241 + var $idField = $j(buildId(parentType + '_id'));
  242 + var $linkToEdit = $j('.pessoa-' + parentType + '-links .editar-pessoa-' + parentType);
  243 +
  244 + if($nomeField.val() && $idField.val()) {
  245 + $linkToEdit.attr('href', hrefToEditParent(parentType));
  246 + $linkToEdit.show().css('display', 'inline');
  247 + }
  248 + else {
  249 + $nomeField.val('')
  250 + $idField.val('');
  251 +
  252 + $linkToEdit.hide();
  253 + }
  254 +}
  255 +
  256 +var changeVisibilityOfLinksToPessoaPai = function() {
  257 + changeVisibilityOfLinksToPessoaParent('pai');
  258 +}
  259 +
  260 +var changeVisibilityOfLinksToPessoaMae = function() {
  261 + changeVisibilityOfLinksToPessoaParent('mae');
  262 +}
  263 +
  264 +
  265 +// children callbacks
  266 +
  267 +var afterSetSearchFields = function() {
  268 + $j('body,html').animate({ scrollTop: $j('#btn_enviar').offset().top }, 'fast');
  269 + $j('#complemento').focus();
  270 +};
  271 +
  272 +var afterUnsetSearchFields = function() {
  273 + $j('body,html').animate({ scrollTop: $j('#btn_enviar').offset().top }, 'fast');
  274 + $j('#cep_').focus();
  275 +};
  276 +
  277 +function afterChangePessoa(targetWindow, parentType, parentId, parentName) {
  278 + targetWindow.close();
  279 +
  280 + var $idField = $j(buildId(parentType + '_id'));
  281 + var $nomeField = $j(buildId(parentType + '_nome'));
  282 +
  283 + // timeout para usuario perceber mudança
  284 + window.setTimeout(function() {
  285 + messageUtils.success('Pessoa alterada com sucesso', $nomeField);
  286 +
  287 + $idField.val(parentId);
  288 + $nomeField.val(parentId + ' - ' +parentName);
  289 + $nomeField.focus();
  290 +
  291 + changeVisibilityOfLinksToPessoaParent(parentType);
  292 +
  293 + }, 500);
  294 +}
  295 +
  296 +
  297 +// simple search options
  298 +
  299 +var simpleSearchPaiOptions = {
  300 + autocompleteOptions : { close : changeVisibilityOfLinksToPessoaPai }
  301 +};
116 302
117 - $submitButton.removeAttr('onclick');  
118 - $submitButton.click(submitForm); 303 +var simpleSearchMaeOptions = {
  304 + autocompleteOptions : { close : changeVisibilityOfLinksToPessoaMae }
  305 +};
119 306
120 - }); // ready  
121 -})(jQuery);  
122 \ No newline at end of file 307 \ No newline at end of file
  308 +$paiNomeField.focusout(changeVisibilityOfLinksToPessoaPai);
  309 +$maeNomeField.focusout(changeVisibilityOfLinksToPessoaMae);
123 \ No newline at end of file 310 \ No newline at end of file
ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css
@@ -5,5 +5,14 @@ @@ -5,5 +5,14 @@
5 } 5 }
6 6
7 .pessoa-links a { 7 .pessoa-links a {
  8 + /*
  9 + obs: no firefox, ao mostrar o elemento (.show, jquery), é setado display como block,
  10 + para reparar isto, após chamar .show(), chamar .css('display', 'inline');
  11 + */
  12 +
8 margin-right: 5px; 13 margin-right: 5px;
  14 +}
  15 +
  16 +#deficiencias_chzn ul {
  17 + width: 307px;
9 } 18 }
10 \ No newline at end of file 19 \ No newline at end of file
ieducar/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css 0 → 100644
@@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
  1 +/* Por alguma razão, no chrome ao mudar o width dos elementos eles recuam 2px */
  2 +@media screen and (-webkit-min-device-pixel-ratio:0) {
  3 + select,
  4 + #data_emissao_certidao_civil,
  5 + #termo_certidao_civil,
  6 + #certidao_nascimento,
  7 + #carteira_trabalho,
  8 + #data_emissao_carteira_trabalho,
  9 + #titulo_eleitor,
  10 + #data_nasc,
  11 + #complemento {
  12 + margin-left: 2px;
  13 + }
  14 +}
  15 +
  16 +select {
  17 + width: 184px !important;
  18 +}
  19 +
  20 +#estado_civil_id {
  21 + width: 133px !important;
  22 +}
  23 +
  24 +#data_emissao_rg, #uf_emissao_rg {
  25 + width: 135px !important;
  26 +}
  27 +
  28 +#data_emissao_certidao_civil, #data_emissao_carteira_trabalho, #data_nasc {
  29 + width: 98px;
  30 +}
  31 +
  32 +#termo_certidao_civil {
  33 + width: 121px !important;
  34 +}
  35 +
  36 +#carteira_trabalho, #titulo_eleitor, #complemento {
  37 + width: 170px;
  38 +}
  39 +
  40 +#zona_localizacao {
  41 + width: 182px !important;
  42 +}
  43 +
  44 +.pessoa-links {
  45 + display: block;
  46 + padding: 5px;
  47 + margin: 2px;
  48 +}
  49 +
  50 +.pessoa-links a {
  51 + /*
  52 + obs: no firefox, ao mostrar o elemento (.show, jquery), é setado display como block,
  53 + para reparar isto, após chamar .show(), chamar .css('display', 'inline');
  54 + */
  55 +
  56 + margin-right: 5px;
  57 +}
0 \ No newline at end of file 58 \ No newline at end of file
ieducar/modules/Cadastro/Views/AlunoController.php
@@ -65,12 +65,12 @@ class AlunoController extends Portabilis_Controller_Page_EditController @@ -65,12 +65,12 @@ class AlunoController extends Portabilis_Controller_Page_EditController
65 ), 65 ),
66 66
67 'mae' => array( 67 'mae' => array(
68 - 'label' => 'M&atilde;e', 68 + 'label' => 'Mãe',
69 'help' => '', 69 'help' => '',
70 ), 70 ),
71 71
72 'responsavel' => array( 72 'responsavel' => array(
73 - 'label' => 'Respons&aacute;vel', 73 + 'label' => 'Responsável',
74 'help' => '', 74 'help' => '',
75 ), 75 ),
76 76
@@ -80,27 +80,27 @@ class AlunoController extends Portabilis_Controller_Page_EditController @@ -80,27 +80,27 @@ class AlunoController extends Portabilis_Controller_Page_EditController
80 ), 80 ),
81 81
82 'transporte' => array( 82 'transporte' => array(
83 - 'label' => 'Transporte p&uacute;blico', 83 + 'label' => 'Transporte público',
84 'help' => '', 84 'help' => '',
85 ), 85 ),
86 86
87 'id' => array( 87 'id' => array(
88 - 'label' => 'C&oacutedigo aluno', 88 + 'label' => 'Código aluno',
89 'help' => '', 89 'help' => '',
90 ), 90 ),
91 91
92 'aluno_inep_id' => array( 92 'aluno_inep_id' => array(
93 - 'label' => 'C&oacutedigo inep', 93 + 'label' => 'Código inep',
94 'help' => '', 94 'help' => '',
95 ), 95 ),
96 96
97 'aluno_estado_id' => array( 97 'aluno_estado_id' => array(
98 - 'label' => 'C&oacutedigo rede estadual', 98 + 'label' => 'Código rede estadual',
99 'help' => '', 99 'help' => '',
100 ), 100 ),
101 101
102 'deficiencias' => array( 102 'deficiencias' => array(
103 - 'label' => 'Defici&ecirc;ncias / habilidades especiais', 103 + 'label' => 'Deficiências / habilidades especiais',
104 'help' => '', 104 'help' => '',
105 ) 105 )
106 ); 106 );
@@ -125,19 +125,19 @@ class AlunoController extends Portabilis_Controller_Page_EditController @@ -125,19 +125,19 @@ class AlunoController extends Portabilis_Controller_Page_EditController
125 { 125 {
126 $this->url_cancelar = '/intranet/educar_aluno_lst.php'; 126 $this->url_cancelar = '/intranet/educar_aluno_lst.php';
127 127
128 - // código rede de ensino municipal 128 + // código aluno
129 $options = array('label' => $this->_getLabel('id'), 'disabled' => true, 129 $options = array('label' => $this->_getLabel('id'), 'disabled' => true,
130 'required' => false, 'size' => 25); 130 'required' => false, 'size' => 25);
131 - $this->inputsHelper()->text('id', $options); 131 + $this->inputsHelper()->integer('id', $options);
132 132
133 133
134 // código aluno inep 134 // código aluno inep
135 - $options = array('label' => $this->_getLabel('aluno_inep_id'), 'required' => false, 'size' => 25);  
136 - $this->inputsHelper()->text('aluno_inep_id', $options); 135 + $options = array('label' => $this->_getLabel('aluno_inep_id'), 'required' => false, 'size' => 25, 'max_length' => 14);
  136 + $this->inputsHelper()->integer('aluno_inep_id', $options);
137 137
138 // código aluno rede estadual 138 // código aluno rede estadual
139 - $options = array('label' => $this->_getLabel('aluno_estado_id'), 'required' => false, 'size' => 25);  
140 - $this->inputsHelper()->text('aluno_estado_id', $options); 139 + $options = array('label' => $this->_getLabel('aluno_estado_id'), 'required' => false, 'size' => 25, 'max_length' => 9);
  140 + $this->inputsHelper()->integer('aluno_estado_id', $options);
141 141
142 // nome 142 // nome
143 $options = array('label' => $this->_getLabel('pessoa'), 'size' => 68); 143 $options = array('label' => $this->_getLabel('pessoa'), 'size' => 68);
@@ -164,7 +164,10 @@ class AlunoController extends Portabilis_Controller_Page_EditController @@ -164,7 +164,10 @@ class AlunoController extends Portabilis_Controller_Page_EditController
164 // responsável 164 // responsável
165 165
166 // tipo 166 // tipo
167 - $tiposResponsavel = array(null => 'Selecione', 167 +
  168 + $label = Portabilis_String_Utils::toLatin1($this->_getLabel('responsavel'));
  169 +
  170 + $tiposResponsavel = array(null => $label,
168 'pai' => 'Pai', 171 'pai' => 'Pai',
169 'mae' => 'M&atilde;e', 172 'mae' => 'M&atilde;e',
170 'outra_pessoa' => 'Outra pessoa'); 173 'outra_pessoa' => 'Outra pessoa');
@@ -185,7 +188,10 @@ class AlunoController extends Portabilis_Controller_Page_EditController @@ -185,7 +188,10 @@ class AlunoController extends Portabilis_Controller_Page_EditController
185 188
186 189
187 // transporte publico 190 // transporte publico
188 - $tiposTransporte = array(null => 'Selecione', 191 +
  192 + $label = Portabilis_String_Utils::toLatin1($this->_getLabel('transporte'));
  193 +
  194 + $tiposTransporte = array(null => $label,
189 'nenhum' => 'N&atilde;o utiliza', 195 'nenhum' => 'N&atilde;o utiliza',
190 'municipal' => 'Municipal', 196 'municipal' => 'Municipal',
191 'estadual' => 'Estadual'); 197 'estadual' => 'Estadual');
ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js
@@ -28,9 +28,6 @@ var defaultSimpleSearchOptions = { @@ -28,9 +28,6 @@ var defaultSimpleSearchOptions = {
28 attrName : undefined, 28 attrName : undefined,
29 searchPath : undefined, 29 searchPath : undefined,
30 30
31 - // options that can be overwritten  
32 - placeholder : 'Informe um valor',  
33 -  
34 // additional search params to send to api 31 // additional search params to send to api
35 params : {}, 32 params : {},
36 33
@@ -124,8 +121,6 @@ var simpleSearch = { @@ -124,8 +121,6 @@ var simpleSearch = {
124 $input.data('simple-search-options', options); 121 $input.data('simple-search-options', options);
125 $input.data('hidden-input-id', $hiddenInput); 122 $input.data('hidden-input-id', $hiddenInput);
126 123
127 - $input.attr('placeholder', options.get('placeholder'));  
128 -  
129 $hiddenInput.addClass('simple-search-id'); 124 $hiddenInput.addClass('simple-search-id');
130 $hiddenInput.attr('data-for', $input.attr('id')); 125 $hiddenInput.attr('data-for', $input.attr('id'));
131 126
ieducar/modules/Portabilis/Assets/Javascripts/Utils.js
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 // jquery utils 2 // jquery utils
3 3
4 function buildId(id) { 4 function buildId(id) {
5 - return typeof(id) == 'string' && id.length > 0 && id[0] != '#' ? '#' + id : id; 5 + return typeof(id) == 'string' && id.length > 0 && id.charAt(0) != '#' ? '#' + id : id;
6 } 6 }
7 7
8 8
@@ -216,67 +216,57 @@ var messageUtils = { @@ -216,67 +216,57 @@ var messageUtils = {
216 216
217 notice : function(msg, targetId) { 217 notice : function(msg, targetId) {
218 handleMessages([{type : 'notice', msg : safeUtf8Decode(msg)}], targetId); 218 handleMessages([{type : 'notice', msg : safeUtf8Decode(msg)}], targetId);
219 - }  
220 -}; 219 + },
221 220
222 -function handleMessages(messages, targetId, useDelayClassRemoval) {  
223 -  
224 - var $feedbackMessages = $j('#feedback-messages');  
225 - var hasErrorMessages = false;  
226 - var hasSuccessMessages = false;  
227 - var hasNoticeMessages = false;  
228 - var delayClassRemoval = 20000;  
229 -  
230 - var $targetElement = buildId(targetId);  
231 - var $targetElement = $j($targetElement);  
232 -  
233 - for (var i = 0; i < messages.length; i++) {  
234 - if (messages[i].type == 'success')  
235 - var delay = 5000;  
236 - else if (messages[i].type != 'error')  
237 - var delay = 10000;  
238 - else  
239 - var delay = 20000;  
240 -  
241 - $j('<p />').hide()  
242 - .addClass(messages[i].type)  
243 - .html(safeUtf8Decode(messages[i].msg))  
244 - .appendTo($feedbackMessages)  
245 - .fadeIn()  
246 - .delay(delay)  
247 - .fadeOut(function() { $j(this).remove() })  
248 - .data('target_id', targetId);  
249 -  
250 - if (! hasErrorMessages && messages[i].type == 'error')  
251 - hasErrorMessages = true;  
252 - else if(! hasSuccessMessages && messages[i].type == 'success')  
253 - hasSuccessMessages = true;  
254 - else if(! hasNoticeMessages && messages[i].type == 'notice')  
255 - hasNoticeMessages = true;  
256 - } 221 + removeStyle : function(targetElementOrId, delay) {
  222 + // 30 seconds, by default
  223 + if (delay == undefined)
  224 + delay = 30000;
257 225
258 - if($targetElement) {  
259 - if (hasErrorMessages) {  
260 - $targetElement.addClass('error').removeClass('success').removeClass('notice');  
261 - $targetElement.first().focus();  
262 - } 226 + var $targetElement = $j(buildId(targetElementOrId));
263 227
264 - else if (hasSuccessMessages)  
265 - $targetElement.addClass('success').removeClass('error').removeClass('notice'); 228 + window.setTimeout(function() {
  229 + $targetElement.removeClass('success').removeClass('error').removeClass('notice');
  230 + }, delay);
  231 +
  232 + },
266 233
267 - else if (hasNoticeMessages)  
268 - $targetElement.addClass('notice').removeClass('error').removeClass('sucess'); 234 + handleMessages : function(messages, targetElementOrId) {
269 235
270 - else  
271 - $targetElement.removeClass('success').removeClass('error').removeClass('notice'); 236 + var $feedbackMessages = $j('#feedback-messages');
  237 + var $targetElement = $j(buildId(targetElementOrId));
  238 + var messagesType = [];
272 239
273 - if (useDelayClassRemoval) {  
274 - window.setTimeout(function() {  
275 - $targetElement.removeClass('success').removeClass('error').removeClass('notice');  
276 - }, delayClassRemoval); 240 + for (var i = 0; i < messages.length; i++) {
  241 + var delay = messages[i].type == 'success' ? 5000 : 10000;
  242 +
  243 + $j('<p />').hide()
  244 + .data('target_id', $targetElement.attr('id'))
  245 + .addClass(messages[i].type)
  246 + .html(stringUtils.toUtf8(messages[i].msg))
  247 + .appendTo($feedbackMessages)
  248 + .fadeIn().delay(delay).fadeOut(function() {
  249 + $j(this).remove()
  250 + });
  251 +
  252 + if (messagesType.indexOf(messages[i].type < 0))
  253 + messagesType.push(messages[i].type);
  254 + }
  255 +
  256 + if ($targetElement) {
  257 + $targetElement.removeClass('error').removeClass('success').removeClass('notice');
  258 +
  259 + $targetElement.addClass(messagesType.join(' '));
  260 + messageUtils.removeStyle($targetElement);
  261 +
  262 + if (messagesType.indexOf('error') > -1)
  263 + $targetElement.first().focus();
277 } 264 }
278 } 265 }
279 -} 266 +};
  267 +
  268 +// backward compatibility
  269 +var handleMessages = messageUtils.handleMessages;
280 270
281 271
282 // when page is ready 272 // when page is ready
ieducar/modules/Portabilis/Assets/Javascripts/Validator.js
@@ -11,11 +11,14 @@ var validationUtils = { @@ -11,11 +11,14 @@ var validationUtils = {
11 var fields = $j("input[id^='data_'][value!=''], input[id^='dt_'][value!='']"); 11 var fields = $j("input[id^='data_'][value!=''], input[id^='dt_'][value!='']");
12 12
13 $j.each(fields, function(index, field) { 13 $j.each(fields, function(index, field) {
14 - allValid = validationUtils.validatesDate(field.value);  
15 - }); 14 + if (! validationUtils.validatesDate(field.value)) {
  15 + messageUtils.error('Informe a data corretamente.', field);
  16 + allValid = false;
16 17
17 - if (! allValid)  
18 - messageUtils.error('Informe a data corretamente.', fields.first()); 18 + // break jquery loop
  19 + return false;
  20 + }
  21 + });
19 22
20 return allValid; 23 return allValid;
21 }, 24 },
@@ -69,7 +72,7 @@ var validationUtils = { @@ -69,7 +72,7 @@ var validationUtils = {
69 72
70 function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields) { 73 function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields) {
71 var $emptyFields = []; 74 var $emptyFields = [];
72 - requiredFields = document.getElementsByClassName('obrigatorio'); 75 + requiredFields = $j('.obrigatorio:not(.skip-presence-validation)');
73 76
74 if (additionalFields) 77 if (additionalFields)
75 requiredFields = $j.merge(requiredFields, additionalFields); 78 requiredFields = $j.merge(requiredFields, additionalFields);
@@ -78,7 +81,7 @@ function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields @@ -78,7 +81,7 @@ function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields
78 simpleSearch.fixupRequiredFieldsValidation(); 81 simpleSearch.fixupRequiredFieldsValidation();
79 82
80 for (var i = 0; i < requiredFields.length; i++) { 83 for (var i = 0; i < requiredFields.length; i++) {
81 - var $requiredField = $j(requiredFields[i]); 84 + var $requiredField = $j(requiredFields[i]);
82 85
83 if ($requiredField.length > 0 && 86 if ($requiredField.length > 0 &&
84 /*$requiredField.css('display') != 'none' &&*/ 87 /*$requiredField.css('display') != 'none' &&*/
@@ -91,6 +94,8 @@ function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields @@ -91,6 +94,8 @@ function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields
91 94
92 if (! $requiredField.hasClass('error')) 95 if (! $requiredField.hasClass('error'))
93 $requiredField.addClass('error'); 96 $requiredField.addClass('error');
  97 +
  98 + messageUtils.removeStyle($requiredField);
94 } 99 }
95 else if ($requiredField.length > 0) 100 else if ($requiredField.length > 0)
96 $requiredField.removeClass('error'); 101 $requiredField.removeClass('error');
ieducar/modules/Portabilis/Assets/Version.php
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 usado pelo metodos loadJavascript e loadStylesheet do helper Portabilis_View_Helper_Application */ 4 usado pelo metodos loadJavascript e loadStylesheet do helper Portabilis_View_Helper_Application */
5 5
6 class Portabilis_Assets_Version { 6 class Portabilis_Assets_Version {
7 - const VERSION = "0_0_0_1004"; 7 + const VERSION = "0_0_0_1005";
8 } 8 }
9 9
10 ?> 10 ?>