diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarTarifaMinimaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarTarifaMinimaController.java index c2add93e9..c12a1dd94 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarTarifaMinimaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/tarifas/EditarTarifaMinimaController.java @@ -4,26 +4,6 @@ */ package com.rjconsultores.ventaboletos.web.gui.controladores.tarifas; -import com.rjconsultores.ventaboletos.entidad.ClaseServicio; -import com.rjconsultores.ventaboletos.entidad.Marca; -import com.rjconsultores.ventaboletos.entidad.Moneda; -import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; -import com.rjconsultores.ventaboletos.entidad.Parada; -import com.rjconsultores.ventaboletos.entidad.Plaza; -import com.rjconsultores.ventaboletos.entidad.TarifaMinima; -import com.rjconsultores.ventaboletos.service.ClaseServicioService; -import com.rjconsultores.ventaboletos.service.MarcaService; -import com.rjconsultores.ventaboletos.service.MonedaService; -import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; -import com.rjconsultores.ventaboletos.service.ParadaService; -import com.rjconsultores.ventaboletos.service.PlazaService; -import com.rjconsultores.ventaboletos.service.TarifaMinimaService; -import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; -import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada; -import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; -import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; -import com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal; - import java.util.Calendar; import java.util.List; @@ -39,6 +19,30 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Button; import org.zkoss.zul.Combobox; +import com.rjconsultores.ventaboletos.entidad.Categoria; +import com.rjconsultores.ventaboletos.entidad.ClaseServicio; +import com.rjconsultores.ventaboletos.entidad.Marca; +import com.rjconsultores.ventaboletos.entidad.Moneda; +import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente; +import com.rjconsultores.ventaboletos.entidad.Plaza; +import com.rjconsultores.ventaboletos.entidad.TarifaMinima; +import com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria; +import com.rjconsultores.ventaboletos.service.CategoriaService; +import com.rjconsultores.ventaboletos.service.ClaseServicioService; +import com.rjconsultores.ventaboletos.service.MarcaService; +import com.rjconsultores.ventaboletos.service.MonedaService; +import com.rjconsultores.ventaboletos.service.OrgaoConcedenteService; +import com.rjconsultores.ventaboletos.service.ParadaService; +import com.rjconsultores.ventaboletos.service.PlazaService; +import com.rjconsultores.ventaboletos.service.TarifaMinimaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxParada; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTarifaMinimaCategoria; + /** * * @author rodrigo @@ -47,7 +51,9 @@ import org.zkoss.zul.Combobox; @Scope("prototype") public class EditarTarifaMinimaController extends MyGenericForwardComposer { - @Autowired + private static final long serialVersionUID = 1L; + + @Autowired private TarifaMinimaService tarifaMinimaService; @Autowired private MarcaService marcaService; @@ -61,6 +67,9 @@ public class EditarTarifaMinimaController extends MyGenericForwardComposer { private MonedaService monedaService; @Autowired private OrgaoConcedenteService orgaoConcedenteService; + @Autowired + private CategoriaService categoriaService; + private List lsMoneda; private List lsMarcas; private List lsClaseServico; @@ -79,6 +88,10 @@ public class EditarTarifaMinimaController extends MyGenericForwardComposer { private List lsOrgaoConcedente; private static Logger log = Logger.getLogger(EditarTarifaMinimaController.class); + private List lsCategorias; + private MyComboboxEstandar cmbCategorias; + private MyListbox tarifaMinimaCategoriaList; + public List getLsMoneda() { return lsMoneda; } @@ -214,6 +227,7 @@ public class EditarTarifaMinimaController extends MyGenericForwardComposer { tarifaMinima = (TarifaMinima) Executions.getCurrent().getArg().get("tarifaMinima"); tarifaMinimaList = (MyListbox) Executions.getCurrent().getArg().get("tarifaMinimaList"); + lsCategorias = categoriaService.obtenerTodasCategoriasVisibles(); lsOrgaoConcedente = orgaoConcedenteService.obtenerTodos(); lsMoneda = monedaService.obtenerTodos(); lsMarcas = marcaService.buscarMarcaPorEmpresa(UsuarioLogado.getUsuarioLogado().getEmpresa()); @@ -222,8 +236,13 @@ public class EditarTarifaMinimaController extends MyGenericForwardComposer { if (tarifaMinima.getTarifaminimaId() == null) { btnApagar.setVisible(Boolean.FALSE); + } else { + tarifaMinima = tarifaMinimaService.obtenerID(tarifaMinima.getTarifaminimaId()); } txtImportancia.focus(); + + tarifaMinimaCategoriaList.setItemRenderer(new RenderTarifaMinimaCategoria()); + tarifaMinimaCategoriaList.setData(tarifaMinima.getTarifaMinimaCategorias()); } public void onClick$btnSalvar(Event ev) throws InterruptedException { @@ -355,6 +374,62 @@ public class EditarTarifaMinimaController extends MyGenericForwardComposer { log.error(ex); } } + + public void onClick$btnAdicionarCategoria(Event ev) throws InterruptedException { + try { + + Categoria categoria = (Categoria) cmbCategorias.getSelectedItem().getValue(); + + if(categoria != null) { + + TarifaMinimaCategoria tarifaMinimaCategoria = new TarifaMinimaCategoria(); + tarifaMinimaCategoria.setCategoria(categoria); + tarifaMinimaCategoria.setTarifaMinima(tarifaMinima); + + tarifaMinimaCategoria = tarifaMinimaService.adicionarTarifaMinimaCategoria(tarifaMinimaCategoria); + + tarifaMinimaCategoriaList.updateItem(tarifaMinimaCategoria); + + Messagebox.show(Labels.getLabel("editarTarifaMinimaController.msg.adicionarTarifaMinimaCategoria"), + Labels.getLabel("editarTarifaMinimaController.window.title"), + Messagebox.OK,Messagebox.INFORMATION); + + } + + } catch (Exception e) { + log.error(e.getMessage(), e); + Messagebox.show(Labels.getLabel("MSG.Error"), + Labels.getLabel("editarTarifaMinimaController.window.title"), + Messagebox.OK,Messagebox.ERROR); + } + } + + public void onClick$btnRemoverCategoria(Event ev) throws InterruptedException { + try { + if(tarifaMinimaCategoriaList.getSelected() != null) { + int resp = Messagebox.show( + Labels.getLabel("editarTarifaMinimaController.msg.removerTarifaMinimaCategoriaPergunta"), + Labels.getLabel("editarTarifaMinimaController.window.title"), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + TarifaMinimaCategoria tarifaMinimaCategoria = (TarifaMinimaCategoria) tarifaMinimaCategoriaList.getSelected(); + tarifaMinimaService.removerTarifaMinimaCategoria(tarifaMinimaCategoria); + tarifaMinimaCategoriaList.removeItem(tarifaMinimaCategoria); + + Messagebox.show(Labels.getLabel("editarTarifaMinimaController.msg.removerTarifaMinimaCategoria"), + Labels.getLabel("editarTarifaMinimaController.window.title"), + Messagebox.OK,Messagebox.INFORMATION); + } + } + + } catch (Exception e) { + log.error(e.getMessage(), e); + Messagebox.show(Labels.getLabel("MSG.Error"), + Labels.getLabel("editarTarifaMinimaController.window.title"), + Messagebox.OK,Messagebox.ERROR); + } + } public List getLsOrgaoConcedente() { return lsOrgaoConcedente; @@ -363,4 +438,12 @@ public class EditarTarifaMinimaController extends MyGenericForwardComposer { public void setLsOrgaoConcedente(List lsOrgaoConcedente) { this.lsOrgaoConcedente = lsOrgaoConcedente; } + + public List getLsCategorias() { + return lsCategorias; + } + + public void setLsCategorias(List lsCategorias) { + this.lsCategorias = lsCategorias; + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderTarifaMinimaCategoria.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderTarifaMinimaCategoria.java new file mode 100644 index 000000000..22ac7d70b --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/RenderTarifaMinimaCategoria.java @@ -0,0 +1,25 @@ +package com.rjconsultores.ventaboletos.web.utilerias.render; + +import org.zkoss.zul.Listcell; +import org.zkoss.zul.Listitem; +import org.zkoss.zul.ListitemRenderer; + +import com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria; + +public class RenderTarifaMinimaCategoria implements ListitemRenderer { + + @Override + public void render(Listitem lstm, Object o) throws Exception { + + TarifaMinimaCategoria tarifaMinimaCategoria = (TarifaMinimaCategoria) o; + + Listcell lc = new Listcell(); + + lc = new Listcell(tarifaMinimaCategoria.getCategoria().getDesccategoria()); + lc.setParent(lstm); + + lstm.setAttribute("data", tarifaMinimaCategoria); + + } + +} diff --git a/src/java/spring-config.xml b/src/java/spring-config.xml index 3dd41d4ce..dd7be5e88 100644 --- a/src/java/spring-config.xml +++ b/src/java/spring-config.xml @@ -413,6 +413,7 @@ com.rjconsultores.ventaboletos.entidad.ComEmpCategoria com.rjconsultores.ventaboletos.entidad.ComEmpFormapago com.rjconsultores.ventaboletos.entidad.ComEmpTipoEventoExtra + com.rjconsultores.ventaboletos.entidad.TarifaMinimaCategoria diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 413379a31..794fb0ae8 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -2025,6 +2025,11 @@ editarTarifaMinimaController.btnFechar.MSG.origen = Necesita informar un origen editarTarifaMinimaController.btnFechar.MSG.destino = Necesita informar un destino editarTarifaMinimaController.btnFechar.MSG.orgao = Necessita informar una instituición Concedente editarTarifaMinimaController.btnFechar.MSG.tipo = Necesita informar un tipo de clase +editarTarifaMinimaController.btnAdicionarCategoria.tooltiptext = Incluir Tipo Pasaje +editarTarifaMinimaController.btnRemoverCategoria.tooltiptext = Borrar Tipo Pasaje +editarTarifaMinimaController.msg.adicionarTarifaMinimaCategoria = Tipo Pasaje añadido con éxito +editarTarifaMinimaController.msg.removerTarifaMinimaCategoriaPergunta = Desea borrar el tipo de pasaje seleccionado? +editarTarifaMinimaController.msg.removerTarifaMinimaCategoria = Tipo Pasaje se eliminó exitosamente # Búsqueda de Tarifas: busquedaTarifaController.window.title = Cambio de tarifa diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 13c24b8ff..590691cee 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -2069,6 +2069,11 @@ editarTarifaMinimaController.btnFechar.MSG.origen = Necessita informar um origem editarTarifaMinimaController.btnFechar.MSG.destino = Necessita informar um destino editarTarifaMinimaController.btnFechar.MSG.orgao = Necessita informar um Órgão Concedente editarTarifaMinimaController.btnFechar.MSG.tipo = Necessita informar um tipo de classe +editarTarifaMinimaController.btnAdicionarCategoria.tooltiptext = Adicionar Tipo Passagem +editarTarifaMinimaController.btnRemoverCategoria.tooltiptext = Remover Tipo Passagem +editarTarifaMinimaController.msg.adicionarTarifaMinimaCategoria = Tipo Passagem adicionada com sucesso +editarTarifaMinimaController.msg.removerTarifaMinimaCategoriaPergunta = Deseja remover o tipo de passagem selecionado? +editarTarifaMinimaController.msg.removerTarifaMinimaCategoria = Tipo Passagem removida com sucesso # Pesquisa de Tarifas: busquedaTarifaController.window.title = Alteração de Preço diff --git a/web/gui/tarifas/editarTarifasMinimas.zul b/web/gui/tarifas/editarTarifasMinimas.zul index a2179fe3f..0dc11fb3f 100644 --- a/web/gui/tarifas/editarTarifasMinimas.zul +++ b/web/gui/tarifas/editarTarifasMinimas.zul @@ -7,7 +7,7 @@ @@ -95,8 +95,38 @@ selectedItem="@{winEditarTarifaMinima$composer.tarifaMinima.claseServicio}"/> - - + + + + + +