diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarEstacionController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarEstacionController.java index b58cc63f1..3cc17f543 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarEstacionController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/seguridad/EditarEstacionController.java @@ -9,6 +9,7 @@ import java.util.List; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Predicate; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -24,19 +25,23 @@ import org.zkoss.zul.Combobox; import org.zkoss.zul.Intbox; import org.zkoss.zul.Longbox; import org.zkoss.zul.Radio; +import org.zkoss.zul.Tab; import org.zkoss.zul.Textbox; import org.zkoss.zul.api.Comboitem; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.Estacion; import com.rjconsultores.ventaboletos.entidad.EstacionImpresora; +import com.rjconsultores.ventaboletos.entidad.EstacionRioCard; import com.rjconsultores.ventaboletos.entidad.EstacionSitef; import com.rjconsultores.ventaboletos.exception.BusinessException; import com.rjconsultores.ventaboletos.service.EstacionService; +import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxPuntoVenta; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; +import com.rjconsultores.ventaboletos.web.utilerias.render.EstacionRioCardRender; import com.rjconsultores.ventaboletos.web.utilerias.render.EstacionSitefRender; import com.rjconsultores.ventaboletos.web.utilerias.render.RenderEstacionImpresora; @@ -56,8 +61,10 @@ public class EditarEstacionController extends MyGenericForwardComposer { private MyListbox estacionList; private MyListbox estacionSitefList; private MyListbox estacionImpresoraList; + private MyListbox estacionRioCardList; private Combobox cmbEmpresa; private Combobox cmbEmpresaImpressora; + private Combobox cmbEmpresaRioCard; private Button btnApagar; private Textbox txtDescEstacion; private Textbox txtDescMac; @@ -68,14 +75,17 @@ public class EditarEstacionController extends MyGenericForwardComposer { private Intbox txtNumEmpresa; private Intbox txtNumFilial; private Intbox txtNumPdv; + private Textbox txtOperadora; private List lsEmpresa; private List lsEstacionSitef; + private List lsEstacionRiocard; private List lsEstacionImpresora; private static Logger log = Logger.getLogger(EditarEstacionController.class); private Textbox txtNomImpressoara; private Textbox txtNomeArquivoLayout; private Radio rdPausarImpressoraNo; private Radio rdPausarImpressoraSi; + private Tab tabRioCard; public Estacion getEstacion() { return estacion; @@ -99,6 +109,11 @@ public class EditarEstacionController extends MyGenericForwardComposer { estacionList = (MyListbox) Executions.getCurrent().getArg().get("estacionList"); estacionSitefList.setItemRenderer(new EstacionSitefRender()); estacionImpresoraList.setItemRenderer(new RenderEstacionImpresora()); + estacionRioCardList.setItemRenderer(new EstacionRioCardRender()); + + if (ApplicationProperties.getInstance().integracionRioCard()) { + tabRioCard.setVisible(true); + } if (estacion.getEstacionId() == null) { btnApagar.setVisible(Boolean.FALSE); @@ -121,6 +136,9 @@ public class EditarEstacionController extends MyGenericForwardComposer { lsEstacionSitef = estacion.getEstacionSitefList(); estacionSitefList.setData(lsEstacionSitef); + + lsEstacionRiocard = estacion.getEstacionRioCardList(); + estacionRioCardList.setData(lsEstacionRiocard); lsEstacionImpresora = estacion.getLsEstacionImpresora(); estacionImpresoraList.setData(lsEstacionImpresora); @@ -145,6 +163,7 @@ public class EditarEstacionController extends MyGenericForwardComposer { txtNumPdv.getValue(); txtDescEstacion.getValue(); txtNumCaja.getValue(); + txtOperadora.getValue(); String descMac = txtDescMac.getText(); @@ -161,6 +180,7 @@ public class EditarEstacionController extends MyGenericForwardComposer { try { estacion.setEstacionSitefList(estacionSitefList.getListData()); + estacion.setEstacionRioCardList(estacionRioCardList.getListData()); estacion.setLsEstacionImpresora(estacionImpresoraList.getListData()); estacionService.suscribirActualizar(estacion); @@ -264,6 +284,62 @@ public class EditarEstacionController extends MyGenericForwardComposer { estacionSitefList.addItemNovo(es); } } + + public void onClick$btnAddConfRioCard(Event e) { + Comboitem cbiEmpresa = cmbEmpresaRioCard.getSelectedItem(); + String operadora = txtOperadora.getValue(); + if (cbiEmpresa != null && StringUtils.isNotBlank(operadora)) { + Empresa empresa = (Empresa) cbiEmpresa.getValue(); + + final Integer empresaId = empresa.getEmpresaId(); + + boolean empresaExiste = CollectionUtils.exists(estacionRioCardList.getListData(), new Predicate() { + + @Override + public boolean evaluate(Object obj) { + + EstacionRioCard e = (EstacionRioCard) obj; + + return (e.getActivo() && e.getEmpresa().getEmpresaId().equals(empresaId)); + + } + }); + + if (empresaExiste) { + Clients.alert(Labels.getLabel("editarEstacionController.MSG.empresaYaExiste"), Labels.getLabel("editarEstacionController.window.title"), Messagebox.INFORMATION); + + return; + } + + EstacionRioCard estacionRioCard = new EstacionRioCard(); + estacionRioCard.setEmpresa(empresa); + estacionRioCard.setEstacion(estacion); + estacionRioCard.setOperadora(operadora); + estacionRioCard.setActivo(Boolean.TRUE); + estacionRioCard.setFecmodif(Calendar.getInstance().getTime()); + estacionRioCard.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + estacionRioCardList.addItemNovo(estacionRioCard); + } + } + + public void onClick$btnRemConfRioCard(Event ev) { + if (estacionRioCardList.getSelected() == null) { + return; + } + + EstacionRioCard rc = (EstacionRioCard) estacionRioCardList.getSelected(); + estacionImpresoraList.removeSelectedItem(); + + if (rc.getEstacionRioCardId() != null) { + rc.setFecmodif(Calendar.getInstance().getTime()); + rc.setActivo(Boolean.FALSE); + rc.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); + + estacionRioCardList.addItemNovo(rc); + + } + } public void onClick$btnAddEstacionImpresora(Event ev) { Comboitem cbiEmpresa = cmbEmpresaImpressora.getSelectedItem(); diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/EstacionRioCardRender.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/EstacionRioCardRender.java new file mode 100644 index 000000000..fed1415ac --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/render/EstacionRioCardRender.java @@ -0,0 +1,34 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +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.EstacionRioCard; + +/** + * + * @author RJ + */ +public class EstacionRioCardRender implements ListitemRenderer { + + public void render(Listitem lstm, Object o) throws Exception { + EstacionRioCard rc = (EstacionRioCard) o; + + if (!rc.getActivo()) { + return; + } + + Listcell lc = new Listcell(rc.getEmpresa().getNombempresa()); + lc.setParent(lstm); + + lc = new Listcell(rc.getOperadora().toString()); + lc.setParent(lstm); + + lstm.setValue(rc); + } +} diff --git a/web/gui/seguridad/editarEstacion.zul b/web/gui/seguridad/editarEstacion.zul index b5f09e70d..72f9faed6 100644 --- a/web/gui/seguridad/editarEstacion.zul +++ b/web/gui/seguridad/editarEstacion.zul @@ -29,6 +29,8 @@ label="${c:l('editarEstacionController.window.title')}" /> + @@ -188,6 +190,53 @@ + + + + + + + + + + + + + + + + + +