diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEmpresaCorrida.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEmpresaCorrida.java index 90c52c87c..08f5fc070 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEmpresaCorrida.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEmpresaCorrida.java @@ -31,8 +31,9 @@ public class RelatorioEmpresaCorrida extends Relatorio { String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00"; String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59"; + String empresa = parametros.get("empresa") != null ? parametros.get("empresa").toString() : ""; - String sql = getSql(); + String sql = getSql(empresa); System.out.println(sql); @@ -42,7 +43,9 @@ public class RelatorioEmpresaCorrida extends Relatorio { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); stmt.setTimestamp("fecInicio", new java.sql.Timestamp(sdf.parse(fecInicio).getTime())); stmt.setTimestamp("fecFinal", new java.sql.Timestamp(sdf.parse(fecFinal).getTime())); - + if (empresa != null && !empresa.equals("")){ + stmt.setInt("empresa_id", Integer.parseInt(empresa)); + } rset = stmt.executeQuery(); lsDadosRelatorio = new ArrayList(); @@ -78,7 +81,7 @@ public class RelatorioEmpresaCorrida extends Relatorio { protected void processaParametros() throws Exception { } - private String getSql() { + private String getSql(String empresa) { StringBuffer sql = new StringBuffer(); sql.append("SELECT DISTINCT empresa_id, "); @@ -161,6 +164,9 @@ public class RelatorioEmpresaCorrida extends Relatorio { sql.append(" AND d.parada_id = b.destino_id "); sql.append(" AND b.motivocancelacion_id IS NULL "); sql.append(" AND b.empresacorrida_id = empresa_id "); + if (empresa != null && !empresa.isEmpty()){ + sql.append(" AND empresa_id = :empresa_id "); + } sql.append(" AND b.fechorventa BETWEEN :fecInicio AND :fecFinal "); sql.append("ORDER BY empresa_id, "); sql.append(" linea "); diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmpresaCorridaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmpresaCorridaController.java index 146a7d536..6590021ab 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmpresaCorridaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioEmpresaCorridaController.java @@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; import java.text.SimpleDateFormat; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.sql.DataSource; @@ -15,9 +16,11 @@ import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zul.Datebox; -import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioEmpresaOnibus; +import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioEmpresaCorrida; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; @Controller("relatorioEmpresaCorridaController") @@ -28,17 +31,27 @@ public class RelatorioEmpresaCorridaController extends MyGenericForwardComposer @Autowired private DataSource dataSource; + @Autowired + private EmpresaService empresaService; private Datebox datInicial; private Datebox datFinal; + private MyComboboxEstandar cmbEmpresa; + + private List lsEmpresas; private void executarRelatorio() throws Exception { Map parametros = new HashMap(); - + + Empresa empresa = cmbEmpresa.getSelectedItem() != null ? (Empresa)cmbEmpresa.getSelectedItem().getValue() : null; + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); parametros.put("fecInicio", sdf.format(this.datInicial.getValue())); parametros.put("fecFinal", sdf.format(this.datFinal.getValue())); + if (empresa != null){ + parametros.put("empresa", empresa.getEmpresaId()); + } parametros.put("TITULO", Labels.getLabel("relatorioEmpresaCorridaController.window.title")); Relatorio relatorio = new RelatorioEmpresaCorrida(parametros, dataSource.getConnection()); @@ -57,7 +70,24 @@ public class RelatorioEmpresaCorridaController extends MyGenericForwardComposer @Override public void doAfterCompose(Component comp) throws Exception { + lsEmpresas = empresaService.obtenerTodos(); super.doAfterCompose(comp); } + public MyComboboxEstandar getCmbEmpresa() { + return cmbEmpresa; + } + + public void setCmbEmpresa(MyComboboxEstandar cmbEmpresa) { + this.cmbEmpresa = cmbEmpresa; + } + + public List getLsEmpresas() { + return lsEmpresas; + } + + public void setLsEmpresas(List lsEmpresas) { + this.lsEmpresas = lsEmpresas; + } + } diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index cf5073784..854bf75d2 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -300,6 +300,7 @@ relatorioAproveitamentoController.btnBuscarServico.label = Buscar servicio relatorioEmpresaCorridaController.window.title=Reporte Empresa Corrida relatorioEmpresaCorridaController.lbDataIni.value=Fecha Inicio relatorioEmpresaCorridaController.lbDataFin.value=Fecha Final +relatorioEmpresaCorridaController.lbEmpresa.value=Empresa # Relatorio Empresa Onibus relatorioEmpresaOnibusController.window.title=Reporte Empresa Onibus diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index b2625ea4e..89075b6ff 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -305,6 +305,7 @@ relatorioAproveitamentoController.btnBuscarServico.label = Buscar Serviço relatorioEmpresaCorridaController.window.title=Relatório Empresa Corrida relatorioEmpresaCorridaController.lbDataIni.value=Data Inicial relatorioEmpresaCorridaController.lbDataFin.value=Data Final +relatorioEmpresaCorridaController.lbEmpresa.value=Empresa # Relatorio Empresa Onibus relatorioEmpresaOnibusController.window.title=Relatório Empresa Ônibus diff --git a/web/gui/relatorios/filtroRelatorioEmpresaCorrida.zul b/web/gui/relatorios/filtroRelatorioEmpresaCorrida.zul index 7997586da..d291caf84 100644 --- a/web/gui/relatorios/filtroRelatorioEmpresaCorrida.zul +++ b/web/gui/relatorios/filtroRelatorioEmpresaCorrida.zul @@ -30,6 +30,14 @@ format="dd/MM/yyyy" lenient="false" constraint="no empty" maxlength="10" /> + +