public void clear() {
   if (!filtro[0]) {
     listSelectItem = new ArrayList[1];
     listSelectItem[0] = new ArrayList<>();
   }
   if (!filtro[1]) {
     data[0] = DataHoje.dataHoje();
     data[1] = DataHoje.dataHoje();
     hora[0] = "";
     hora[1] = "";
   }
   if (!filtro[2]) {
     usuario = new Usuario();
   }
   if (!filtro[3]) {
     filtroEvento[0] = false;
     filtroEvento[1] = false;
     filtroEvento[2] = false;
     filtroEvento[3] = false;
     filtroEvento[4] = false;
     loadListRotinas();
   }
   if (!filtro[4]) {
     porPesquisa = "";
     descPesquisa = "";
   }
 }
 public void close(String close) {
   if (close.equals("periodo")) {
     filtro[0] = false;
     data[0] = DataHoje.dataHoje();
     data[1] = DataHoje.dataHoje();
     hora[0] = "";
     hora[1] = "";
   } else if (close.equals("usuario")) {
     filtro[1] = false;
     usuario = new Usuario();
   } else if (close.equals("rotina")) {
     filtro[2] = false;
     listSelectItem = new ArrayList[1];
     listSelectItem[0] = new ArrayList<>();
   } else if (close.equals("evento")) {
     filtro[3] = false;
     filtroEvento[0] = false;
     filtroEvento[1] = false;
     filtroEvento[2] = false;
     filtroEvento[3] = false;
     filtroEvento[4] = false;
   } else if (close.equals("descricao")) {
     filtro[4] = false;
     descPesquisa = "";
     porPesquisa = "";
   }
   PF.update("form_logs:id_panel");
 }
 /**
  * @param list
  * @param idModelo
  * @return
  */
 public static List<HistoricoCarteirinha> gerarHistoricoCarteirinhas(
     List<Movimento> list, Integer idModelo) {
   HistoricoCarteirinha historicoCarteirinha;
   SocioCarteirinhaDao socioCarteirinhaDB = new SocioCarteirinhaDao();
   Dao dao = new Dao();
   dao.openTransaction();
   List<HistoricoCarteirinha> carteirinhas = new ArrayList();
   for (int i = 0; i < list.size(); i++) {
     if (list.get(i).getMatriculaSocios() != null) {
       historicoCarteirinha = new HistoricoCarteirinha();
       historicoCarteirinha.setHora(DataHoje.hora());
       historicoCarteirinha.setDescricao("Impressão de Carteirinha");
       historicoCarteirinha.setEmissao(DataHoje.data());
       historicoCarteirinha.setMovimento(list.get(i));
       historicoCarteirinha.setCarteirinha(
           socioCarteirinhaDB.pesquisaCarteirinhaPessoa(
               list.get(i).getBeneficiario().getId(), idModelo));
       if (!dao.save(historicoCarteirinha)) {
         dao.rollback();
         return new ArrayList();
       }
       carteirinhas.add(historicoCarteirinha);
     }
   }
   if (carteirinhas.isEmpty()) {
     dao.rollback();
     return new ArrayList();
   }
   dao.commit();
   return carteirinhas;
 }
 public Boolean liberaReimpressaoPorData(String emissao) {
   if (getLiberaReimpressao()) {
     if (!emissao.isEmpty()) {
       return !DataHoje.igualdadeData(emissao, DataHoje.data());
     }
   }
   return false;
 }
 public List<SelectItem> getListaRefReplica() {
   List<SelectItem> lista = new ArrayList<SelectItem>();
   List select = new ArrayList();
   select.add(Integer.valueOf(DataHoje.data().substring(6)) - 1);
   select.add(DataHoje.data().substring(6));
   for (int i = 0; i < select.size(); i++) {
     lista.add(new SelectItem(i, select.get(i).toString(), Integer.toString(i)));
   }
   return lista;
 }
  public String replicar() {
    MensagemConvencaoDB db = new MensagemConvencaoDBToplink();
    List<MensagemConvencao> listam = new ArrayList();

    listam = db.pesquisaTodosAno(this.getListaRefReplica().get(idReplica).getLabel());

    Dao dao = new Dao();
    if (!listam.isEmpty()) {
      dao.openTransaction();
    }
    DataHoje dh = new DataHoje();
    boolean comita = false;
    for (int i = 0; i < listam.size(); i++) {
      MensagemConvencao mc = new MensagemConvencao();
      mc =
          db.verificaMensagem(
              listam.get(i).getConvencao().getId(),
              listam.get(i).getServicos().getId(),
              listam.get(i).getTipoServico().getId(),
              listam.get(i).getGrupoCidade().getId(),
              listam.get(i).getReferencia().substring(0, 3) + replicaPara);
      if (mc != null && mc.getId() != -1) {
        continue;
      }

      MensagemConvencao men =
          new MensagemConvencao(
              -1,
              listam.get(i).getGrupoCidade(),
              listam.get(i).getConvencao(),
              listam.get(i).getServicos(),
              listam.get(i).getTipoServico(),
              listam.get(i).getMensagemContribuinte(),
              listam.get(i).getMensagemCompensacao(),
              listam.get(i).getReferencia().substring(0, 3) + replicaPara,
              DataHoje.converte(dh.incrementarAnos(1, listam.get(i).getVencimento())));

      if (dao.save(men)) {
        comita = true;
      } else {
      }
    }
    if (comita) {
      dao.commit();
      msgConfirma = "Registro replicado com Sucesso!";
      GenericaMensagem.info("Sucesso", msgConfirma);
    } else {
      dao.rollback();
      msgConfirma = "Nenhuma mensagem para Replicar!";
      GenericaMensagem.warn("Erro", msgConfirma);
    }
    return "";
  }
  public void salvarRecibo(byte[] arquivo, Baixa baixa) {
    if (baixa.getCaixa() == null) {
      return;
    }

    String caminho =
        ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
            .getRealPath(
                "/Cliente/"
                    + ControleUsuarioBean.getCliente()
                    + "/"
                    + "Arquivos/recibo/"
                    + baixa.getCaixa().getCaixa()
                    + "/"
                    + DataHoje.converteData(baixa.getDtBaixa()).replace("/", "-"));
    Diretorio.criar(
        "Arquivos/recibo/"
            + baixa.getCaixa().getCaixa()
            + "/"
            + DataHoje.converteData(baixa.getDtBaixa()).replace("/", "-"));

    String path_arquivo =
        caminho
            + "/"
            + String.valueOf(baixa.getUsuario().getId())
            + "_"
            + String.valueOf(baixa.getId())
            + ".pdf";
    File file_arquivo = new File(path_arquivo);

    if (file_arquivo.exists()) {
      path_arquivo =
          caminho
              + "/"
              + String.valueOf(baixa.getUsuario().getId())
              + "_"
              + String.valueOf(baixa.getId())
              + "_(2).pdf";
    }

    try {
      File fl = new File(path_arquivo);
      FileOutputStream out = new FileOutputStream(fl);
      out.write(arquivo);
      out.flush();
      out.close();
    } catch (IOException e) {
      System.out.println(e);
    }
  }
  public void loadList() {
    lista.clear();
    listaMovimentoBoleto.clear();

    if (descricaoPesquisa.isEmpty()) {
      GenericaMensagem.warn("Atenção", "Digite uma pesquisa!");
      return;
    }

    // listaMovimentoBoleto = new PesquisaBoletosSocialDao().listaMovimentoBoleto(tipoPesquisa,
    // descricaoPesquisa);
    List<Object> result =
        new PesquisaBoletosSocialDao().listaMovimentoBoleto(tipoPesquisa, descricaoPesquisa);

    for (Object linha : result) {
      listaMovimentoBoleto.add(
          new LinhaBoleto(
              (Integer) ((List) linha).get(0), // id_titular
              (String) ((List) linha).get(1), // nome_titular
              (Integer) ((List) linha).get(2), // id_beneficiario
              (String) ((List) linha).get(3), // nome_beneficiario
              (Integer) ((List) linha).get(4), // id_servico
              (String) ((List) linha).get(5), // nome_servico
              ((Double) ((List) linha).get(6)).floatValue(), // valor
              DataHoje.converteData((Date) ((List) linha).get(7)), // vencimento
              (String) ((List) linha).get(8), // boleto atual
              (String) ((List) linha).get(9), // boleto anterior
              DataHoje.converteData((Date) ((List) linha).get(10)), // quitacao
              (Integer) ((List) linha).get(11), // id_movimento (atual)
              (Integer) ((List) linha).get(12), // id_boleto (anterior)
              (ContaCobranca)
                  new Dao()
                      .find(
                          new ContaCobranca(),
                          (Integer) ((List) linha).get(13)) // id_conta_cobranca
              ));
    }

    if (listaMovimentoBoleto.isEmpty()) {
      GenericaMensagem.warn("Atenção", "Nenhum Boleto encontrado!");
    }
  }
Beispiel #9
0
 public ChequePag() {
   this.id = -1;
   this.cheque = "";
   this.dtEmissao = DataHoje.dataHoje();
   this.dtVencimento = null;
   this.plano5 = new Plano5();
   this.dtCancelamento = null;
   this.operadorImpressao = null;
   this.operadorCancelamento = null;
   this.dtImpressao = null;
 }
  public List<Log> getListLogs() {
    if (listLogs.isEmpty()) {
      String dtInicial = null;
      String dtFinal = null;
      String hrInicial = null;
      String hrFinal = null;
      int idR = 0;
      int idU = 0;
      String idInEventos = null;
      if (filtro[0]) {
        dtInicial = DataHoje.converteData(data[0]);
        dtFinal = DataHoje.converteData(data[1]);
        hrInicial = hora[0];
        hrFinal = hora[1];
      }
      if (filtro[1]) {
        if (usuario.getId() != -1) {
          idU = usuario.getId();
        }
      }
      if (filtro[2]) {
        if (!getListRotinas().isEmpty()) {
          idR = Integer.parseInt(getListRotinas().get(index[0]).getDescription());
        }
      }
      if (filtro[3]) {
        if (!inIdEventos().isEmpty()) {
          idInEventos = inIdEventos();
        }
      }
      if (filtro[4]) {}

      PesquisaLogDao pld = new PesquisaLogDao();
      listLogs =
          (List<Log>)
              pld.pesquisaLogs(
                  dtInicial, dtFinal, hrInicial, hrFinal, idU, idR, idInEventos, descPesquisa);
    }
    return listLogs;
  }
Beispiel #11
0
 public SisPessoa() {
   this.id = -1;
   this.nome = "";
   this.documento = "";
   this.rg = "";
   this.telefone = "";
   this.celular = "";
   this.email1 = "";
   this.email2 = "";
   this.observacao = "";
   this.complemento = "";
   this.numero = "";
   this.sexo = "";
   this.tipoDocumento = new TipoDocumento();
   this.endereco = new Endereco();
   this.dtCriacao = DataHoje.dataHoje();
   this.dtNascimento = null;
   this.dtImportacao = DataHoje.dataHoje();
   this.fotoPerfil = "";
   this.fotoArquivo = "";
   this.fisica = new Fisica();
 }
Beispiel #12
0
 public SisPessoa(
     Integer id,
     String nome,
     String documento,
     String rg,
     String telefone,
     String celular,
     String email1,
     String email2,
     String observacao,
     String complemento,
     String numero,
     String sexo,
     TipoDocumento tipoDocumento,
     Endereco endereco,
     String criacao,
     String nascimento,
     String fotoPerfil,
     String fotoArquivo) {
   this.id = id;
   this.nome = nome;
   this.documento = documento;
   this.rg = rg;
   this.telefone = telefone;
   this.celular = celular;
   this.email1 = email1;
   this.email2 = email2;
   this.observacao = observacao;
   this.complemento = complemento;
   this.numero = numero;
   this.sexo = sexo;
   this.tipoDocumento = tipoDocumento;
   this.endereco = endereco;
   this.dtCriacao = DataHoje.converte(criacao);
   this.dtNascimento = DataHoje.converte(nascimento);
   this.fotoPerfil = fotoPerfil;
   this.fotoArquivo = fotoArquivo;
 }
  public String novo() {
    GenericaSessao.remove("mensagemPesquisa");
    GenericaSessao.remove("mensagemConvencaoBean");
    //        mensagemConvencao = new MensagemConvencao();
    //        msgConfirma = "";
    //        idGrupo = 0;
    //        idConvencao = 0;
    //        idServico = 0;
    //        idTipoServico = 0;
    //        vencimento = DataHoje.data();

    mensagemConvencao.setReferencia(DataHoje.data().substring(3));
    return "mensagem";
  }
 @PostConstruct
 public void init() {
   filtro = new Boolean[5];
   filtro[0] = false;
   filtro[1] = false;
   filtro[2] = false;
   filtro[3] = false;
   filtro[4] = false;
   filtroEvento = new Boolean[5];
   filtro[0] = false;
   filtro[1] = false;
   filtro[2] = false;
   filtro[3] = false;
   blockUsuario = false;
   blockRotina = false;
   listLogs = new ArrayList<>();
   listSelectItem = new ArrayList[1];
   listSelectItem[0] = new ArrayList<>();
   data = new Date[2];
   data[0] = DataHoje.dataHoje();
   data[1] = DataHoje.dataHoje();
   hora = new String[2];
   hora[0] = "";
   hora[1] = "";
   index = new Integer[1];
   index[0] = 0;
   tipo = "Avançado";
   indexAccordion = "Avançado";
   porPesquisa = "";
   descPesquisa = "";
   usuario = new Usuario();
   log = new Log();
   loadListRotinas();
   if (GenericaSessao.exists("rotinaPesquisaLog")) {
     meusLogs((Integer.parseInt(GenericaSessao.getString("rotinaPesquisaLog", true))));
   }
 }
  public void imprimirSocioCarteirinha(List list) {
    if (list.isEmpty()) {
      return;
    }
    Boolean isBeneficiario = false;
    List<SocioCarteirinha> carteirinhas = new ArrayList<>();
    String type = list.get(0).getClass().getSimpleName();
    if (type.equals("HistoricoCarteirinha")) {
      List<HistoricoCarteirinha> historicoCarteirinhas = list;
      for (int i = 0; i < historicoCarteirinhas.size(); i++) {
        carteirinhas.add(historicoCarteirinhas.get(i).getCarteirinha());
        isBeneficiario = true;
      }
    } else {
      carteirinhas = (List<SocioCarteirinha>) list;
    }

    SocioCarteirinhaDao dbc = new SocioCarteirinhaDao();
    List listAux = new ArrayList();
    for (int i = 0; i < list.size(); i++) {
      carteirinhas.get(i).setEmissao(DataHoje.data());
      new Dao().update(carteirinhas.get(i), true);
      if (isBeneficiario) {
        listAux.addAll(
            dbc.filtroCartao(
                ((HistoricoCarteirinha) list.get(i)).getMovimento().getBeneficiario().getId()));
      } else {
        HistoricoCarteirinha hc = new HistoricoCarteirinha();

        hc.setCarteirinha(carteirinhas.get(i));
        hc.setDescricao("Impressão de Carteirinha pela Geração de Cartão");

        if (!new Dao().save(hc, true)) {
          return;
        }

        listAux.addAll(dbc.filtroCartao(carteirinhas.get(i).getPessoa().getId()));
      }
    }
    ImpressaoParaSocios.imprimirCarteirinha(listAux);
    GenericaSessao.put("cartao_social_sucesso", true);
  }
  private void createLineModels(List<ArrayList> resultGraph) {
    LineChartModel model = new LineChartModel();
    LineChartSeries series1 = new LineChartSeries();
    series1.setLabel("");
    for (int i = 0; i < resultGraph.size(); i++) {
      List list = resultGraph.get(i);
      Integer qtde = Integer.parseInt(list.get(2).toString());
      String data = DataHoje.converteData((Date) list.get(1));
      try {
        if (list.get(3) != null) {
          data = list.get(3).toString().substring(0, 2);
        }
      } catch (Exception e) {

      }
      series1.set(data, qtde);
    }
    model.addSeries(series1);
    graficoFrequencia1 = model;
    graficoFrequencia1.setTitle("Frequência");
    graficoFrequencia1.setLegendPosition("e");
    graficoFrequencia1.getAxes().put(AxisType.X, new CategoryAxis("Datas"));
    Axis yAxis = graficoFrequencia1.getAxis(AxisType.Y);
    // yAxis.setMin(0);
    // yAxis.setMax(10);
    yAxis.setLabel("Quantidade Acessos");

    //        graficoFrequencia2 = initCategoryModel();
    //        graficoFrequencia2.setTitle("Category Chart");
    //        graficoFrequencia2.setLegendPosition("e");
    //        graficoFrequencia2.setShowPointLabels(true);
    //        graficoFrequencia2.getAxes().put(AxisType.X, new CategoryAxis("Years"));
    //        yAxis = graficoFrequencia2.getAxis(AxisType.Y);
    //        yAxis.setLabel("Births");
    //        yAxis.setMin(0);
    //        yAxis.setMax(200);
  }
Beispiel #17
0
 public String getDtImpressaoString() {
   return DataHoje.converteData(dtImpressao);
 }
Beispiel #18
0
 public void setDtCancelamentoString(String cancelamentoString) {
   this.dtCancelamento = DataHoje.converte(cancelamentoString);
 }
Beispiel #19
0
 public String getDtCancelamentoString() {
   return DataHoje.converteData(dtCancelamento);
 }
Beispiel #20
0
 public void setDtVencimentoString(String vencimentoString) {
   this.dtVencimento = DataHoje.converte(vencimentoString);
 }
Beispiel #21
0
 public String getDtVencimentoString() {
   return DataHoje.converteData(dtVencimento);
 }
Beispiel #22
0
 public void setDtEmissaoString(String emissaoString) {
   this.dtEmissao = DataHoje.converte(emissaoString);
 }
Beispiel #23
0
 public void setCriacao(String criacao) {
   this.dtCriacao = DataHoje.converte(criacao);
 }
Beispiel #24
0
 public void setDtImpressaoString(String dtImpressaoString) {
   this.dtImpressao = DataHoje.converte(dtImpressaoString);
 }
Beispiel #25
0
 public String getNascimento() {
   return DataHoje.converteData(dtNascimento);
 }
Beispiel #26
0
 public String getDtEmissaoString() {
   return DataHoje.converteData(dtEmissao);
 }
  public final void loadListaFrequenciaCatraca(Boolean relatorio) {
    listaFrequenciaCatraca.clear();

    if (!chkData) {
      dataInicio = "";
      dataFinal = "";
    }

    if (!chkHora) {
      horaInicio = "";
      horaFinal = "";
    }

    List<ArrayList> result =
        new FrequenciaCatracaDao()
            .listaFrequencia(
                Integer.valueOf(listaDepartamento.get(indexDepartamento).getDescription()),
                dataInicio,
                dataFinal,
                horaInicio,
                horaFinal,
                pessoa.getId() != -1 ? pessoa.getId() : null,
                sisPessoa.getId() != -1 ? sisPessoa.getId() : null,
                es,
                relatorio);

    List<ArrayList> resultGraph =
        new FrequenciaCatracaDao()
            .listaFrequenciaGraph(
                Integer.valueOf(listaDepartamento.get(indexDepartamento).getDescription()),
                dataInicio,
                dataFinal,
                horaInicio,
                horaFinal,
                pessoa.getId() != -1 ? pessoa.getId() : null,
                sisPessoa.getId() != -1 ? sisPessoa.getId() : null,
                es,
                relatorio);

    createLineModels(resultGraph);

    for (List list : result) {
      CatracaFrequencia cf =
          (CatracaFrequencia) new Dao().find(new CatracaFrequencia(), (Integer) list.get(0));
      listaFrequenciaCatraca.add(
          new ListaFrequenciaCatraca(
              (Integer) list.get(0), // ID CATRACA FREQUENCIA
              (Integer) list.get(1), // ID DEPARTAMENTO
              (String) list.get(2) + " " + (String) list.get(7), // NOME
              DataHoje.converteData((Date) list.get(3)), // DATA ACESSO
              (String) list.get(4), // HORA ACESSO
              (String) list.get(5), // ES
              (Integer) list.get(6), // ID PESSOA
              (String) list.get(7), // TIPO
              (String) list.get(8), // DEPARTAMENTO
              (cf.getPessoa() != null)
                  ? cf.getPessoa().getFoto()
                  : cf.getSisPessoa().getFotoPerfil() // FOTO
              ));
    }
  }
Beispiel #28
0
 public void setNascimento(String nascimento) {
   this.dtNascimento = DataHoje.converte(nascimento);
 }
  public String recibo(int id_movimento) {
    MovimentoDB db = new MovimentoDBToplink();
    Movimento movimento = db.pesquisaCodigo(id_movimento);
    try {
      Collection vetor = new ArrayList();
      Juridica sindicato =
          (Juridica) (new SalvarAcumuladoDBToplink()).pesquisaCodigo(1, "Juridica");
      PessoaEnderecoDB dbp = new PessoaEnderecoDBToplink();
      // MovimentosReceberSocialDB dbs = new MovimentosReceberSocialDBToplink();

      PessoaEndereco pe = dbp.pesquisaEndPorPessoaTipo(1, 2);
      String formas[] = new String[10];

      // PESQUISA FORMA DE PAGAMENTO
      List<FormaPagamento> fp = db.pesquisaFormaPagamento(movimento.getBaixa().getId());
      float soma_dinheiro = 0;
      for (int i = 0; i < fp.size(); i++) {
        // 4 - CHEQUE
        if (fp.get(i).getTipoPagamento().getId() == 4) {
          formas[i] =
              fp.get(i).getTipoPagamento().getDescricao()
                  + ": R$ "
                  + Moeda.converteR$Float(fp.get(i).getValor())
                  + " (B: "
                  + fp.get(i).getChequeRec().getBanco()
                  + " Ag: "
                  + fp.get(i).getChequeRec().getAgencia()
                  + " C: "
                  + fp.get(i).getChequeRec().getConta()
                  + " CH: "
                  + fp.get(i).getChequeRec().getCheque()
                  + ")";
          // 5 - CHEQUE PRÉ
        } else if (fp.get(i).getTipoPagamento().getId() == 5) {
          formas[i] =
              fp.get(i).getTipoPagamento().getDescricao()
                  + ": R$ "
                  + Moeda.converteR$Float(fp.get(i).getValor())
                  + " (B: "
                  + fp.get(i).getChequeRec().getBanco()
                  + " Ag: "
                  + fp.get(i).getChequeRec().getAgencia()
                  + " C: "
                  + fp.get(i).getChequeRec().getConta()
                  + " CH: "
                  + fp.get(i).getChequeRec().getCheque()
                  + " P: "
                  + fp.get(i).getChequeRec().getVencimento()
                  + ")";
          // QUALQUER OUTRO
        } else {
          formas[i] =
              fp.get(i).getTipoPagamento().getDescricao()
                  + ": R$ "
                  + Moeda.converteR$Float(fp.get(i).getValor());
          if (fp.get(i).getTipoPagamento().getId() == 3) {
            soma_dinheiro = soma_dinheiro + fp.get(i).getValor();
          }
        }
      }
      String lblVencimento = "";
      String vencimento = "";
      DataHoje dataHoje = new DataHoje();
      List<Movimento> lista = db.listaMovimentoBaixaOrder(movimento.getBaixa().getId());
      for (int i = 0; i < lista.size(); i++) {
        // tem casos de ter responsaveis diferentes, resultando em empresas conveniadas diferentes
        Guia gu = db.pesquisaGuias(lista.get(i).getLote().getId());
        String conveniada = "", mensagemConvenio = "";
        if (gu.getId() != -1) {
          if (gu.getPessoa() != null) {
            conveniada = gu.getPessoa().getNome();
          }
        }

        if (lista.get(i).getLote().getRotina().getId() == 132) {
          if (lista.get(i).getServicos().isValidadeGuias()
              && !lista.get(i).getServicos().isValidadeGuiasVigente()) {
            lblVencimento = "Validade";
            vencimento =
                dataHoje.incrementarDias(
                    lista.get(i).getServicos().getValidade(), lista.get(i).getLote().getEmissao());
          } else if (lista.get(i).getServicos().isValidadeGuias()
              && lista.get(i).getServicos().isValidadeGuiasVigente()) {
            lblVencimento = "Validade";
            vencimento = DataHoje.converteData(DataHoje.lastDayOfMonth(DataHoje.dataHoje()));
          } else {
            lblVencimento = "Validade";
            vencimento = "";
          }

          // MOSTRANDO MENSAGEM APENAS SE VIER DA PAGINA EMISSÃO DE GUIAS --- by rogerinho
          // 17/03/2015 -- chamado 579
          mensagemConvenio = lista.get(i).getLote().getHistorico();
        } else {
          lblVencimento = "Vencimento";
          vencimento = lista.get(i).getVencimento();
        }

        vetor.add(
            new ParametroRecibo(
                ((ServletContext)
                        FacesContext.getCurrentInstance().getExternalContext().getContext())
                    .getRealPath(
                        "/Cliente/"
                            + ControleUsuarioBean.getCliente()
                            + "/Imagens/LogoCliente.png"),
                sindicato.getPessoa().getNome(),
                pe.getEndereco().getDescricaoEndereco().getDescricao(),
                pe.getEndereco().getLogradouro().getDescricao(),
                pe.getNumero(),
                pe.getComplemento(),
                pe.getEndereco().getBairro().getDescricao(),
                pe.getEndereco().getCep().substring(0, 5)
                    + "-"
                    + pe.getEndereco().getCep().substring(5),
                pe.getEndereco().getCidade().getCidade(),
                pe.getEndereco().getCidade().getUf(),
                sindicato.getPessoa().getTelefone1(),
                sindicato.getPessoa().getEmail1(),
                sindicato.getPessoa().getSite(),
                sindicato.getPessoa().getDocumento(),
                lista.get(i).getPessoa().getNome(), // RESPONSÁVEL
                String.valueOf(lista.get(i).getPessoa().getId()), // ID_RESPONSAVEL
                String.valueOf(lista.get(i).getBaixa().getId()), // ID_BAIXA
                lista.get(i).getBeneficiario().getNome(), // BENEFICIÁRIO
                lista.get(i).getServicos().getDescricao(), // SERVICO
                vencimento, // VENCIMENTO
                new BigDecimal(lista.get(i).getValorBaixa()), // VALOR BAIXA
                lista.get(i).getBaixa().getUsuario().getLogin(),
                lista.get(i).getBaixa().getBaixa(),
                DataHoje.horaMinuto(),
                formas[0],
                formas[1],
                formas[2],
                formas[3],
                formas[4],
                formas[5],
                formas[6],
                formas[7],
                formas[8],
                formas[9],
                (conveniada.isEmpty()) ? "" : "Empresa Conveniada: " + conveniada,
                lblVencimento,
                mensagemConvenio,
                lista.get(i).getPessoa().getDocumento(),
                Moeda.converteR$Float(soma_dinheiro + lista.get(i).getBaixa().getTroco()),
                Moeda.converteR$Float(lista.get(i).getBaixa().getTroco())));
      }

      File fl =
          new File(
              ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
                  .getRealPath("/Relatorios/RECIBO.jasper"));
      JasperReport jasper = (JasperReport) JRLoader.loadObject(fl);

      JRBeanCollectionDataSource dtSource = new JRBeanCollectionDataSource(vetor);
      JasperPrint print = JasperFillManager.fillReport(jasper, null, dtSource);

      boolean printPdf = true;

      if (printPdf) {
        byte[] arquivo = JasperExportManager.exportReportToPdf(print);
        salvarRecibo(arquivo, lista.get(0).getBaixa());
        HttpServletResponse res =
            (HttpServletResponse)
                FacesContext.getCurrentInstance().getExternalContext().getResponse();
        res.setContentType("application/pdf");
        res.setHeader("Content-disposition", "inline; filename=\"" + "recibo" + ".pdf\"");
        res.getOutputStream().write(arquivo);
        res.getCharacterEncoding();

        FacesContext.getCurrentInstance().responseComplete();
      } else {
        // CASO QUEIRA IMPRIMIR EM HTML HTMLPRINT PRINTHTML IMPRIMIRRECIBOHTML TOHTML
        if (lista.get(0).getBaixa().getCaixa() == null) {
          return null;
        }

        String caminho =
            ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
                .getRealPath(
                    "/Cliente/"
                        + ControleUsuarioBean.getCliente()
                        + "/"
                        + "Arquivos/recibo/"
                        + lista.get(0).getBaixa().getCaixa().getCaixa()
                        + "/"
                        + DataHoje.converteData(lista.get(0).getBaixa().getDtBaixa())
                            .replace("/", "-"));
        Diretorio.criar(
            "Arquivos/recibo/"
                + lista.get(0).getBaixa().getCaixa().getCaixa()
                + "/"
                + DataHoje.converteData(lista.get(0).getBaixa().getDtBaixa()).replace("/", "-"));

        String path_arquivo =
            caminho
                + String.valueOf(lista.get(0).getBaixa().getUsuario().getId())
                + "_"
                + String.valueOf(lista.get(0).getBaixa().getId())
                + ".html";
        File file_arquivo = new File(path_arquivo);

        String n =
            String.valueOf(lista.get(0).getBaixa().getUsuario().getId())
                + "_"
                + String.valueOf(lista.get(0).getBaixa().getId())
                + ".html";
        if (file_arquivo.exists()) {
          path_arquivo =
              caminho
                  + String.valueOf(lista.get(0).getBaixa().getUsuario().getId())
                  + "_"
                  + String.valueOf(lista.get(0).getBaixa().getId())
                  + "_(2).html";
          n =
              String.valueOf(lista.get(0).getBaixa().getUsuario().getId())
                  + "_"
                  + String.valueOf(lista.get(0).getBaixa().getId())
                  + "_(2).html";
        }
        JasperExportManager.exportReportToHtmlFile(print, path_arquivo);

        Download download =
            new Download(n, caminho, "text/html", FacesContext.getCurrentInstance());
        download.baixar();

        //                String reportPath =JasperRunManager.runReportToHtmlFile(fl.getPath(),
        // null, dtSource);
        //                File reportHtmlFile = new File(reportPath);
        //                FileInputStream fis = new FileInputStream(reportHtmlFile);
        //                byte[] arquivo =  new byte[(int)reportHtmlFile.length()];
        //                fis.read(arquivo);
        //                HttpServletResponse res = (HttpServletResponse)
        // FacesContext.getCurrentInstance().getExternalContext().getResponse();
        //                res.setHeader("Content-Disposition","inline; filename=myReport.html");
        //                res.setContentType("text/html");
        //                res.setContentLength(arquivo.length);
        //                res.getOutputStream().write(arquivo);
        //                res.getCharacterEncoding();
        //
        //                FacesContext.getCurrentInstance().responseComplete();

        //                FacesContext.getCurrentInstance().responseComplete();
        //                HttpServletResponse response = (HttpServletResponse)
        // FacesContext.getCurrentInstance().getExternalContext().getResponse();
        //
        // response.sendRedirect("http://localhost:8080/Sindical/Cliente/Sindical/Arquivos/recibo/0/16-06-2015/1_683382.html");
        // FacesContext.getCurrentInstance().getExternalContext().redirect("/Sindical/baixaGeral.jsf");

      }

    } catch (JRException | IOException ex) {
      ex.getMessage();
    }

    return null;
  }
Beispiel #30
0
 public void selecionaDataNascimento(SelectEvent event) {
   SimpleDateFormat format = new SimpleDateFormat("d/M/yyyy");
   this.dtNascimento = DataHoje.converte(format.format(event.getObject()));
 }