From e3e0b786e9ee6795b8e728d72439278d562ade7c Mon Sep 17 00:00:00 2001 From: Lucas D'Avila Date: Fri, 15 Feb 2013 20:52:35 -0200 Subject: [PATCH] Facilitado preenchimento dos documentos, ao cadastrar nova pessoa fisica closes #6 --- ieducar/intranet/atendidos_cad.php | 823 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/educar_escola_cad.php | 2 +- ieducar/intranet/include/pessoa/clsDocumento.inc.php | 8 +------- ieducar/intranet/include/pessoa/clsFisica.inc.php | 28 ++++++++++++++++++++-------- ieducar/intranet/scripts/padrao.js | 6 ++++++ ieducar/lib/Portabilis/Array/Utils.php | 28 ++++++++++++++++++++++++++-- ieducar/lib/Portabilis/Date/Utils.php | 25 +++++++++++++++++++------ ieducar/lib/Portabilis/String/Utils.php | 23 ++++++++++++++++++++++- ieducar/lib/Portabilis/View/Helper/Input/Core.php | 23 +++++++++++++++++++++++ ieducar/lib/Portabilis/View/Helper/Input/Date.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/lib/Portabilis/View/Helper/Input/Integer.php | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/lib/Portabilis/View/Helper/Input/Numeric.php | 19 ++++++++++++++++++- ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php | 2 +- ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php | 2 +- ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php | 2 +- ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php | 10 ++-------- ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php | 10 ++-------- ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php | 10 ++-------- ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php | 10 ++-------- ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php | 10 ++-------- ieducar/lib/Portabilis/View/Helper/Input/Resource/TipoLogradouro.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/lib/Portabilis/View/Helper/Input/Resource/Uf.php | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/lib/Portabilis/View/Helper/Input/Select.php | 4 +++- ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php | 7 ++++++- ieducar/lib/Portabilis/View/Helper/Input/Text.php | 6 ++++-- ieducar/lib/Portabilis/View/Helper/Input/TextArea.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/lib/Portabilis/View/Helper/Inputs.php | 42 ++++++++++++++++++++++++++---------------- ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js | 8 ++++---- ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js | 2 +- ieducar/modules/Cadastro/Assets/Javascripts/Escola.js | 3 ++- ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js | 353 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------- ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css | 9 +++++++++ ieducar/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/modules/Cadastro/Views/AlunoController.php | 36 +++++++++++++++++++++--------------- ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js | 5 ----- ieducar/modules/Portabilis/Assets/Javascripts/Utils.js | 98 ++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------ ieducar/modules/Portabilis/Assets/Javascripts/Validator.js | 17 +++++++++++------ ieducar/modules/Portabilis/Assets/Version.php | 2 +- 38 files changed, 1622 insertions(+), 410 deletions(-) create mode 100644 ieducar/lib/Portabilis/View/Helper/Input/Date.php create mode 100644 ieducar/lib/Portabilis/View/Helper/Input/Integer.php create mode 100644 ieducar/lib/Portabilis/View/Helper/Input/Resource/TipoLogradouro.php create mode 100644 ieducar/lib/Portabilis/View/Helper/Input/Resource/Uf.php create mode 100644 ieducar/lib/Portabilis/View/Helper/Input/TextArea.php create mode 100644 ieducar/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css diff --git a/ieducar/intranet/atendidos_cad.php b/ieducar/intranet/atendidos_cad.php index 5048ff8..e3fd977 100755 --- a/ieducar/intranet/atendidos_cad.php +++ b/ieducar/intranet/atendidos_cad.php @@ -1,5 +1,8 @@ bairro, $this->logradouro, $this->cep, $this->idlog, $this->idbai, $this->idtlog, $this->sigla_uf, $this->complemento, $this->numero, $this->bloco, $this->apartamento, $this->andar, $this->zona_localizacao, $this->estado_civil, - $this->pai_id, $this->mae_id, $this->tipo_nacionalidade, $this->pais_origem, $this->naturalidade + $this->pai_id, $this->mae_id, $this->tipo_nacionalidade, $this->pais_origem, $this->naturalidade, + $this->letra ) = $objPessoa->queryRapida( @@ -134,7 +139,7 @@ class indice extends clsCadastro 'url', 'tipo', 'sexo', 'cidade', 'bairro', 'logradouro', 'cep', 'idlog', 'idbai', 'idtlog', 'sigla_uf', 'complemento', 'numero', 'bloco', 'apartamento', 'andar', 'zona_localizacao', 'ideciv', 'idpes_pai', 'idpes_mae', 'nacionalidade', - 'idpais_estrangeiro', 'idmun_nascimento' + 'idpais_estrangeiro', 'idmun_nascimento', 'letra' ); $this->id_federal = is_numeric($this->id_federal) ? int2CPF($this->id_federal) : ''; @@ -160,39 +165,353 @@ class indice extends clsCadastro $this->url_cancelar = $this->retorno == 'Editar' ? 'atendidos_det.php?cod_pessoa=' . $this->cod_pessoa_fj : 'atendidos_lst.php'; + $this->campoCpf('id_federal', 'CPF', $this->id_federal, FALSE); + $this->campoOculto('cod_pessoa_fj', $this->cod_pessoa_fj); $this->campoTexto('nm_pessoa', 'Nome', $this->nm_pessoa, '50', '255', TRUE); - $this->campoCpf('id_federal', 'CPF', $this->id_federal, FALSE); + // sexo + + $options = array( + 'label' => 'Sexo / Estado civil', + 'value' => $this->sexo, + 'resources' => array( + '' => 'Sexo', + 'M' => 'Masculino', + 'F' => 'Feminino' + ), + 'inline' => true + ); + + $this->inputsHelper()->select('sexo', $options); - $this->campoData('data_nasc', 'Data de Nascimento', $this->data_nasc); + // estado civil - $lista_sexos = array(); - $lista_sexos[''] = 'Escolha uma opção...'; - $lista_sexos['M'] = 'Masculino'; - $lista_sexos['F'] = 'Feminino'; - $this->campoLista('sexo', 'Sexo', $lista_sexos, $this->sexo); + $this->inputsHelper()->estadoCivil(array('label' => '')); + + + // data nascimento + + $options = array( + 'label' => 'Data nascimento', + 'value' => $this->data_nasc + ); + + $this->inputsHelper()->date('data_nasc', $options); - $this->inputsHelper()->estadoCivil(array('required' => false)); // pai, mãe - $this->addPaiInput(); - $this->addMaeInput(); + $this->inputPai(); + $this->inputMae(); + + + // documentos + + $documentos = new clsDocumento(); + $documentos->idpes = $this->cod_pessoa_fj; + $documentos = $documentos->detalhe(); + + // rg + + $options = array( + 'required' => false, + 'label' => 'RG / Data emissão', + 'placeholder' => 'Documento identidade', + 'value' => $documentos['rg'], + 'max_length' => 20, + 'size' => 27, + 'inline' => true + ); + + $this->inputsHelper()->integer('rg', $options); + + + // data emissão rg + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Data emissão', + 'value' => $documentos['data_exp_rg'], + 'size' => 19 + ); + + $this->inputsHelper()->date('data_emissao_rg', $options); + + + // orgão emissão rg + + $selectOptions = array( null => 'Orgão emissor' ); + $orgaos = new clsOrgaoEmissorRg(); + $orgaos = $orgaos->lista(); + + foreach ($orgaos as $orgao) + $selectOptions[$orgao['idorg_rg']] = $orgao['sigla']; + + $selectOptions = Portabilis_Array_Utils::sortByValue($selectOptions); + + $options = array( + 'required' => false, + 'label' => '', + 'value' => $documentos['idorg_exp_rg'], + 'resources' => $selectOptions, + 'inline' => true + ); + + $this->inputsHelper()->select('orgao_emissao_rg', $options); + + + // uf emissão rg + + $options = array( + 'required' => false, + 'label' => '', + 'value' => $documentos['sigla_uf_exp_rg'] + ); + + $helperOptions = array( + 'attrName' => 'uf_emissao_rg' + ); + + $this->inputsHelper()->uf($options, $helperOptions); + + + // tipo de certidao civil + + $selectOptions = array( + null => 'Tipo certidão civil', + 'certidao_nascimento_novo_formato' => 'Nascimento (novo formato)', + 91 => 'Nascimento (antigo formato)', + 92 => 'Casamento' + ); + + + // caso certidao nascimento novo formato tenha sido informado, + // considera este o tipo da certidão + if (! empty($documentos['certidao_nascimento'])) + $tipoCertidaoCivil = 'certidao_nascimento_novo_formato'; + else + $tipoCertidaoCivil = $documentos['tipo_cert_civil']; + + $options = array( + 'required' => false, + 'label' => 'Tipo certidão civil', + 'value' => $tipoCertidaoCivil, + 'resources' => $selectOptions, + 'inline' => true + ); + + $this->inputsHelper()->select('tipo_certidao_civil', $options); + + + // termo certidao civil + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Termo', + 'value' => $documentos['num_termo'], + 'max_length' => 8, + 'inline' => true + ); + + $this->inputsHelper()->integer('termo_certidao_civil', $options); + + + // livro certidao civil + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Livro', + 'value' => $documentos['num_livro'], + 'max_length' => 8, + 'size' => 15, + 'inline' => true + ); + + $this->inputsHelper()->text('livro_certidao_civil', $options); + + + // folha certidao civil + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Folha', + 'value' => $documentos['num_folha'], + 'max_length' => 4, + 'inline' => true + ); + + $this->inputsHelper()->integer('folha_certidao_civil', $options); + + + // certidao nascimento (novo padrão) + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Certidão nascimento', + 'value' => $documentos['certidao_nascimento'], + 'max_length' => 50, + 'size' => 50 + ); + + $this->inputsHelper()->text('certidao_nascimento', $options); + + + // uf emissão certidão civil + + $options = array( + 'required' => false, + 'label' => 'Estado emissão / Data emissão', + 'value' => $documentos['sigla_uf_cert_civil'], + 'inline' => true + ); + + $helperOptions = array( + 'attrName' => 'uf_emissao_certidao_civil' + ); + + $this->inputsHelper()->uf($options, $helperOptions); + + + // data emissão certidão civil + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Data emissão', + 'value' => $documentos['data_emissao_cert_civil'] + ); + + $this->inputsHelper()->date('data_emissao_certidao_civil', $options); + + + // cartório emissão certidão civil + + $options = array( + 'required' => false, + 'label' => 'Cartório emissão', + 'value' => $documentos['cartorio_cert_civil'], + 'cols' => 45, + 'max_length' => 150 + ); + + $this->inputsHelper()->textArea('cartorio_emissao_certidao_civil', $options); + + + // carteira de trabalho + + $options = array( + 'required' => false, + 'label' => 'Carteira de trabalho / Série', + 'placeholder' => 'Carteira de trabalho', + 'value' => $documentos['num_cart_trabalho'], + 'max_length' => 7, + 'inline' => true + + ); + + $this->inputsHelper()->integer('carteira_trabalho', $options); + + // serie carteira de trabalho + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Série', + 'value' => $documentos['serie_cart_trabalho'], + 'max_length' => 5 + ); + + $this->inputsHelper()->integer('serie_carteira_trabalho', $options); + + + // uf emissão carteira de trabalho + + $options = array( + 'required' => false, + 'label' => 'Estado emissão / Data emissão', + 'value' => $documentos['sigla_uf_cart_trabalho'], + 'inline' => true + ); + + $helperOptions = array( + 'attrName' => 'uf_emissao_carteira_trabalho' + ); + + $this->inputsHelper()->uf($options, $helperOptions); + + + // data emissão carteira de trabalho + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Data emissão', + 'value' => $documentos['data_emissao_cart_trabalho'] + ); + + $this->inputsHelper()->date('data_emissao_carteira_trabalho', $options); + + + // titulo eleitor + + $options = array( + 'required' => false, + 'label' => 'Titulo eleitor / Zona / Seção', + 'placeholder' => 'Titulo eleitor', + 'value' => $documentos['num_tit_eleitor'], + 'max_length' => 13, + 'inline' => true + ); + + $this->inputsHelper()->integer('titulo_eleitor', $options); + + + // zona titulo eleitor + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Zona', + 'value' => $documentos['zona_tit_eleitor'], + 'max_length' => 4, + 'inline' => true + ); + + $this->inputsHelper()->integer('zona_titulo_eleitor', $options); + + + // seção titulo eleitor + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Seção', + 'value' => $documentos['secao_tit_eleitor'], + 'max_length' => 4 + ); + + $this->inputsHelper()->integer('secao_titulo_eleitor', $options); + // Cor/raça. - $opcoes_raca = array('' => 'Selecione'); - $obj_raca = new clsCadastroRaca(); - $lst_raca = $obj_raca->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE); - if ($lst_raca) { - foreach ($lst_raca as $raca) { - $opcoes_raca[$raca['cod_raca']] = $raca['nm_raca']; - } - } + $racas = new clsCadastroRaca(); + $racas = $racas->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, TRUE); + $selectOptions = array('' => 'Raça'); + + foreach ($racas as $raca) + $selectOptions[$raca['cod_raca']] = $raca['nm_raca']; + + $selectOptions = Portabilis_Array_Utils::sortByValue($selectOptions); + + $this->campoLista('cor_raca', 'Raça', $selectOptions, $this->cod_raca, '', FALSE, '', '', '', FALSE); - $this->campoLista('cor_raca', 'Raça', $opcoes_raca, - $this->cod_raca, '', FALSE, '', '', '', FALSE); // nacionalidade @@ -202,19 +521,31 @@ class indice extends clsCadastro '2' => 'Naturalizado brasileiro', '3' => 'Estrangeiro'); - $options = array('label' => 'Nacionalidade', - 'resources' => $tiposNacionalidade, - 'required' => false, - 'inline' => true, - 'value' => $this->tipo_nacionalidade); + $options = array('label' => 'Nacionalidade', + 'resources' => $tiposNacionalidade, + 'required' => false, + 'inline' => true, + 'value' => $this->tipo_nacionalidade); $this->inputsHelper()->select('tipo_nacionalidade', $options); + // pais origem - $options = array('label' => '', 'required' => true); - $helperOptions = array('objectName' => 'pais_origem', - 'hiddenInputOptions' => array('options' => array('value' => $this->pais_origem_id))); + $options = array( + 'label' => '', + 'placeholder' => 'Informe o nome do pais', + 'required' => true + ); + + $hiddenInputOptions = array( + 'options' => array('value' => $this->pais_origem_id) + ); + + $helperOptions = array( + 'objectName' => 'pais_origem', + 'hiddenInputOptions' => $hiddenInputOptions + ); $this->inputsHelper()->simpleSearchPais('nome', $options, $helperOptions); @@ -222,6 +553,7 @@ class indice extends clsCadastro // naturalidade $options = array('label' => 'Naturalidade', 'required' => false); + $helperOptions = array('objectName' => 'naturalidade', 'hiddenInputOptions' => array('options' => array('value' => $this->naturalidade_id))); @@ -230,26 +562,6 @@ class indice extends clsCadastro // Detalhes do Endereço - $objTipoLog = new clsTipoLogradouro(); - $listaTipoLog = $objTipoLog->lista(); - $listaTLog = array('0' => 'Selecione'); - - if ($listaTipoLog) { - foreach ($listaTipoLog as $tipoLog) { - $listaTLog[$tipoLog['idtlog']] = $tipoLog['descricao']; - } - } - - $objUf = new clsUf(); - $listauf = $objUf->lista(); - $listaEstado = array('0' => 'Selecione'); - - if ($listauf) { - foreach ($listauf as $uf) { - $listaEstado[$uf['sigla_uf']] = $uf['sigla_uf']; - } - } - $this->campoOculto('idbai', $this->idbai); $this->campoOculto('idlog', $this->idlog); $this->campoOculto('cep', $this->cep); @@ -257,153 +569,227 @@ class indice extends clsCadastro $this->campoOculto('ref_idtlog', $this->idtlog); $this->campoOculto('id_cidade', $this->cidade); - $zona = App_Model_ZonaLocalizacao::getInstance(); - if ($this->idlog && $this->idbai && $this->cep && $this->cod_pessoa_fj) { - $this->campoCep('cep_', 'CEP', $this->cep, true, '-', - " ');\">", - TRUE); + // considera como endereço localizado por CEP quando alguma das variaveis de instancia + // idbai (bairro) ou idlog (logradouro) estão definidas, neste caso desabilita a edição + // dos campos definidos via CEP. + $desativarCamposDefinidosViaCep = ($this->idbai || $this->idlog); - $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog, - FALSE, FALSE, FALSE, FALSE, TRUE); + $this->campoCep( + 'cep_', + 'CEP', + $this->cep, + TRUE, + '-', + " ');\">", + $desativarCamposDefinidosViaCep + ); - $this->campoTextoInv('logradouro', 'Logradouro', $this->logradouro, - '50', '255', FALSE); - $this->campoTextoInv('cidade', 'Cidade', $this->cidade, '50', '255', - FALSE); + // estado - $this->campoTextoInv('bairro', 'Bairro', $this->bairro, '50', '255', FALSE); + $options = array( + 'label' => 'Estado / Cidade', + 'value' => $this->sigla_uf, + 'disabled' => $desativarCamposDefinidosViaCep, + 'inline' => true + ); - $this->campoTexto('complemento', 'Complemento', $this->complemento, '50', '255', - FALSE); + $helperOptions = array( + 'attrName' => 'sigla_uf' + ); - $this->campoTexto('numero', 'Número', $this->numero, '10', '10'); + $this->inputsHelper()->uf($options, $helperOptions); - $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE); - $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento, '6', '6', - FALSE); + // cidade - $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE); - $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE); + $options = array( + 'label' => '', + 'placeholder' => 'Cidade', + 'value' => $this->cidade, + 'max_length' => 60, + 'disabled' => $desativarCamposDefinidosViaCep + ); - $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf, - FALSE, FALSE, FALSE, FALSE, TRUE); - } - elseif($this->cod_pessoa_fj && $this->cep) { - $this->campoCep('cep_', 'CEP', $this->cep, true, '-', - " ');\">", - $disabled); + $this->inputsHelper()->text('cidade', $options); + + + // bairro - $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog); + $options = array( + 'label' => 'Bairro / Zona localização', + 'placeholder' => 'Bairro', + 'value' => $this->bairro, + 'max_length' => 40, + 'disabled' => $desativarCamposDefinidosViaCep, + 'inline' => true + ); - $this->campoTexto('logradouro', 'Logradouro', $this->logradouro, '50', - '255', FALSE); + $this->inputsHelper()->text('bairro', $options); - $this->campoTexto('cidade', 'Cidade', $this->cidade, '50', '255', FALSE); - $this->campoTexto('bairro', 'Bairro', $this->bairro, '50', '255', FALSE); + // zona localização - $this->campoTexto('complemento', 'Complemento', $this->complemento, '50', - '255', FALSE); + $zonas = App_Model_ZonaLocalizacao::getInstance(); + $zonas = $zonas->getEnums(); + $zonas = Portabilis_Array_Utils::insertIn(null, 'Zona localização', $zonas); - $this->campoTexto('numero', 'Número', $this->numero, '10', '10'); + $options = array( + 'label' => '', + 'placeholder' => 'Zona localização', + 'value' => $this->zona_localizacao, + 'disabled' => $desativarCamposDefinidosViaCep, + 'resources' => $zonas + ); - $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE); + $this->inputsHelper()->select('zona_localizacao', $options); - $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento, - '6', '6', FALSE); - $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE); + // tipo logradouro - $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE); + $options = array( + 'label' => 'Tipo / Logradouro', + 'value' => $this->idtlog, + 'disabled' => $desativarCamposDefinidosViaCep, + 'inline' => true + ); - $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf); - } - else { - $this->campoCep('cep_', 'CEP', $this->cep, TRUE, '-', - " ');\">", - false - ); + $helperOptions = array( + 'attrName' => 'idtlog' + ); - $this->campoLista('idtlog', 'Tipo Logradouro', $listaTLog, $this->idtlog, - FALSE, FALSE, FALSE, FALSE, FALSE); + $this->inputsHelper()->tipoLogradouro($options, $helperOptions); - $this->campoTexto('logradouro', 'Logradouro', $this->logradouro, - '50', '255'); - $this->campoTexto('cidade', 'Cidade', $this->cidade, '50', '255'); + // logradouro - $this->campoTexto('bairro', 'Bairro', $this->bairro, '50', '255'); + $options = array( + 'label' => '', + 'placeholder' => 'Logradouro', + 'value' => $this->logradouro, + 'max_length' => 150, + 'disabled' => $desativarCamposDefinidosViaCep + ); - $this->campoTexto('complemento', 'Complemento', $this->complemento, - '50', '255', FALSE); + $this->inputsHelper()->text('logradouro', $options); - $this->campoTexto('numero', 'Número', $this->numero, '10', '10'); - $this->campoTexto('letra', 'Letra', $this->letra, '1', '1', FALSE); + // complemento - $this->campoTexto('apartamento', 'Número Apartamento', $this->apartamento, - '6', '6', FALSE); + $options = array( + 'required' => false, + 'value' => $this->complemento, + 'max_length' => 20 + ); - $this->campoTexto('bloco', 'Bloco', $this->bloco, '20', '20', FALSE); + $this->inputsHelper()->text('complemento', $options); - $this->campoTexto('andar', 'Andar', $this->andar, '2', '2', FALSE); - $this->campoLista('sigla_uf', 'Estado', $listaEstado, $this->sigla_uf, - FALSE, FALSE, FALSE, FALSE, FALSE); - } + // numero + + $options = array( + 'required' => false, + 'label' => 'Número / Letra', + 'placeholder' => 'Número', + 'value' => $this->numero, + 'max_length' => 6, + 'inline' => true + ); + + $this->inputsHelper()->integer('numero', $options); + + + // letra - $this->campoLista('zona_localizacao', 'Zona Localização', $zona->getEnums(), - $this->zona_localizacao, FALSE, FALSE, FALSE, FALSE, - ($this->idbai ? TRUE : FALSE) + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Letra', + 'value' => $this->letra, + 'max_length' => 1, + 'size' => 15 ); - $this->campoTexto('ddd_telefone_1', 'DDD Telefone 1', $this->ddd_telefone_1, - '3', '2', FALSE); + $this->inputsHelper()->text('letra', $options); - $this->campoTexto('telefone_1', 'Telefone 1', $this->telefone_1, '10', - '15', FALSE); - $this->campoTexto('ddd_telefone_2', 'DDD Telefone 2', $this->ddd_telefone_2, - '3', '2', FALSE); + // apartamento - $this->campoTexto('telefone_2', 'Telefone 2', $this->telefone_2, '10', - '15', FALSE); + $options = array( + 'required' => false, + 'label' => 'Nº apartamento / Bloco / Andar', + 'placeholder' => 'Nº apartamento', + 'value' => $this->apartamento, + 'max_length' => 6, + 'inline' => true + ); + + $this->inputsHelper()->integer('apartamento', $options); + + + // bloco - $this->campoTexto('ddd_telefone_mov', 'DDD Celular', - $this->ddd_telefone_mov, '3', '2', FALSE); + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Bloco', + 'value' => $this->bloco, + 'max_length' => 20, + 'size' => 15, + 'inline' => true + ); + + $this->inputsHelper()->text('bloco', $options); - $this->campoTexto('telefone_mov', 'Celular', $this->telefone_mov, '10', - '15', FALSE); - $this->campoTexto('ddd_telefone_fax', 'DDD Fax', $this->ddd_telefone_fax, - '3', '2', FALSE); + // andar + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => 'Andar', + 'value' => $this->andar, + 'max_length' => 2 + ); - $this->campoTexto('telefone_fax', 'Fax', $this->telefone_fax, '10', '15', - FALSE); + $this->inputsHelper()->integer('andar', $options); + + + // contato + + $this->inputTelefone('1', 'Telefone residencial'); + $this->inputTelefone('mov', 'Celular'); + $this->inputTelefone('2', 'Telefone adicional'); + $this->inputTelefone('fax', 'Fax'); $this->campoTexto('http', 'Site', $this->http, '50', '255', FALSE); $this->campoTexto('email', 'E-mail', $this->email, '50', '255', FALSE); - if ($this->cod_pessoa_fj) { + /*if ($this->cod_pessoa_fj) { $this->campoRotulo('documentos', 'Documentos', "cod_pessoa_fj}'); \">"); $this->campoCheck('alterado', 'Alterado', $this->alterado); - } + }*/ + + + // after change pessoa pai / mae + + if (isset($_REQUEST['parent_type'])) + $this->inputsHelper()->hidden('parent_type', array('value' => $_REQUEST['parent_type'])); + $styles = array( '/modules/Portabilis/Assets/Stylesheets/Frontend.css', - '/modules/Portabilis/Assets/Stylesheets/Frontend/Resource.css' + '/modules/Portabilis/Assets/Stylesheets/Frontend/Resource.css', + '/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css' ); Portabilis_View_Helper_Application::loadStylesheet($this, $styles); - $script = "/modules/Cadastro/Assets/Javascripts/PessoaFisica.js"; + $script = '/modules/Cadastro/Assets/Javascripts/PessoaFisica.js'; Portabilis_View_Helper_Application::loadJavascript($this, $script); } @@ -425,7 +811,7 @@ class indice extends clsCadastro $fisica = new clsFisica(); $fisica->idpes = $idpes; - $fisica->data_nasc = dataToBanco($this->data_nasc); + $fisica->data_nasc = Portabilis_Date_Utils::brToPgSQL($this->data_nasc); $fisica->sexo = $this->sexo; $fisica->ref_cod_sistema = 'NULL'; $fisica->cpf = idFederal2int($this->id_federal); @@ -438,6 +824,8 @@ class indice extends clsCadastro $fisica->cadastra(); + $this->createOrUpdateDocumentos($idpes); + $objTelefone = new clsPessoaTelefone($idpes, 1, $this->telefone_1, $this->ddd_telefone_1); $objTelefone->cadastra(); @@ -507,20 +895,21 @@ class indice extends clsCadastro $fisica = new clsFisica(); $fisica->idpes = $this->cod_pessoa_fj; - $fisica->data_nasc = dataToBanco($this->data_nasc); + $fisica->data_nasc = Portabilis_Date_Utils::brToPgSQL($this->data_nasc); $fisica->sexo = $this->sexo; $fisica->ref_cod_sistema = 'NULL'; $fisica->cpf = $this->id_federal ? idFederal2int($this->id_federal) : 'NULL'; $fisica->ideciv = $this->estado_civil_id; - - $fisica->idpes_pai = $this->pai_id; - $fisica->idpes_mae = $this->mae_id; + $fisica->idpes_pai = $this->pai_id ? $this->pai_id : "NULL"; + $fisica->idpes_mae = $this->mae_id ? $this->mae_id : "NULL"; $fisica->nacionalidade = $_REQUEST['tipo_nacionalidade']; $fisica->idpais_estrangeiro = $_REQUEST['pais_origem_id']; $fisica->idmun_nascimento = $_REQUEST['naturalidade_id']; $fisica->edita(); + $this->createOrUpdateDocumentos($this->cod_pessoa_fj); + if ($this->alterado) { $db = new clsBanco(); $db->Consulta("UPDATE cadastro.fisica SET alterado = 'TRUE' WHERE idpes = '$this->cod_pessoa_fj'"); @@ -593,11 +982,19 @@ class indice extends clsCadastro function afterChangePessoa($id) { Portabilis_View_Helper_Application::embedJavascript($this, " - if(window.opener && window.opener.afterChangePessoa) - window.opener.afterChangePessoa(self, $id); + + if(window.opener && window.opener.afterChangePessoa) { + var parentType = \$j('#parent_type').val(); + + if (parentType) + window.opener.afterChangePessoa(self, parentType, $id, \$j('#nm_pessoa').val()); + else + window.opener.afterChangePessoa(self, $id); + } else document.location = 'atendidos_lst.php'; - "); + + ", $afterReady = true); } /** @@ -629,11 +1026,11 @@ class indice extends clsCadastro return $aluno->detalhe(); } - protected function addPaiInput() { + protected function inputPai() { $this->addParentsInput('pai'); } - protected function addMaeInput() { + protected function inputMae() { $this->addParentsInput('mae', 'mãe'); } @@ -646,12 +1043,20 @@ class indice extends clsCadastro $parentId = $this->{$parentType . '_id'}; - // mostra uma dica nos casos em que foi informado apenas o nome dos pais, pela antiga interface do cadastro de alunos. + + // mostra uma dica nos casos em que foi informado apenas o nome dos pais, + //pela antiga interface do cadastro de alunos. + if (! $parentId && $this->_aluno['nm_' . $parentType]) { - $nome = Portabilis_String_Utils::toLatin1($this->_aluno['nm_' . $parentType], array('transform' => true, 'escape' => false)); - $inputHint = 'Dica: Foi informado o nome "' . $nome . '" no cadastro de aluno, tente pesquisar esta pessoa pelo CPF ou RG.'; + $nome = Portabilis_String_Utils::toLatin1($this->_aluno['nm_' . $parentType], + array('transform' => true, 'escape' => false)); + + $inputHint = '
Dica: Foi informado o nome "' . $nome . + '" no cadastro de aluno,
tente pesquisar esta pessoa ' . + 'pelo CPF ou RG, caso não encontre, cadastre uma nova pessoa.'; } + $hiddenInputOptions = array('options' => array('value' => $parentId)); $helperOptions = array('objectName' => $parentType, 'hiddenInputOptions' => $hiddenInputOptions); @@ -686,6 +1091,122 @@ class indice extends clsCadastro return $isValid; } + + protected function createOrUpdateDocumentos($pessoaId) { + $documentos = new clsDocumento(); + $documentos->idpes = $pessoaId; + + + // rg + + $documentos->rg = $_REQUEST['rg']; + + $documentos->data_exp_rg = Portabilis_Date_Utils::brToPgSQL( + $_REQUEST['data_emissao_rg'] + ); + + $documentos->idorg_exp_rg = $_REQUEST['orgao_emissao_rg']; + $documentos->sigla_uf_exp_rg = $_REQUEST['uf_emissao_rg']; + + + // certidão civil + + + // o tipo certidão novo padrão é apenas para exibição ao usuário, + // não precisa ser gravado no banco + // + // quando selecionado um tipo diferente do novo formato, + // é removido o valor de certidao_nascimento. + // + if ($_REQUEST['tipo_certidao_civil'] == 'certidao_nascimento_novo_formato') { + $documentos->tipo_cert_civil = null; + $documentos->certidao_nascimento = $_REQUEST['certidao_nascimento']; + } + else { + $documentos->tipo_cert_civil = $_REQUEST['tipo_certidao_civil']; + $documentos->certidao_nascimento = ''; + } + + $documentos->num_termo = $_REQUEST['termo_certidao_civil']; + $documentos->num_livro = $_REQUEST['livro_certidao_civil']; + $documentos->num_folha = $_REQUEST['folha_certidao_civil']; + + $documentos->data_emissao_cert_civil = Portabilis_Date_Utils::brToPgSQL( + $_REQUEST['data_emissao_certidao_civil'] + ); + + $documentos->sigla_uf_cert_civil = $_REQUEST['uf_emissao_certidao_civil']; + $documentos->cartorio_cert_civil = $_REQUEST['cartorio_emissao_certidao_civil']; + + + + // carteira de trabalho + + $documentos->num_cart_trabalho = $_REQUEST['carteira_trabalho']; + $documentos->serie_cart_trabalho = $_REQUEST['serie_carteira_trabalho']; + + $documentos->data_emissao_cart_trabalho = Portabilis_Date_Utils::brToPgSQL( + $_REQUEST['data_emissao_carteira_trabalho'] + ); + + $documentos->sigla_uf_cart_trabalho = $_REQUEST['uf_emissao_carteira_trabalho']; + + + // titulo de eleitor + + $documentos->num_tit_eleitor = $_REQUEST['titulo_eleitor']; + $documentos->zona_tit_eleitor = $_REQUEST['zona_titulo_eleitor']; + $documentos->secao_tit_eleitor = $_REQUEST['secao_titulo_eleitor']; + + + // Alteração de documentos compativel com a versão anterior do cadastro, + // onde era possivel criar uma pessoa, não informando os documentos, + // o que não criaria o registro do documento, sendo assim, ao editar uma pessoa, + // o registro do documento será criado, caso não exista. + + $sql = "select 1 from cadastro.documento WHERE idpes = $1 limit 1"; + + if (Portabilis_Utils_Database::selectField($sql, $pessoaId) != 1) + $documentos->cadastra(); + else + $documentos->edita(); + } + + // inputs usados em Gerar, + // implementado estes metodos para não duplicar código + // uma vez que estes campos são usados várias vezes em Gerar. + + protected function inputTelefone($type, $typeLabel = '') { + if (! $typeLabel) + $typeLabel = "Telefone {$type}"; + + // ddd + + $options = array( + 'required' => false, + 'label' => "(ddd) / {$typeLabel}", + 'placeholder' => 'ddd', + 'value' => $this->{"ddd_telefone_{$type}"}, + 'max_length' => 3, + 'size' => 3, + 'inline' => true + ); + + $this->inputsHelper()->integer("ddd_telefone_{$type}", $options); + + + // telefone + + $options = array( + 'required' => false, + 'label' => '', + 'placeholder' => $typeLabel, + 'value' => $this->{"telefone_{$type}"}, + 'max_length' => 11 + ); + + $this->inputsHelper()->integer("telefone_{$type}", $options); + } } // Instancia objeto de página diff --git a/ieducar/intranet/educar_escola_cad.php b/ieducar/intranet/educar_escola_cad.php index 216ebd7..0afe4f5 100644 --- a/ieducar/intranet/educar_escola_cad.php +++ b/ieducar/intranet/educar_escola_cad.php @@ -402,7 +402,7 @@ class indice extends clsCadastro } else { - $this->inputsHelper()->numeric('escola_inep_id', array('label' => 'Código inep', 'required' => false)); + $this->inputsHelper()->integer('escola_inep_id', array('label' => 'Código inep', 'required' => false)); if( $_POST ) foreach( $_POST AS $campo => $val ) diff --git a/ieducar/intranet/include/pessoa/clsDocumento.inc.php b/ieducar/intranet/include/pessoa/clsDocumento.inc.php index 171770c..9cb919d 100755 --- a/ieducar/intranet/include/pessoa/clsDocumento.inc.php +++ b/ieducar/intranet/include/pessoa/clsDocumento.inc.php @@ -67,7 +67,7 @@ class clsDocumento * @return Object:clsDocumento */ 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) - { + { $objPessoa = new clsFisica($int_idpes); if($objPessoa->detalhe()) { @@ -448,16 +448,10 @@ class clsDocumento $set .= $gruda."certidao_nascimento = '{$this->certidao_nascimento}'"; $gruda = ", "; } - #else - #{ - # $set .= $gruda."certidao_nascimento = NULL"; - # $gruda = ", "; - #} if($set) { $db = new clsBanco(); -// ECHO "UPDATE {$this->schema}.{$this->tabela} $set WHERE idpes = '$this->idpes'" ;DIE; $db->Consulta( "UPDATE {$this->schema}.{$this->tabela} $set WHERE idpes = '$this->idpes'" ); return true; } diff --git a/ieducar/intranet/include/pessoa/clsFisica.inc.php b/ieducar/intranet/include/pessoa/clsFisica.inc.php index 2779a2f..d709946 100755 --- a/ieducar/intranet/include/pessoa/clsFisica.inc.php +++ b/ieducar/intranet/include/pessoa/clsFisica.inc.php @@ -193,16 +193,28 @@ class clsFisica { $campos = ""; $valores = ""; - if(is_string($this->data_nasc)) - { - $campos .= ", data_nasc"; + + + // data_nasc + + $campos .= ", data_nasc"; + + if($this->data_nasc) $valores .= ", '{$this->data_nasc}'"; - } - if(is_string($this->sexo)) - { - $campos .= ", sexo"; + else + $valores .= ", NULL"; + + + // sexo + + $campos .= ", sexo"; + + if($this->sexo) $valores .= ", '$this->sexo' "; - } + else + $valores .= ", NULL"; + + if(is_numeric($this->idpes_mae)) { $campos .= ", idpes_mae"; diff --git a/ieducar/intranet/scripts/padrao.js b/ieducar/intranet/scripts/padrao.js index a965500..1a54a99 100755 --- a/ieducar/intranet/scripts/padrao.js +++ b/ieducar/intranet/scripts/padrao.js @@ -791,6 +791,9 @@ function cv_set_campo(campo1, valor1, campo2, valor2, campo3, valor3, campo4, } window.parent.fechaExpansivel('div_dinamico_' + (parent.DOM_divs.length * 1 - 1)); + + if(parent.afterSetSearchFields) + parent.afterSetSearchFields(self); } 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 parent.document.getElementById(campo8).disabled = false; parent.document.getElementById(campo8).value = '1'; } + + if(parent.afterUnsetSearchFields) + parent.afterUnsetSearchFields(self); } // Função a ser executada antes de fechar a janela. diff --git a/ieducar/lib/Portabilis/Array/Utils.php b/ieducar/lib/Portabilis/Array/Utils.php index df3984d..cccf33f 100644 --- a/ieducar/lib/Portabilis/Array/Utils.php +++ b/ieducar/lib/Portabilis/Array/Utils.php @@ -128,8 +128,12 @@ class Portabilis_Array_Utils { /* transforma um conjunto de arrays "chave => valor, chave => valor" em um array "id => value", ex: (('id' => 1, 'nome' => 'lucas'), ('id' => 2, 'nome' => 'davila')) - é transformado em (1 => 'lucas', 2 => davila), caso uma mesma chave se repita em mais de um array, + é transformado em (1 => 'lucas', 2 => davila), + + caso uma mesma chave se repita em mais de um array, será mantido a chave => valor do ultimo array que a contem. + + o array retornado, será ordenado por valor. */ public static function setAsIdValue($arrays, $keyAttr, $valueAtt) { if (empty($arrays)) @@ -143,7 +147,7 @@ class Portabilis_Array_Utils { foreach ($arrays as $array) $idValueArray = self::merge($idValueArray, self::asIdValue($array, $keyAttr, $valueAtt)); - return $idValueArray; + return Portabilis_Array_Utils::sortByValue($idValueArray); } @@ -164,6 +168,14 @@ class Portabilis_Array_Utils { return $array; } + /* ordena array por valor mantendo as chaves associativas, usando função php uasort. */ + public static function sortByValue($array) { + uasort($array, function ($a, $b) { + return Portabilis_Array_Utils::_valueSorter($a, $b); + }); + + return $array; + } public static function _keySorter($key, $array, $otherArray) { $a = $array[$key]; @@ -175,6 +187,18 @@ class Portabilis_Array_Utils { return ($a < $b) ? -1 : 1; } + public static function _valueSorter($a, $b) { + if (is_string($a)) + $a = Portabilis_String_Utils::unaccent($a); + + if (is_string($b)) + $b = Portabilis_String_Utils::unaccent($b); + + if ($a == $b) + return 0; + + return ($a < $b) ? -1 : 1; + } /* trim values for a given array */ public static function trim($array) { diff --git a/ieducar/lib/Portabilis/Date/Utils.php b/ieducar/lib/Portabilis/Date/Utils.php index bc1aed5..aaa45e9 100644 --- a/ieducar/lib/Portabilis/Date/Utils.php +++ b/ieducar/lib/Portabilis/Date/Utils.php @@ -48,6 +48,9 @@ class Portabilis_Date_Utils * @param string $date */ public static function brToPgSQL($date) { + if (! $date) + return $date; + // #TODO usar classe nativa datetime http://www.phptherightway.com/#date_and_time ? list($dia, $mes, $ano) = explode("/", $date); return "$ano-$mes-$dia"; @@ -58,13 +61,23 @@ class Portabilis_Date_Utils * @param string $timestamp */ public static function pgSQLToBr($timestamp) { - $format = 'Y-m-d H:i:s'; - $hasMicroseconds = strpos($timestamp, '.') > -1; + $pgFormat = 'Y-m-d'; + $brFormat = 'd/m/Y'; + + $hasTime = strpos($timestamp, ':') > -1; + + if ($hasTime) { + $pgFormat .= ' H:i:s'; + $brFormat .= ' H:i:s'; + + $hasMicroseconds = strpos($timestamp, '.') > -1; + + if ($hasMicroseconds) + $pgFormat .= '.u'; + } - if ($hasMicroseconds) - $format .= '.u'; + $d = DateTime::createFromFormat($pgFormat, $timestamp); - $d = DateTime::createFromFormat($format, $timestamp); - return ($d ? $d->format('d/m/Y H:i:s') : null); + return ($d ? $d->format($brFormat) : null); } } diff --git a/ieducar/lib/Portabilis/String/Utils.php b/ieducar/lib/Portabilis/String/Utils.php index 32d8220..595ab47 100644 --- a/ieducar/lib/Portabilis/String/Utils.php +++ b/ieducar/lib/Portabilis/String/Utils.php @@ -47,6 +47,7 @@ class Portabilis_String_Utils { return Portabilis_Array_Utils::merge($options, $defaultOptions); } + /* splits a string in a array, eg: $divisors = array('-', ' '); // or $divisors = '-'; @@ -77,12 +78,14 @@ class Portabilis_String_Utils { return $result; } + /* scapes a string, adding backslashes before characters that need to be quoted, this method is useful to scape values to be inserted via database queries. */ public static function escape($str) { return addslashes($str); } + /* encodes latin1 strings to utf-8, this method is useful to return latin1 strings (with accents) stored in db, in json api's. */ @@ -96,6 +99,7 @@ class Portabilis_String_Utils { if ($options['transform']) $str = ucwords(mb_strtolower($str)); + $str = utf8_encode($str); if ($options['convert_html_special_chars']) @@ -104,6 +108,7 @@ class Portabilis_String_Utils { return $str; } + /* encodes utf-8 strings to latin1, this method is useful to store utf-8 string (with accents) get from json api's, in latin1 db's. */ @@ -117,7 +122,11 @@ class Portabilis_String_Utils { if ($options['transform']) $str = ucwords(mb_strtolower($str)); - if (mb_detect_encoding($str, 'utf-8, iso-8859-1') == 'UTF-8') + + // apenas converte para latin1, strings utf-8 + // impedindo assim, converter para latin1 strings que já sejam latin1 + + if (Portabilis_String_Utils::encoding($str) == 'UTF-8') $str = utf8_decode($str); if ($options['convert_html_special_chars']) @@ -126,15 +135,27 @@ class Portabilis_String_Utils { return $str; } + public static function unaccent($str) { + $fromEncoding = Portabilis_String_Utils::encoding($str); + return iconv($fromEncoding, 'US-ASCII//TRANSLIT', $str); + } + + + public static function encoding($str) { + return mb_detect_encoding($str, 'UTF-8, ISO-8859-1', $strict = true); + } + public static function camelize($str) { return str_replace(' ', '', ucwords(str_replace('_', ' ', $str))); } + public static function underscore($str) { $words = preg_split('/(?=[A-Z])/', $str, -1, PREG_SPLIT_NO_EMPTY); return strtolower(implode('_', $words)); } + public static function humanize($str) { $robotWords = array('_id', 'ref_cod_', 'ref_ref_cod_'); diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Core.php b/ieducar/lib/Portabilis/View/Helper/Input/Core.php index 68cd496..1a13d3f 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Core.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Core.php @@ -80,8 +80,31 @@ class Portabilis_View_Helper_Input_Core { return $value; } + protected function inputPlaceholder($inputOptions) { + return isset($inputOptions['placeholder']) ? $inputOptions['placeholder'] : $inputOptions['label']; + } + + protected function fixupPlaceholder($inputOptions) { + $id = $inputOptions['id']; + $placeholder = $this->inputPlaceholder($inputOptions); + + $script = " + var \$input = \$j('#" . $id . "'); + if (\$input.is(':enabled')) + \$input.attr('placeholder', '" . $placeholder . "'); + "; + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $script, $afterReady = true); + } + protected function loadCoreAssets() { + // carrega estilo para feedback messages, devido algumas validações de inuts + // adicionarem mensagens + + $style = "/modules/Portabilis/Assets/Stylesheets/Frontend.css"; + Portabilis_View_Helper_Application::loadStylesheet($this->viewInstance, $style); + + Portabilis_View_Helper_Application::loadJQueryLib($this->viewInstance); Portabilis_View_Helper_Application::loadJQueryUiLib($this->viewInstance); diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Date.php b/ieducar/lib/Portabilis/View/Helper/Input/Date.php new file mode 100644 index 0000000..c96863c --- /dev/null +++ b/ieducar/lib/Portabilis/View/Helper/Input/Date.php @@ -0,0 +1,74 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÃFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Arquivo disponível desde a versão 1.1.0 + * @version $Id$ + */ + +require_once 'Portabilis/View/Helper/Input/Core.php'; +require_once 'Portabilis/Date/Utils.php'; + +/** + * Portabilis_View_Helper_Input_Date class. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Classe disponível desde a versão 1.1.0 + * @version @@package_version@@ + */ +class Portabilis_View_Helper_Input_Date extends Portabilis_View_Helper_Input_Core { + + public function date($attrName, $options = array()) { + $defaultOptions = array('options' => array(), 'objectName' => ''); + + $options = $this->mergeOptions($options, $defaultOptions); + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; + + $label = ! empty($attrName) ? $attrName : $options['objectName']; + $label = str_replace('_id', '', $label); + + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, + 'label' => ucwords($label), + 'value' => null, + 'required' => true, + 'label_hint' => '', + 'inline' => false, + 'callback' => false, + 'disabled' => false); + + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + + $isDbFormated = strrpos($inputOptions['value'], '-') > -1; + + if ($isDbFormated) + $inputOptions['value'] = Portabilis_Date_Utils::pgSQLToBr($inputOptions['value']); + + call_user_func_array(array($this->viewInstance, 'campoData'), $inputOptions); + $this->fixupPlaceholder($inputOptions); + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Integer.php b/ieducar/lib/Portabilis/View/Helper/Input/Integer.php new file mode 100644 index 0000000..5032046 --- /dev/null +++ b/ieducar/lib/Portabilis/View/Helper/Input/Integer.php @@ -0,0 +1,66 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÃFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Arquivo disponível desde a versão 1.1.0 + * @version $Id$ + */ + +require_once 'lib/Portabilis/View/Helper/Input/Numeric.php'; + + +/** + * Portabilis_View_Helper_Input_Integer class. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Classe disponível desde a versão 1.1.0 + * @version @@package_version@@ + */ +class Portabilis_View_Helper_Input_Integer extends Portabilis_View_Helper_Input_Numeric { + + protected function fixupValidation($inputOptions) { + // fixup para remover caracteres não numericos + // inclusive pontos '.', não removidos pela super classe + $js = " \$j('#" . $inputOptions['id'] . "').keyup(function(){ + var oldValue = this.value; + + this.value = this.value.replace(/[^0-9\.]/g, ''); + this.value = this.value.replace('.', ''); + + if (oldValue != this.value) + messageUtils.error('Informe apenas números.', this); + + });"; + + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false); + } + + public function integer($attrName, $options = array()) { + parent::numeric($attrName, $options); + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Numeric.php b/ieducar/lib/Portabilis/View/Helper/Input/Numeric.php index 650a6a6..5142ea7 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Numeric.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Numeric.php @@ -44,6 +44,20 @@ require_once 'lib/Portabilis/View/Helper/Input/Core.php'; */ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_Core { + protected function fixupValidation($inputOptions) { + // fixup para remover caracteres não numericos + $js = " \$j(#'" . $inputOptions['id'] . "').keyup(function(){ + var oldValue = this.value; + this.value = this.value.replace(/[^0-9\.]/g, ''); + + if (oldValue != this.value) + messageUtils.error('Informe apenas números.', this); + + });"; + + Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = false); + } + public function numeric($attrName, $options = array()) { $defaultOptions = array('options' => array(), 'objectName' => ''); @@ -59,7 +73,7 @@ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_ 'size' => 15, 'max_length' => 15, 'required' => true, - 'label_hint' => '', + 'label_hint' => ' ', 'input_hint' => '', 'script' => false, 'event' => 'onKeyUp', @@ -67,7 +81,10 @@ class Portabilis_View_Helper_Input_Numeric extends Portabilis_View_Helper_Input_ 'disabled' => false); $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + $inputOptions['label'] = Portabilis_String_Utils::toLatin1($inputOptions['label'], array('escape' => false)); call_user_func_array(array($this->viewInstance, 'campoNumero'), $inputOptions); + $this->fixupPlaceholder($inputOptions); + $this->fixupValidation($inputOptions); } } diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php index 64e29d9..8b09b94 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/Beneficio.php @@ -53,7 +53,7 @@ class Portabilis_View_Helper_Input_Resource_Beneficio extends Portabilis_View_He $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_aluno_beneficio', 'nm_beneficio'); } - return $this->insertOption(null, "Selecione", $resources); + return $this->insertOption(null, "Beneficio", $resources); } public function beneficio($options = array()) { diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php index 53847ce..75a0a62 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/EstadoCivil.php @@ -53,7 +53,7 @@ class Portabilis_View_Helper_Input_Resource_EstadoCivil extends Portabilis_View_ $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'ideciv', 'descricao'); } - return $this->insertOption(null, "Selecione", $resources); + return $this->insertOption(null, "Estado civil", $resources); } public function estadoCivil($options = array()) { diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php index fb08af5..ebecc01 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/Religiao.php @@ -54,7 +54,7 @@ class Portabilis_View_Helper_Input_Resource_Religiao extends Portabilis_View_Hel $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'cod_religiao', 'nm_religiao'); } - return $this->insertOption(null, "Selecione", $resources); + return $this->insertOption(null, Portabilis_String_Utils::toLatin1("Religião"), $resources); } diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php index d573545..35e50f8 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchAluno.php @@ -50,17 +50,11 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchAluno extends Portabilis $options = $this->mergeOptions($options, $defaultOptions); - $this->placeholderJs($options); - parent::simpleSearch($options['objectName'], $attrName, $options); } - protected function placeholderJs($options) { - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = stringUtils.toUtf8('Informe o nome do aluno ou código');"; - - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); + protected function inputPlaceholder($inputOptions) { + return 'Informe o código ou nome do aluno'; } protected function loadAssets() { diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php index 477c253..c3b43c6 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMatricula.php @@ -50,17 +50,11 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchMatricula extends Portab $options = $this->mergeOptions($options, $defaultOptions); - $this->placeholderJs($options); - parent::simpleSearch($options['objectName'], $attrName, $options); } - protected function placeholderJs($options) { - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = stringUtils.toUtf8('Informe o nome do aluno, código ou código matricula');"; - - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); + protected function inputPlaceholder($inputOptions) { + return 'Informe o nome do aluno, código ou código da matricula'; } protected function loadAssets() { diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php index 276daac..85d3919 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchMunicipio.php @@ -64,16 +64,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchMunicipio extends Portab $options = $this->mergeOptions($options, $defaultOptions); - $this->placeholderJs($options); - parent::simpleSearch($options['objectName'], $attrName, $options); } - protected function placeholderJs($options) { - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = safeUtf8Decode('Informe o código ou nome da cidade');"; - - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); + protected function inputPlaceholder($inputOptions) { + return 'Informe o código ou nome da cidade'; } } \ No newline at end of file diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php index 1b786bb..1288d13 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPais.php @@ -62,16 +62,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchPais extends Portabilis_ $options = $this->mergeOptions($options, $defaultOptions); - $this->placeholderJs($options); - parent::simpleSearch($options['objectName'], $attrName, $options); } - protected function placeholderJs($options) { - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = safeUtf8Decode('Informe o código ou nome do pais de origem');"; - - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); + protected function inputPlaceholder($inputOptions) { + return 'Informe o código ou nome do pais de origem'; } } \ No newline at end of file diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php index bbd17eb..88a32fd 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/SimpleSearchPessoa.php @@ -62,16 +62,10 @@ class Portabilis_View_Helper_Input_Resource_SimpleSearchPessoa extends Portabili $options = $this->mergeOptions($options, $defaultOptions); - $this->placeholderJs($options); - parent::simpleSearch($options['objectName'], $attrName, $options); } - protected function placeholderJs($options) { - $optionsVarName = "simpleSearch" . Portabilis_String_Utils::camelize($options['objectName']) . "Options"; - $js = "if (typeof $optionsVarName == 'undefined') { $optionsVarName = {} }; - $optionsVarName.placeholder = safeUtf8Decode('Informe o nome, código, CPF ou RG da pessoa');"; - - Portabilis_View_Helper_Application::embedJavascript($this->viewInstance, $js, $afterReady = true); + protected function inputPlaceholder($inputOptions) { + return 'Informe o nome, código, CPF ou RG da pessoa'; } } \ No newline at end of file diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/TipoLogradouro.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/TipoLogradouro.php new file mode 100644 index 0000000..8b15d71 --- /dev/null +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/TipoLogradouro.php @@ -0,0 +1,64 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÃFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Arquivo disponível desde a versão 1.1.0 + * @version $Id$ + */ + +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; + + +/** + * Portabilis_View_Helper_Input_Resource_TipoLogradouro class. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Classe disponível desde a versão 1.1.0 + * @version @@package_version@@ + */ + +class Portabilis_View_Helper_Input_Resource_TipoLogradouro extends Portabilis_View_Helper_Input_CoreSelect { + + protected function inputOptions($options) { + $resources = $options['resources']; + + if (empty($options['resources'])) { + $resources = new clsTipoLogradouro(); + $resources = $resources->lista(); + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'idtlog', 'descricao'); + } + + return $this->insertOption(null, "Tipo logradouro", $resources); + } + + + public function tipoLogradouro($options = array()) { + parent::select($options); + } +} \ No newline at end of file diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Resource/Uf.php b/ieducar/lib/Portabilis/View/Helper/Input/Resource/Uf.php new file mode 100644 index 0000000..2dfe87e --- /dev/null +++ b/ieducar/lib/Portabilis/View/Helper/Input/Resource/Uf.php @@ -0,0 +1,64 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÃFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Arquivo disponível desde a versão 1.1.0 + * @version $Id$ + */ + +require_once 'lib/Portabilis/View/Helper/Input/CoreSelect.php'; + + +/** + * Portabilis_View_Helper_Input_Resource_Uf class. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Classe disponível desde a versão 1.1.0 + * @version @@package_version@@ + */ + +class Portabilis_View_Helper_Input_Resource_Uf extends Portabilis_View_Helper_Input_CoreSelect { + + protected function inputOptions($options) { + $resources = $options['resources']; + + if (empty($options['resources'])) { + $resources = new clsUf(); + $resources = $resources->lista(); + $resources = Portabilis_Array_Utils::setAsIdValue($resources, 'sigla_uf', 'sigla_uf'); + } + + return $this->insertOption(null, "Estado", $resources); + } + + + public function uf($options = array()) { + parent::select($options); + } +} \ No newline at end of file diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Select.php b/ieducar/lib/Portabilis/View/Helper/Input/Select.php index 0cf0b73..a332896 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Select.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Select.php @@ -61,7 +61,9 @@ class Portabilis_View_Helper_Input_Select extends Portabilis_View_Helper_Input_C 'required' => true, 'multiple' => false); - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + $inputOptions['label'] = Portabilis_String_Utils::toLatin1($inputOptions['label'], array('escape' => false)); + call_user_func_array(array($this->viewInstance, 'campoLista'), $inputOptions); } } \ No newline at end of file diff --git a/ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php b/ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php index 436f379..c7592bf 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/SimpleSearch.php @@ -95,6 +95,11 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I protected function textInput($objectName, $attrName, $options) { $textHelperOptions = array('objectName' => $objectName); + $options['options']['placeholder'] = Portabilis_String_Utils::toLatin1( + $this->inputPlaceholder(), + array('escape' => false) + ); + $this->inputsHelper()->text($attrName, $options['options'], $textHelperOptions); } @@ -110,7 +115,7 @@ class Portabilis_View_Helper_Input_SimpleSearch extends Portabilis_View_Helper_I /* all search options (including the option autocompleteOptions, that is passed for jquery autocomplete plugin), - can be overwritten adding "var = simpleSearchOptions = { placeholder : '...', optionName : '...' };" + can be overwritten adding "var = simpleSearchOptions = { option : '...', optionName : '...' };" in the script file for the resource controller. */ diff --git a/ieducar/lib/Portabilis/View/Helper/Input/Text.php b/ieducar/lib/Portabilis/View/Helper/Input/Text.php index 5b0c1c6..22b32fa 100644 --- a/ieducar/lib/Portabilis/View/Helper/Input/Text.php +++ b/ieducar/lib/Portabilis/View/Helper/Input/Text.php @@ -51,7 +51,7 @@ class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Cor $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; $label = ! empty($attrName) ? $attrName : $options['objectName']; - $label = str_replace('_id', '', $label); + $label = str_replace('_id', '', $label); $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, 'label' => ucwords($label), @@ -67,8 +67,10 @@ class Portabilis_View_Helper_Input_Text extends Portabilis_View_Helper_Input_Cor 'event' => 'onKeyUp', 'disabled' => false); - $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + $inputOptions['label'] = Portabilis_String_Utils::toLatin1($inputOptions['label'], array('escape' => false)); call_user_func_array(array($this->viewInstance, 'campoTexto'), $inputOptions); + $this->fixupPlaceholder($inputOptions); } } diff --git a/ieducar/lib/Portabilis/View/Helper/Input/TextArea.php b/ieducar/lib/Portabilis/View/Helper/Input/TextArea.php new file mode 100644 index 0000000..b547a28 --- /dev/null +++ b/ieducar/lib/Portabilis/View/Helper/Input/TextArea.php @@ -0,0 +1,74 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÃFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Arquivo disponível desde a versão 1.1.0 + * @version $Id$ + */ + +require_once 'lib/Portabilis/View/Helper/Input/Core.php'; + + +/** + * Portabilis_View_Helper_Input_TextArea class. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Portabilis + * @since Classe disponível desde a versão 1.1.0 + * @version @@package_version@@ + */ +class Portabilis_View_Helper_Input_TextArea extends Portabilis_View_Helper_Input_Core { + + public function textArea($attrName, $options = array()) { + $defaultOptions = array('options' => array(), 'objectName' => ''); + + $options = $this->mergeOptions($options, $defaultOptions); + $spacer = ! empty($options['objectName']) && ! empty($attrName) ? '_' : ''; + + $label = ! empty($attrName) ? $attrName : $options['objectName']; + $label = str_replace('_id', '', $label); + + $defaultInputOptions = array('id' => $options['objectName'] . $spacer . $attrName, + 'label' => ucwords($label), + 'value' => null, + 'cols' => 49, + 'rows' => 5, + 'required' => true, + 'label_hint' => '', + 'max_length' => '', + 'inline' => false, + 'script' => false, + 'event' => 'onClick', + 'disabled' => false); + + $inputOptions = $this->mergeOptions($options['options'], $defaultInputOptions); + + call_user_func_array(array($this->viewInstance, 'campoMemo'), $inputOptions); + $this->fixupPlaceholder($inputOptions); + } +} diff --git a/ieducar/lib/Portabilis/View/Helper/Inputs.php b/ieducar/lib/Portabilis/View/Helper/Inputs.php index 6136d03..2ace721 100644 --- a/ieducar/lib/Portabilis/View/Helper/Inputs.php +++ b/ieducar/lib/Portabilis/View/Helper/Inputs.php @@ -84,6 +84,14 @@ class Portabilis_View_Helper_Inputs { // input helpers + public function input($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) { + $helperClassName = "Portabilis_View_Helper_Input_" . ucfirst($helperName); + + $this->includeHelper($helperClassName); + $helper = new $helperClassName($this->viewInstance, $this); + $helper->$helperName($attrName, $this->mergeInputOptions($inputOptions, $helperOptions)); + } + public function text($attrNames, $inputOptions = array(), $helperOptions = array()) { if (! is_array($attrNames)) $attrNames = array($attrNames); @@ -93,42 +101,36 @@ class Portabilis_View_Helper_Inputs { } } - public function numeric($attrNames, $inputOptions = array(), $helperOptions = array()) { - if (! is_array($attrNames)) - $attrNames = array($attrNames); - - foreach($attrNames as $attrName) { - $this->input('numeric', $attrName, $inputOptions, $helperOptions); - } + public function numeric($attrName, $inputOptions = array(), $helperOptions = array()) { + $this->input('numeric', $attrName, $inputOptions, $helperOptions); } + public function integer($attrName, $inputOptions = array(), $helperOptions = array()) { + $this->input('integer', $attrName, $inputOptions, $helperOptions); + } public function select($attrName, $inputOptions = array(), $helperOptions = array()) { $this->input('select', $attrName, $inputOptions, $helperOptions); } - public function search($attrName, $inputOptions = array(), $helperOptions = array()) { $this->input('search', $attrName, $inputOptions, $helperOptions); } - public function hidden($attrName, $inputOptions = array(), $helperOptions = array()) { $this->input('hidden', $attrName, $inputOptions, $helperOptions); } - public function checkbox($attrName, $inputOptions = array(), $helperOptions = array()) { $this->input('checkbox', $attrName, $inputOptions, $helperOptions); } + public function date($attrName, $inputOptions = array(), $helperOptions = array()) { + $this->input('date', $attrName, $inputOptions, $helperOptions); + } - public function input($helperName, $attrName, $inputOptions = array(), $helperOptions = array()) { - $helperClassName = "Portabilis_View_Helper_Input_" . ucfirst($helperName); - - $this->includeHelper($helperClassName); - $helper = new $helperClassName($this->viewInstance, $this); - $helper->$helperName($attrName, $this->mergeInputOptions($inputOptions, $helperOptions)); + public function textArea($attrName, $inputOptions = array(), $helperOptions = array()) { + $this->input('textArea', $attrName, $inputOptions, $helperOptions); } @@ -196,6 +198,14 @@ class Portabilis_View_Helper_Inputs { $this->resourceInput('turmaTurno', $this->mergeInputOptions($inputOptions, $helperOptions)); } + public function uf($inputOptions = array(), $helperOptions = array()) { + $this->resourceInput('uf', $this->mergeInputOptions($inputOptions, $helperOptions)); + } + + public function tipoLogradouro($inputOptions = array(), $helperOptions = array()) { + $this->resourceInput('tipoLogradouro', $this->mergeInputOptions($inputOptions, $helperOptions)); + } + // protected methods protected function resourceInput($helperName, $options = array()) { diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js b/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js index 01a132e..5b77485 100644 --- a/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js +++ b/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js @@ -83,7 +83,7 @@ var handleGetPersonDetails = function(dataResponse) { else { $j('.pessoa-links .editar-pessoa').attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + dataResponse.id) - .show(); + .show().css('display', 'inline'); $submitButton.removeAttr('disabled').show(); } @@ -174,8 +174,8 @@ function afterChangePessoa(targetWindow, pessoaId) { $j('#pessoa_id').val(pessoaId); getPersonDetails(pessoaId); - window.setTimeout(function() { $nomeField.removeClass('success'); }, 10000); - $nomeField.focus(); + if ($nomeField.is(':active')) + $nomeField.focus(); }, 500); } @@ -209,7 +209,7 @@ function afterChangePessoa(targetWindow, pessoaId) { if (resource.isNew()) { $nomeField.focus(); - $j('.pessoa-links .cadastrar-pessoa').show(); + $j('.pessoa-links .cadastrar-pessoa').show().css('display', 'inline'); } else $nomeField.attr('disabled', 'disabled'); diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js b/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js index aacb5ee..d607dc7 100644 --- a/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js +++ b/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js @@ -87,7 +87,7 @@ var handleGetMatriculas = function(dataResponse) { } $matriculasTable.fadeIn('slow'); - $j('body').animate({scrollTop: $j('#matriculas').offset().top }, 900); + $j('body,html').animate({scrollTop: $j('#matriculas').offset().top }, 900); $matriculasTable.find('tr:even').addClass('even'); } diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/Escola.js b/ieducar/modules/Cadastro/Assets/Javascripts/Escola.js index 48dd781..2643f06 100644 --- a/ieducar/modules/Cadastro/Assets/Javascripts/Escola.js +++ b/ieducar/modules/Cadastro/Assets/Javascripts/Escola.js @@ -1,7 +1,8 @@ var $submitButton = $j('#btn_enviar'); var submitForm = function(){ - putEscola(); + if (validationUtils.validatesFields()) + putEscola(); } var handleGetEscola = function(dataResponse) { diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js b/ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js index 13241e7..ef166bc 100644 --- a/ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js +++ b/ieducar/modules/Cadastro/Assets/Javascripts/PessoaFisica.js @@ -1,121 +1,308 @@ -(function($) { - $(document).ready(function() { - var $form = $j('#formcadastro'); - var $submitButton = $j('#btn_enviar'); - var $cpfField = $j('#id_federal'); - var $cpfNotice = $j('').html('') - .addClass('error resource-notice') - .hide() - .width($j('#nm_pessoa').outerWidth() - 12) - .appendTo($cpfField.parent()); +// before page is ready +function hrefToCreateParent(parentType) { + return '/intranet/atendidos_cad.php?parent_type=' + parentType; +} + +function hrefToEditParent(parentType) { + var id = $j(buildId(parentType + '_id')).val(); + return hrefToCreateParent(parentType) + '&cod_pessoa_fj=' + id; +} + +var pessoaId = $j('#cod_pessoa_fj').val(); +var $form = $j('#formcadastro'); +var $submitButton = $j('#btn_enviar'); +var $cpfField = $j('#id_federal'); +var $cpfNotice = $j('').html('') + .addClass('error resource-notice') + .hide() + .width($j('#nm_pessoa').outerWidth() - 12) + .appendTo($cpfField.parent()); - var handleGetPersonByCpf = function(dataResponse) { - handleMessages(dataResponse.msgs); - $cpfNotice.hide(); - var pessoaId = dataResponse.id; +// links pessoa pai, mãe + +var $paiNomeField = $j('#pai_nome'); +var $paiIdField = $j('#pai_id'); + +var $maeNomeField = $j('#mae_nome'); +var $maeIdField = $j('#mae_id'); + + +var $pessoaPaiActionBar = $j('').html('') + .addClass('pessoa-links pessoa-pai-links') + .width($paiNomeField.outerWidth() - 12) + .appendTo($paiNomeField.parent()); + +var $pessoaMaeActionBar = $pessoaPaiActionBar.clone() + .removeClass('pessoa-pai-links') + .addClass('pessoa-mae-links') + .appendTo($maeNomeField.parent()); - if (pessoaId && pessoaId != $j('#cod_pessoa_fj').val()) { - $cpfNotice.html(stringUtils.toUtf8('CPF já utilizado pela pessoa código ' + pessoaId + ', ')).slideDown('fast'); +var $linkToCreatePessoaPai = $j('').addClass('cadastrar-pessoa-pai decorated') + .attr('href', hrefToCreateParent('pai')) + .attr('target', '_blank') + .html('Cadastrar pessoa') + .appendTo($pessoaPaiActionBar); - $j('').addClass('decorated') - .attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + pessoaId) - .attr('target', '_blank') - .html('acessar cadastro.') - .appendTo($cpfNotice); +var $linkToEditPessoaPai = $j('').hide() + .addClass('editar-pessoa-pai decorated') + .attr('href', hrefToEditParent('pai')) + .attr('target', '_blank') + .html('Editar pessoa') + .appendTo($pessoaPaiActionBar); - $j('body').animate({ scrollTop: $j('body').offset().top }, 'fast'); - } +var $linkToCreatePessoaMae = $linkToCreatePessoaPai.clone() + .removeClass('cadastrar-pessoa-pai') + .addClass('cadastrar-pessoa-mae') + .attr('href', hrefToCreateParent('mae')) + .appendTo($pessoaMaeActionBar); - else if ($j(document).data('submit_form_after_ajax_validation')) - formUtils.submit(); - } +var $linkToEditPessoaMae = $linkToEditPessoaPai.clone() + .removeClass('editar-pessoa-pai') + .addClass('editar-pessoa-mae') + .attr('href', hrefToEditParent('mae')) + .appendTo($pessoaMaeActionBar); +var handleGetPersonByCpf = function(dataResponse) { + handleMessages(dataResponse.msgs); + $cpfNotice.hide(); - var getPersonByCpf = function(cpf) { - var options = { - url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa'), - dataType : 'json', - data : { cpf : cpf }, - success : handleGetPersonByCpf, + var pessoaId = dataResponse.id; - // forçado requisições sincronas, evitando erro com requisições ainda não concluidas, - // como no caso, onde o usuário pressiona cancelar por exemplo. - async : false - }; + if (pessoaId && pessoaId != $j('#cod_pessoa_fj').val()) { + $cpfNotice.html(stringUtils.toUtf8('CPF já utilizado pela pessoa código ' + pessoaId + ', ')).slideDown('fast'); - getResource(options); - } + $j('').addClass('decorated') + .attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + pessoaId) + .attr('target', '_blank') + .html('acessar cadastro.') + .appendTo($cpfNotice); + $j('body,html').animate({ scrollTop: $j('body').offset().top }, 'fast'); + } - // hide or show #pais_origem_nome by #tipo_nacionalidade - var checkTipoNacionalidade = function() { - if ($j.inArray($j('#tipo_nacionalidade').val(), ['2', '3']) > -1) - $j('#pais_origem_nome').show(); - else - $j('#pais_origem_nome').hide(); - } + else if ($j(document).data('submit_form_after_ajax_validation')) + formUtils.submit(); +} - var validatesCpf = function() { - var valid = true; - var cpf = $cpfField.val(); +var getPersonByCpf = function(cpf) { + var options = { + url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa'), + dataType : 'json', + data : { cpf : cpf }, + success : handleGetPersonByCpf, - $cpfNotice.hide(); + // forçado requisições sincronas, evitando erro com requisições ainda não concluidas, + // como no caso, onde o usuário pressiona cancelar por exemplo. + async : false + }; - if (cpf && ! validationUtils.validatesCpf(cpf)) { - $cpfNotice.html(stringUtils.toUtf8('O CPF informado é inválido')).slideDown('fast'); + getResource(options); +} - // não usado $cpfField.focus(), pois isto prenderia o usuário a página, - // caso o mesmo tenha informado um cpf invalido e clique em cancelar - $j('body').animate({ scrollTop: $j('body').offset().top }, 'fast'); - valid = false; - } +// hide or show #pais_origem_nome by #tipo_nacionalidade +var checkTipoNacionalidade = function() { + if ($j.inArray($j('#tipo_nacionalidade').val(), ['2', '3']) > -1) + $j('#pais_origem_nome').show(); + else + $j('#pais_origem_nome').hide(); +} - return valid; - } +// hide or show *certidao* fields, by #tipo_certidao_civil +var checkTipoCertidaoCivil = function() { + var $certidaoCivilFields = $j('#termo_certidao_civil, #livro_certidao_civil, #folha_certidao_civil'); + var $certidaoNascimentoField = $j('#certidao_nascimento'); + var tipoCertidaoCivil = $j('#tipo_certidao_civil').val(); + $certidaoCivilFields.hide(); + $certidaoNascimentoField.hide(); - var validatesUniquenessOfCpf = function() { - var cpf = $cpfField.val(); + if ($j.inArray(tipoCertidaoCivil, ['91', '92']) > -1) { + $certidaoCivilFields.show(); + $j('#tr_tipo_certidao_civil td:first span').html(stringUtils.toUtf8('Tipo certidão civil / Termo / Livro / Folha')); + } - if(cpf && validatesCpf()) - getPersonByCpf(cpf); - } + else if (tipoCertidaoCivil == 'certidao_nascimento_novo_formato') { + $certidaoNascimentoField.show(); + $j('#tr_tipo_certidao_civil td:first span').html(stringUtils.toUtf8('Tipo certidão civil / Certidão nascimento')); + } +} - var submitForm = function(event) { +var validatesCpf = function() { + var valid = true; + var cpf = $cpfField.val(); - if ($cpfField.val()) { - $j(document).data('submit_form_after_ajax_validation', true); - validatesUniquenessOfCpf(); - } + $cpfNotice.hide(); - else - formUtils.submit(); - } + if (cpf && ! validationUtils.validatesCpf(cpf)) { + $cpfNotice.html(stringUtils.toUtf8('O CPF informado é inválido')).slideDown('fast'); + // não usado $cpfField.focus(), pois isto prenderia o usuário a página, + // caso o mesmo tenha informado um cpf invalido e clique em cancelar + $j('body,html').animate({ scrollTop: $j('body').offset().top }, 'fast'); - // style fixup + valid = false; + } - $('#pais_origem_nome').css('width', '150px'); + return valid; +} - // bind events +var validatesUniquenessOfCpf = function() { + var cpf = $cpfField.val(); - checkTipoNacionalidade(); - $j('#tipo_nacionalidade').change(checkTipoNacionalidade); + $cpfNotice.hide(); - $cpfField.focusout(function() { - $j(document).removeData('submit_form_after_ajax_validation'); - validatesUniquenessOfCpf(); + if(cpf && validatesCpf()) + getPersonByCpf(cpf); +} + + +var submitForm = function(event) { + if ($cpfField.val()) { + $j(document).data('submit_form_after_ajax_validation', true); + validatesUniquenessOfCpf(); + } + + else + formUtils.submit(); +} + +// when page is ready + +$j(document).ready(function() { + $cpfField.focus(); + + changeVisibilityOfLinksToPessoaPai(); + changeVisibilityOfLinksToPessoaMae(); + + // style fixup + + $j('#pais_origem_nome').css('width', '150px'); + + // agrupado zebra por tipo documento, branco => .formlttd, colorido => .formmdtd + + $j('#tr_uf_emissao_certidao_civil td').removeClass('formmdtd'); + $j('#tr_carteira_trabalho td').removeClass('formlttd').addClass('formmdtd'); + + + // remove obrigatoriedade de determinados campos, ao criar pessoa pai ou mãe + // para agilizar o cadastro do filho; + + if ($j.inArray($j('#parent_type').val(), ['pai', 'mae']) > -1) { + var $elements = $j('#sexo, #estado_civil_id, #data_nasc, #cep_, #sigla_uf, #cidade, #bairro,\ + #zona_localizacao, #idtlog, #logradouro').filter('[value=]'); + + $elements.addClass('skip-presence-validation'); + + // remove '*' obrigatório ao lado do label. + $elements.each(function(index, element) { + $j(element).closest('tr').find('.campo_obrigatorio').hide(); + }); + } + + // bind events + + checkTipoNacionalidade(); + $j('#tipo_nacionalidade').change(checkTipoNacionalidade); + + checkTipoCertidaoCivil(); + $j('#tipo_certidao_civil').change(checkTipoCertidaoCivil); + + $cpfField.focusout(function() { + $j(document).removeData('submit_form_after_ajax_validation'); + validatesUniquenessOfCpf(); + }); + + + // ao clicar na lupa de pesquisa de cep, move página para cima, + // pois (exceto no ie), a popup de pesquisa é exibida no topo da página. + if (! $j.browser.msie) { + $j('#cep_').siblings('img').click(function(){ + $j('body,html').animate({ scrollTop: $j('body').offset().top }, 'fast'); }); + } + + $submitButton.removeAttr('onclick'); + $submitButton.click(submitForm); + +}); // ready + + +// pessoa links callbacks + +var changeVisibilityOfLinksToPessoaParent = function(parentType) { + var $nomeField = $j(buildId(parentType + '_nome')); + var $idField = $j(buildId(parentType + '_id')); + var $linkToEdit = $j('.pessoa-' + parentType + '-links .editar-pessoa-' + parentType); + + if($nomeField.val() && $idField.val()) { + $linkToEdit.attr('href', hrefToEditParent(parentType)); + $linkToEdit.show().css('display', 'inline'); + } + else { + $nomeField.val('') + $idField.val(''); + + $linkToEdit.hide(); + } +} + +var changeVisibilityOfLinksToPessoaPai = function() { + changeVisibilityOfLinksToPessoaParent('pai'); +} + +var changeVisibilityOfLinksToPessoaMae = function() { + changeVisibilityOfLinksToPessoaParent('mae'); +} + + +// children callbacks + +var afterSetSearchFields = function() { + $j('body,html').animate({ scrollTop: $j('#btn_enviar').offset().top }, 'fast'); + $j('#complemento').focus(); +}; + +var afterUnsetSearchFields = function() { + $j('body,html').animate({ scrollTop: $j('#btn_enviar').offset().top }, 'fast'); + $j('#cep_').focus(); +}; + +function afterChangePessoa(targetWindow, parentType, parentId, parentName) { + targetWindow.close(); + + var $idField = $j(buildId(parentType + '_id')); + var $nomeField = $j(buildId(parentType + '_nome')); + + // timeout para usuario perceber mudança + window.setTimeout(function() { + messageUtils.success('Pessoa alterada com sucesso', $nomeField); + + $idField.val(parentId); + $nomeField.val(parentId + ' - ' +parentName); + $nomeField.focus(); + + changeVisibilityOfLinksToPessoaParent(parentType); + + }, 500); +} + + +// simple search options + +var simpleSearchPaiOptions = { + autocompleteOptions : { close : changeVisibilityOfLinksToPessoaPai } +}; - $submitButton.removeAttr('onclick'); - $submitButton.click(submitForm); +var simpleSearchMaeOptions = { + autocompleteOptions : { close : changeVisibilityOfLinksToPessoaMae } +}; - }); // ready -})(jQuery); \ No newline at end of file +$paiNomeField.focusout(changeVisibilityOfLinksToPessoaPai); +$maeNomeField.focusout(changeVisibilityOfLinksToPessoaMae); \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css b/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css index 2892d9c..3e55879 100644 --- a/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css +++ b/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css @@ -5,5 +5,14 @@ } .pessoa-links a { + /* + obs: no firefox, ao mostrar o elemento (.show, jquery), é setado display como block, + para reparar isto, após chamar .show(), chamar .css('display', 'inline'); + */ + margin-right: 5px; +} + +#deficiencias_chzn ul { + width: 307px; } \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css b/ieducar/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css new file mode 100644 index 0000000..3c2670f --- /dev/null +++ b/ieducar/modules/Cadastro/Assets/Stylesheets/PessoaFisica.css @@ -0,0 +1,57 @@ +/* Por alguma razão, no chrome ao mudar o width dos elementos eles recuam 2px */ +@media screen and (-webkit-min-device-pixel-ratio:0) { + select, + #data_emissao_certidao_civil, + #termo_certidao_civil, + #certidao_nascimento, + #carteira_trabalho, + #data_emissao_carteira_trabalho, + #titulo_eleitor, + #data_nasc, + #complemento { + margin-left: 2px; + } +} + +select { + width: 184px !important; +} + +#estado_civil_id { + width: 133px !important; +} + +#data_emissao_rg, #uf_emissao_rg { + width: 135px !important; +} + +#data_emissao_certidao_civil, #data_emissao_carteira_trabalho, #data_nasc { + width: 98px; +} + +#termo_certidao_civil { + width: 121px !important; +} + +#carteira_trabalho, #titulo_eleitor, #complemento { + width: 170px; +} + +#zona_localizacao { + width: 182px !important; +} + +.pessoa-links { + display: block; + padding: 5px; + margin: 2px; +} + +.pessoa-links a { + /* + obs: no firefox, ao mostrar o elemento (.show, jquery), é setado display como block, + para reparar isto, após chamar .show(), chamar .css('display', 'inline'); + */ + + margin-right: 5px; +} \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Views/AlunoController.php b/ieducar/modules/Cadastro/Views/AlunoController.php index 3769508..ee07ad3 100644 --- a/ieducar/modules/Cadastro/Views/AlunoController.php +++ b/ieducar/modules/Cadastro/Views/AlunoController.php @@ -65,12 +65,12 @@ class AlunoController extends Portabilis_Controller_Page_EditController ), 'mae' => array( - 'label' => 'Mãe', + 'label' => 'Mãe', 'help' => '', ), 'responsavel' => array( - 'label' => 'Responsável', + 'label' => 'Responsável', 'help' => '', ), @@ -80,27 +80,27 @@ class AlunoController extends Portabilis_Controller_Page_EditController ), 'transporte' => array( - 'label' => 'Transporte público', + 'label' => 'Transporte público', 'help' => '', ), 'id' => array( - 'label' => 'Código aluno', + 'label' => 'Código aluno', 'help' => '', ), 'aluno_inep_id' => array( - 'label' => 'Código inep', + 'label' => 'Código inep', 'help' => '', ), 'aluno_estado_id' => array( - 'label' => 'Código rede estadual', + 'label' => 'Código rede estadual', 'help' => '', ), 'deficiencias' => array( - 'label' => 'Deficiências / habilidades especiais', + 'label' => 'Deficiências / habilidades especiais', 'help' => '', ) ); @@ -125,19 +125,19 @@ class AlunoController extends Portabilis_Controller_Page_EditController { $this->url_cancelar = '/intranet/educar_aluno_lst.php'; - // código rede de ensino municipal + // código aluno $options = array('label' => $this->_getLabel('id'), 'disabled' => true, 'required' => false, 'size' => 25); - $this->inputsHelper()->text('id', $options); + $this->inputsHelper()->integer('id', $options); // código aluno inep - $options = array('label' => $this->_getLabel('aluno_inep_id'), 'required' => false, 'size' => 25); - $this->inputsHelper()->text('aluno_inep_id', $options); + $options = array('label' => $this->_getLabel('aluno_inep_id'), 'required' => false, 'size' => 25, 'max_length' => 14); + $this->inputsHelper()->integer('aluno_inep_id', $options); // código aluno rede estadual - $options = array('label' => $this->_getLabel('aluno_estado_id'), 'required' => false, 'size' => 25); - $this->inputsHelper()->text('aluno_estado_id', $options); + $options = array('label' => $this->_getLabel('aluno_estado_id'), 'required' => false, 'size' => 25, 'max_length' => 9); + $this->inputsHelper()->integer('aluno_estado_id', $options); // nome $options = array('label' => $this->_getLabel('pessoa'), 'size' => 68); @@ -164,7 +164,10 @@ class AlunoController extends Portabilis_Controller_Page_EditController // responsável // tipo - $tiposResponsavel = array(null => 'Selecione', + + $label = Portabilis_String_Utils::toLatin1($this->_getLabel('responsavel')); + + $tiposResponsavel = array(null => $label, 'pai' => 'Pai', 'mae' => 'Mãe', 'outra_pessoa' => 'Outra pessoa'); @@ -185,7 +188,10 @@ class AlunoController extends Portabilis_Controller_Page_EditController // transporte publico - $tiposTransporte = array(null => 'Selecione', + + $label = Portabilis_String_Utils::toLatin1($this->_getLabel('transporte')); + + $tiposTransporte = array(null => $label, 'nenhum' => 'Não utiliza', 'municipal' => 'Municipal', 'estadual' => 'Estadual'); diff --git a/ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js b/ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js index 08e61e3..480143a 100644 --- a/ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js +++ b/ieducar/modules/Portabilis/Assets/Javascripts/Frontend/Inputs/SimpleSearch.js @@ -28,9 +28,6 @@ var defaultSimpleSearchOptions = { attrName : undefined, searchPath : undefined, - // options that can be overwritten - placeholder : 'Informe um valor', - // additional search params to send to api params : {}, @@ -124,8 +121,6 @@ var simpleSearch = { $input.data('simple-search-options', options); $input.data('hidden-input-id', $hiddenInput); - $input.attr('placeholder', options.get('placeholder')); - $hiddenInput.addClass('simple-search-id'); $hiddenInput.attr('data-for', $input.attr('id')); diff --git a/ieducar/modules/Portabilis/Assets/Javascripts/Utils.js b/ieducar/modules/Portabilis/Assets/Javascripts/Utils.js index 43a6e61..bd9fbf7 100644 --- a/ieducar/modules/Portabilis/Assets/Javascripts/Utils.js +++ b/ieducar/modules/Portabilis/Assets/Javascripts/Utils.js @@ -2,7 +2,7 @@ // jquery utils function buildId(id) { - return typeof(id) == 'string' && id.length > 0 && id[0] != '#' ? '#' + id : id; + return typeof(id) == 'string' && id.length > 0 && id.charAt(0) != '#' ? '#' + id : id; } @@ -216,67 +216,57 @@ var messageUtils = { notice : function(msg, targetId) { handleMessages([{type : 'notice', msg : safeUtf8Decode(msg)}], targetId); - } -}; + }, -function handleMessages(messages, targetId, useDelayClassRemoval) { - - var $feedbackMessages = $j('#feedback-messages'); - var hasErrorMessages = false; - var hasSuccessMessages = false; - var hasNoticeMessages = false; - var delayClassRemoval = 20000; - - var $targetElement = buildId(targetId); - var $targetElement = $j($targetElement); - - for (var i = 0; i < messages.length; i++) { - if (messages[i].type == 'success') - var delay = 5000; - else if (messages[i].type != 'error') - var delay = 10000; - else - var delay = 20000; - - $j('

').hide() - .addClass(messages[i].type) - .html(safeUtf8Decode(messages[i].msg)) - .appendTo($feedbackMessages) - .fadeIn() - .delay(delay) - .fadeOut(function() { $j(this).remove() }) - .data('target_id', targetId); - - if (! hasErrorMessages && messages[i].type == 'error') - hasErrorMessages = true; - else if(! hasSuccessMessages && messages[i].type == 'success') - hasSuccessMessages = true; - else if(! hasNoticeMessages && messages[i].type == 'notice') - hasNoticeMessages = true; - } + removeStyle : function(targetElementOrId, delay) { + // 30 seconds, by default + if (delay == undefined) + delay = 30000; - if($targetElement) { - if (hasErrorMessages) { - $targetElement.addClass('error').removeClass('success').removeClass('notice'); - $targetElement.first().focus(); - } + var $targetElement = $j(buildId(targetElementOrId)); - else if (hasSuccessMessages) - $targetElement.addClass('success').removeClass('error').removeClass('notice'); + window.setTimeout(function() { + $targetElement.removeClass('success').removeClass('error').removeClass('notice'); + }, delay); + + }, - else if (hasNoticeMessages) - $targetElement.addClass('notice').removeClass('error').removeClass('sucess'); + handleMessages : function(messages, targetElementOrId) { - else - $targetElement.removeClass('success').removeClass('error').removeClass('notice'); + var $feedbackMessages = $j('#feedback-messages'); + var $targetElement = $j(buildId(targetElementOrId)); + var messagesType = []; - if (useDelayClassRemoval) { - window.setTimeout(function() { - $targetElement.removeClass('success').removeClass('error').removeClass('notice'); - }, delayClassRemoval); + for (var i = 0; i < messages.length; i++) { + var delay = messages[i].type == 'success' ? 5000 : 10000; + + $j('

').hide() + .data('target_id', $targetElement.attr('id')) + .addClass(messages[i].type) + .html(stringUtils.toUtf8(messages[i].msg)) + .appendTo($feedbackMessages) + .fadeIn().delay(delay).fadeOut(function() { + $j(this).remove() + }); + + if (messagesType.indexOf(messages[i].type < 0)) + messagesType.push(messages[i].type); + } + + if ($targetElement) { + $targetElement.removeClass('error').removeClass('success').removeClass('notice'); + + $targetElement.addClass(messagesType.join(' ')); + messageUtils.removeStyle($targetElement); + + if (messagesType.indexOf('error') > -1) + $targetElement.first().focus(); } } -} +}; + +// backward compatibility +var handleMessages = messageUtils.handleMessages; // when page is ready diff --git a/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js b/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js index 37f173d..719bbda 100644 --- a/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js +++ b/ieducar/modules/Portabilis/Assets/Javascripts/Validator.js @@ -11,11 +11,14 @@ var validationUtils = { var fields = $j("input[id^='data_'][value!=''], input[id^='dt_'][value!='']"); $j.each(fields, function(index, field) { - allValid = validationUtils.validatesDate(field.value); - }); + if (! validationUtils.validatesDate(field.value)) { + messageUtils.error('Informe a data corretamente.', field); + allValid = false; - if (! allValid) - messageUtils.error('Informe a data corretamente.', fields.first()); + // break jquery loop + return false; + } + }); return allValid; }, @@ -69,7 +72,7 @@ var validationUtils = { function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields) { var $emptyFields = []; - requiredFields = document.getElementsByClassName('obrigatorio'); + requiredFields = $j('.obrigatorio:not(.skip-presence-validation)'); if (additionalFields) requiredFields = $j.merge(requiredFields, additionalFields); @@ -78,7 +81,7 @@ function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields simpleSearch.fixupRequiredFieldsValidation(); for (var i = 0; i < requiredFields.length; i++) { - var $requiredField = $j(requiredFields[i]); + var $requiredField = $j(requiredFields[i]); if ($requiredField.length > 0 && /*$requiredField.css('display') != 'none' &&*/ @@ -91,6 +94,8 @@ function validatesPresenseOfValueInRequiredFields(additionalFields, exceptFields if (! $requiredField.hasClass('error')) $requiredField.addClass('error'); + + messageUtils.removeStyle($requiredField); } else if ($requiredField.length > 0) $requiredField.removeClass('error'); diff --git a/ieducar/modules/Portabilis/Assets/Version.php b/ieducar/modules/Portabilis/Assets/Version.php index 02f0c29..fa22138 100644 --- a/ieducar/modules/Portabilis/Assets/Version.php +++ b/ieducar/modules/Portabilis/Assets/Version.php @@ -4,7 +4,7 @@ usado pelo metodos loadJavascript e loadStylesheet do helper Portabilis_View_Helper_Application */ class Portabilis_Assets_Version { - const VERSION = "0_0_0_1004"; + const VERSION = "0_0_0_1005"; } ?> -- libgit2 0.21.2