diff --git a/pom.xml b/pom.xml
index 8476acbd6..0a9b4db6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,12 +4,12 @@
4.0.0
br.com.rjconsultores
ventaboletosadm
- 1.54.9
+ 1.55.0
war
1.40.7
- 1.30.1
+ 1.31.0
UTF-8
UTF-8
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java
new file mode 100644
index 000000000..f6c621a5d
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java
@@ -0,0 +1,266 @@
+/**
+ *
+ */
+package com.rjconsultores.ventaboletos.relatorios.impl;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.rjconsultores.ventaboletos.entidad.Empresa;
+import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
+import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
+import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioBilhetesVendidosEstoqueAgenciaBean;
+import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioIndiceIRKBean;
+import com.rjconsultores.ventaboletos.utilerias.DateUtil;
+import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
+
+import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
+
+/**
+ * @author Wallace
+ *
+ */
+public class RelatorioBilhetesVendidosEstoqueAgencia extends Relatorio {
+ private List lsDadosRelatorio;
+
+ public RelatorioBilhetesVendidosEstoqueAgencia(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();
+ String pnutoVentasIds = (String) parametros.get("NUMPUNTOVENTA");
+ Integer empresa = (Integer) parametros.get("EMPRESA_ID");
+ Date datainicial = (Date) parametros.get("DATA_INICIAL");
+ Date dataFinal = (Date) parametros.get("DATA_FINAL");
+
+ NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql(pnutoVentasIds));
+
+ stmt.setInt("EMPRESA_ID", empresa);
+ stmt.setString("dataInicio", DateUtil.getStringDate(datainicial, "dd/MM/yyyy") + " 00:00:00");
+ stmt.setString("dataFinal", DateUtil.getStringDate(dataFinal, "dd/MM/yyyy") + " 23:59:59");
+
+ ResultSet rset = stmt.executeQuery();
+ List lsTemp = new ArrayList<>();
+ List lsRelatorioBilhetesVendidosEstoqueAgenciaBean = new ArrayList<>();
+ List lsRelatorioBilhetesVendidosEstoqueAgenciaBeanGeradoSequencia = new ArrayList<>();
+ while (rset.next()) {
+
+ Map dataResult = new HashMap();
+
+ RelatorioBilhetesVendidosEstoqueAgenciaBean bean = new RelatorioBilhetesVendidosEstoqueAgenciaBean();
+ bean.setAidfId(rset.getInt("aidfId"));
+ bean.setNombpuntoventa(rset.getString("descpuntoVenta"));
+ bean.setSerie(rset.getString("serie"));
+ bean.setFechorVenta(DateUtil.getDateFromString(rset.getString("dataVenda"), "ddMMyyyy"));
+ bean.setChave(rset.getString("chave"));
+ bean.setFolio(rset.getString("folio"));
+ bean.setNomeEmpresa(rset.getString("nomeEmpresa"));
+ bean.setTipoEvento("Incluir");
+ lsRelatorioBilhetesVendidosEstoqueAgenciaBean.add(bean);
+
+ this.dados.add(dataResult);
+
+ }
+
+ Map map = new HashMap();
+ for (RelatorioBilhetesVendidosEstoqueAgenciaBean i : lsRelatorioBilhetesVendidosEstoqueAgenciaBean) {
+ map.put(i.getChave(), i.getChave());
+ }
+ for (Map.Entry entry : map.entrySet()) {
+ for (RelatorioBilhetesVendidosEstoqueAgenciaBean i : lsRelatorioBilhetesVendidosEstoqueAgenciaBean) {
+ if(entry.getKey().equals(i.getChave())) {
+ lsTemp.add(i);
+ }
+ }
+
+ for (RelatorioBilhetesVendidosEstoqueAgenciaBean bean : lsTemp) {
+ lsRelatorioBilhetesVendidosEstoqueAgenciaBeanGeradoSequencia.addAll(agruparSequenciasBilhetes(lsTemp));
+ break;
+ }
+ lsTemp = new ArrayList<>();
+ }
+
+ Collections.sort(lsRelatorioBilhetesVendidosEstoqueAgenciaBeanGeradoSequencia, new Comparator() {
+ @Override
+ public int compare(RelatorioBilhetesVendidosEstoqueAgenciaBean rel1, RelatorioBilhetesVendidosEstoqueAgenciaBean rel2) {
+ return DateUtil.compareDate(rel1.getFechorVenta(), rel2.getFechorVenta());
+ }
+ });
+
+ this.resultSet = rset;
+ setLsDadosRelatorio(lsRelatorioBilhetesVendidosEstoqueAgenciaBeanGeradoSequencia);
+ }
+ });
+ }
+
+ public void setLsDadosRelatorio(List lsDadosRelatorio) {
+ this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio));
+ this.lsDadosRelatorio = lsDadosRelatorio;
+ }
+
+ public List getLsDadosRelatorio() {
+ return lsDadosRelatorio;
+ }
+
+ private String sql(String puntoVentasId) {
+
+ StringBuilder sql = new StringBuilder();
+
+ sql.append(" SELECT TB.aidfId as aidfId, ");
+ sql.append(" TB.descpuntoVenta as descpuntoVenta, ");
+ sql.append(" TB.SERIE as serie, ");
+ sql.append(" TB.puntoventaId, ");
+ sql.append(" TB.dataVenda as dataVenda, ");
+ sql.append(" TB.chave as chave, ");
+ sql.append(" TB.nomeEmpresa as nomeEmpresa , TB.folio as folio ");
+ sql.append(" FROM (SELECT DAB.AIDF_ID AS aidfId, ");
+ sql.append(" pv.nombpuntoventa AS descpuntoVenta, ");
+ sql.append(" c.numseriepreimpresa AS SERIE, ");
+ sql.append(" c.puntoventa_id AS puntoventaId, ");
+ sql.append(" to_char(c.fechorventa, 'ddMMyyyy') AS dataVenda, ");
+ sql.append(" DAB.AIDF_ID || c.numseriepreimpresa || c.puntoventa_id || to_char(c.fechorventa, 'ddMMyyyy') AS chave, ");
+ sql.append(" em.nombEmpresa as nomeEmpresa , c.numfoliopreimpreso as folio ");
+ sql.append(" FROM caja c, ");
+ sql.append(" PUNTO_VENTA PV, ");
+ sql.append(" EMPRESA EM, ");
+ sql.append(" AIDF AI, ");
+ sql.append(" ABASTO_BOLETO AB ");
+ sql.append(" LEFT JOIN DET_ABASTO_BOLETO DAB ON (AB.ABASTOBOLETO_ID = DAB.ABASTOBOLETO_ID) ");
+ sql.append(" WHERE fechorventa BETWEEN TO_DATE(:dataInicio,'dd/mm/yyyy hh24:mi:ss') AND TO_DATE(:dataFinal,'dd/mm/yyyy hh24:mi:ss') ");
+ sql.append(" AND TO_NUMBER(c.NUMFOLIOPREIMPRESO) BETWEEN TO_NUMBER(DAB.NUMFOLIOINICIAL) AND TO_NUMBER(DAB.NUMFOLIOFINAL) ");
+ sql.append(" AND c.PUNTOVENTA_ID = AB.PUNTOVENTA_ID ");
+ if (puntoVentasId != null && !puntoVentasId.equals("-1")) {
+ sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVentasId + ") ");
+ }
+ sql.append(" AND EM.EMPRESA_ID = AB.EMPRESA_ID ");
+ sql.append(" AND c.PUNTOVENTA_ID = PV.PUNTOVENTA_ID ");
+ sql.append(" AND DAB.AIDF_ID = AI.AIDF_ID ");
+ sql.append(" AND EM.EMPRESA_ID =:EMPRESA_ID ");
+ sql.append(" GROUP BY DAB.AIDF_ID,c.numseriepreimpresa, c.numfoliopreimpreso, ");
+ sql.append(" c.puntoventa_id, ");
+ sql.append(" to_char(c.fechorventa, 'ddMMyyyy'), ");
+ sql.append(" pv.nombpuntoventa, ");
+ sql.append(" em.nombEmpresa ");
+ sql.append(" ");
+ sql.append(" UNION ALL ");
+ sql.append(" SELECT DAB.AIDF_ID AS aidfId, ");
+ sql.append(" pv.nombpuntoventa AS descpuntoVenta, ");
+ sql.append(" c.numseriepreimpresa AS SERIE, ");
+ sql.append(" c.puntoventa_id AS puntoventaId, ");
+ sql.append(" to_char(c.FECHORVTA, 'ddMMyyyy') AS dataVenda, ");
+ sql.append(" DAB.AIDF_ID || c.numseriepreimpresa || c.puntoventa_id || to_char(c.FECHORVTA, 'ddMMyyyy') AS chave, ");
+ sql.append(" em.nombEmpresa as nomeEmpresa , c.numfoliopreimpreso as folio ");
+ sql.append(" FROM caja_diversos c, ");
+ sql.append(" PUNTO_VENTA PV, ");
+ sql.append(" EMPRESA EM, ");
+ sql.append(" AIDF AI, ");
+ sql.append(" ABASTO_BOLETO AB ");
+ sql.append(" LEFT JOIN DET_ABASTO_BOLETO DAB ON (AB.ABASTOBOLETO_ID = DAB.ABASTOBOLETO_ID) ");
+ sql.append(" WHERE FECHORVTA BETWEEN TO_DATE(:dataInicio,'dd/mm/yyyy hh24:mi:ss') AND TO_DATE(:dataFinal,'dd/mm/yyyy hh24:mi:ss') ");
+ sql.append(" AND TO_NUMBER(c.NUMFOLIOPREIMPRESO) BETWEEN TO_NUMBER(DAB.NUMFOLIOINICIAL) AND TO_NUMBER(DAB.NUMFOLIOFINAL) ");
+ sql.append(" AND c.PUNTOVENTA_ID = AB.PUNTOVENTA_ID ");
+ if (puntoVentasId != null && !puntoVentasId.equals("-1")) {
+ sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVentasId + ") ");
+ }
+ sql.append(" AND EM.EMPRESA_ID = AB.EMPRESA_ID ");
+ sql.append(" AND c.PUNTOVENTA_ID = PV.PUNTOVENTA_ID ");
+ sql.append(" AND DAB.AIDF_ID = AI.AIDF_ID ");
+ sql.append(" AND EM.EMPRESA_ID =:EMPRESA_ID ");
+ sql.append(" GROUP BY DAB.AIDF_ID,c.numseriepreimpresa, c.numfoliopreimpreso, ");
+ sql.append(" c.puntoventa_id, ");
+ sql.append(" to_char(c.FECHORVTA, 'ddMMyyyy'), ");
+ sql.append(" pv.nombpuntoventa, ");
+ sql.append(" em.nombEmpresa ");
+ sql.append(" )TB ");
+ sql.append(" ORDER BY to_number(TB.FOLIO) ");
+ System.out.println(sql.toString());
+ return sql.toString();
+
+
+ }
+
+ private List agruparSequenciasBilhetes(List lista) {
+
+
+ int[] bilhetesInt = new int[lista.size()];
+ int i = 0;
+
+ for (RelatorioBilhetesVendidosEstoqueAgenciaBean relatorioBilhetesVendidosEstoqueAgenciaBean : lista) {
+ bilhetesInt[i] = Integer.parseInt(relatorioBilhetesVendidosEstoqueAgenciaBean.getFolio());
+ i++;
+ }
+ Arrays.sort(bilhetesInt);
+ List listaAgrupada = new ArrayList<>();
+
+ RelatorioBilhetesVendidosEstoqueAgenciaBean bean = lista.get(0);
+
+ bilhetesInt = reajustarPosicaoArray(bilhetesInt.length, bilhetesInt, bilhetesInt[0], 1);
+ int inicio = bilhetesInt[0];
+ int fim = bilhetesInt.length == 1 ? bilhetesInt[0] : bilhetesInt[1];
+
+ for (int j = 2; j < bilhetesInt.length; ++j) {
+ if (fim + 1 == bilhetesInt[j]) {
+ fim++;
+ } else {
+ listaAgrupada.add(gerarAgrupamento(inicio, fim, new RelatorioBilhetesVendidosEstoqueAgenciaBean(bean)));
+ inicio = bilhetesInt[j];
+ fim = bilhetesInt[j];
+ }
+ }
+
+ listaAgrupada.add(gerarAgrupamento(inicio, fim, bean));
+
+ return listaAgrupada;
+ }
+
+
+ private RelatorioBilhetesVendidosEstoqueAgenciaBean gerarAgrupamento(int inicio, int fim, RelatorioBilhetesVendidosEstoqueAgenciaBean bean) {
+
+ RelatorioBilhetesVendidosEstoqueAgenciaBean object = new RelatorioBilhetesVendidosEstoqueAgenciaBean(bean);
+
+
+ if (inicio != fim) {
+ object.setQuantidade((fim-inicio+1));
+ object.setFolioInicial(inicio);
+ object.setFolioFinal(fim);
+
+ } else {
+ object.setQuantidade(1);
+ object.setFolioInicial(inicio);
+ object.setFolioFinal(inicio);
+ }
+ return object;
+ }
+ private int[] reajustarPosicaoArray(int numero, int arr[],int x, int posicao)
+ {
+ int novoArray[] = new int[numero + 1];
+
+ for (int i = 0; i < numero + 1; i++) {
+ if (i < posicao - 1)
+ novoArray[i] = arr[i];
+ else if (i == posicao - 1)
+ novoArray[i] = x;
+ else
+ novoArray[i] = arr[i - 1];
+ }
+ return novoArray;
+ }
+
+ @Override
+ protected void processaParametros() throws Exception {
+
+ }
+
+}
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgencia_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgencia_es.properties
new file mode 100644
index 000000000..6128dbef4
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgencia_es.properties
@@ -0,0 +1,20 @@
+#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:
+
+#Labels header
+label.aidf=AIDF
+label.empresa=Empresa
+label.agencia=Agencia
+label.serie=Serie
+label.bilhete=Bilhetes
+label.numeracao=Numeração
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgencia_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgencia_pt_BR.properties
new file mode 100644
index 000000000..6128dbef4
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgencia_pt_BR.properties
@@ -0,0 +1,20 @@
+#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:
+
+#Labels header
+label.aidf=AIDF
+label.empresa=Empresa
+label.agencia=Agencia
+label.serie=Serie
+label.bilhete=Bilhetes
+label.numeracao=Numeração
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgencia.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgencia.jasper
new file mode 100644
index 000000000..73e4ff4df
Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgencia.jasper differ
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgencia.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgencia.jrxml
new file mode 100644
index 000000000..0d887a7e2
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgencia.jrxml
@@ -0,0 +1,254 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java
new file mode 100644
index 000000000..50ef35b41
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java
@@ -0,0 +1,111 @@
+package com.rjconsultores.ventaboletos.relatorios.utilitarios;
+
+import java.util.Date;
+
+public class RelatorioBilhetesVendidosEstoqueAgenciaBean {
+
+ private String nombpuntoventa;
+ private Date fechorVenta;
+ private Integer quantidade;
+ private String tipoEvento;
+ private String serie;
+ private Integer folioInicial;
+ private Integer folioFinal;
+ private Integer aidfId;
+ private String nomeEmpresa;
+ private String range;
+ private String chave;
+ private String folio;
+
+
+ public RelatorioBilhetesVendidosEstoqueAgenciaBean(RelatorioBilhetesVendidosEstoqueAgenciaBean bean) {
+ this.aidfId = bean.getAidfId();
+ this.nombpuntoventa = bean.getNombpuntoventa();
+ this.nomeEmpresa = bean.getNomeEmpresa();
+ this.tipoEvento = bean.getTipoEvento();
+ this.serie = bean.getSerie();
+ this.chave = bean.getChave();
+ this.range = bean.getRange();
+ this.fechorVenta = bean.getFechorVenta();
+
+ }
+
+ public RelatorioBilhetesVendidosEstoqueAgenciaBean() {
+
+ }
+ public String getNombpuntoventa() {
+ return nombpuntoventa;
+ }
+ public void setNombpuntoventa(String nombpuntoventa) {
+ this.nombpuntoventa = nombpuntoventa;
+ }
+ public Date getFechorVenta() {
+ return fechorVenta;
+ }
+ public void setFechorVenta(Date fechorVenta) {
+ this.fechorVenta = fechorVenta;
+ }
+ public Integer getQuantidade() {
+ return quantidade;
+ }
+ public void setQuantidade(Integer quantidade) {
+ this.quantidade = quantidade;
+ }
+ public String getTipoEvento() {
+ return tipoEvento;
+ }
+ public void setTipoEvento(String tipoEvento) {
+ this.tipoEvento = tipoEvento;
+ }
+ public String getSerie() {
+ return serie;
+ }
+ public void setSerie(String serie) {
+ this.serie = serie;
+ }
+ public Integer getFolioInicial() {
+ return folioInicial;
+ }
+ public void setFolioInicial(Integer folioInicial) {
+ this.folioInicial = folioInicial;
+ }
+ public Integer getFolioFinal() {
+ return folioFinal;
+ }
+ public void setFolioFinal(Integer folioFinal) {
+ this.folioFinal = folioFinal;
+ }
+ public Integer getAidfId() {
+ return aidfId;
+ }
+ public void setAidfId(Integer aidfId) {
+ this.aidfId = aidfId;
+ }
+ public String getNomeEmpresa() {
+ return nomeEmpresa;
+ }
+ public void setNomeEmpresa(String nomeEmpresa) {
+ this.nomeEmpresa = nomeEmpresa;
+ }
+ public String getRange() {
+ return range;
+ }
+ public void setRange(String range) {
+ this.range = range;
+ }
+ public String getChave() {
+ return chave;
+ }
+ public void setChave(String chave) {
+ this.chave = chave;
+ }
+
+ public String getFolio() {
+ return folio;
+ }
+
+ public void setFolio(String folio) {
+ this.folio = folio;
+ }
+
+}
diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java
new file mode 100644
index 000000000..ff5b21f0a
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java
@@ -0,0 +1,213 @@
+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.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.Combobox;
+import org.zkoss.zul.Comboitem;
+import org.zkoss.zul.Datebox;
+import org.zkoss.zul.Paging;
+import org.zkoss.zul.Radiogroup;
+
+import com.rjconsultores.ventaboletos.entidad.Empresa;
+import com.rjconsultores.ventaboletos.entidad.Estado;
+import com.rjconsultores.ventaboletos.entidad.Moneda;
+import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
+import com.rjconsultores.ventaboletos.enums.IndStatusBoleto;
+import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidos;
+import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidosEstoqueAgencia;
+import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidosNovoLayout;
+import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
+import com.rjconsultores.ventaboletos.service.EmpresaService;
+import com.rjconsultores.ventaboletos.service.EstadoService;
+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;
+import com.rjconsultores.ventaboletos.web.utilerias.render.RenderRelatorioVendasBilheteiroSelecionados;
+
+@Controller("relatorioBilhetesVendidosEstoqueAgenciaController")
+@Scope("prototype")
+public class RelatorioBilhetesVendidosEstoqueAgenciaController extends MyGenericForwardComposer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Autowired
+ private DataSource dataSourceRead;
+
+ @Autowired
+ private EmpresaService empresaService;
+
+ private Datebox datInicial;
+ private Datebox datFinal;
+ private MyComboboxEstandar cmbEmpresa;
+ private Combobox cmbMoeda;
+ private List lsEmpresa;
+ private List lsEstado;
+ @Autowired
+ private transient PagedListWrapper plwPuntoVenta;
+ private MyTextbox txtNombrePuntoVenta;
+ private Bandbox bbPesquisaPuntoVenta;
+ private MyListbox puntoVentaList;
+ private MyListbox puntoVentaSelList;
+ private Paging pagingPuntoVenta;
+
+
+ @Override
+ public void doAfterCompose(Component comp) throws Exception {
+ lsEmpresa = empresaService.obtenerTodos();
+ super.doAfterCompose(comp);
+ puntoVentaList.setItemRenderer(new RenderRelatorioVendasBilheteiro());
+ puntoVentaSelList.setItemRenderer(new RenderRelatorioVendasBilheteiroSelecionados());
+
+ }
+
+ public List getLsEmpresa() {
+ return lsEmpresa;
+ }
+
+ public void setLsEmpresa(List lsEmpresa) {
+ this.lsEmpresa = lsEmpresa;
+ }
+
+ public List getLsEstado() {
+ return lsEstado;
+ }
+
+ public void setLsEstado(List lsEstado) {
+ this.lsEstado = lsEstado;
+ }
+
+ 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(false);
+ }
+
+ public void onClick$btnExecutarRelatorioNovoLayout(Event ev) throws Exception {
+ executarRelatorio(true);
+ }
+
+ /**
+ * @throws Exception
+ *
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ private void executarRelatorio(boolean novoLayout) 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("relatorioBilhetesVendidosEstoqueAgenciaController.window.title"));
+ parametros.put("USUARIO", UsuarioLogado.getUsuarioLogado().getNombusuario());
+
+ String status = "";
+
+ 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;");
+ }
+
+ relatorio = new RelatorioBilhetesVendidosEstoqueAgencia(parametros, dataSourceRead.getConnection());
+ parametros.put("FILTROS", filtro.toString());
+
+ Map args = new HashMap();
+ args.put("relatorio", relatorio);
+
+ openWindow("/component/reportView.zul", Labels.getLabel("relatorioBilhetesVendidosController.window.title"), args, MODAL);
+ }
+
+}
+
diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioBilhetesVendidosEstoqueAgencia.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioBilhetesVendidosEstoqueAgencia.java
new file mode 100644
index 000000000..cb2f68069
--- /dev/null
+++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/relatorios/ItemMenuRelatorioBilhetesVendidosEstoqueAgencia.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 ItemMenuRelatorioBilhetesVendidosEstoqueAgencia extends DefaultItemMenuSistema {
+
+ public ItemMenuRelatorioBilhetesVendidosEstoqueAgencia() {
+ super("indexController.mniRelatorioBilhetesVendidosEstoqueAgencia.label");
+ }
+
+ @Override
+ public String getClaveMenu() {
+ return "COM.RJCONSULTORES.ADMINISTRACION.GUI.RELATORIOS.MENU.RELATORIOBILHETESVENDIDOSESTOQUEAGENCIA";
+ }
+
+ @Override
+ public void ejecutar() {
+ PantallaUtileria.openWindow("/gui/relatorios/filtroRelatorioBilhetesVendidosEstoqueAgencia.zul",
+ Labels.getLabel("relatorioBilhetesVendidosEstoqueAgenciaController.window.title"), getArgs() ,desktop);
+ }
+
+}
diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties
index 48c75451a..9a8926c47 100644
--- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties
+++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties
@@ -184,6 +184,7 @@ analitico.gerenciais.operacionais.linhasHorario=com.rjconsultores.ventaboletos.w
analitico.gerenciais.operacionais.demandas=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioDemandas
analitico.gerenciais.operacionais.embarqueLocalidade=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioEmbarqueLocalidade
analitico.gerenciais.operacionais.remarcacaoTransferencia=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioRemarcacaoPassagensTransferencia
+analitico.gerenciais.operacionais.bilhetesVendidosEstoqueAgencia=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioBilhetesVendidosEstoqueAgencia
analitico.gerenciais.estatisticos=com.rjconsultores.ventaboletos.web.utilerias.menu.item.analitico.gerenciais.estatisticos.SubMenuRelatorioEstatisticos
analitico.gerenciais.estatisticos.quadroDemonstrativoPassageiro=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioQuadroDemonstrativoMovimentoPassageiros
analitico.gerenciais.estatisticos.receitaLinhaOperacional=com.rjconsultores.ventaboletos.web.utilerias.menu.item.relatorios.ItemMenuRelatorioLinhaOperacional
diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label
index 2d0636668..a4ba6b581 100644
--- a/web/WEB-INF/i3-label_es_MX.label
+++ b/web/WEB-INF/i3-label_es_MX.label
@@ -593,6 +593,31 @@ relatorioBilhetesVendidosController.reimpresso.label = Reimpresso
relatorioBilhetesVendidosController.marcado.label = Marcado
relatorioBilhetesVendidosController.categoria.label = Categoria
+# Relatório Bilhetes Vendidos Estoque Agencia
+relatorioBilhetesVendidosEstoqueAgenciaController.window.title = Bilhetes Vendidos Estoque Agência
+relatorioBilhetesVendidosEstoqueAgenciaController.lbDatInicial.value = Data Inicial
+relatorioBilhetesVendidosEstoqueAgenciaController.lbDatFinal.value = Data Final
+relatorioBilhetesVendidosEstoqueAgenciaController.lbDatFinal.value = Data Final
+relatorioBilhetesVendidosEstoqueAgenciaController.lbEmpresa.value = Empresa
+relatorioBilhetesVendidosEstoqueAgenciaController.lbPuntoVenta.value = Agência
+relatorioBilhetesVendidosEstoqueAgenciaController.lbEstado.value = Estado
+relatorioBilhetesVendidosEstoqueAgenciaController.lbStatus.value = Status
+relatorioBilhetesVendidosEstoqueAgenciaController.lbNumero.value = Número
+relatorioBilhetesVendidosEstoqueAgenciaController.vendido.label = Vendido
+relatorioBilhetesVendidosEstoqueAgenciaController.cancelado.label = Cancelado
+relatorioBilhetesVendidosEstoqueAgenciaController.IdaVolta.label = Ida/Volta
+relatorioBilhetesVendidosEstoqueAgenciaController.dataVenda.label = Data Venda
+relatorioBilhetesVendidosEstoqueAgenciaController.dataEmissao.label = Data Emissão
+relatorioBilhetesVendidosEstoqueAgenciaController.dataViagem.label = Data Viagem
+relatorioBilhetesVendidosEstoqueAgenciaController.transferido.label = Transferido
+relatorioBilhetesVendidosEstoqueAgenciaController.entregue.label = Entregue
+relatorioBilhetesVendidosEstoqueAgenciaController.reservado.label = Reservado
+relatorioBilhetesVendidosEstoqueAgenciaController.extravidado.label = Extraviado
+relatorioBilhetesVendidosEstoqueAgenciaController.reimpresso.label = Reimpresso
+relatorioBilhetesVendidosEstoqueAgenciaController.marcado.label = Marcado
+relatorioBilhetesVendidosEstoqueAgenciaController.categoria.label = Categoria
+
+
# Relatório Recarga Rvhub
indexController.mniRelatorioRecargaRvhub.label = Recarga Rvhub
relatorioRecargaRvhubController.window.title = Recarga Rvhub
diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label
index 4e7fc71fc..5cdd3f498 100644
--- a/web/WEB-INF/i3-label_pt_BR.label
+++ b/web/WEB-INF/i3-label_pt_BR.label
@@ -361,6 +361,7 @@ indexController.mniRelatorioPassagensAGER.label = Relatório Passagens AGER
indexController.mniRelatorioGratuidadeAGEPAN.label = Gratuidades AGEPAN
indexController.mniRelatorioOperacionalFinanceiro.label = Relatório Operacional Financeiro
indexController.mniRelatorioBilhetesVendidos.label = Bilhetes Vendidos
+indexController.mniRelatorioBilhetesVendidosEstoqueAgencia.label = Bilhetes Vendidos Estoque Agencia
indexController.mniRelatorioGratuidadeIdosoDeficiente.label = Gratuidades Idoso/Deficiente
indexController.mniRelatorioAproveitamentoFinanceiro.label = Aproveitamento Financeiro
indexController.mniRelatorioVendasBilheteiro.label = Vendas por Bilheteiro
@@ -8432,6 +8433,30 @@ relatorioBilhetesVendidosController.reimpresso.label = Reimpresso
relatorioBilhetesVendidosController.marcado.label = Marcado
relatorioBilhetesVendidosController.categoria.label = Categoria
+# Relatório Bilhetes Vendidos Estoque Agencia
+relatorioBilhetesVendidosEstoqueAgenciaController.window.title = Bilhetes Vendidos Estoque Agência
+relatorioBilhetesVendidosEstoqueAgenciaController.lbDatInicial.value = Data Inicial
+relatorioBilhetesVendidosEstoqueAgenciaController.lbDatFinal.value = Data Final
+relatorioBilhetesVendidosEstoqueAgenciaController.lbDatFinal.value = Data Final
+relatorioBilhetesVendidosEstoqueAgenciaController.lbEmpresa.value = Empresa
+relatorioBilhetesVendidosEstoqueAgenciaController.lbPuntoVenta.value = Agência
+relatorioBilhetesVendidosEstoqueAgenciaController.lbEstado.value = Estado
+relatorioBilhetesVendidosEstoqueAgenciaController.lbStatus.value = Status
+relatorioBilhetesVendidosEstoqueAgenciaController.lbNumero.value = Número
+relatorioBilhetesVendidosEstoqueAgenciaController.vendido.label = Vendido
+relatorioBilhetesVendidosEstoqueAgenciaController.cancelado.label = Cancelado
+relatorioBilhetesVendidosEstoqueAgenciaController.IdaVolta.label = Ida/Volta
+relatorioBilhetesVendidosEstoqueAgenciaController.dataVenda.label = Data Venda
+relatorioBilhetesVendidosEstoqueAgenciaController.dataEmissao.label = Data Emissão
+relatorioBilhetesVendidosEstoqueAgenciaController.dataViagem.label = Data Viagem
+relatorioBilhetesVendidosEstoqueAgenciaController.transferido.label = Transferido
+relatorioBilhetesVendidosEstoqueAgenciaController.entregue.label = Entregue
+relatorioBilhetesVendidosEstoqueAgenciaController.reservado.label = Reservado
+relatorioBilhetesVendidosEstoqueAgenciaController.extravidado.label = Extraviado
+relatorioBilhetesVendidosEstoqueAgenciaController.reimpresso.label = Reimpresso
+relatorioBilhetesVendidosEstoqueAgenciaController.marcado.label = Marcado
+relatorioBilhetesVendidosEstoqueAgenciaController.categoria.label = Categoria
+
# Relatório Recarga Rvhub
indexController.mniRelatorioRecargaRvhub.label = Recarga Rvhub
relatorioRecargaRvhubController.window.title = Recarga Rvhub
diff --git a/web/gui/relatorios/filtroRelatorioBilhetesVendidosEstoqueAgencia.zul b/web/gui/relatorios/filtroRelatorioBilhetesVendidosEstoqueAgencia.zul
new file mode 100644
index 000000000..42221a695
--- /dev/null
+++ b/web/gui/relatorios/filtroRelatorioBilhetesVendidosEstoqueAgencia.zul
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file