From a689834eafb0dd492803ee6376acafc2f29dede8 Mon Sep 17 00:00:00 2001 From: "bruno.neves" Date: Fri, 7 Jul 2017 22:40:22 +0000 Subject: [PATCH] bug #0009181 bug #0009182 - git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@71155 d1611594-4594-4d17-8e1d-87c2c4800839 --- ...quedaMotivoDevolucaoBilheteController.java | 139 ++++++++++++++ ...ditarMotivoDevolucaoBilheteController.java | 170 ++++++++++++++++++ .../ItemMenuMotivoDevolucaoBilhete.java | 26 +++ .../utilerias/menu/menu_original.properties | 1 + .../render/RenderMotivoDevolucaoBilhete.java | 29 +++ .../render/RenderPrecoFixoPedagio.java | 4 +- .../busquedaMotivoDevolucaoBilhete.zul | 63 +++++++ .../editarMotivoDevolucaoBilhete.zul | 48 +++++ 8 files changed, 478 insertions(+), 2 deletions(-) create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/BusquedaMotivoDevolucaoBilheteController.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoDevolucaoBilheteController.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/confcomerciales/ItemMenuMotivoDevolucaoBilhete.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderMotivoDevolucaoBilhete.java create mode 100644 web/gui/configuraciones_comerciales/busquedaMotivoDevolucaoBilhete.zul create mode 100644 web/gui/configuraciones_comerciales/editarMotivoDevolucaoBilhete.zul diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/BusquedaMotivoDevolucaoBilheteController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/BusquedaMotivoDevolucaoBilheteController.java new file mode 100644 index 000000000..380c58ad0 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/BusquedaMotivoDevolucaoBilheteController.java @@ -0,0 +1,139 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales; + +import java.util.HashMap; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.util.resource.Labels; +import org.zkoss.zhtml.Messagebox; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zul.Combobox; +import org.zkoss.zul.Paging; +import org.zkoss.zul.Textbox; + +import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderMotivoDevolucaoBilhete; + +/** + * + * @author Bruno Neves + */ +@Controller("busquedaMotivoDevolucaoBilheteController") +@Scope("prototype") +public class BusquedaMotivoDevolucaoBilheteController extends MyGenericForwardComposer { + + @Autowired + private transient PagedListWrapper plwMotivoDevolucaoBilhete; + private MyListbox motivoDevolucaoBilheteList; + private Paging pagingMotivoDevolucaoBilhete; + private Textbox txtNombre; + private Combobox cmbTipoMotivo; + + public Combobox getCmbTipoMotivo() { + return cmbTipoMotivo; + } + + public void setCmbTipoMotivo(Combobox cmbTipoMotivo) { + this.cmbTipoMotivo = cmbTipoMotivo; + } + + public Paging getPagingMotivoDevolucaoBilhete() { + return pagingMotivoDevolucaoBilhete; + } + + public void setPagingMotivoDevolucaoBilhete(Paging pagingMotivoDevolucaoBilhete) { + this.pagingMotivoDevolucaoBilhete = pagingMotivoDevolucaoBilhete; + } + + public MyListbox getMotivoDevolucaoBilheteList() { + return motivoDevolucaoBilheteList; + } + + public void setMotivoDevolucaoBilheteList(MyListbox motivoDevolucaoBilheteList) { + this.motivoDevolucaoBilheteList = motivoDevolucaoBilheteList; + } + + public PagedListWrapper getPlwMotivoDevolucaoBilhete() { + return plwMotivoDevolucaoBilhete; + } + + public void setPlwMotivoDevolucaoBilhete(PagedListWrapper plwMotivoDevolucaoBilhete) { + this.plwMotivoDevolucaoBilhete = plwMotivoDevolucaoBilhete; + } + + public void onClick$btnPesquisa(Event ev) throws InterruptedException { + refreshLista(); + } + + public void onClick$btnRefresh(Event ev) { + refreshLista(); + } + + public void onClick$btnNovo(Event ev) { + verPeriodo(new MotivoDevolucaoBilhete()); + } + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + + motivoDevolucaoBilheteList.setItemRenderer(new RenderMotivoDevolucaoBilhete()); + motivoDevolucaoBilheteList.addEventListener("onDoubleClick", new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + MotivoDevolucaoBilhete mc = (MotivoDevolucaoBilhete) motivoDevolucaoBilheteList.getSelected(); + verPeriodo(mc); + } + }); + + refreshLista(); + + txtNombre.focus(); + } + + private void verPeriodo(MotivoDevolucaoBilhete mc) { + if (mc == null) { + return; + } + + Map args = new HashMap(); + args.put("motivoDevolucaoBilhete", mc); + args.put("motivoDevolucaoBilheteList", motivoDevolucaoBilheteList); + + openWindow("/gui/configuraciones_comerciales/editarMotivoDevolucaoBilhete.zul", + Labels.getLabel("editarMotivoDevolucaoBilheteController.window.title"), args, MODAL); + } + + private void refreshLista() { + HibernateSearchObject claseServicioBusqueda = + new HibernateSearchObject(MotivoDevolucaoBilhete.class, pagingMotivoDevolucaoBilhete.getPageSize()); + + claseServicioBusqueda.addFilterLike("descmotivo", "%" + txtNombre.getText().trim().concat("%")); + claseServicioBusqueda.addFilterEqual("activo", true); + claseServicioBusqueda.addSortAsc("descmotivo"); + + plwMotivoDevolucaoBilhete.init(claseServicioBusqueda, motivoDevolucaoBilheteList, pagingMotivoDevolucaoBilhete); + + if (motivoDevolucaoBilheteList.getData().length == 0) { + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("busquedaMotivoDevolucaoBilheteController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + } + } + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoDevolucaoBilheteController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoDevolucaoBilheteController.java new file mode 100644 index 000000000..b35653b39 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/configuracioneccomerciales/EditarMotivoDevolucaoBilheteController.java @@ -0,0 +1,170 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales; + +import java.util.Calendar; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.util.resource.Labels; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zul.Button; +import org.zkoss.zul.Messagebox; +import org.zkoss.zul.Textbox; + +import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete; +import com.rjconsultores.ventaboletos.service.MotivoDevolucaoBilheteService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; + +/** + * + * @author Bruno Neves + */ +@Controller("editarMotivoDevolucaoBilheteController") +@Scope("prototype") +public class EditarMotivoDevolucaoBilheteController extends MyGenericForwardComposer { + + private static final long serialVersionUID = 1L; + + @Autowired + private MotivoDevolucaoBilheteService motivoDevolucaoBilheteService; + private MotivoDevolucaoBilhete motivoDevolucaoBilhete; + private MyListbox motivoDevolucaoBilheteList; + private static Logger log = Logger.getLogger(EditarMotivoDevolucaoBilheteController.class); + private Textbox txtNome; + private Button btnApagar; + + + public Button getBtnApagar() { + return btnApagar; + } + + public void setBtnApagar(Button btnApagar) { + this.btnApagar = btnApagar; + } + + public Textbox getTxtNome() { + return txtNome; + } + + public void setTxtNome(Textbox txtNome) { + this.txtNome = txtNome; + } + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + + motivoDevolucaoBilhete = (MotivoDevolucaoBilhete) Executions.getCurrent().getArg().get("motivoDevolucaoBilhete"); + motivoDevolucaoBilheteList = (MyListbox) Executions.getCurrent().getArg().get("motivoDevolucaoBilheteList"); + + if (motivoDevolucaoBilhete.getMotivodevolucaobilheteId() == null) { + btnApagar.setVisible(Boolean.FALSE); + } else { + if (motivoDevolucaoBilheteService.validaMotivoDevolucaoBilheteConstante(motivoDevolucaoBilhete)) { + btnApagar.setVisible(false); + txtNome.setDisabled(true); + + Messagebox.show( + Labels.getLabel("MSG.noEditabled"), + Labels.getLabel("editarMotivoDevolucaoBilheteController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } + } + if (motivoDevolucaoBilhete.getMotivodevolucaobilheteId() == 1 ) { + btnApagar.setVisible(Boolean.FALSE); + txtNome.setDisabled(Boolean.TRUE); + + + Messagebox.show( + Labels.getLabel("MSG.noEditabled"), + Labels.getLabel("editarFormaPagoController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } + + txtNome.focus(); + } + + public void onClick$btnSalvar(Event ev) throws InterruptedException { + txtNome.getValue(); + try { + motivoDevolucaoBilhete.setDescmotivo(txtNome.getValue()); + motivoDevolucaoBilhete.setActivo(true); + motivoDevolucaoBilhete.setFecmodif(Calendar.getInstance().getTime()); + motivoDevolucaoBilhete.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + if (motivoDevolucaoBilhete.getMotivodevolucaobilheteId() == null) { + motivoDevolucaoBilhete = motivoDevolucaoBilheteService.suscribir(motivoDevolucaoBilhete); + motivoDevolucaoBilheteList.addItem(motivoDevolucaoBilhete); + }else{ + motivoDevolucaoBilhete = motivoDevolucaoBilheteService.actualizacion(motivoDevolucaoBilhete); + motivoDevolucaoBilheteList.updateItem(motivoDevolucaoBilhete);; + } + closeWindow(); + + } catch (Exception ex) { + log.error("editarMotivoDevolucaoBilheteController: " + ex); + Messagebox.show( + Labels.getLabel("MSG.Error"), + Labels.getLabel("editarMotivoDevolucaoBilheteController.window.title"), + Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagar(Event ev) { + try { + + int resp = Messagebox.show( + Labels.getLabel("editarMotivoDevolucaoBilheteController.MSG.borrarPergunta"), + Labels.getLabel("editarMotivoDevolucaoBilheteController.window.title"), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + motivoDevolucaoBilheteService.borrar(motivoDevolucaoBilhete); + + Messagebox.show( + Labels.getLabel("editarMotivoDevolucaoBilheteController.MSG.borrarOK"), + Labels.getLabel("editarMotivoDevolucaoBilheteController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + + motivoDevolucaoBilheteList.removeItem(motivoDevolucaoBilhete); + + closeWindow(); + } + } catch (Exception ex) { + log.error(ex); + } + } + + public MotivoDevolucaoBilhete getMotivoDevolucaoBilhete() { + return motivoDevolucaoBilhete; + } + + public void setMotivoDevolucaoBilhete(MotivoDevolucaoBilhete motivoDevolucaoBilhete) { + this.motivoDevolucaoBilhete = motivoDevolucaoBilhete; + } + + public MyListbox getMotivoDevolucaoBilheteList() { + return motivoDevolucaoBilheteList; + } + + public void setMotivoDevolucaoBilheteList(MyListbox motivoDevolucaoBilheteList) { + this.motivoDevolucaoBilheteList = motivoDevolucaoBilheteList; + } + + public MotivoDevolucaoBilheteService getMotivoDevolucaoBilheteService() { + return motivoDevolucaoBilheteService; + } + + public void setMotivoDevolucaoBilheteService(MotivoDevolucaoBilheteService motivoDevolucaoBilheteService) { + this.motivoDevolucaoBilheteService = motivoDevolucaoBilheteService; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/confcomerciales/ItemMenuMotivoDevolucaoBilhete.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/confcomerciales/ItemMenuMotivoDevolucaoBilhete.java new file mode 100644 index 000000000..710895343 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/confcomerciales/ItemMenuMotivoDevolucaoBilhete.java @@ -0,0 +1,26 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuMotivoDevolucaoBilhete extends DefaultItemMenuSistema { + + public ItemMenuMotivoDevolucaoBilhete() { + super("indexController.mniMotivoDevolucaoBilhete.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.CATALOGO.MENU.MOTIVOSDELADEVOLUCAOBILHETE"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/configuraciones_comerciales/busquedaMotivoDevolucaoBilhete.zul", + Labels.getLabel("busquedaMotivoDevolucaoBilheteController.window.title"), getArgs(), desktop); + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties index 222882d22..b9b253428 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties @@ -43,6 +43,7 @@ confComerciales.secretaria=com.rjconsultores.ventaboletos.web.utilerias.menu.ite confComerciales.convenio=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuConvenio confComerciales.tipoCambioCiudad=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuTipoCambioCiudad confComerciales.motivoCancelacion=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuMotivoCancelacion +confComerciales.motivoDevolucaoBilhete=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuMotivoDevolucaoBilhete confComerciales.configuracionCancelacion=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuConfiguracionCancelacion confComerciales.configuracionCategorias=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuConfiguracionCategorias confComerciales.configuracionReservacion=com.rjconsultores.ventaboletos.web.utilerias.menu.item.confcomerciales.ItemMenuConfiguracionReservacion diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderMotivoDevolucaoBilhete.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderMotivoDevolucaoBilhete.java new file mode 100644 index 000000000..138361fb0 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderMotivoDevolucaoBilhete.java @@ -0,0 +1,29 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.utilerias.render; + +import com.rjconsultores.ventaboletos.entidad.MotivoDevolucaoBilhete; +import org.zkoss.zul.Listcell; +import org.zkoss.zul.Listitem; +import org.zkoss.zul.ListitemRenderer; + +/** + * + * @author Bruno Neves + */ +public class RenderMotivoDevolucaoBilhete implements ListitemRenderer { + + public void render(Listitem lstm, Object o) throws Exception { + MotivoDevolucaoBilhete motivoDevolucaoBilhete = (MotivoDevolucaoBilhete) o; + + Listcell lc = new Listcell(motivoDevolucaoBilhete.getMotivodevolucaobilheteId().toString()); + lc.setParent(lstm); + + lc = new Listcell(motivoDevolucaoBilhete.getDescmotivo()); + lc.setParent(lstm); + + lstm.setAttribute("data", motivoDevolucaoBilhete); + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderPrecoFixoPedagio.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderPrecoFixoPedagio.java index adca8db1f..bdfe9484b 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderPrecoFixoPedagio.java +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderPrecoFixoPedagio.java @@ -12,9 +12,9 @@ public class RenderPrecoFixoPedagio implements ListitemRenderer { PrecioFixoPedagio cp = (PrecioFixoPedagio) o; if (cp != null) { - Listcell lc = new Listcell(cp.getOrgaoConcedenteId().toString()); + Listcell lc = new Listcell(cp.getOrgaoConcedenteId() == null ? "": cp.getOrgaoConcedenteId().toString()); lc.setParent(lstm); - lc = new Listcell(cp.getClasseId().toString()); + lc = new Listcell(cp.getClasseId() == null ? "": cp.getClasseId().toString()); lc.setParent(lstm); lc = new Listcell(cp.getValorFixo().toString()); lc.setParent(lstm); diff --git a/web/gui/configuraciones_comerciales/busquedaMotivoDevolucaoBilhete.zul b/web/gui/configuraciones_comerciales/busquedaMotivoDevolucaoBilhete.zul new file mode 100644 index 000000000..19856a985 --- /dev/null +++ b/web/gui/configuraciones_comerciales/busquedaMotivoDevolucaoBilhete.zul @@ -0,0 +1,63 @@ + + + + + + + + + +