rodrigo 2013-07-10 21:06:35 +00:00
parent 369102e551
commit 4e1d8b560a
6 changed files with 257 additions and 212 deletions

View File

@ -1,7 +1,10 @@
package com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccomerciales;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
@ -12,11 +15,16 @@ 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.Intbox;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Paging;
import org.zkoss.zul.api.Datebox;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Estado;
import com.rjconsultores.ventaboletos.entidad.Feriado;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.EstadoService;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox;
@ -31,44 +39,41 @@ public class BusquedaConfigFeriadoController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
@Autowired
private transient PagedListWrapper<Feriado> plwFeriado;
@Autowired
private EmpresaService empresaService;
@Autowired
private EstadoService estadoService;
private List<Empresa> lsEmpresa;
private List<Estado> lsEstado;
private MyListbox configFeriadoList;
private Paging pagingConfigFeriado;
private MyTextbox textboxDescricao;
private Intbox txtID;
private Datebox fecFeriado;
private Combobox cmbEstado;
private Combobox cmbEmpresa;
public MyTextbox getTextboxDescricao() {
return textboxDescricao;
public List<Empresa> getLsEmpresa() {
return lsEmpresa;
}
public void setTextboxDescricao(MyTextbox textboxDescricao) {
this.textboxDescricao = textboxDescricao;
public void setLsEmpresa(List<Empresa> lsEmpresa) {
this.lsEmpresa = lsEmpresa;
}
public Intbox getTxtID() {
return txtID;
public List<Estado> getLsEstado() {
return lsEstado;
}
public void setTxtID(Intbox txtID) {
this.txtID = txtID;
}
public Datebox getFecFeriado() {
return fecFeriado;
}
public void setFecFeriado(Datebox fecFeriado) {
this.fecFeriado = fecFeriado;
public void setLsEstado(List<Estado> lsEstado) {
this.lsEstado = lsEstado;
}
@Override
public void doAfterCompose(Component comp) throws Exception {
lsEmpresa = empresaService.obtenerTodos();
lsEstado = estadoService.obtenerTodos();
super.doAfterCompose(comp);
configFeriadoList.setItemRenderer(new RenderFeriado());
configFeriadoList.addEventListener("onDoubleClick", new EventListener() {
@ -80,8 +85,6 @@ public class BusquedaConfigFeriadoController extends MyGenericForwardComposer {
});
refreshLista();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@ -99,37 +102,42 @@ public class BusquedaConfigFeriadoController extends MyGenericForwardComposer {
}
private void refreshLista() {
HibernateSearchObject<Feriado> feriado=
new HibernateSearchObject<Feriado>(Feriado.class,
pagingConfigFeriado.getPageSize());
HibernateSearchObject<Feriado> searchFeriado =
new HibernateSearchObject<Feriado>(Feriado.class, pagingConfigFeriado.getPageSize());
Integer idFeriado= txtID.getValue();
if (idFeriado != null) {
feriado.addFilterEqual("feriadoId", idFeriado);
Comboitem cbiEmpresa = cmbEmpresa.getSelectedItem();
if (cbiEmpresa != null) {
Empresa empresa = (Empresa) cbiEmpresa.getValue();
searchFeriado.addFilterEqual("empresa", empresa);
}
Comboitem cbiEstado = cmbEstado.getSelectedItem();
if (cbiEstado != null) {
Estado estado = (Estado) cbiEstado.getValue();
searchFeriado.addFilterEqual("estado", estado);
}
String descricao = textboxDescricao.getText();
if ((descricao != null)) {
feriado.addFilterLike("descferiado", "%" + descricao.trim().concat("%"));
searchFeriado.addFilterLike("descferiado", "%" + descricao.trim().concat("%"));
}
if (fecFeriado.getValue() != null) {
Date data = fecFeriado.getValue();
data.setHours(00);
data.setMinutes(00);
data.setSeconds(00);
feriado.addFilterEqual("fecferiado",data);
GregorianCalendar gc = new GregorianCalendar();
gc.setTime(data);
gc.set(Calendar.HOUR_OF_DAY, 00);
gc.set(Calendar.MINUTE, 00);
gc.set(Calendar.SECOND, 00);
searchFeriado.addFilterEqual("fecferiado", gc.getTime());
}
feriado.addFilterEqual("activo", Boolean.TRUE);
feriado.addSortAsc("descferiado");
feriado.addFilterNotEqual("feriadoId", -1);
searchFeriado.addFilterEqual("activo", Boolean.TRUE);
searchFeriado.addSortAsc("descferiado");
searchFeriado.addFilterNotEqual("feriadoId", -1);
plwFeriado.init(feriado, configFeriadoList, pagingConfigFeriado);
plwFeriado.init(searchFeriado, configFeriadoList, pagingConfigFeriado);
if (configFeriadoList.getData().length == 0) {
try {
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
@ -151,7 +159,4 @@ public class BusquedaConfigFeriadoController extends MyGenericForwardComposer {
public void onClick$btnNovo(Event ev) {
verFeriado(new Feriado());
}
}

View File

@ -3,6 +3,7 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.configuracioneccome
import java.util.List;
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;
@ -13,31 +14,36 @@ import org.zkoss.zul.Button;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Messagebox;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Estado;
import com.rjconsultores.ventaboletos.entidad.Feriado;
import com.rjconsultores.ventaboletos.service.EmpresaService;
import com.rjconsultores.ventaboletos.service.EstadoService;
import com.rjconsultores.ventaboletos.service.FeriadoService;
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox;
@Controller("editarConfigFeriadoController")
@Scope("prototype")
public class EditarConfigFeriadoController extends MyGenericForwardComposer {
private static final long serialVersionUID = 1L;
private static Logger log = Logger.getLogger(EditarConfigFeriadoController.class);
@Autowired
private FeriadoService feriadoService;
@Autowired
private EmpresaService empresaService;
@Autowired
private EstadoService estadoService;
private List<Empresa> lsEmpresa;
private List<Estado> lsEstado;
private Feriado feriado;
private MyListbox configFeriadoList;
private MyTextbox textboxDescricao;
private Datebox fecFeriado;
private Button btnApagar;
public Feriado getFeriado() {
return feriado;
}
@ -46,48 +52,39 @@ public class EditarConfigFeriadoController extends MyGenericForwardComposer {
this.feriado = feriado;
}
public FeriadoService getFeriadoService() {
return feriadoService;
public List<Empresa> getLsEmpresa() {
return lsEmpresa;
}
public void setFeriadoService(FeriadoService feriadoService) {
this.feriadoService = feriadoService;
public void setLsEmpresa(List<Empresa> lsEmpresa) {
this.lsEmpresa = lsEmpresa;
}
public MyTextbox getTextboxDescricao() {
return textboxDescricao;
public List<Estado> getLsEstado() {
return lsEstado;
}
public void setTextboxDescricao(MyTextbox textboxDescricao) {
this.textboxDescricao = textboxDescricao;
public void setLsEstado(List<Estado> lsEstado) {
this.lsEstado = lsEstado;
}
@Override
public void doAfterCompose(Component comp) throws Exception {
lsEmpresa = empresaService.obtenerTodos();
lsEstado = estadoService.obtenerTodos();
super.doAfterCompose(comp);
try {
feriado = (Feriado) Executions.getCurrent().getArg().get("feriado");
configFeriadoList = (MyListbox) Executions.getCurrent().getArg().get("configFeriadoList");
if (feriado.getFeriadoId() == null) {
btnApagar.setVisible(Boolean.FALSE);
} else {
feriado = feriadoService.obtenerID(feriado.getFeriadoId());
}
textboxDescricao.focus();
} catch (Exception e) {
log.error("Feriado: " + e);
Messagebox.show(
@ -95,21 +92,12 @@ public class EditarConfigFeriadoController extends MyGenericForwardComposer {
Labels.getLabel("editarConfigFeriadoController.window.title"),
Messagebox.OK, Messagebox.ERROR);
}
}
public void onClick$btnSalvar(Event ev) throws InterruptedException {
textboxDescricao.getValue();
fecFeriado.getValue();
if (feriado.getFeriadoId() == null) {
java.sql.Date data = new java.sql.Date(fecFeriado.getValue().getTime());
List<Feriado> lsFeriado = feriadoService.buscar(data);
@ -120,18 +108,13 @@ public class EditarConfigFeriadoController extends MyGenericForwardComposer {
Messagebox.OK, Messagebox.EXCLAMATION);
return;
}
}
try {
if (feriado.getFeriadoId() == null) {
feriadoService.suscribir(feriado);
configFeriadoList.addItem(feriado);
configFeriadoList.addItemNovo(feriado);
} else {
feriadoService.actualizacion(feriado);
configFeriadoList.updateItem(feriado);
@ -143,7 +126,6 @@ public class EditarConfigFeriadoController extends MyGenericForwardComposer {
Messagebox.OK, Messagebox.INFORMATION);
closeWindow();
} catch (Exception ex) {
log.error("editarConfigFeriadoController: " + ex);
Messagebox.show(
@ -177,5 +159,4 @@ public class EditarConfigFeriadoController extends MyGenericForwardComposer {
log.error(ex);
}
}
}

View File

@ -6,10 +6,10 @@ import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Estado;
import com.rjconsultores.ventaboletos.entidad.Feriado;
public class RenderFeriado implements ListitemRenderer {
public void render(Listitem lstm, Object o) throws Exception {
@ -18,7 +18,6 @@ public class RenderFeriado implements ListitemRenderer {
Listcell lc = new Listcell(feriado.getFeriadoId().toString());
lc.setParent(lstm);
SimpleDateFormat data = new SimpleDateFormat("dd/MM/yyyy");
lc = new Listcell(data.format(feriado.getFecferiado()));
lc.setParent(lstm);
@ -26,6 +25,22 @@ public class RenderFeriado implements ListitemRenderer {
lc = new Listcell(feriado.getDescferiado());
lc.setParent(lstm);
Empresa empresa = feriado.getEmpresa();
if (empresa != null) {
lc = new Listcell(empresa.getNombempresa());
} else {
lc = new Listcell("");
}
lc.setParent(lstm);
Estado estado = feriado.getEstado();
if (estado != null) {
lc = new Listcell(estado.getNombestado());
} else {
lc = new Listcell("");
}
lc.setParent(lstm);
lstm.setAttribute("data", feriado);
}
}

View File

@ -4212,6 +4212,8 @@ busquedaConfigFeriadoController.btnNovo.tooltiptext = Incluir
busquedaConfigFeriadoController.btnCerrar.tooltiptext = Fechar
busquedaConfigFeriadoController.btnPesquisa.label = Pesquisa
busquedaConfigFeriadoController.lhId.label = ID
busquedaConfigFeriadoController.lhEmpresa.label = Empresa
busquedaConfigFeriadoController.lhEstado.label = Estado
busquedaConfigFeriadoController.lhData.label = Data
busquedaConfigFeriadoController.lhDescricao.label = Descrição

View File

@ -5,17 +5,21 @@
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winBusquedaConfigFeriado" title="${c:l('busquedaConfigFeriadoController.window.title')}"
apply="${busquedaConfigFeriadoController}" contentStyle="overflow:auto"
width="700px" height="500px" border="normal" xmlns:h="http://www.w3.org/1999/xhtml">
<window id="winBusquedaConfigFeriado"
title="${c:l('busquedaConfigFeriadoController.window.title')}"
apply="${busquedaConfigFeriadoController}"
contentStyle="overflow:auto" width="800px" height="500px"
border="normal" xmlns:h="http://www.w3.org/1999/xhtml">
<toolbar>
<button id="btnRefresh" image="/gui/img/refresh.png" width="35px"
<button id="btnRefresh" image="/gui/img/refresh.png"
width="35px"
tooltiptext="${c:l('busquedaConfigFeriadoController.btnRefresh.tooltiptext')}" />
<separator orient="vertical" />
<button id="btnNovo" image="/gui/img/add.png" width="35px"
tooltiptext="${c:l('busquedaConfigFeriadoController.btnNovo.tooltiptext')}" />
<separator orient="vertical" />
<button id="btnCerrar" image="/gui/img/exit.png" width="35px" onClick="winBusquedaConfigFeriado.detach()"
<button id="btnCerrar" image="/gui/img/exit.png"
width="35px" onClick="winBusquedaConfigFeriado.detach()"
tooltiptext="${c:l('busquedaConfigFeriadoController.btnCerrar.tooltiptext')}" />
</toolbar>
<grid fixedLayout="true">
@ -25,20 +29,34 @@
</columns>
<rows>
<row>
<label value="${c:l('lb.id')}"/>
<intbox id="txtID" width="40%"/>
<label
value="${c:l('editarConfigFeriadoController.lbDescricao.value')}" />
<textbox id="textboxDescricao"
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox"
width="95%" />
</row>
<row>
<label value="${c:l('editarConfigFeriadoController.lbData.value')}"/>
<datebox id="fecFeriado" width="40%" mold="rounded" lenient="false"/>
<label
value="${c:l('editarConfigFeriadoController.lbData.value')}" />
<datebox id="fecFeriado" width="25%" mold="rounded"
lenient="false" />
</row>
<row>
<label value="${c:l('editarConfigFeriadoController.lbDescricao.value')}"/>
<textbox id="textboxDescricao" use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox"
width="70%" />
<label
value="${c:l('busquedaConfigFeriadoController.lhEstado.label')}" />
<combobox id="cmbEstado" width="50%" mold="rounded"
buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
model="@{winBusquedaConfigFeriado$composer.lsEstado}" />
</row>
<row>
<label
value="${c:l('busquedaConfigFeriadoController.lhEmpresa.label')}" />
<combobox id="cmbEmpresa"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
mold="rounded" width="50%"
model="@{winBusquedaConfigFeriado$composer.lsEmpresa}" />
</row>
</rows>
</grid>
@ -48,23 +66,26 @@
</toolbar>
<paging id="pagingConfigFeriado" pageSize="20" />
<listbox id="configFeriadoList" use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
<listbox id="configFeriadoList"
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
multiple="false" vflex="true" height="50%">
<listhead sizable="true">
<listheader width="50px" image="/gui/img/builder.gif"
<listheader width="5%" image="/gui/img/builder.gif"
label="${c:l('busquedaConfigFeriadoController.lhId.label')}"
sort="auto(feriadoId)" />
<listheader image="/gui/img/builder.gif"
label="${c:l('busquedaConfigFeriadoController.lhData.label')}"
sort="auto(fecferiado)" />
sort="auto(fecferiado)" width="10%" />
<listheader image="/gui/img/builder.gif"
label="${c:l('busquedaConfigFeriadoController.lhDescricao.label')}"
sort="auto(descferiado)" />
<listheader image="/gui/img/builder.gif"
label="${c:l('busquedaConfigFeriadoController.lhEmpresa.label')}"
sort="auto(empresa.nombempresa)" />
<listheader image="/gui/img/builder.gif"
label="${c:l('busquedaConfigFeriadoController.lhEstado.label')}"
sort="auto(estado.nombestado)" />
</listhead>
</listbox>
</window>
</zk>

View File

@ -6,8 +6,8 @@
<zk xmlns="http://www.zkoss.org/2005/zul">
<window id="winEditarConfigFeriado" border="normal"
apply="${editarConfigFeriadoController}"
width="500px" height="175px" contentStyle="overflow:auto"
apply="${editarConfigFeriadoController}" width="500px"
contentStyle="overflow:auto"
title="${c:l('editarConfigFeriadoController.window.title')}">
<toolbar>
<hbox spacing="5px" style="padding:1px" align="right">
@ -18,30 +18,51 @@
image="/gui/img/save.png" width="35px"
tooltiptext="${c:l('editarConfigFeriadoController.btnSalvar.tooltiptext')}" />
<button id="btnFechar" height="20"
image="/gui/img/exit.png" width="35px" onClick="winEditarConfigFeriado.detach()"
image="/gui/img/exit.png" width="35px"
onClick="winEditarConfigFeriado.detach()"
tooltiptext="${c:l('editarConfigFeriadoController.btnFechar.tooltiptext')}" />
</hbox>
</toolbar>
<grid fixedLayout="true">
<columns>
<column width="20%" />
<column width="80%" />
<column width="30%" />
<column width="70%" />
</columns>
<rows>
<row>
<label value="${c:l('editarConfigFeriadoController.lbData.value')}"/>
<datebox id="fecFeriado" width="40%" mold="rounded" lenient="false" constraint="no empty"
<label
value="${c:l('editarConfigFeriadoController.lbDescricao.value')}" />
<textbox id="textboxDescricao"
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox"
value="@{winEditarConfigFeriado$composer.feriado.descferiado}"
constraint="no empty" width="95%" />
</row>
<row>
<label
value="${c:l('editarConfigFeriadoController.lbData.value')}" />
<datebox id="fecFeriado" width="40%" mold="rounded"
lenient="false" constraint="no empty"
value="@{winEditarConfigFeriado$composer.feriado.fecferiado}" />
</row>
<row>
<label value="${c:l('editarConfigFeriadoController.lbDescricao.value')}"/>
<textbox id="textboxDescricao" use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox"
value="@{winEditarConfigFeriado$composer.feriado.descferiado}" constraint="no empty" width="70%" />
<label
value="${c:l('busquedaConfigFeriadoController.lhEstado.label')}" />
<combobox id="cmbEstado" width="95%" mold="rounded"
buttonVisible="true"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
model="@{winEditarConfigFeriado$composer.lsEstado}"
selectedItem="@{winEditarConfigFeriado$composer.feriado.estado}" />
</row>
<row>
<label
value="${c:l('busquedaConfigFeriadoController.lhEmpresa.label')}" />
<combobox id="cmbEmpresa"
use="com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar"
mold="rounded" width="95%"
model="@{winEditarConfigFeriado$composer.lsEmpresa}"
selectedItem="@{winEditarConfigFeriado$composer.feriado.empresa}" />
</row>
</rows>
</grid>
</window>