diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidos.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidos.java new file mode 100644 index 000000000..d84a395d3 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidos.java @@ -0,0 +1,151 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.IndStatusBoleto; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +/** + * @author Thiago + * + */ +public class RelatorioBilhetesVendidos extends Relatorio { + + + public RelatorioBilhetesVendidos(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new ArrayDataSource(this) { + @Override + public void initDados() throws Exception { + + Connection conexao = this.relatorio.getConexao(); + Map parametros = this.relatorio.getParametros(); + + StringBuilder sql = new StringBuilder(); + + sql.append(" select "); + sql.append(" B.NUMFOLIOSISTEMA NUMERO_PASSAGEM, "); + sql.append(" B.NUMSERIEPREIMPRESA SERIE, "); + sql.append(" B.NUMSERIEPREIMPRESA SUB_SERIE, "); + sql.append(" B.NUMFOLIOPREIMPRESO PRE_IMPRESSO, "); + sql.append(" p_origen.DESCPARADA ORIGEM, "); + sql.append(" p_destino.DESCPARADA DESTINO, "); + sql.append(" pv.NOMBPUNTOVENTA NOME_AGENCIA, "); + sql.append(" B.FECMODIF DATA, "); + sql.append(" B.FECCORRIDA DATA_VIAGEM, "); + sql.append(" B.CORRIDA_ID SERVICO, "); + sql.append(" to_char(B.FECCORRIDA, 'hh:mm:ss') HORA, "); + sql.append(" B.NUMASIENTO NUMASIENTO, "); + sql.append(" ct.DESCCATEGORIA CATEGORIA, "); + sql.append(" R.INDSENTIDOIDA SENTIDO, "); + sql.append(" R.DESCRUTA DESC_LINHA, "); + sql.append(" B.INDSTATUSBOLETO STATUS_PASSAGEM, "); + sql.append(" B.PRECIOPAGADO TARIFA, "); + sql.append(" B.IMPORTETAXAEMBARQUE TX_EMBARQUE, "); + sql.append(" B.IMPORTEPEDAGIO PEDAGIO, "); + sql.append(" B.IMPORTESEGURO SEGURO "); + + sql.append(" FROM BOLETO B "); + sql.append(" JOIN RUTA R ON R.RUTA_ID = B.RUTA_ID "); + sql.append(" JOIN PUNTO_VENTA pv on B.PUNTOVENTA_ID = pv.PUNTOVENTA_ID "); + sql.append(" JOIN USUARIO u on u.USUARIO_ID = B.USUARIO_ID "); + sql.append(" JOIN PARADA p_origen on p_origen.PARADA_ID = B.ORIGEN_ID "); + sql.append(" JOIN PARADA p_destino on p_destino.PARADA_ID = B.DESTINO_ID "); + sql.append(" JOIN CATEGORIA ct on ct.CATEGORIA_ID = B.CATEGORIA_ID "); + sql.append(" JOIN CLASE_SERVICIO cs on cs.CLASESERVICIO_ID = B.CLASESERVICIO_ID "); + sql.append(" JOIN MARCA m on m.marca_id = B.marca_id "); + sql.append(" WHERE "); + sql.append(" m.EMPRESA_ID = :EMPRESA_ID "); + sql.append(" and B.FECHORVENTA >= :DATA_INICIAL "); + sql.append(" and B.FECHORVENTA <= :DATA_FINAL "); + if (parametros.get("NUMPUNTOVENTA") != null) { + sql.append(" and pv.PUNTOVENTA_ID IN (" + parametros.get("NUMPUNTOVENTA").toString() + ")"); + } + if (parametros.get("STATUS") != null) { + sql.append(" and b.INDSTATUSBOLETO in (" + parametros.get("STATUS") + ") "); + } + sql.append(" order by u.CVEUSUARIO, "); + sql.append(" u.NOMBUSUARIO, "); + sql.append(" pv.NUMPUNTOVENTA, "); + sql.append(" pv.NOMBPUNTOVENTA, "); + sql.append(" B.NUMFOLIOSISTEMA, "); + sql.append(" p_origen.DESCPARADA, "); + sql.append(" p_destino.DESCPARADA, "); + sql.append(" ct.DESCCATEGORIA, "); + sql.append(" B.INDSTATUSBOLETO, "); + sql.append(" B.FECCORRIDA, "); + sql.append(" B.CORRIDA_ID "); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql.toString()); + + stmt.setInt("EMPRESA_ID", Integer.valueOf(parametros.get("EMPRESA_ID").toString())); + stmt.setTimestamp("DATA_INICIAL", new Timestamp(DateUtil.inicioFecha((Date) parametros.get("DATA_INICIAL")).getTime())); + stmt.setTimestamp("DATA_FINAL", new Timestamp(DateUtil.fimFecha((Date) parametros.get("DATA_FINAL")).getTime())); + + ResultSet rset = stmt.executeQuery(); + + while (rset.next()) { + + Map dataResult = new HashMap(); + + dataResult.put("NUMERO_PASSAGEM", rset.getString("NUMERO_PASSAGEM")); + if (rset.getString("SERIE") != null) { + if (rset.getString("SERIE").split("-").length == 1) { + dataResult.put("SERIE", rset.getString("SERIE")); + } else { + dataResult.put("SERIE", rset.getString("SERIE").split("-")[0]); + dataResult.put("SUB_SERIE", rset.getString("SERIE").split("-")[1]); + } + } + dataResult.put("PRE_IMPRESSO", rset.getString("PRE_IMPRESSO")); + dataResult.put("ORIGEM", rset.getString("ORIGEM")); + dataResult.put("DESTINO", rset.getString("DESTINO")); + dataResult.put("NOME_AGENCIA", rset.getString("NOME_AGENCIA")); + dataResult.put("DATA", rset.getString("DATA")); + dataResult.put("DATA_VIAGEM", rset.getString("DATA_VIAGEM")); + dataResult.put("SERVICO", rset.getString("SERVICO")); + dataResult.put("HORA", rset.getString("HORA")); + dataResult.put("NUMASIENTO", rset.getString("NUMASIENTO")); + dataResult.put("CATEGORIA", rset.getString("CATEGORIA")); + dataResult.put("SENTIDO", rset.getString("SENTIDO")); + dataResult.put("DESC_LINHA", rset.getString("DESC_LINHA")); + if (rset.getString("STATUS_PASSAGEM") != null) { + dataResult.put("STATUS_PASSAGEM", IndStatusBoleto.valueOf(rset.getString("STATUS_PASSAGEM")).getValue()); + } + dataResult.put("TARIFA", rset.getString("TARIFA")); + dataResult.put("TX_EMBARQUE", rset.getString("TX_EMBARQUE")); + dataResult.put("PEDAGIO", rset.getString("PEDAGIO")); + dataResult.put("SEGURO", rset.getString("SEGURO")); + + this.dados.add(dataResult); + + } + + this.resultSet = rset; + } + }); + } + + /* + * (non-Javadoc) + * + * @see com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio#processaParametros() + */ + @Override + protected void processaParametros() throws Exception { + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendas_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendas_pt_BR.properties new file mode 100644 index 000000000..01f6ecc2b --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendas_pt_BR.properties @@ -0,0 +1,13 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + + +#Labels cabeçalho +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidos.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidos.properties new file mode 100644 index 000000000..01f6ecc2b --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidos.properties @@ -0,0 +1,13 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + + +#Labels cabeçalho +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidos.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidos.jasper new file mode 100644 index 000000000..dda2f7744 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidos.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidos.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidos.jrxml new file mode 100644 index 000000000..6528adbfb --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidos.jrxml @@ -0,0 +1,433 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosController.java new file mode 100644 index 000000000..2cf83712a --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosController.java @@ -0,0 +1,242 @@ +package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +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.zhtml.Messagebox; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zul.Bandbox; +import org.zkoss.zul.Checkbox; +import org.zkoss.zul.Comboitem; +import org.zkoss.zul.Datebox; +import org.zkoss.zul.Paging; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.entidad.PuntoVenta; +import com.rjconsultores.ventaboletos.enums.IndStatusBoleto; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidos; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; +import com.rjconsultores.ventaboletos.web.utilerias.MyListbox; +import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject; +import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper; +import com.rjconsultores.ventaboletos.web.utilerias.render.RenderRelatorioVendasBilheteiro; + +@Controller("relatorioBilhetesVendidosController") +@Scope("prototype") +public class RelatorioBilhetesVendidosController extends MyGenericForwardComposer { + + /** + * + */ + private static final long serialVersionUID = 1L; + private static Logger log = Logger.getLogger(RelatorioVendasBilheteiroController.class); + + @Autowired + private DataSource dataSourceRead; + + @Autowired + private EmpresaService empresaService; + + private Datebox datInicial; + private Datebox datFinal; + + private MyComboboxEstandar cmbEmpresa; + private List lsEmpresa; + + @Autowired + private transient PagedListWrapper plwPuntoVenta; + + private MyTextbox txtNombrePuntoVenta; + private Bandbox bbPesquisaPuntoVenta; + private MyListbox puntoVentaList; + private MyListbox puntoVentaSelList; + private Paging pagingPuntoVenta; + + private Checkbox chkVendido; + private Checkbox chkCancelado; +// private Checkbox chkTransferido; +// private Checkbox chkEntregue; +// private Checkbox chkReservado; +// private Checkbox chkExtraviado; +// private Checkbox chkReimpresso; +// private Checkbox chkMarcado; + + @Override + public void doAfterCompose(Component comp) throws Exception { + lsEmpresa = empresaService.obtenerTodos(); + super.doAfterCompose(comp); + + chkVendido.setChecked(true); + chkCancelado.setChecked(true); +// chkTransferido.setChecked(true); +// chkEntregue.setChecked(true); +// chkReservado.setChecked(true); +// chkExtraviado.setChecked(true); +// chkReimpresso.setChecked(true); +// chkMarcado.setChecked(true); + + puntoVentaList.setItemRenderer(new RenderRelatorioVendasBilheteiro()); + + } + + public List getLsEmpresa() { + return lsEmpresa; + } + + public void setLsEmpresa(List lsEmpresa) { + this.lsEmpresa = lsEmpresa; + } + + private void executarPesquisaAgencia() { + HibernateSearchObject puntoVentaBusqueda = + new HibernateSearchObject(PuntoVenta.class, pagingPuntoVenta.getPageSize()); + + puntoVentaBusqueda.addFilterILike("nombpuntoventa", "%" + txtNombrePuntoVenta.getValue() + "%"); + puntoVentaBusqueda.addFilterEqual("activo", Boolean.TRUE); + + puntoVentaBusqueda.addSortAsc("nombpuntoventa"); + + puntoVentaBusqueda.addFilterEqual("activo", Boolean.TRUE); + + plwPuntoVenta.init(puntoVentaBusqueda, puntoVentaList, pagingPuntoVenta); + + if (puntoVentaList.getData().length == 0) { + try { + Messagebox.show(Labels.getLabel("MSG.ningunRegistro"), + Labels.getLabel("relatorioVendasBilheteiroController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + } catch (InterruptedException ex) { + ex.printStackTrace(); + } + } + } + + public void onClick$btnPesquisa(Event ev) { + executarPesquisaAgencia(); + } + + public void onDoubleClick$puntoVentaSelList(Event ev) { + PuntoVenta puntoVenta = (PuntoVenta) puntoVentaSelList.getSelected(); + puntoVentaSelList.removeItem(puntoVenta); + } + + public void onDoubleClick$puntoVentaList(Event ev) { + PuntoVenta puntoVenta = (PuntoVenta) puntoVentaList.getSelected(); + puntoVentaSelList.addItemNovo(puntoVenta); + } + + public void onClick$btnLimpar(Event ev) { + puntoVentaList.setData(new ArrayList()); + + bbPesquisaPuntoVenta.setText(""); + } + + public void onClick$btnExecutarRelatorio(Event ev) throws Exception { + executarRelatorio(); + } + + /** + * @throws Exception + * + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + private void executarRelatorio() throws Exception { + Relatorio relatorio; + Map parametros = new HashMap(); + StringBuilder filtro = new StringBuilder(); + + filtro.append("Agência: "); + String puntoVentaIds = ""; + String puntoVentas = ""; + List lsPuntoVentaSelecionados = new ArrayList(Arrays.asList(puntoVentaSelList.getData())); + if (lsPuntoVentaSelecionados.isEmpty()) { + puntoVentas = "Todas"; + } else { + for (int i = 0; i < lsPuntoVentaSelecionados.size(); i++) { + PuntoVenta puntoVenta = lsPuntoVentaSelecionados.get(i); + puntoVentas = puntoVentas + puntoVenta.getNombpuntoventa() + ","; + + puntoVentaIds = puntoVentaIds + puntoVenta.getPuntoventaId() + ","; + } + + // removendo ultima virgula + puntoVentaIds = puntoVentaIds.substring(0, puntoVentaIds.length() - 1); + puntoVentas = puntoVentas.substring(0, puntoVentas.length() - 1); + parametros.put("NUMPUNTOVENTA", puntoVentaIds); + } + filtro.append(puntoVentas).append(";"); + + parametros.put("DATA_INICIAL", (java.util.Date) this.datInicial.getValue()); + parametros.put("DATA_FINAL", (java.util.Date) this.datFinal.getValue()); + parametros.put("NOME_RELATORIO", Labels.getLabel("relatorioVendasBilheteiroController.window.title")); + parametros.put("USUARIO", UsuarioLogado.getUsuarioLogado().getUsuarioId().toString()); + + String status = ""; + if (chkCancelado.isChecked()) { + status += "'" + IndStatusBoleto.C + "',"; + } +// if (chkEntregue.isChecked()) { +// status += "'" + IndStatusBoleto.E + "',"; +// } +// if (chkExtraviado.isChecked()) { +// status += "'" + IndStatusBoleto.X + "',"; +// } +// if (chkMarcado.isChecked()) { +// status += "'" + IndStatusBoleto.M + "',"; +// } +// if (chkReimpresso.isChecked()) { +// status += "'" + IndStatusBoleto.R + "',"; +// } +// if (chkReservado.isChecked()) { +// status += "'" + IndStatusBoleto.S + "',"; +// } +// if (chkTransferido.isChecked()) { +// status += "'" + IndStatusBoleto.T + "',"; +// } + if (chkVendido.isChecked()) { + status += "'" + IndStatusBoleto.V + "',"; + } + if (status.length() > 0) { + status = status.substring(0, status.length()-1); + } else { + status = null; + } + parametros.put("STATUS", status); + + filtro.append(" Empresa: "); + + Comboitem itemEmpresa = cmbEmpresa.getSelectedItem(); + if (itemEmpresa != null) { + Empresa empresa = (Empresa) itemEmpresa.getValue(); + parametros.put("EMPRESA_ID", empresa.getEmpresaId()); + parametros.put("EMPRESA", empresa.getNombempresa()); + filtro.append(empresa.getNombempresa() + ";"); + } else { + filtro.append(" Todas;"); + } + + parametros.put("FILTROS", filtro.toString()); + relatorio = new RelatorioBilhetesVendidos(parametros, dataSourceRead.getConnection()); + + Map args = new HashMap(); + args.put("relatorio", relatorio); + + openWindow("/component/reportView.zul", Labels.getLabel("relatorioVendasBilheteiroController.window.title"), args, MODAL); + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioBilhetesVendidos.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioBilhetesVendidos.java new file mode 100644 index 000000000..d90e18562 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioBilhetesVendidos.java @@ -0,0 +1,25 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuRelatorioBilhetesVendidos extends DefaultItemMenuSistema { + + public ItemMenuRelatorioBilhetesVendidos() { + super("indexController.mniRelatorioBilhetesVendidos.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOBILHTESVENDIDOS"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/relatorios/filtroRelatorioBilhetesVendidos.zul", + Labels.getLabel("relatorioBilhetesVendidosController.window.title"), getArgs() ,desktop); + } + +} diff --git a/web/gui/relatorios/filtroRelatorioBilhetesVendidos.zul b/web/gui/relatorios/filtroRelatorioBilhetesVendidos.zul new file mode 100644 index 000000000..182e28aca --- /dev/null +++ b/web/gui/relatorios/filtroRelatorioBilhetesVendidos.zul @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +