From f92f05501c08ccb852c88afc8bf8d9075e39f248 Mon Sep 17 00:00:00 2001 From: wilian Date: Thu, 26 Nov 2020 13:04:35 +0000 Subject: [PATCH] fixes bug#20923 dev:wilian qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@104529 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../sendaAmigo/EditarClienteController.java | 157 +++++++++++------- web/WEB-INF/i3-label_es_MX.label | 2 + web/WEB-INF/i3-label_pt_BR.label | 3 +- 3 files changed, 101 insertions(+), 61 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/sendaAmigo/EditarClienteController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/sendaAmigo/EditarClienteController.java index 3464270b6..93547ada0 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/sendaAmigo/EditarClienteController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/sendaAmigo/EditarClienteController.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.brazilutils.br.cpfcnpj.Cpf; @@ -35,11 +36,13 @@ import org.zkoss.zul.Radiogroup; import org.zkoss.zul.Tab; import org.zkoss.zul.Textbox; +import com.rjconsultores.ventaboletos.constantes.Constantes; import com.rjconsultores.ventaboletos.entidad.Cliente; import com.rjconsultores.ventaboletos.entidad.ClienteCurso; import com.rjconsultores.ventaboletos.entidad.ClienteDescuento; import com.rjconsultores.ventaboletos.entidad.ClienteDireccion; import com.rjconsultores.ventaboletos.entidad.ClienteFidelidad; +import com.rjconsultores.ventaboletos.entidad.Constante; import com.rjconsultores.ventaboletos.entidad.Curso; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.Escola; @@ -52,6 +55,7 @@ import com.rjconsultores.ventaboletos.entidad.TipoIdentificacion; import com.rjconsultores.ventaboletos.entidad.TipoOcupacion; import com.rjconsultores.ventaboletos.service.ClienteCursoService; import com.rjconsultores.ventaboletos.service.ClienteService; +import com.rjconsultores.ventaboletos.service.ConstanteService; import com.rjconsultores.ventaboletos.service.EmpresaService; import com.rjconsultores.ventaboletos.service.EscolaService; import com.rjconsultores.ventaboletos.service.MotivoViajeService; @@ -96,6 +100,9 @@ public class EditarClienteController extends MyGenericForwardComposer { @Autowired TipoIdentificacionService tipoIdentificacionService; + + @Autowired + ConstanteService constanteService; private Cliente cliente; private MyListbox clienteList; @@ -853,67 +860,9 @@ public class EditarClienteController extends MyGenericForwardComposer { cmbMotivacionViaje.getValue(); cmbOcupacion.getValue(); - if (txtNumRfc.getText() != null && !txtNumRfc.getText().isEmpty()) { - if ( cmbTipoIdentificacion != null - && cmbTipoIdentificacion.getSelectedItem() != null - && cmbTipoIdentificacion.getSelectedItem().getValue() != null - && CPF.equals(cmbTipoIdentificacion.getSelectedItem().getValue().toString())) { - String numDoc = txtNumRfc.getText(); - if(!validarCPF(numDoc)) { - Messagebox.show(Labels.getLabel("editarClienteController.MSG.validacaoCPFInvalido"), - Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, - Messagebox.EXCLAMATION); - txtNumRfc.focus(); - return; - } - } - } - if (txtNumRfc2.getText() != null && !txtNumRfc2.getText().isEmpty()) { - if ( cmbTipoIdentificacion2 != null - && cmbTipoIdentificacion2.getSelectedItem() != null - && cmbTipoIdentificacion2.getSelectedItem().getValue() != null - && CPF.equals(cmbTipoIdentificacion2.getSelectedItem().getValue().toString())) { - String numDoc = txtNumRfc2.getText(); - if(!validarCPF(numDoc)) { - Messagebox.show(Labels.getLabel("editarClienteController.MSG.validacaoCPFInvalido"), - Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, - Messagebox.EXCLAMATION); - txtNumRfc2.focus(); - return; - } - } - } - List lsCliente = new ArrayList(); - if ((txtNumRfc.getText() != null && !txtNumRfc.getText().isEmpty()) && cmbTipoIdentificacion != null - && cmbTipoIdentificacion.getSelectedItem() != null - && cmbTipoIdentificacion.getSelectedItem().getValue() != null - && CPF.equals(cmbTipoIdentificacion.getSelectedItem().getValue().toString())){ - lsCliente = clienteService.buscarPorDocumento(txtNumRfc.getValue()); - if (lsCliente.size() > 1 - || (lsCliente.size() == 1 && !lsCliente.get(0).getClienteId().equals(cliente.getClienteId()))) { - Messagebox.show(Labels.getLabel("editarClienteController.MSG.documentoexiste"), - Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, - Messagebox.EXCLAMATION); - txtNumRfc.focus(); - return; - } - } - - if (txtNumRfc2.getText() != null && !txtNumRfc2.getText().isEmpty() && cmbTipoIdentificacion2 != null - && cmbTipoIdentificacion2.getSelectedItem() != null - && cmbTipoIdentificacion2.getSelectedItem().getValue() != null - && CPF.equals(cmbTipoIdentificacion2.getSelectedItem().getValue().toString())) { - lsCliente = clienteService.buscarPorDocumento(txtNumRfc2.getValue()); - if (lsCliente.size() > 1 - || (lsCliente.size() == 1 && !lsCliente.get(0).getClienteId().equals(cliente.getClienteId()))) { - Messagebox.show(Labels.getLabel("editarClienteController.MSG.documentoexiste"), - Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, - Messagebox.EXCLAMATION); - txtNumRfc2.focus(); - return; - } - + if(!validarCampos()) { + return; } if (StringUtils.isNotBlank(this.replaceTextbox(txtNumFax))) { @@ -990,6 +939,94 @@ public class EditarClienteController extends MyGenericForwardComposer { } + private boolean validarCampos() throws InterruptedException { + if (txtNumRfc.getText() != null && !txtNumRfc.getText().isEmpty()) { + if ( cmbTipoIdentificacion != null + && cmbTipoIdentificacion.getSelectedItem() != null + && cmbTipoIdentificacion.getSelectedItem().getValue() != null + && CPF.equals(cmbTipoIdentificacion.getSelectedItem().getValue().toString())) { + String numDoc = txtNumRfc.getText(); + if(!validarCPF(numDoc)) { + Messagebox.show(Labels.getLabel("editarClienteController.MSG.validacaoCPFInvalido"), + Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, + Messagebox.EXCLAMATION); + txtNumRfc.focus(); + return false; + } + } + } + + if (txtNumRfc2.getText() != null && !txtNumRfc2.getText().isEmpty()) { + if ( cmbTipoIdentificacion2 != null + && cmbTipoIdentificacion2.getSelectedItem() != null + && cmbTipoIdentificacion2.getSelectedItem().getValue() != null + && CPF.equals(cmbTipoIdentificacion2.getSelectedItem().getValue().toString())) { + String numDoc = txtNumRfc2.getText(); + if(!validarCPF(numDoc)) { + Messagebox.show(Labels.getLabel("editarClienteController.MSG.validacaoCPFInvalido"), + Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, + Messagebox.EXCLAMATION); + txtNumRfc2.focus(); + return false; + } + } + } + List lsCliente = new ArrayList(); + if ((txtNumRfc.getText() != null && !txtNumRfc.getText().isEmpty()) && cmbTipoIdentificacion != null + && cmbTipoIdentificacion.getSelectedItem() != null + && cmbTipoIdentificacion.getSelectedItem().getValue() != null + && CPF.equals(cmbTipoIdentificacion.getSelectedItem().getValue().toString())){ + lsCliente = clienteService.buscarPorDocumento(txtNumRfc.getValue()); + if (lsCliente.size() > 1 + || (lsCliente.size() == 1 && !lsCliente.get(0).getClienteId().equals(cliente.getClienteId()))) { + Messagebox.show(Labels.getLabel("editarClienteController.MSG.documentoexiste"), + Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, + Messagebox.EXCLAMATION); + txtNumRfc.focus(); + return false; + } + } + + if (txtNumRfc2.getText() != null && !txtNumRfc2.getText().isEmpty() && cmbTipoIdentificacion2 != null + && cmbTipoIdentificacion2.getSelectedItem() != null + && cmbTipoIdentificacion2.getSelectedItem().getValue() != null + && CPF.equals(cmbTipoIdentificacion2.getSelectedItem().getValue().toString())) { + lsCliente = clienteService.buscarPorDocumento(txtNumRfc2.getValue()); + if (lsCliente.size() > 1 + || (lsCliente.size() == 1 && !lsCliente.get(0).getClienteId().equals(cliente.getClienteId()))) { + Messagebox.show(Labels.getLabel("editarClienteController.MSG.documentoexiste"), + Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, + Messagebox.EXCLAMATION); + txtNumRfc2.focus(); + return false; + } + + } + + Constante exigeEmailOuTelefone = constanteService.buscarPorNomeConstante(Constantes.EXIGE_EMAIL_OU_TEL_CAD_CLIENTE); + if(exigeEmailOuTelefone != null && BooleanUtils.toBoolean(exigeEmailOuTelefone.getValorconstante())) { + + boolean isTelefoneNaoInformado = StringUtils.isBlank(this.replaceTextbox(txtNumFax)) && + StringUtils.isBlank(this.replaceTextbox(numtelefonouno)) && + StringUtils.isBlank(this.replaceTextbox(numtelefonodos)); + + boolean isEmailNaoInformado = StringUtils.isBlank(txtDescorreo.getValue()); + + if(isTelefoneNaoInformado && isEmailNaoInformado) { + Messagebox.show(Labels.getLabel("editarClienteController.MSG.exigeEmailOuTelefone"), + Labels.getLabel("editarClienteController.window.title"), Messagebox.OK, + Messagebox.EXCLAMATION); + return false; + } + + } + + + + return true; + } + + /** * @param numDoc * @throws InterruptedException diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 28db6d99d..88329dbd1 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -4520,6 +4520,7 @@ editarEstacionController.lbNumEmpresa.value = Código de la empresa/Identificado editarEstacionController.lbNumFilial.value = Código de la filial editarEstacionController.lbNumPdv.value = No do PDV/Ponto de Captura editarEstacionController.tab.label.impresora = Impresoras +editarEstacionController.MSG.numEmpresa= El campo {0} solo permite números # Búsqueda Excepción ida y regreso busquedaExceptionRedondoController.window.title = Excepción viaje ida y regreso @@ -6471,6 +6472,7 @@ busquedaClienteController.nombmaterno.label = Apellido Materno busquedaClienteController.numtelefono.label = Teléfono busquedaClienteController.numtelefonodos.label = Celular busquedaClienteController.lbDescorreo.value = E-mail +editarClienteController.MSG.exigeEmailOuTelefone = Ingrese correo electrónico o teléfono #Editar Cliente editarClienteController.window.title = Cliente diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 9b5c22246..bbd55d05a 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -4758,6 +4758,7 @@ editarEstacionController.lbNumEmpresa.value = Código da Empresa/Identificador d editarEstacionController.lbNumFilial.value = Código da Filial editarEstacionController.lbNumPdv.value = Número PDV/Ponto de Captura editarEstacionController.tab.label.impresora = Impressoras +editarEstacionController.MSG.numEmpresa= O campo {0} permite somente números # Pesquisa Exceção Ida e Volta busquedaExceptionRedondoController.window.title = Exceção Viagem Ida e Volta @@ -6759,7 +6760,7 @@ busquedaClienteController.nombmaterno.label = Sobrenome Materno busquedaClienteController.numtelefono.label = Telefone busquedaClienteController.numtelefonodos.label = Celular busquedaClienteController.lbDescorreo.value = E-mail - +editarClienteController.MSG.exigeEmailOuTelefone = Informe o E-mail ou Telefone #Editar Cliente editarClienteController.window.title = Cliente