diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCarteirinha.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCarteirinha.java index 3cdb65a9c..442b1258a 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCarteirinha.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioCarteirinha.java @@ -7,6 +7,7 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,11 +29,12 @@ public class RelatorioCarteirinha extends Relatorio { private static Logger log = org.slf4j.LoggerFactory.getLogger(RelatorioCarteirinha.class); private List clientes; - + private Integer tipoLayout; - public RelatorioCarteirinha(Map parametros, final List lsClienteSelecionados, Connection conexao) throws Exception { + public RelatorioCarteirinha(Map parametros, final List lsClienteSelecionados, Connection conexao, Integer tipoLayout) throws Exception { super(parametros, conexao); this.clientes = lsClienteSelecionados; + this.tipoLayout = tipoLayout; this.setCustomDataSource(new ArrayDataSource(this) { public void initDados() throws Exception { Connection conexao = this.relatorio.getConexao(); @@ -40,6 +42,16 @@ public class RelatorioCarteirinha extends Relatorio { } }); } + + @Override + public String getNome() { + if(tipoLayout.intValue() == 1 ){ + return this.getClass().getSimpleName(); + }else{ + return "RelatorioCarteirinhaLayout2"; + } + + } @Override protected void processaParametros() throws Exception { @@ -70,13 +82,27 @@ public class RelatorioCarteirinha extends Relatorio { log.error("", e); } for(int i = 0; i < clientes.size(); i++){ - Map dataResult = new HashMap(); - preencherDadosCliente(i, dataResult); - preencherDadosEmpresa(dados, rset, image, dataResult); + if(validadeDescuentoValida(clientes.get(i))){ + Map dataResult = new HashMap(); + preencherDadosCliente(i, dataResult); + preencherDadosEmpresa(dados, rset, image, dataResult); + } } } resultSet = rset; } + + private boolean validadeDescuentoValida(Cliente c){ + boolean b = false; + if(c.getLsClienteDescuento() != null && !c.getLsClienteDescuento().isEmpty()){ + for(ClienteDescuento cd : c.getLsClienteDescuento()){ + if(cd.getFecFin().after(Calendar.getInstance().getTime())){ + b = true; + } + } + } + return b; + } private void preencherDadosEmpresa(List> dados, ResultSet rset, BufferedImage image, Map dataResult) throws SQLException { dataResult.put("logomarca", image); @@ -115,13 +141,40 @@ public class RelatorioCarteirinha extends Relatorio { }else{ dataResult.put("escola", ""); } + Date validadeDate = null; + if(clientes.get(i).getLsClienteDescuento() != null && !clientes.get(i).getLsClienteDescuento().isEmpty() && + clientes.get(i).getLsClienteDescuento().get(0) != null){ + validadeDate = clientes.get(i).getLsClienteDescuento().get(0).getFecFin(); + } + + for(ClienteDescuento cd : clientes.get(i).getLsClienteDescuento()){ + if(validadeDate != null && cd.getFecFin().before(validadeDate) ){ + validadeDate = cd.getFecFin(); + } + } + + if(validadeDate != null ){ + dataResult.put("validade", validadeDate.toString() ); + }else{ + dataResult.put("validade", "" ); + } if(clientes.get(i).getLsClienteDescuento() != null && clientes.get(i).getLsClienteDescuento().size() > 0){ StringBuilder trechosDescuento = new StringBuilder(); for(ClienteDescuento clienteDescuento : clientes.get(i).getLsClienteDescuento()){ - trechosDescuento.append(clienteDescuento.getOrigem().getDescparada()); + if(tipoLayout.intValue() == 2 && clienteDescuento.getOrigem().getParadaId().intValue() != -1 ){ + trechosDescuento.append(clienteDescuento.getOrigem().getCveparada()); + }else{ + trechosDescuento.append(clienteDescuento.getOrigem().getDescparada()); + } + trechosDescuento.append(" >> "); - trechosDescuento.append(clienteDescuento.getDestino().getDescparada()); + if(tipoLayout.intValue() == 2 && clienteDescuento.getDestino().getParadaId().intValue() != -1 ){ + trechosDescuento.append(clienteDescuento.getDestino().getCveparada()); + }else{ + trechosDescuento.append(clienteDescuento.getDestino().getDescparada()); + } + trechosDescuento.append(","); } trechosDescuento.deleteCharAt(trechosDescuento.length()-1); @@ -195,4 +248,12 @@ public class RelatorioCarteirinha extends Relatorio { enderecoCompleto.append(rset.getString("NOMBESTADO") != null ? rset.getString("NOMBESTADO") : "" ); return enderecoCompleto.toString(); } + + public Integer getTipoLayout() { + return tipoLayout; + } + + public void setTipoLayout(Integer tipoLayout) { + this.tipoLayout = tipoLayout; + } } diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioCarteirinhaLayout2_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioCarteirinhaLayout2_es.properties new file mode 100644 index 000000000..2770032a0 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioCarteirinhaLayout2_es.properties @@ -0,0 +1,9 @@ +label.titulo=CARTEIRA DE IDENTIFICAÇÃO - PASSE ESCOLAR +label.numero = Nº: +label.nome = Nome: +label.endereco = Endereço: +label.escola = Escola: +label.trajeto = Trajeto: +label.assinatura = Assinatura +label.de = de +label.validade = validade \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioCarteirinhaLayout2_pt.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioCarteirinhaLayout2_pt.properties new file mode 100644 index 000000000..2770032a0 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioCarteirinhaLayout2_pt.properties @@ -0,0 +1,9 @@ +label.titulo=CARTEIRA DE IDENTIFICAÇÃO - PASSE ESCOLAR +label.numero = Nº: +label.nome = Nome: +label.endereco = Endereço: +label.escola = Escola: +label.trajeto = Trajeto: +label.assinatura = Assinatura +label.de = de +label.validade = validade \ No newline at end of file diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioCarteirinhaLayout2.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioCarteirinhaLayout2.jasper new file mode 100644 index 000000000..e4737d787 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioCarteirinhaLayout2.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioCarteirinhaLayout2.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioCarteirinhaLayout2.jrxml new file mode 100644 index 000000000..79f27ed70 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioCarteirinhaLayout2.jrxml @@ -0,0 +1,216 @@ + + + + + +