Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.automaster.autoview.client.ui.paineis.tabs; import com.automaster.autoview.client.Info; import com.automaster.autoview.client.ui.paineis.dialogs.pdf.Contrato; import com.automaster.autoview.client.ui.paineis.dialogs.cadastro.NovoComando; import com.automaster.autoview.client.ui.paineis.dialogs.cadastro.NovoVeiculo; import com.automaster.autoview.client.ui.paineis.dialogs.editar.EditarCliente; import com.automaster.autoview.client.ui.paineis.dialogs.editar.EditarVeiculo; import com.automaster.autoview.client.ui.paineis.dialogs.informacao.HistoricoVeiculo; import com.automaster.autoview.client.ui.paineis.login.Login; import com.automaster.autoview.client.ui.paineis.tabs.monitoramento.TabInicio; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; import com.google.gwt.i18n.client.TimeZone; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.RecordList; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.AnimationEffect; import com.smartgwt.client.types.CharacterCasing; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.types.SortDirection; import com.smartgwt.client.types.VisibilityMode; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.HTMLPane; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.CloseClickEvent; import com.smartgwt.client.widgets.events.CloseClickHandler; import com.smartgwt.client.widgets.events.DrawEvent; import com.smartgwt.client.widgets.events.DrawHandler; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItemIcon; import com.smartgwt.client.widgets.form.fields.RadioGroupItem; import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.fields.events.IconClickEvent; import com.smartgwt.client.widgets.form.fields.events.IconClickHandler; import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent; import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.DataArrivedEvent; import com.smartgwt.client.widgets.grid.events.DataArrivedHandler; import com.smartgwt.client.widgets.grid.events.RecordDoubleClickEvent; import com.smartgwt.client.widgets.grid.events.RecordDoubleClickHandler; import com.smartgwt.client.widgets.grid.events.SelectionUpdatedEvent; import com.smartgwt.client.widgets.grid.events.SelectionUpdatedHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.SectionStack; import com.smartgwt.client.widgets.layout.SectionStackSection; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.tab.Tab; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Date; import java.util.LinkedHashMap; import java.util.Map; import java.util.TreeMap; /** * * @author Adriano */ public class TabBuscarCliente extends Tab { //private boolean verificaArrived = true; public static double totalMensalidadesVeiculos = 0; private int codigoUnidade = Integer.parseInt( (Info.usuarioLogado.get("codUnidadeCliente") == null) ? Info.usuarioLogado.get("codUnidadeFuncionario") : Info.usuarioLogado.get("codUnidadeCliente")); private int codUnidadeClienteSelecionado = 0; private int indexVeiculoPlaca = 0; private final TabBuscarCliente tabBuscaCliente = this; //private int contador; private int codigoCliente = 0; private int codUnidadeCliente = 0; private String nomeCliente = null; private int tipoCliente = 0; private String cpfCnpj = null; private ArrayList<TreeMap<String, String>> gruposAutorizadosRastrear = new ArrayList<>(); private ArrayList<TreeMap<String, String>> dadosVeiculo; private String placaVeiculoCopia = ""; private final IButton editCliente = new IButton(Info.titulosMsg.get("editarCliente")); private final IButton senhaCliente = new IButton(Info.titulosMsg.get("tituloSenhaTelefone")); private final IButton totalDividaCliente; private final IButton historicoVeiculo; // private final ImgButton addLancamento = new ImgButton(); private final IButton gerarContrato = new IButton("Gerar contrato"); private final IButton rastrearVeiculo = new IButton(Info.titulosMsg.get("rastrearVeiculo")); private final IButton addVeiculo = new IButton(Info.titulosMsg.get("adicionarVeiculo")); private final IButton editVeiculo = new IButton(Info.titulosMsg.get("editarVeiculo")); private final IButton addComando = new IButton(Info.titulosMsg.get("novoComando")); private final DynamicForm formBusca = new DynamicForm(); private final RadioGroupItem tipoBusca = new RadioGroupItem(); private final TextItem buscaCliente = new TextItem(); private final ListGrid dadosCliente = new ListGrid(); private final ListGridField codigo = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); private final ListGridField nome = new ListGridField("nome", Info.titulosMsg.get("tituloNome")); private final ListGridField dataAdesao = new ListGridField("dataAdesao", Info.titulosMsg.get("dataAdesao")); private final ListGridField unidade = new ListGridField("unidade", Info.titulosMsg.get("unidade")); private final ListGridField cpf = new ListGridField("cpf", Info.titulosMsg.get("cpf")); private final ListGridField dataNasc = new ListGridField("dataNasc", Info.titulosMsg.get("dataNascimento")); private final ListGridField cnpj = new ListGridField("cnpj", Info.titulosMsg.get("cnpj")); private final ListGridField dataAbert = new ListGridField("dataAbert", Info.titulosMsg.get("dataDeAbertura")); private final ListGridField codEnvio = new ListGridField("codEnvio", "codEnvio"); private final ListGridField modoEnvio = new ListGridField("modoEnvio", Info.titulosMsg.get("envioCobranca")); private final ListGrid enderecos = new ListGrid(); private final ListGrid telefones = new ListGrid(); private final ListGrid emails = new ListGrid(); private final ListGrid logins = new ListGrid(); private final Label labelSaldoCliente = new Label( "<strong style=\"font-size:15px; \">" + Info.titulosMsg.get("saldoAtual") + "00,00\n</strong>"); private double multa = 0; private double juros = 0; private double totalLancamentos = 0; private double totalFaturas = 0; private double saldo = 0; private String mensalidade = ""; private DataSource dataSource; //private DataSource dataSource; private ArrayList<TreeMap<String, String>> arrayFaturasBD = new ArrayList<>(); public double getTotalLancamentos() { return totalLancamentos; } public void setTotalLancamentos(double totalLancamentos) { this.totalLancamentos = totalLancamentos; } public double getTotalFaturas() { return totalFaturas; } public void setTotalFaturas(double totalFaturas) { this.totalFaturas = totalFaturas; } public double getSaldo() { return saldo; } public void setSaldo(double saldo) { this.saldo = saldo; } private final ListGrid lancamento; /*= new ListGrid() { @Override protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { String fieldName = this.getFieldName(colNum); final ListGrid listAux = this; if (fieldName.equals("excluir")) { HLayout recordCanvas = new HLayout(3); recordCanvas.setHeight(22); recordCanvas.setWidth100(); recordCanvas.setAlign(Alignment.CENTER); ImgButton excluirImg = new ImgButton(); excluirImg.setShowDown(false); excluirImg.setShowRollOver(false); excluirImg.setLayoutAlign(Alignment.CENTER); excluirImg.setSrc("[SKIN]actions/remove.png"); excluirImg.setPrompt("Excluir lanamento"); excluirImg.setHeight(16); excluirImg.setWidth(16); excluirImg.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { final Window janelaCarregando = new Window(); janelaCarregando.setShowTitle(false); janelaCarregando.setWidth(100); janelaCarregando.setHeight(50); janelaCarregando.setShowEdges(false); janelaCarregando.setShowCloseButton(false); janelaCarregando.setShowMinimizeButton(false); janelaCarregando.setIsModal(true); janelaCarregando.setShowModalMask(true); janelaCarregando.centerInPage(); janelaCarregando.setLayoutAlign(Alignment.CENTER); final Label mensagem = new Label("Carregando.."); mensagem.setHeight(16); new Timer() { public void run() { if (contador != 100) { //destroy(); contador += 1 + (int) (5 * Math.random()); schedule(1 + (int) (50 * Math.random())); mensagem.setContents("Carregando: " + contador + "%"); janelaCarregando.addItem(mensagem); janelaCarregando.setAnimateTime(1200); janelaCarregando.animateShow(AnimationEffect.FADE); if (contador >= 100) { mensagem.setContents("Carregando: 100%"); Info.dbService.deletarLancamento(record.getAttributeAsInt("codigo"), new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(Void result) { listAux.removeData(record); SC.say("Lanamento excluido com sucesso!"); } }); janelaCarregando.addItem(mensagem); janelaCarregando.setAnimateTime(1200); janelaCarregando.animateHide(AnimationEffect.FADE); contador = 100; janelaCarregando.destroy(); } } else { contador = 0; } } }.schedule(50); } }); recordCanvas.addMember(excluirImg); return recordCanvas; } else { return null; } } };*/ private String placaVeiculo = null; private final ListGrid veicPlacas; private boolean flagDrawGrid = false; private final HTMLPane tabelaVeiculos = new HTMLPane(); private String tabelaVazia = "<table width=\"100%\" height=\"100%\" border=\"1\" bordercolor=\"#CCCCCC\">\n" + " <tr align=\"center\" bgcolor=\"#CCCCCC\">\n" + " <td>" + Info.titulosMsg.get("naoExisteItens") + "</td>\n" + " </tr>\n" + "</table>"; private TreeMap<String, ArrayList<TreeMap<String, String>>> veiculos; public TreeMap<String, ArrayList<TreeMap<String, String>>> getVeiculos() { return veiculos; } public void setVeiculos(TreeMap<String, ArrayList<TreeMap<String, String>>> veiculos) { this.veiculos = veiculos; } public void tabelaVeiculoRedraw(String tabelaVeiculosVazia) { this.tabelaVeiculos.redraw(); this.tabelaVeiculos.setContents(tabelaVeiculosVazia); } private ArrayList<TreeMap<String, String>> clienteAuxiliar = new ArrayList<>(); private static TreeMap<String, ArrayList<TreeMap<String, String>>> clienteEdicao; public TabBuscarCliente() { //setanto o titulo da aba TAB this.veiculos = new TreeMap<>(); this.lancamento = new ListGrid(); this.veicPlacas = new ListGrid(); setTitle(Info.titulosMsg.get("buscarCliente")); final TabBuscarCliente tabBuscarClienteAux = this; //criando o Vlayout que ir armazenar o painelNovoCliente HLayout painelPai = new HLayout(); painelPai.setWidth100(); painelPai.setHeight100(); painelPai.setAlign(Alignment.CENTER); //Criando o painel que ir armazenar to tab, sections e butoes VLayout painelBuscaCliente = new VLayout(); painelBuscaCliente.setMembersMargin(15); painelBuscaCliente.setWidth("100%"); painelBuscaCliente.setDefaultLayoutAlign(Alignment.CENTER); editCliente.setTooltip(Info.titulosMsg.get("editarCliente")); editCliente.setDisabled(true); editCliente.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { //GWT.log("cliente edio"+getClienteEdicao()); //GWT.log("dados cliente"+dadosCliente.getRecord(0).getAttributeAsString("nome")); EditarCliente editarCliente = new EditarCliente(tabBuscarClienteAux, getClienteEdicao(), enderecos, telefones, emails, logins, dadosCliente); //GWT.log("linha 01"); editarCliente.setAnimateTime(1200); //GWT.log("linha 02"); editarCliente.animateShow(AnimationEffect.FADE); //GWT.log("linha 03"); } }); totalDividaCliente = new IButton("Dbito mensal"); totalDividaCliente.setDisabled(true); totalDividaCliente.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say("Total a pagar mensal (somente veculos ativos!)", "<center><strong style=\"font-size:20px; \">R$" + Info.formataSaldo(TabBuscarCliente.totalMensalidadesVeiculos) + "</strong></center>"); } }); senhaCliente.setTooltip(Info.titulosMsg.get("tituloSenhaTelefone")); senhaCliente.setDisabled(true); senhaCliente.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { SC.say("Senha : " + getClienteEdicao().get(String.valueOf(codigoCliente)).get(0).get("senhaTelefone")); //GWT.log("Senha : "+getClienteEdicao().get(String.valueOf(codigoCliente)).get(0).get("senhaTelefone")); } }); HLayout painelBotaoContratoCliente = new HLayout(); //painelBotaoContratoCliente.setMargin(5); //painelBotaoContratoCliente.setMembersMargin(10); //painelBotoaSenhaCliente.setHeight(40); //gerarContrato.setAlign(Alignment.RIGHT); //gerarContrato.setLayoutAlign(Alignment.RIGHT); //gerarContrato.setWidth(120); //download=\"Contrato.pdf\" // <a href="#" onclick="window.open('endereo_de_seu_link', '_blank','menubar=no')">link</a> //gerarContrato.setContents("<a href=\"#\" onclick=\"window.open('./ContratoPfServlet', '_blank','menubar=no'><input type=\"button\" value=\"Gerar contrato\" disabled=\"disabled\"></a>"); painelBotaoContratoCliente.setAlign(Alignment.CENTER); painelBotaoContratoCliente.addMember(gerarContrato); HLayout painelBotoaSenhaCliente = new HLayout(); painelBotoaSenhaCliente.setMargin(5); painelBotoaSenhaCliente.setMembersMargin(10); //painelBotoaSenhaCliente.setHeight(40); painelBotoaSenhaCliente.setAlign(Alignment.LEFT); painelBotoaSenhaCliente.addMember(senhaCliente); painelBotoaSenhaCliente.addMember(totalDividaCliente); HLayout painelBotoaEditCliente = new HLayout(); painelBotoaEditCliente.setMargin(5); painelBotoaEditCliente.setMembersMargin(10); //painelBotoaEditCliente.setHeight(40); painelBotoaEditCliente.setAlign(Alignment.RIGHT); painelBotoaEditCliente.addMember(editCliente); HLayout painelBotoesCliente = new HLayout(); painelBotoesCliente.setMargin(5); painelBotoesCliente.setMembersMargin(10); painelBotoesCliente.setHeight(40); //painelBotoesCliente.setAlign(Alignment.RIGHT); painelBotoesCliente.addMember(painelBotoaSenhaCliente); painelBotoesCliente.addMember(painelBotaoContratoCliente); painelBotoesCliente.addMember(painelBotoaEditCliente); formBusca.setWidth(600); formBusca.setAutoFocus(true); formBusca.setLayoutAlign(Alignment.CENTER); buscaCliente.setName(Info.titulosMsg.get("digite")); //buscaCliente.setCharacterCasing(CharacterCasing.UPPER); buscaCliente.setAlign(Alignment.CENTER); buscaCliente.setTooltip(Info.titulosMsg.get("buscarCliente")); FormItemIcon icon = new FormItemIcon(); icon.setSrc("[SKIN]actions/view.png"); icon.setName("buscar"); buscaCliente.setIcons(icon); tipoBusca.setTitle(Info.titulosMsg.get("tipoBusca")); LinkedHashMap<String, String> tp = new LinkedHashMap<>(); tp.put("1", Info.titulosMsg.get("nomeCliente")); tp.put("2", Info.titulosMsg.get("cpf")); tp.put("3", Info.titulosMsg.get("cnpj")); tipoBusca.setValueMap(tp); tipoBusca.setRequired(true); tipoBusca.setValue("1"); //tipoBusca.setShowTitle(false); tipoBusca.setAlign(Alignment.CENTER); tipoBusca.setTooltip(Info.titulosMsg.get("buscarCliente")); tipoBusca.setWidth(350); tipoBusca.setVertical(false); //buscaCliente.setKeyPressFilter("[a-zA-Z?? 0-9]"); //final LengthRangeValidator tamanhoTextItem = new LengthRangeValidator(); //tamanhoTextItem.setMin(3); //buscaCliente.setValidators(tamanhoTextItem); //buscaCliente.setRequired(true); buscaCliente.setWidth(500); veicPlacas.addDataArrivedHandler(new DataArrivedHandler() { @Override public void onDataArrived(DataArrivedEvent event) { // Autor JR // if (veicPlacas.getTotalRows() != 0) { //veicPlacas.focus(); gerarContrato.setDisabled(false); if (codigoUnidade == 1 || codUnidadeClienteSelecionado == codigoUnidade) { //editCliente.setDisabled(false); historicoVeiculo.setDisabled(false); rastrearVeiculo.setDisabled(false); editVeiculo.setDisabled(false); } else { //editCliente.setDisabled(true); historicoVeiculo.setDisabled(true); rastrearVeiculo.setDisabled(true); editVeiculo.setDisabled(true); } //editVeiculo.setDisabled(false); //rastrearVeiculo.setDisabled(false); gerarContrato.setDisabled(false); addComando.setDisabled(false); if (indexVeiculoPlaca == veicPlacas.getTotalRows()) { //veicPlacas.deselectAllRecords(); indexVeiculoPlaca--; veicPlacas.selectRecord(indexVeiculoPlaca); } else { //veicPlacas.deselectAllRecords(); veicPlacas.selectRecord(indexVeiculoPlaca); } } else { gerarContrato.setDisabled(true); editVeiculo.setDisabled(true); addComando.setDisabled(true); } } }); // veicPlacas.addFocusChangedHandler(new FocusChangedHandler() { // @Override // public void onFocusChanged(FocusChangedEvent event) { // if (veicPlacas.getTotalRows() != 0) { // if (indexVeiculoPlaca >= veicPlacas.getTotalRows()) { // indexVeiculoPlaca--; // veicPlacas.selectRecord(0); // } else { // veicPlacas.selectRecord(indexVeiculoPlaca); // } // } // } // }); tipoBusca.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { String groupItem = (String) event.getValue(); if (groupItem.equals("1")) { buscaCliente.redraw(); buscaCliente.setMask(null); try { //GWT.log("try try"); buscaCliente.setCharacterCasing(CharacterCasing.UPPER); formBusca.focusInItem(buscaCliente); buscaCliente.setKeyPressFilter("[a-zA-Z?? 0-9]"); } catch (Exception e) { //GWT.log("catch (Exception e)"); buscaCliente.setCharacterCasing(CharacterCasing.UPPER); buscaCliente.setValue(""); formBusca.focusInItem(buscaCliente); buscaCliente.setKeyPressFilter("[a-zA-Z?? 0-9]"); } buscaCliente.setMaskPromptChar(" "); } else if (groupItem.equals("2")) { buscaCliente.redraw(); buscaCliente.setCharacterCasing(null); //tamanhoTextItem.setMin(1); buscaCliente.setMask("###.###.###-##"); buscaCliente.setMaskPromptChar("_"); formBusca.focusInItem(buscaCliente); } else if (groupItem.equals("3")) { buscaCliente.redraw(); buscaCliente.setCharacterCasing(null); //tamanhoTextItem.setMin(1); buscaCliente.setMask("##.###.###/####-##"); buscaCliente.setMaskPromptChar("_"); formBusca.focusInItem(buscaCliente); } } }); formBusca.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { formBusca.focusInItem(buscaCliente); //buscaCliente.setKeyPressFilter("[A-Z?? 0-9]"); //buscaCliente.setTextBoxStyle("positivo"); } }); formBusca.setFields(tipoBusca, buscaCliente); buscaCliente.addIconClickHandler(new IconClickHandler() { @Override public void onIconClick(IconClickEvent event) { consultaCliente(); } }); buscaCliente.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent event) { if (event.getKeyName().equals("Enter")) { consultaCliente(); } } }); final SectionStackSection formSection = new SectionStackSection(); formSection.setTitle(Info.titulosMsg.get("buscarCliente")); formSection.setItems(formBusca); formSection.setExpanded(true); final DynamicForm formCliente = new DynamicForm(); formCliente.setWidth(600); formCliente.setAutoFocus(true); formCliente.setLayoutAlign(Alignment.CENTER); codigo.setHidden(true); codEnvio.setHidden(true); dadosCliente.setHeight(50); dadosCliente.setScrollbarSize(0); dadosCliente.setCanPickFields(false); dadosCliente.setSortDirection(SortDirection.ASCENDING); dadosCliente.setSortField("codigo"); unidade.setAlign(Alignment.CENTER); codigo.setAlign(Alignment.CENTER); modoEnvio.setAlign(Alignment.CENTER); final ListGridField codigoEnd = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoEnd.setHidden(true); final ListGridField descricaoEnd = new ListGridField("descricao", Info.titulosMsg.get("descricao")); descricaoEnd.setWidth(160); final ListGridField logradouro = new ListGridField("logradouro", Info.titulosMsg.get("logradouro")); logradouro.setWidth(200); logradouro.setAlign(Alignment.CENTER); final ListGridField numeroEnd = new ListGridField("numero", Info.titulosMsg.get("numeroEndereco")); numeroEnd.setWidth(40); numeroEnd.setAlign(Alignment.CENTER); final ListGridField bairroEnd = new ListGridField("bairro", Info.titulosMsg.get("bairroEndereco")); bairroEnd.setWidth(110); bairroEnd.setAlign(Alignment.CENTER); final ListGridField cep = new ListGridField("cep", Info.titulosMsg.get("cepEndereco")); cep.setWidth(60); cep.setAlign(Alignment.CENTER); final ListGridField uf = new ListGridField("estado", Info.titulosMsg.get("estadoEndereco")); uf.setWidth(30); uf.setAlign(Alignment.CENTER); final ListGridField estadoCod = new ListGridField("estadoCod", "EstadoCod"); estadoCod.setHidden(true); estadoCod.setAlign(Alignment.CENTER); final ListGridField cidade = new ListGridField("cidade", Info.titulosMsg.get("cidadeEndereco")); cidade.setWidth(150); cidade.setAlign(Alignment.CENTER); final ListGridField cidadeCod = new ListGridField("cidadeCod", "CidadeCod"); cidadeCod.setHidden(true); cidadeCod.setAlign(Alignment.CENTER); final ListGridField referenciaEnd = new ListGridField("referencia", Info.titulosMsg.get("referencia")); enderecos.setWidth("100%"); enderecos.setHeight(70); referenciaEnd.setAlign(Alignment.CENTER); enderecos.setFields(codigoEnd, descricaoEnd, logradouro, numeroEnd, bairroEnd, cep, cidade, cidadeCod, uf, estadoCod, referenciaEnd); enderecos.setCanPickFields(false); enderecos.setSortDirection(SortDirection.ASCENDING); enderecos.setSortField("codigo"); final ListGridField codTel = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); codTel.setHidden(true); codTel.setAlign(Alignment.CENTER); final ListGridField descricaoTel = new ListGridField("descricao", Info.titulosMsg.get("descricao")); descricaoTel.setAlign(Alignment.CENTER); final ListGridField numeroTel = new ListGridField("numero", Info.titulosMsg.get("tituloNumero")); numeroTel.setAlign(Alignment.CENTER); telefones.setFields(codTel, descricaoTel, numeroTel); telefones.setCanPickFields(false); telefones.setSortDirection(SortDirection.ASCENDING); telefones.setSortField("codigo"); final ListGridField codEmail = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); codEmail.setHidden(true); codEmail.setAlign(Alignment.CENTER); final ListGridField descricaoEmail = new ListGridField("descricao", Info.titulosMsg.get("descricao")); descricaoEmail.setWidth(80); descricaoEmail.setAlign(Alignment.CENTER); final ListGridField email = new ListGridField("email", Info.titulosMsg.get("email")); email.setAlign(Alignment.CENTER); emails.setFields(codEmail, descricaoEmail, email); emails.setCanPickFields(false); emails.setSortDirection(SortDirection.ASCENDING); emails.setSortField("codigo"); final ListGridField codUsuario = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); codUsuario.setHidden(true); codUsuario.setAlign(Alignment.CENTER); final ListGridField usuario = new ListGridField("usuario", Info.titulosMsg.get("tituloUsuario")); usuario.setAlign(Alignment.CENTER); final ListGridField senha = new ListGridField("senha", Info.titulosMsg.get("tituloSenha")); senha.setAlign(Alignment.CENTER); final ListGridField statusCod = new ListGridField("statusCod", Info.titulosMsg.get("tituloStatus")); statusCod.setHidden(true); statusCod.setAlign(Alignment.CENTER); final ListGridField status = new ListGridField("status", Info.titulosMsg.get("tituloStatus")); status.setAlign(Alignment.CENTER); final ListGridField codGrupo = new ListGridField("codGrupo", Info.titulosMsg.get("tituloCodigo")); codGrupo.setHidden(true); codGrupo.setAlign(Alignment.CENTER); final ListGridField grupo = new ListGridField("grupo", "grupo"); grupo.setHidden(true); grupo.setAlign(Alignment.CENTER); final ListGridField reset = new ListGridField("resetUsuario", Info.titulosMsg.get("reset")); reset.setAlign(Alignment.CENTER); //reset.setHidden(true); logins.setFields(codUsuario, usuario, senha, statusCod, status, codGrupo, grupo, reset); logins.setCanPickFields(false); logins.setSortDirection(SortDirection.ASCENDING); logins.setSortField("codigo"); logins.setCanSort(false); ListGridField codVeic = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); codVeic.setHidden(true); ListGridField placaVeic = new ListGridField("placa", Info.titulosMsg.get("placa")); placaVeic.setAlign(Alignment.CENTER); //placaVeic.setWidth(80); //veicPlacas.setHeight("100%"); this.veicPlacas.setSelectionType(SelectionStyle.SINGLE); this.veicPlacas.setWidth("10%"); //this.veicPlacas.setSortDirection(SortDirection.ASCENDING); //this.veicPlacas.setSortField("placa"); this.veicPlacas.setShowFilterEditor(true); //this.veicPlacas.setTooltip(Info.titulosMsg.get("listaVeiculos")); //this.veicPlacas.setPrintMaxRows(500); //this.veicPlacas.setAlternateRecordStyles(true); this.veicPlacas.setFilterOnKeypress(true); this.veicPlacas.addSelectionUpdatedHandler(new SelectionUpdatedHandler() { @Override public void onSelectionUpdated(SelectionUpdatedEvent event) { placaVeiculo = veicPlacas.getSelectedRecord().getAttribute("placa"); if (placaVeiculo != null && placaVeiculo.length() > 7) { indexVeiculoPlaca = veicPlacas.getRecordIndex(veicPlacas.getSelectedRecord()); //GWT.log("Index: "+indexVeiculoPlaca+" - "+veicPlacas.getTotalRows()+ " - "+placaVeiculo); } //GWT.log("Linha addSelectionUpdatedHandler 01 : "+placaVeiculo); mensalidade = ""; dadosVeiculo = getVeiculos().get(placaVeiculo); placaVeiculoCopia = placaVeiculo; tabelaVeiculos.redraw(); // verificando o valor a mensalidade do veculo // if (dadosVeiculo.get(0).get("codPlano").equalsIgnoreCase("1")) { mensalidade = Info.formataSaldo( Info.formataDecimal(Double.parseDouble(dadosVeiculo.get(0).get("valorPlano")) - ((Double.parseDouble(dadosVeiculo.get(0).get("valorPlano")) * 0.1) * (Integer.parseInt(dadosVeiculo.get(0).get("numeroIndicacoes")))) - (Double.parseDouble(dadosVeiculo.get(0).get("desconto"))))); } else { //if(dadosVeiculo.get(0).get("codPlano").equalsIgnoreCase("2")){ mensalidade = Info.formataSaldo( Info.formataDecimal(Double.parseDouble(dadosVeiculo.get(0).get("valorPlano")) - (Double.parseDouble(dadosVeiculo.get(0).get("desconto"))))); } String infoVeiculo = ""; String tipoVenda = ""; String infoVeiculoP2 = ""; String table2 = ""; String table3 = ""; String cabecalhoPadraoLig = ""; //DateUtil.setDefaultDisplayTimezone("-03:00"); //width=\"840\" height=\"350\" infoVeiculo = "<table width=\"0\" border=\"1\" bordercolor=\"#CCCCCC\">\n" + " <tr align=\"center\">\n" + " <td><table height=\"330\" border=\"0\">\n" + "<tr align=\"center\">\n" + " <td colspan=\"6\" align=\"center\" bgcolor=\"#CCCCCC\"><strong>INFORMAES DO VE?CULO</strong></td>\n" + " </tr>\n" + " <tr align=\"center\">\n" + " <td width=\"111\"><strong>" + Info.titulosMsg.get("placa") + "</strong></td>\n" + " \n" + " <td width=\"160\"><strong>" + Info.titulosMsg.get("fabricante") + "</strong></td>\n" + " <td ><strong>" + Info.titulosMsg.get("modelo") + "</strong></td>\n" + " <td ><strong>" + Info.titulosMsg.get("ano") + "</strong></td>\n" + " <td width=\"215\"><strong>" + Info.titulosMsg.get("cor") + "</strong></td>\n" + " <td width=\"200\" rowspan=9 bgcolor=\"#CCCCCC\"><strong>" + Info.titulosMsg.get("tipoCobranca") + "</strong><br/><br/>"; if (dadosVeiculo.get(0).get("vendaOutra") == null) { tipoVenda = dadosVeiculo.get(0).get("descricaoTc") + "<strong><br/><br/>" + Info.titulosMsg.get("numeroParcela") + "</strong><br/><br/>" + dadosVeiculo.get(0).get("numeroParcela") + "<strong><br/><br/>" + Info.titulosMsg.get("valor") + "</strong><br/><br/>R$" + String.valueOf( Info.formataValor(Float.parseFloat(dadosVeiculo.get(0).get("valorParcela")))) + "</td>"; } else { tipoVenda = "Outra<br/><br/>" + dadosVeiculo.get(0).get("vendaOutra") + "</td>"; } infoVeiculoP2 = " </tr>\n" + " <tr align=\"center\">\n" + " <td height=\"24\" style=\"font-size:12px;\"><strong>" + dadosVeiculo.get(0).get("placaVeiculo") + "</strong></td>\n" + " <td>" + (dadosVeiculo.get(0).get("fabricante") == null ? dadosVeiculo.get(0).get("fabricantev") : dadosVeiculo.get(0).get("fabricante")) + "</td>\n" + " <td >" + (dadosVeiculo.get(0).get("modelo") == null ? dadosVeiculo.get(0).get("modelov") : dadosVeiculo.get(0).get("modelo")) + "</td>\n" + " <td >" + (dadosVeiculo.get(0).get("ano") == null ? dadosVeiculo.get(0).get("anov") : dadosVeiculo.get(0).get("ano")) + "</td>\n" + " <td>" + dadosVeiculo.get(0).get("cor") + "</td>\n" //+ " <td bgcolor=\"#CCCCCC\">" + dadosVeiculo.get(0).get("descricaoTc") + "</td>" + " </tr>\n" + " <tr align=\"center\">\n" + " <td><strong>" + Info.titulosMsg.get("equipamento") + "</strong></td>\n" + " <td width=\"215\"><strong>" + Info.titulosMsg.get("instalador") + "</strong></td>\n" + " <td><strong>" + Info.titulosMsg.get("cidadeEndereco") + "</strong></td>\n" + " <td width=\"215\"><strong>" + Info.titulosMsg.get("estadoEndereco") + "</strong></td>\n" + " <td width=\"111\"><strong>" + Info.titulosMsg.get("chassi") + "</strong></td>\n" //+ " <td width=\"150\" bgcolor=\"#CCCCCC\"><strong>" + Info.titulosMsg.get("numeroParcela") + "</strong></td>" + " </tr>\n" + " <tr align=\"center\">\n" + " <td><strong>" + ((dadosVeiculo.get(0).get("codEquipamento") == null) ? "Sem equipamento" : "ID:" + dadosVeiculo.get(0).get("idEquipamento") + " / " + dadosVeiculo.get(0).get("fabricanteMod") + " / " + dadosVeiculo.get(0).get("descricaoModelo") + " / N " + Info.formataTelefone(dadosVeiculo.get(0).get("numeroChip")) + " / " + dadosVeiculo.get(0).get("nomeMecf")) + "</strong></td>\n" + " <td>" + dadosVeiculo.get(0).get("nomeInstalador") + "</td>\n" + " <td>" + dadosVeiculo.get(0).get("cidadeNome") + "</td>\n" + " <td>" + dadosVeiculo.get(0).get("estadoNome") + "</td>\n" + " <td>" + dadosVeiculo.get(0).get("chassi") + "</td>\n"; //+ " <td bgcolor=\"#CCCCCC\"> 0" + dadosVeiculo.get(0).get("numeroParcela") + "</td>"; cabecalhoPadraoLig = " </tr>\n" + " <tr align=\"center\">\n" + " <td width=\"160\">" + Info.titulosMsg.get("ativo") + "</td>\n" + " <td width=\"198\"><strong>" + Info.titulosMsg.get("plano") + "</strong></td>\n" + " <td width=\"111\"><strong>" + Info.titulosMsg.get("indicado") + "</strong></td>\n" + " <td width=\"198\"><strong>" + Info.titulosMsg.get("dataAdesao") + "</strong></td>\n" + " <td width=\"160\"><strong>" + Info.titulosMsg.get("desconto") + "</strong></td>\n" //+ " <td width=\"150\" bgcolor=\"#CCCCCC\"><strong>" + Info.titulosMsg.get("valor") + "</strong></td>" + " </tr>\n" + " <tr align=\"center\">\n" + " <td>" + ((dadosVeiculo.get(0).get("ativoVeic").equalsIgnoreCase("t")) ? "<strong class=\"positivo\">Sim</strong>" : "<strong><nbr>No</nbr></strong>") + "</td>\n" + " <td>" + dadosVeiculo.get(0).get("descricaoPlano") + "</td>\n" + " <td>" + ((dadosVeiculo.get(0).get("veiculoCodVeiculo").equalsIgnoreCase("0") && dadosVeiculo.get(0).get("placaIndicador") == null && dadosVeiculo.get(0).get("nomeRep") == null) ? Info.titulosMsg.get("indicacaoEmpresa") : (dadosVeiculo.get(0).get("placaIndicador") == null) ? "REP.: " + dadosVeiculo.get(0).get("nomeRep") : dadosVeiculo.get(0).get("placaIndicador")) + "</td>\n" //+ " <td>" + DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(dadosVeiculo.get(0).get("dataAdesao"))), TimeZone.createTimeZone(120)) + "</td>\n" + " <td>" + dadosVeiculo.get(0).get("dataAdesaoString") + "</td>\n" + " <td>R$" + String.valueOf(Info.formataValor(Float.parseFloat(dadosVeiculo.get(0).get("desconto")))) + "</td>\n" //+ " <td bgcolor=\"#CCCCCC\" style=\"font-size:14px;\">R$" + String.valueOf(Info.formataValor(Float.parseFloat(dadosVeiculo.get(0).get("valorParcela")))) + "</td>\n" + " </tr>\n" + " <tr align=\"center\">\n" + " <td colspan=\"5\" style=\"font-size:12px;\"><strong>" + (dadosVeiculo.get(0).get("numeroIndicacoes").equalsIgnoreCase("0") ? "" : "N de Indicaes: " + ((dadosVeiculo.get(0).get("numeroIndicacoes")).length() == 1 ? "0" + (dadosVeiculo.get(0).get("numeroIndicacoes")) + " " : (dadosVeiculo.get(0).get("numeroIndicacoes")))) + " " + ((dadosVeiculo.get(dadosVeiculo.size() - 1).get("veiculosIndicados").equalsIgnoreCase("")) ? "" : " Placa(s): " + dadosVeiculo.get(dadosVeiculo.size() - 1).get("veiculosIndicados") .substring(0, dadosVeiculo.get(dadosVeiculo.size() - 1).get("veiculosIndicados") .lastIndexOf(","))) + "</strong></td>\n" + " </tr>\n" + " <tr align=\"center\">\n" + " <td colspan=\"5\" style=\"font-size:16px;\"><strong>" + Info.titulosMsg.get("valorMensalidade") + "</strong></td>\n" + " </tr>\n" + " <tr align=\"center\">\n" + " <td colspan=\"5\" style=\"font-size:16px;\"><strong>R$"; //GWT.log(dadosVeiculo.get(0).get("veiculoCodVeiculo")+"/nPLACA INDICADOR: "+dadosVeiculo.get(0).get("placaIndicador")); String obs = "<td colspan=\"6\" align=\"center\" bgcolor=\"#CCCCCC\"><strong>OBSERVAES</strong></td><tr>" + "<td colspan=\"6\" style=\"font-size:12px;\"><center>" + ((dadosVeiculo.get(0).get("observacoes") == null || dadosVeiculo.get(0).get("observacoes").equalsIgnoreCase("")) ? "Sem informao" : dadosVeiculo.get(0).get("observacoes")) + "</center></td></tr>"; String cabecalhoFio = " </strong></td></tr>\n" + " <tr align=\"center\">\n" + " <td colspan=\"6\" align=\"center\" bgcolor=\"#CCCCCC\"><strong>PADRES DE LIGAO</strong></td>\n" + " </tr>\n" + " <tr align=\"center\">\n" + " <td width=\"111\"><strong>" + Info.titulosMsg.get("corFio") + "</strong></td>\n" + " <td width=\"198\"><strong>" + Info.titulosMsg.get("sinal") + "</strong></td>\n" + " <td width=\"198\"><strong>" + Info.titulosMsg.get("padrao") + "</strong></td>\n" + " <td width=\"144\"><strong>" + Info.titulosMsg.get("funcao") + "</strong></td>\n" + " <td width=\"215\"><strong>" + Info.titulosMsg.get("ativo") + "</strong></td>\n" + " <td colspan=\"2\"><strong>" + Info.titulosMsg.get("descricao") + "</strong></td>\n" + " </tr>\n"; TreeMap<String, String> codVeiculos = new TreeMap<>(); for (TreeMap<String, String> padraoLig : dadosVeiculo) { if (padraoLig.get("codPad") != null && codVeiculos.get(padraoLig.get("codPad")) == null) { table2 = table2 + "<tr align=\"center\">\n" + "<td id=\"corFio\">" + ((padraoLig.get("corFio") == null) ? "Sem informao" : padraoLig.get("corFio")) + "</td>\n" + "<td id=\"corFio\">" + ((padraoLig.get("sinalPad") == null) ? "Sem informao" : (padraoLig.get("sinalPad").equalsIgnoreCase("t")) ? "Positivo" : "Negativo") + "</td>\n" + "<td id=\"corFio\">" + ((padraoLig.get("padraoLd") == null) ? "Sem informao" : (padraoLig.get("padraoLd").equalsIgnoreCase("t")) ? "Ligado" : "Desligado") + "</td>\n" + "<td id=\"corFio\">" + ((padraoLig.get("funcaoPad") == null) ? "Sem informao" : (padraoLig.get("funcaoPad").equalsIgnoreCase("t")) ? "Entrada" : "Sada") + "</td>\n" + "<td id=\"corFio\">" + ((padraoLig.get("ativoPad") == null) ? "Sem informao" : (padraoLig.get("ativoPad").equalsIgnoreCase("t")) ? "Sim" : "No") + "</td>\n" + "<td id=\"descPad\" colspan=\"2\">" + ((padraoLig.get("descricaoPad") == null || padraoLig.get("descricaoPad").equalsIgnoreCase("")) ? "Sem informao" : padraoLig.get("descricaoPad")) + "</td>\n</tr>\n"; codVeiculos.put(padraoLig.get("codPad"), padraoLig.get("codPad")); } } String tablePad = "<tr>\n" + " <td colspan=\"6\" align=\"center\" bgcolor=\"#CCCCCC\"><strong>PESSOAS AUTORIZADAS</strong></td>\n" + " </tr>\n" + " <tr align=\"center\">\n" + " <td colspan=\"2\"><strong>" + Info.titulosMsg.get("tituloNome") + "</strong></td> \n" + " <td width=\"180\"><strong>" + Info.titulosMsg.get("telefone") + "</strong></td>\n" + " <td width=\"200\"><strong>" + Info.titulosMsg.get("senhaPorTelefone") + "</strong></td>\n" + " <td colspan=\"2\"><strong>" + Info.titulosMsg.get("descricao") + "</strong></td>\n" + " </tr>\n"; TreeMap<String, String> codPessoaAutorizada = new TreeMap<>(); for (TreeMap<String, String> pessoAutorizada : dadosVeiculo) { if (pessoAutorizada.get("codPes") != null && codPessoaAutorizada.get(pessoAutorizada.get("codPes")) == null) { table3 = table3 + " <tr align=\"center\">\n" + " <td colspan=\"2\">" + ((pessoAutorizada.get("nomePes") == null) ? "Sem informao" : pessoAutorizada.get("nomePes")) + "</td>\n" + " <td width=\"180\">" + ((pessoAutorizada.get("telefonePes") == null || pessoAutorizada.get("telefonePes").equals("")) ? "Sem informao" : Info.formataTelefone(pessoAutorizada.get("telefonePes"))) + "</td>\n" + " <td width=\"200\">" + ((pessoAutorizada.get("senhaPes") == null || pessoAutorizada.get("senhaPes").equalsIgnoreCase("")) ? "Sem informao" : pessoAutorizada.get("senhaPes")) + "</td>\n" + " <td colspan=\"2\">" + ((pessoAutorizada.get("descricaoPes") == null || pessoAutorizada.get("descricaoPes").equalsIgnoreCase("")) ? "Sem informao" : pessoAutorizada.get("descricaoPes")) + "</td>\n" + " </tr>\n"; codPessoaAutorizada.put(pessoAutorizada.get("codPes"), pessoAutorizada.get("codPes")); } } String fechaTabela = "</table></td>\n" + " </tr>\n" + "</table>"; String veiculoFinal = infoVeiculo + tipoVenda + infoVeiculoP2 + cabecalhoPadraoLig + mensalidade + tablePad + table3 + obs + cabecalhoFio + table2 + fechaTabela; tabelaVeiculos.setContents(veiculoFinal); //TreeMap<String, String> grupoVeiculoAuxiliar = new TreeMap<String, String>(); gruposAutorizadosRastrear.clear(); Info.dbService.buscarGrupoPorCliente(codigoCliente, new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(ArrayList<TreeMap<String, String>> result) { LinkedHashMap<String, String> user = new LinkedHashMap<>(); if (result != null) { TreeMap<String, String> grupoAuxiliar = new TreeMap<String, String>(); for (TreeMap<String, String> grupVeic : result) { for (TreeMap<String, String> grup : dadosVeiculo) { if (grupVeic.get("codGrupo").equalsIgnoreCase(grup.get("grupoGv")) && grupoAuxiliar.get(grup.get("grupoGv")) == null) { TreeMap<String, String> grupoAutorizados = new TreeMap<String, String>(); grupoAutorizados.put("grupoGv", grup.get("grupoGv")); grupoAutorizados.put("veiculoGv", grup.get("veiculoGv")); gruposAutorizadosRastrear.add(grupoAutorizados); grupoAuxiliar.put(grup.get("grupoGv"), grup.get("grupoGv")); } } } } else { user.put("0", Info.titulosMsg.get("clienteSemGrupo")); } } }); } }); HLayout painelVeiculos = new HLayout(); painelVeiculos.setMargin(5); painelVeiculos.setMembersMargin(5); painelVeiculos.setAlign(Alignment.CENTER); ////////************************************************************************** tabelaVeiculos.setWidth("80%"); tabelaVeiculos.setHeight("100%"); tabelaVeiculos.setContents(tabelaVazia); painelVeiculos.addMember(veicPlacas); painelVeiculos.addMember(tabelaVeiculos); VLayout infoClientes = new VLayout(); infoClientes.setWidth("100%"); infoClientes.setHeight(250); VLayout listGridInfoClientes = new VLayout(); listGridInfoClientes.setWidth("100%"); //listGridInfoClientes.setHeight(400); listGridInfoClientes.addMember(dadosCliente); listGridInfoClientes.addMember(enderecos); VLayout vLayoutInfoCliente = new VLayout(); vLayoutInfoCliente.setWidth("100%"); //vLayoutInfoCliente.setHeight(400); //vLayoutInfoCliente.addMember(telefones); //vLayoutInfoCliente.addMember(emails); //vLayoutInfoCliente.addMember(logins); ListGridField codigoLancamento = new ListGridField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoLancamento.setHidden(true); ListGridField dataLanc = new ListGridField("data", Info.titulosMsg.get("dataHora")); dataLanc.setAlign(Alignment.CENTER); //dataLanc.setWidth(120); ListGridField valorLanc = new ListGridField("valor", Info.titulosMsg.get("valor")); valorLanc.setAlign(Alignment.CENTER); lancamento.setSortDirection(SortDirection.DESCENDING); lancamento.setSortField("codigo"); lancamento.setCanPickFields(false); lancamento.setFields(codigoLancamento, dataLanc, valorLanc); lancamento.setShowRecordComponents(true); lancamento.setShowRecordComponentsByCell(true); lancamento.setCanResizeFields(true); // addLancamento.setSrc("[SKIN]actions/add.png"); // addLancamento.setSize(16); // addLancamento.setShowFocused(false); // addLancamento.setShowRollOver(false); // addLancamento.setShowDown(false); // addLancamento.setTooltip("Adicionar lanamento"); // addLancamento.setDisabled(true); final SectionStackSection lancamentoSection = new SectionStackSection(); lancamentoSection.setTitle("<center>" + Info.titulosMsg.get("lancamento") + "</center>"); // lancamentoSection.setControls(addLancamento); lancamentoSection.setItems(lancamento); lancamentoSection.setExpanded(true); // addLancamento.addClickHandler(new ClickHandler() { // // @Override // public void onClick(ClickEvent event) { // NovoLancamento novoLancamento = new NovoLancamento(codigoCliente, lancamento, null, null, null, null, null); // novoLancamento.setAnimateTime(1200); // novoLancamento.animateShow(AnimationEffect.FADE); // } // }); final SectionStackSection telefonesSection = new SectionStackSection(); telefonesSection.setTitle("<center>" + Info.titulosMsg.get("telefones") + "</center>"); telefonesSection.setItems(telefones); telefonesSection.setExpanded(true); final SectionStack telefonesCliente = new SectionStack(); telefonesCliente.setSections(telefonesSection); telefonesCliente.setVisibilityMode(VisibilityMode.MULTIPLE); telefonesCliente.setAnimateSections(true); telefonesCliente.setWidth("25%"); telefonesCliente.setHeight(100); telefonesCliente.setOverflow(Overflow.VISIBLE); telefonesCliente.setBorder("0px"); final SectionStackSection emailSection = new SectionStackSection(); emailSection.setTitle("<center>" + Info.titulosMsg.get("emails") + "</center>"); emailSection.setItems(emails); emailSection.setExpanded(true); final SectionStack emailsCliente = new SectionStack(); emailsCliente.setSections(emailSection); emailsCliente.setVisibilityMode(VisibilityMode.MULTIPLE); emailsCliente.setAnimateSections(true); emailsCliente.setWidth("30%"); emailsCliente.setHeight(100); emailsCliente.setOverflow(Overflow.VISIBLE); emailsCliente.setBorder("0px"); final SectionStackSection usuariosSection = new SectionStackSection(); usuariosSection.setTitle("<center>" + Info.titulosMsg.get("usuarios") + "</center>"); usuariosSection.setItems(logins); usuariosSection.setExpanded(true); final SectionStack usuariosCliente = new SectionStack(); usuariosCliente.setSections(usuariosSection); usuariosCliente.setVisibilityMode(VisibilityMode.MULTIPLE); usuariosCliente.setAnimateSections(true); usuariosCliente.setWidth("40%"); usuariosCliente.setHeight(100); usuariosCliente.setOverflow(Overflow.VISIBLE); usuariosCliente.setBorder("0px"); final SectionStack lancamentosClientes = new SectionStack(); lancamentosClientes.setSections(lancamentoSection); lancamentosClientes.setVisibilityMode(VisibilityMode.MULTIPLE); lancamentosClientes.setAnimateSections(true); lancamentosClientes.setWidth("100%"); lancamentosClientes.setHeight(100); lancamentosClientes.setOverflow(Overflow.VISIBLE); lancamentosClientes.setBorder("0px"); final VLayout lacamentoSaldo = new VLayout(5); lacamentoSaldo.setWidth("30%"); labelSaldoCliente.setHeight(18); labelSaldoCliente.setAlign(Alignment.CENTER); //adiciona no VLayout a grid Lanamentos e a Label Saldo lacamentoSaldo.addMember(lancamentosClientes); lacamentoSaldo.addMember(labelSaldoCliente); //adiciona no HLayout as listGrid com endereo, telefone, email, usurio do cliente e os lanamentos e saldo do cliente infoClientes.addMember(listGridInfoClientes); HLayout hLayoutInfoCliente = new HLayout(); hLayoutInfoCliente.setWidth("100%"); //hLayoutInfoCliente.addMember(vLayoutInfoCliente); hLayoutInfoCliente.addMember(telefonesCliente); hLayoutInfoCliente.addMember(emailsCliente); hLayoutInfoCliente.addMember(usuariosCliente); hLayoutInfoCliente.addMember(lacamentoSaldo); infoClientes.addMember(hLayoutInfoCliente); final SectionStackSection clienteSection = new SectionStackSection(); clienteSection.setTitle("<center>" + Info.titulosMsg.get("dadosCliente") + "</center>"); clienteSection.setItems(infoClientes, painelBotoesCliente); clienteSection.setExpanded(true); HLayout painelBotoesVeiculo = new HLayout(); addComando.setTooltip(Info.titulosMsg.get("adicionarComando")); addComando.setDisabled(true); addComando.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (dadosVeiculo.get(0).get("codEquipamento") == null || dadosVeiculo.get(0).get("codEquipamento").equalsIgnoreCase("") || dadosVeiculo.get(0).get("codEquipamento").equalsIgnoreCase("0")) { SC.warn(Info.titulosMsg.get("veiculoSemEquipamento")); } else { NovoComando novoComando = new NovoComando(dadosVeiculo); novoComando.setAnimateTime(1200); novoComando.animateShow(AnimationEffect.FADE); } } }); addVeiculo.setDisabled(true); addVeiculo.setTooltip(Info.titulosMsg.get("adicionarVeiculo")); addVeiculo.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { NovoVeiculo novoVeiculo = new NovoVeiculo(codigoCliente, nomeCliente, veicPlacas, tabBuscaCliente, tabelaVazia, veiculos); novoVeiculo.setAnimateTime(1200); novoVeiculo.animateShow(AnimationEffect.FADE); } }); historicoVeiculo = new IButton("Histrico"); historicoVeiculo.setDisabled(true); historicoVeiculo.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { GWT.log("historicoVeiculo: z" + veicPlacas.getSelectedRecord().getAttribute("codigo")); HistoricoVeiculo dialogHistoricoVeiculo = new HistoricoVeiculo( veicPlacas.getSelectedRecord().getAttributeAsInt("codigo")); dialogHistoricoVeiculo.setAnimateTime(1200); dialogHistoricoVeiculo.animateShow(AnimationEffect.FADE); } }); rastrearVeiculo.setDisabled(true); rastrearVeiculo.setTooltip(Info.titulosMsg.get("rastrearVeiculo")); rastrearVeiculo.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (dadosVeiculo.get(0).get("codEquipamento") != null && dadosVeiculo.get(0).get("ativoVeic").equalsIgnoreCase("t")) { //dadosVeiculo.get(0).get("codEquipamento") == null //dadosVeiculo.get(0).get("ativoVeic").equalsIgnoreCase("t") Login.principal.selectTab(Login.tabMonitoramento); Login.tabsMonitorar.selectTab(0); ListGridRecord[] tempVeiculosInicio = TabInicio.veiculos.getRecords(); for (int y = 0; y < tempVeiculosInicio.length; y++) { //GWT.log("Placa busca : "+ veicPlacas.getSelectedRecord().getAttributeAsString("placa") + " Placa inicio: "+tempVeiculosInicio[y].getAttributeAsString("placa")+ " Y: "+y); if (tempVeiculosInicio[y].getAttributeAsString("placa") .equalsIgnoreCase(veicPlacas.getSelectedRecord().getAttributeAsString("placa"))) { //TabInicio.veiculos.markForRedraw(); //TabInicio.veiculos.setShowFilterEditor(false); //TabInicio.veiculos.markForRedraw(); //TabInicio.veiculos.setShowFilterEditor(true); TabInicio.veiculos.deselectAllRecords(); TabInicio.veiculos.selectRecord(y + 1); TabInicio.indexVeiculoPlaca = y + 1; //GWT.log(" Y "+y); } } //GWT.log("Veculo selecionado: " + veicPlacas.getSelectedRecord().getAttributeAsString("codigo") + " placa : " + veicPlacas.getSelectedRecord().getAttributeAsString("placa")); } else { SC.warn("O ID do equipamento no vlido ou o veculo encontra-se inativo!"); } //TabInicio.veiculos.selectRecord(temp); } }); gerarContrato.setDisabled(true); gerarContrato.setTooltip("Gerar contrato"); gerarContrato.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Contrato contrato = new Contrato(codigoCliente, tipoCliente, codUnidadeCliente, cpfCnpj); contrato.setAnimateTime(1200); contrato.animateShow(AnimationEffect.FADE); } }); editVeiculo.setTooltip(Info.titulosMsg.get("editarVeiculo")); editVeiculo.setDisabled(true); editVeiculo.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { EditarVeiculo editarVeiculo = new EditarVeiculo(codigoCliente, nomeCliente, tabBuscaCliente, dadosVeiculo, veicPlacas, tabelaVeiculos, veiculos, placaVeiculoCopia, gruposAutorizadosRastrear); editarVeiculo.setAnimateTime(200); editarVeiculo.animateShow(AnimationEffect.FADE); } }); painelBotoesVeiculo.setMargin(5); painelBotoesVeiculo.setMembersMargin(10); painelBotoesVeiculo.setHeight(40); painelBotoesVeiculo.setAlign(Alignment.RIGHT); //painelBotoesVeiculo.addMember(gerarContrato); painelBotoesVeiculo.addMember(rastrearVeiculo); painelBotoesVeiculo.addMember(addComando); painelBotoesVeiculo.addMember(historicoVeiculo); painelBotoesVeiculo.addMember(editVeiculo); painelBotoesVeiculo.addMember(addVeiculo); final SectionStackSection veiculoSection = new SectionStackSection(); veiculoSection.setTitle("<center>" + Info.titulosMsg.get("dadosVeiculo") + "</center>"); veiculoSection.setItems(painelVeiculos, painelBotoesVeiculo); //veiculoSection.setItems(veicPlacas, painelBotoesVeiculo); veiculoSection.setExpanded(true); final SectionStack buscarClientes = new SectionStack(); buscarClientes.setSections(formSection, clienteSection, veiculoSection); buscarClientes.setVisibilityMode(VisibilityMode.MULTIPLE); buscarClientes.setAnimateSections(true); buscarClientes.setWidth("70%"); buscarClientes.setHeight100(); buscarClientes.setOverflow(Overflow.VISIBLE); painelBuscaCliente.addMember(buscarClientes); painelPai.addMember(painelBuscaCliente); setPane(painelPai); dataSource = new DataSource(); dataSource.setClientOnly(true); DataSourceTextField codigoDataSource = new DataSourceTextField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoDataSource.setHidden(true); codigoDataSource.setRequired(true); codigoDataSource.setPrimaryKey(true); DataSourceTextField placaVeiculoDataSoruce = new DataSourceTextField("placa", Info.titulosMsg.get("lista")); placaVeiculoDataSoruce.setRequired(true); dataSource.setFields(codigoDataSource, placaVeiculoDataSoruce); } private void consultaCliente() { if (buscaCliente.getValueAsString() == null || buscaCliente.getValueAsString().equalsIgnoreCase("")) { Info.abrirJanelaCarregando(); DataSourceTextField codigoDs = new DataSourceTextField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoDs.setHidden(true); DataSourceTextField cpfCnpjDs = new DataSourceTextField("cpfCnpj", "CPF / CNPJ"); DataSourceTextField nomeDs = new DataSourceTextField("nome", Info.titulosMsg.get("tituloNome")); DataSourceTextField dataAdesaoDs = new DataSourceTextField("dataAdesao", Info.titulosMsg.get("dataAdesao")); DataSourceTextField codUnidadeDs = new DataSourceTextField("codUnidade", Info.titulosMsg.get("unidade")); codUnidadeDs.setHidden(true); DataSourceTextField unidadeDs = new DataSourceTextField("unidade", Info.titulosMsg.get("unidade")); final DataSource dsTodos = new DataSource(); dsTodos.setClientOnly(true); dsTodos.setFields(codigoDs, cpfCnpjDs, nomeDs, dataAdesaoDs, codUnidadeDs, unidadeDs); Info.dbService.buscarTodosClientesPorUnidade(new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(ArrayList<TreeMap<String, String>> result) { if (result != null) { Info.fecharJanelaCarrgando(); final ListGrid clientes = new ListGrid(); clientes.setSelectionType(SelectionStyle.SINGLE); clientes.setCanPickFields(false); clientes.setShowFilterEditor(true); clientes.setFilterOnKeypress(true); ArrayList<TreeMap<String, String>> cli = new ArrayList<>(result); if (cli.size() > 0) { for (TreeMap<String, String> cli1 : cli) { //GWT.log("TabBuscarCliente - LINHA 01"); final ListGridRecord registros = new ListGridRecord(); //GWT.log("TabBuscarCliente - LINHA 02"); registros.setAttribute("nome", cli1.get("nome")); //GWT.log("TabBuscarCliente - LINHA 03"); registros.setAttribute("cpfCnpj", (cli1.get("cpf") == null) ? Info.formataCNPJ(cli1.get("cnpj")) : Info.formataCPF(cli1.get("cpf"))); //GWT.log("TabBuscarCliente - LINHA 04"); registros.setAttribute("codigo", cli1.get("codCliente")); //GWT.log("TabBuscarCliente - LINHA 05"); //DateUtil.setDefaultDisplayTimezone("-03:00"); //registros.setAttribute("dataAdesao", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(cli1.get("dataAdesao"))), TimeZone.createTimeZone(120))); registros.setAttribute("dataAdesao", cli1.get("dataAdesaoString")); //GWT.log("TabBuscarCliente - LINHA 06"); registros.setAttribute("codUnidade", Integer.parseInt(cli1.get("codUnidade"))); //GWT.log("TabBuscarCliente - LINHA 07"); registros.setAttribute("unidade", cli1.get("nomeUnidade")); //GWT.log("TabBuscarCliente - LINHA 08"); dsTodos.addData(registros); } } clientes.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { clientes.setDataSource(dsTodos); clientes.fetchData(); clientes.selectRecord(0, true); clientes.focus(); } }); final Window gridClientes = new Window(); gridClientes.setTitle(Info.titulosMsg.get("listaClientes")); gridClientes.setWidth(800); gridClientes.setHeight(300); gridClientes.setShowMinimizeButton(false); gridClientes.setIsModal(true); gridClientes.setShowModalMask(true); gridClientes.centerInPage(); gridClientes.setLayoutAlign(Alignment.CENTER); gridClientes.addItem(clientes); gridClientes.setAnimateTime(1200); gridClientes.animateShow(AnimationEffect.FADE); gridClientes.addCloseClickHandler(new CloseClickHandler() { @Override public void onCloseClick(CloseClickEvent event) { gridClientes.destroy(); } }); clientes.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { Record record = event.getRecord(); buscarPorCodCliente(record.getAttributeAsInt("codigo"), record.getAttributeAsInt("codUnidade")); gridClientes.destroy(); } }); // busca cliente por nome// Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 27, new Timestamp(System.currentTimeMillis()), " Nome do cliente: " + buscaCliente.getDisplayValue()); } else { Info.fecharJanelaCarrgando(); // no cliente cadastrado com esse nome para esta unidade // Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 194, new Timestamp(System.currentTimeMillis()), " Nome do cliente: " + buscaCliente.getDisplayValue()); SC.warn(Info.titulosMsg.get("clienteNaoCadastrado")); formBusca.focusInItem(buscaCliente); } } }); } else //GWT.log("ELSE FORA- BuscarCliente! "+buscaCliente.getValueAsString()+" "+tipoBusca.getValueAsString()); if (tipoBusca.getValueAsString().equalsIgnoreCase("1")) { Info.abrirJanelaCarregando(); DataSourceTextField codigoDs = new DataSourceTextField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoDs.setHidden(true); DataSourceTextField cpfCnpjDs = new DataSourceTextField("cpfCnpj", "CPF / CNPJ"); DataSourceTextField nomeDs = new DataSourceTextField("nome", Info.titulosMsg.get("tituloNome")); DataSourceTextField dataAdesaoDs = new DataSourceTextField("dataAdesao", Info.titulosMsg.get("dataAdesao")); DataSourceTextField codUnidadeDs = new DataSourceTextField("codUnidade", Info.titulosMsg.get("unidade")); codUnidadeDs.setHidden(true); DataSourceTextField unidadeDs = new DataSourceTextField("unidade", Info.titulosMsg.get("unidade")); final DataSource dsNomeCliente = new DataSource(); dsNomeCliente.setClientOnly(true); dsNomeCliente.setFields(codigoDs, cpfCnpjDs, nomeDs, dataAdesaoDs, codUnidadeDs, unidadeDs); Info.dbService.buscarPorNomeCliente(buscaCliente.getDisplayValue(), new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(ArrayList<TreeMap<String, String>> result) { if (result != null) { Info.fecharJanelaCarrgando(); final ListGrid clientes = new ListGrid(); clientes.setSelectionType(SelectionStyle.SINGLE); clientes.setCanPickFields(false); clientes.setShowFilterEditor(true); clientes.setFilterOnKeypress(true); ArrayList<TreeMap<String, String>> cli = new ArrayList<>(result); if (cli.size() > 0) { for (TreeMap<String, String> cli1 : cli) { final ListGridRecord registros = new ListGridRecord(); registros.setAttribute("nome", cli1.get("nome")); registros.setAttribute("cpfCnpj", (cli1.get("cpf") == null) ? Info.formataCNPJ(cli1.get("cnpj")) : Info.formataCPF(cli1.get("cpf"))); registros.setAttribute("codigo", cli1.get("codCliente")); //DateUtil.setDefaultDisplayTimezone("-03:00"); //registros.setAttribute("dataAdesao", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(cli1.get("dataAdesao"))), TimeZone.createTimeZone(120))); registros.setAttribute("dataAdesao", cli1.get("dataAdesaoString")); registros.setAttribute("codUnidade", Integer.parseInt(cli1.get("codUnidade"))); registros.setAttribute("unidade", cli1.get("nomeUnidade")); dsNomeCliente.addData(registros); } } clientes.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { clientes.setDataSource(dsNomeCliente); clientes.fetchData(); clientes.selectRecord(0, true); clientes.focus(); } }); final Window gridClientes = new Window(); gridClientes.setTitle(Info.titulosMsg.get("listaClientes")); gridClientes.setWidth(800); gridClientes.setHeight(300); gridClientes.setShowMinimizeButton(false); gridClientes.setIsModal(true); gridClientes.setShowModalMask(true); gridClientes.centerInPage(); gridClientes.setLayoutAlign(Alignment.CENTER); gridClientes.addItem(clientes); gridClientes.setAnimateTime(1200); gridClientes.animateShow(AnimationEffect.FADE); gridClientes.addCloseClickHandler(new CloseClickHandler() { @Override public void onCloseClick(CloseClickEvent event) { gridClientes.destroy(); } }); clientes.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { Record record = event.getRecord(); buscarPorCodCliente(record.getAttributeAsInt("codigo"), record.getAttributeAsInt("codUnidade")); gridClientes.destroy(); } }); // busca cliente por nome// Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 27, new Timestamp(System.currentTimeMillis()), "Nome do cliente: " + buscaCliente.getDisplayValue()); } else { Info.fecharJanelaCarrgando(); // no cliente cadastrado com esse nome para esta unidade // Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 194, new Timestamp(System.currentTimeMillis()), " Nome do cliente: " + buscaCliente.getDisplayValue()); SC.warn(Info.titulosMsg.get("clienteNaoCadastrado")); formBusca.focusInItem(buscaCliente); } } }); } else if (tipoBusca.getValueAsString().equalsIgnoreCase("2")) { Info.abrirJanelaCarregando(); DataSourceTextField codigoDs = new DataSourceTextField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoDs.setHidden(true); DataSourceTextField cpfCnpjDs = new DataSourceTextField("cpf", "CPF"); DataSourceTextField nomeDs = new DataSourceTextField("nome", Info.titulosMsg.get("tituloNome")); DataSourceTextField dataAdesaoDs = new DataSourceTextField("dataAdesao", Info.titulosMsg.get("dataAdesao")); DataSourceTextField codUnidadeDs = new DataSourceTextField("codUnidade", Info.titulosMsg.get("unidade")); codUnidadeDs.setHidden(true); DataSourceTextField unidadeDs = new DataSourceTextField("unidade", Info.titulosMsg.get("unidade")); final DataSource dsPessoa = new DataSource(); dsPessoa.setClientOnly(true); dsPessoa.setFields(codigoDs, cpfCnpjDs, nomeDs, dataAdesaoDs, codUnidadeDs, unidadeDs); Info.dbService.buscarPorCPF(buscaCliente.getValueAsString(), new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(ArrayList<TreeMap<String, String>> pessoa) { if (pessoa != null) { Info.fecharJanelaCarrgando(); final ListGrid clientes = new ListGrid(); clientes.setSelectionType(SelectionStyle.SINGLE); clientes.setCanPickFields(false); clientes.setShowFilterEditor(true); clientes.setFilterOnKeypress(true); ArrayList<TreeMap<String, String>> cli = new ArrayList<>(pessoa); if (cli.size() > 0) { for (TreeMap<String, String> cli1 : cli) { ListGridRecord registros = new ListGridRecord(); registros.setAttribute("nome", cli1.get("nome")); registros.setAttribute("cpf", Info.formataCPF(cli1.get("cpf"))); registros.setAttribute("codigo", cli1.get("codCliente")); //DateUtil.setDefaultDisplayTimezone("-03:00"); //registros.setAttribute("dataAdesao", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(cli1.get("dataAdesao"))), TimeZone.createTimeZone(120))); registros.setAttribute("dataAdesao", cli1.get("dataAdesaoString")); registros.setAttribute("codUnidade", Integer.parseInt(cli1.get("codUnidade"))); registros.setAttribute("unidade", cli1.get("nomeUnidade")); dsPessoa.addData(registros); } } clientes.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { clientes.setDataSource(dsPessoa); clientes.fetchData(); clientes.selectRecord(0, true); clientes.focus(); } }); final Window gridClientes = new Window(); gridClientes.setTitle(Info.titulosMsg.get("listaClientes")); gridClientes.setWidth(800); gridClientes.setHeight(300); gridClientes.setShowMinimizeButton(false); gridClientes.setIsModal(true); gridClientes.setShowModalMask(true); gridClientes.centerInPage(); gridClientes.setLayoutAlign(Alignment.CENTER); gridClientes.addItem(clientes); gridClientes.setAnimateTime(1200); gridClientes.animateShow(AnimationEffect.FADE); gridClientes.addCloseClickHandler(new CloseClickHandler() { @Override public void onCloseClick(CloseClickEvent event) { gridClientes.destroy(); } }); clientes.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { Record record = event.getRecord(); buscarPorCodCliente(record.getAttributeAsInt("codigo"), record.getAttributeAsInt("codUnidade")); gridClientes.destroy(); } }); ////////////////////////////// // busca cliente por CPF// Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 28, new Timestamp(System.currentTimeMillis()), " CPF do cliente: " + buscaCliente.getDisplayValue()); } else { Info.fecharJanelaCarrgando(); // no cliente cadastrado com esse CPF para esta unidade // Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 195, new Timestamp(System.currentTimeMillis()), " CPF do cliente: " + buscaCliente.getDisplayValue()); SC.warn(Info.titulosMsg.get("clienteNaoCadastrado")); formBusca.focusInItem(buscaCliente); } } }); } //else if (tipoBusca.getValueAsString().equalsIgnoreCase("3")) else { Info.abrirJanelaCarregando(); DataSourceTextField codigoDs = new DataSourceTextField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoDs.setHidden(true); DataSourceTextField cpfCnpjDs = new DataSourceTextField("cnpj", "CNPJ"); DataSourceTextField nomeDs = new DataSourceTextField("nome", Info.titulosMsg.get("tituloNome")); DataSourceTextField dataAdesaoDs = new DataSourceTextField("dataAdesao", Info.titulosMsg.get("dataAdesao")); DataSourceTextField codUnidadeDs = new DataSourceTextField("codUnidade", Info.titulosMsg.get("unidade")); codUnidadeDs.setHidden(true); DataSourceTextField unidadeDs = new DataSourceTextField("unidade", Info.titulosMsg.get("unidade")); final DataSource dsEmpresa = new DataSource(); dsEmpresa.setClientOnly(true); dsEmpresa.setFields(codigoDs, cpfCnpjDs, nomeDs, dataAdesaoDs, codUnidadeDs, unidadeDs); Info.dbService.buscarPorCNPJ(buscaCliente.getValueAsString(), new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(ArrayList<TreeMap<String, String>> empresa) { if (empresa != null) { Info.fecharJanelaCarrgando(); final ListGrid clientes = new ListGrid(); clientes.setSelectionType(SelectionStyle.SINGLE); clientes.setCanPickFields(false); clientes.setShowFilterEditor(true); clientes.setFilterOnKeypress(true); ArrayList<TreeMap<String, String>> cli = new ArrayList<>(empresa); if (cli.size() > 0) { for (TreeMap<String, String> cli1 : cli) { final ListGridRecord registros = new ListGridRecord(); registros.setAttribute("nome", cli1.get("nome")); registros.setAttribute("cnpj", Info.formataCNPJ(cli1.get("cnpj"))); registros.setAttribute("codigo", cli1.get("codCliente")); //DateUtil.setDefaultDisplayTimezone("-03:00"); //registros.setAttribute("dataAdesao", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(cli1.get("dataAdesao"))), TimeZone.createTimeZone(120))); registros.setAttribute("dataAdesao", cli1.get("dataAdesaoString")); registros.setAttribute("codUnidade", Integer.parseInt(cli1.get("codUnidade"))); registros.setAttribute("unidade", cli1.get("nomeUnidade")); dsEmpresa.addData(registros); } } clientes.addDrawHandler(new DrawHandler() { @Override public void onDraw(DrawEvent event) { clientes.setDataSource(dsEmpresa); clientes.fetchData(); clientes.setSelectionType(SelectionStyle.SINGLE); clientes.selectRecord(0, true); clientes.focus(); } }); final Window gridClientes = new Window(); gridClientes.setTitle(Info.titulosMsg.get("listaClientes")); gridClientes.setWidth(800); gridClientes.setHeight(300); gridClientes.setShowMinimizeButton(false); gridClientes.setIsModal(true); gridClientes.setShowModalMask(true); gridClientes.centerInPage(); gridClientes.setLayoutAlign(Alignment.CENTER); gridClientes.addItem(clientes); gridClientes.setAnimateTime(1200); gridClientes.animateShow(AnimationEffect.FADE); gridClientes.addCloseClickHandler(new CloseClickHandler() { @Override public void onCloseClick(CloseClickEvent event) { gridClientes.destroy(); } }); clientes.addRecordDoubleClickHandler(new RecordDoubleClickHandler() { @Override public void onRecordDoubleClick(RecordDoubleClickEvent event) { Record record = event.getRecord(); buscarPorCodCliente(record.getAttributeAsInt("codigo"), record.getAttributeAsInt("codUnidade")); gridClientes.destroy(); } }); // busca cliente por CNPJ// Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 26, new Timestamp(System.currentTimeMillis()), " CNPJ do cliente: " + buscaCliente.getDisplayValue()); } else { Info.fecharJanelaCarrgando(); // no cliente cadastrado com esse CNPJ para esta unidade // Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 196, new Timestamp(System.currentTimeMillis()), " CNPJ do cliente: " + buscaCliente.getDisplayValue()); SC.say(Info.titulosMsg.get("clienteNaoCadastrado")); formBusca.focusInItem(buscaCliente); } } }); } } public void buscarPorCodCliente(int codCliente, final int codUnidCliente) { codUnidadeClienteSelecionado = codUnidCliente; dataSource = new DataSource(); dataSource.setClientOnly(true); DataSourceTextField codigoDataSource = new DataSourceTextField("codigo", Info.titulosMsg.get("tituloCodigo")); codigoDataSource.setHidden(true); codigoDataSource.setRequired(true); codigoDataSource.setPrimaryKey(true); DataSourceTextField placaVeiculoDataSoruce = new DataSourceTextField("placa", Info.titulosMsg.get("lista")); placaVeiculoDataSoruce.setRequired(true); dataSource.setFields(codigoDataSource, placaVeiculoDataSoruce); Info.dbService.buscarPorCodCliente(codCliente, new AsyncCallback<TreeMap<String, ArrayList<TreeMap<String, String>>>>() { @Override public void onFailure(Throwable caught) { //GWT.log(caught.getMessage()); throw new UnsupportedOperationException( "Not supported yet...........................buscarPorCodCliente"); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(TreeMap<String, ArrayList<TreeMap<String, String>>> cliente) { GWT.log("Linha buscarPorCodCliente 01"); if (cliente != null) { //editCliente.setDisabled(false); if (codigoUnidade == 1 || codUnidCliente == codigoUnidade) { editCliente.setDisabled(false); //editVeiculo.setDisabled(false); } else { editCliente.setDisabled(true); //editVeiculo.setDisabled(true); } senhaCliente.setDisabled(false); if (Info.usuarioLogado.containsKey("4")) { totalDividaCliente.setDisabled(false); } //Fazendo Cpia do Cliente Retornado setClienteEdicao(cliente); //final ArrayList<TreeMap<String, String>> clienteAuxiliar = cliente.pollFirstEntry().getValue(); clienteAuxiliar = getClienteEdicao().get(getClienteEdicao().firstKey()); if (!dadosCliente.getRecordList().isEmpty()) { dadosCliente.setData(new RecordList()); } codigoCliente = Integer.parseInt(clienteAuxiliar.get(0).get("codCliente")); nomeCliente = clienteAuxiliar.get(0).get("nomeCliente"); tipoCliente = Integer.parseInt(clienteAuxiliar.get(0).get("tipoCliente")); codUnidadeCliente = Integer.parseInt(clienteAuxiliar.get(0).get("codUnidade")); Record regCliente = new Record(); regCliente.setAttribute("codigo", codigoCliente); regCliente.setAttribute("nome", clienteAuxiliar.get(0).get("nomeCliente")); //DateUtil.setDefaultDisplayTimezone("-03:00"); //regCliente.setAttribute("dataAdesao", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(clienteAuxiliar.get(0).get("dataAdesao"))), TimeZone.createTimeZone(120))); regCliente.setAttribute("dataAdesao", clienteAuxiliar.get(0).get("dataAdesaoString")); regCliente.setAttribute("unidade", clienteAuxiliar.get(0).get("nomeUnidade")); regCliente.setAttribute("codEnvio", clienteAuxiliar.get(0).get("codEnvio")); regCliente.setAttribute("modoEnvio", clienteAuxiliar.get(0).get("nomeCobranca")); /* GWT.log("CPF: "+clienteAuxiliar.get(0).get("cpf")); GWT.log("CNPJ: "+clienteAuxiliar.get(0).get("cnpj"));*/ dadosCliente.markForRedraw(); if (clienteAuxiliar.get(0).get("cpf") == null) { cpfCnpj = Info.formataCNPJ(clienteAuxiliar.get(0).get("cnpj")); regCliente.setAttribute("cnpj", Info.formataCNPJ(clienteAuxiliar.get(0).get("cnpj"))); //DateUtil.setDefaultDisplayTimezone("-03:00"); //regCliente.setAttribute("dataAbert", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(clienteAuxiliar.get(0).get("dataAbertura"))), TimeZone.createTimeZone(120))); regCliente.setAttribute("dataAbert", clienteAuxiliar.get(0).get("dataAberturaString")); dadosCliente.setFields(nome, cnpj, dataAbert, dataAdesao, unidade, codigo, codEnvio, modoEnvio); cnpj.setAlign(Alignment.CENTER); dataAbert.setAlign(Alignment.CENTER); dataAdesao.setAlign(Alignment.CENTER); } else { cpfCnpj = Info.formataCPF(clienteAuxiliar.get(0).get("cpf")); regCliente.setAttribute("cpf", Info.formataCPF(clienteAuxiliar.get(0).get("cpf"))); //DateUtil.setDefaultDisplayTimezone("-03:00"); //regCliente.setAttribute("dataNasc", DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT).format(new Date(Long.parseLong(clienteAuxiliar.get(0).get("dataNasc"))), TimeZone.createTimeZone(120))); regCliente.setAttribute("dataNasc", clienteAuxiliar.get(0).get("dataNascString")); dadosCliente.setFields(nome, cpf, dataNasc, dataAdesao, unidade, codigo, codEnvio, modoEnvio); cpf.setAlign(Alignment.CENTER); dataNasc.setAlign(Alignment.CENTER); dataAdesao.setAlign(Alignment.CENTER); } dadosCliente.addData(regCliente); if (!enderecos.getRecordList().isEmpty()) { enderecos.setData(new RecordList()); } TreeMap<String, String> endAuxiliar = new TreeMap<>(); for (TreeMap<String, String> ends : clienteAuxiliar) { if (clienteAuxiliar.get(0).get("codEndereco") != null && endAuxiliar.get(ends.get("codEndereco")) == null) { Record regEnd = new Record(); regEnd.setAttribute("codigo", Integer.parseInt(ends.get("codEndereco"))); regEnd.setAttribute("descricao", ends.get("descricaoEndereco")); regEnd.setAttribute("logradouro", ends.get("logradouro")); regEnd.setAttribute("numero", ends.get("numeroEndereco")); regEnd.setAttribute("bairro", ends.get("bairro")); regEnd.setAttribute("cep", ends.get("cep")); regEnd.setAttribute("cidade", ends.get("nomeCidade")); regEnd.setAttribute("cidadeCod", ends.get("codCidade")); regEnd.setAttribute("estado", ends.get("estadoUf")); regEnd.setAttribute("estadoCod", ends.get("codEstado")); regEnd.setAttribute("referencia", (ends.get("referenciaEndereco") == null || ends.get("referenciaEndereco").equalsIgnoreCase("") ? "Sem informao" : ends.get("referenciaEndereco"))); enderecos.addData(regEnd); endAuxiliar.put(ends.get("codEndereco"), ends.get("codEndereco")); } } if (!telefones.getRecordList().isEmpty()) { telefones.setData(new RecordList()); } TreeMap<String, String> foneAuxiliar = new TreeMap<>(); for (TreeMap<String, String> tels : clienteAuxiliar) { if (clienteAuxiliar.get(0).get("codFone") != null && foneAuxiliar.get(tels.get("codFone")) == null) { Record regTel = new Record(); regTel.setAttribute("codigo", Integer.parseInt(tels.get("codFone"))); regTel.setAttribute("descricao", tels.get("descricaoFone")); regTel.setAttribute("numero", Info.formataTelefone(tels.get("numeroFone"))); telefones.addData(regTel); foneAuxiliar.put(tels.get("codFone"), tels.get("codFone")); } } if (!emails.getRecordList().isEmpty()) { emails.setData(new RecordList()); } TreeMap<String, String> emailAuxiliar = new TreeMap<>(); for (TreeMap<String, String> ems : clienteAuxiliar) { if (clienteAuxiliar.get(0).get("codEmail") != null && emailAuxiliar.get(ems.get("codEmail")) == null) { Record regEmails = new Record(); regEmails.setAttribute("codigo", Integer.parseInt(ems.get("codEmail"))); regEmails.setAttribute("descricao", ems.get("descricaoEmail")); regEmails.setAttribute("email", ems.get("email")); emails.addData(regEmails); emailAuxiliar.put(ems.get("codEmail"), ems.get("codEmail")); } } if (!logins.getRecordList().isEmpty()) { logins.setData(new RecordList()); } TreeMap<String, String> usuarioAuxiliar = new TreeMap<>(); for (TreeMap<String, String> user : clienteAuxiliar) { if (clienteAuxiliar.get(0).get("codUsuario") != null && usuarioAuxiliar.get(user.get("codUsuario")) == null) { Record regUsers = new Record(); regUsers.setAttribute("codigo", Integer.parseInt(user.get("codUsuario"))); regUsers.setAttribute("usuario", user.get("usuario")); regUsers.setAttribute("senha", (user.get("resetUsuario").equalsIgnoreCase("t")) ? "Alterada" : "Padro"); regUsers.setAttribute("statusCod", user.get("ativoUsuario")); regUsers.setAttribute("status", ((user.get("ativoUsuario").equalsIgnoreCase("t")) ? "Ativo" : "Bloqueado")); regUsers.setAttribute("codGrupo", user.get("codGrupo")); regUsers.setAttribute("grupo", user.get("nomeGrupo")); regUsers.setAttribute("resetUsuario", ((user.get("resetUsuario").equalsIgnoreCase("t")) ? "Resetado" : "Resetar")); logins.addData(regUsers); usuarioAuxiliar.put(user.get("codUsuario"), user.get("codUsuario")); } } if (!lancamento.getRecordList().isEmpty()) { lancamento.setData(new RecordList()); } TreeMap<String, String> lancamentoAuxiliar = new TreeMap<>(); for (TreeMap<String, String> lanc : clienteAuxiliar) { if (clienteAuxiliar.get(0).get("codLancamento") != null && lancamentoAuxiliar.get(lanc.get("codLancamento")) == null) { Record regLanc = new Record(); regLanc.setAttribute("codigo", Integer.parseInt(lanc.get("codLancamento"))); //DateUtil.setDefaultDisplayTimezone("-03:00"); regLanc.setAttribute("data", DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_SHORT).format( new Date(Long.parseLong(lanc.get("dataLancamento"))), TimeZone.createTimeZone(120))); regLanc.setAttribute("valor", "R$" + Info.formataSaldo(Double.parseDouble(lanc.get("valorLancamento")))); lancamento.addData(regLanc); lancamentoAuxiliar.put(lanc.get("codLancamento"), lanc.get("codLancamento")); } } //editCliente.setDisabled(false); addVeiculo.setDisabled(false); //rastrearVeiculo.setDisabled(false); //gerarContrato.redraw(); //download=\"Contrato.pdf\" //gerarContrato.setContents("<a href=\"#\" onclick=\"window.open('./ContratoPfServlet', '_blank','menubar=no'><input type=\"button\" value=\"Gerar contrato\" disabled=\"disabled\"></a>"); Info.dbService.buscarVeiculoPorCliente( Integer.parseInt(clienteAuxiliar.get(0).get("codCliente")), new AsyncCallback<TreeMap<String, ArrayList<TreeMap<String, String>>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException( "Not supported yet. buscarVeiculoPorCliente"); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess( TreeMap<String, ArrayList<TreeMap<String, String>>> dadosVeic) { //GWT.log(""); GWT.log("Linha buscarVeiculoPorCliente 01"); TabBuscarCliente.totalMensalidadesVeiculos = 0; veiculos = new TreeMap<>(); if (dadosVeic != null) { if (!veicPlacas.getRecordList().isEmpty()) { veicPlacas.setData(new Record[0]); flagDrawGrid = false; veicPlacas.markForRedraw(); tabelaVeiculos.setContents(tabelaVazia); tabelaVeiculos.redraw(); indexVeiculoPlaca = 0; } //GWT.log("Linha buscarVeiculoPorCliente 02"); veiculos = new TreeMap<>(dadosVeic); TreeMap<String, String> placasVeciuloAux = new TreeMap<>(); for (Map.Entry<String, ArrayList<TreeMap<String, String>>> entrySet : dadosVeic .entrySet()) { String key = entrySet.getKey(); GWT.log("PLACA FRANGO: " + key); ArrayList<TreeMap<String, String>> value = entrySet.getValue(); if (!placasVeciuloAux .containsKey(value.get(0).get("placaVeiculo"))) { Record recordVeiculos = new Record(); recordVeiculos.setAttribute("placa", value.get(0).get("placaVeiculo")); recordVeiculos.setAttribute("codigo", value.get(0).get("codVeiculo")); // recordVeiculos.setAttribute("icone", value.get(0).get("codIcone")); // recordVeiculos.setAttribute("grupo", value.get(0).get("nomeGrupo")); // recordVeiculos.setAttribute("fabricante", value.get(0).get("fabricante")); // recordVeiculos.setAttribute("modelo", value.get(0).get("modelo")); // recordVeiculos.setAttribute("cor", value.get(0).get("cor")); // recordVeiculos.setAttribute("ano", value.get(0).get("ano")); //dataSource.setCacheAllData(true); //dataSource.setCacheData(recordVeiculos); dataSource.addData(recordVeiculos); //veicPlacas.setDataSource(dataSource); //veicPlacas.fetchRelatedData(recordVeiculos, dataSource); placasVeciuloAux.put(value.get(0).get("placaVeiculo"), value.get(0).get("placaVeiculo")); if (value.get(0).get("ativoVeic").equalsIgnoreCase("t")) { if (Integer .parseInt(value.get(0).get("codPlano")) == 1) { double desconto = Double .parseDouble(value.get(0).get("desconto")); double numeroIndicicoes = Double.parseDouble( value.get(0).get("numeroIndicacoes")); double valorPlano = Double.parseDouble( value.get(0).get("valorPlano")); double dezPorCentoPlano = Double.parseDouble( value.get(0).get("valorPlano")) * 0.1; double descontoIndicacao = Info.formataDecimal( numeroIndicicoes * dezPorCentoPlano); double valorMensalidade = Info .formataDecimal(valorPlano - (desconto + descontoIndicacao)); TabBuscarCliente.totalMensalidadesVeiculos = Info .formataDecimal( TabBuscarCliente.totalMensalidadesVeiculos + valorMensalidade); } else { double desconto = Double .parseDouble(value.get(0).get("desconto")); double valorPlano = Double.parseDouble( value.get(0).get("valorPlano")); double valorMensalidade = Info .formataDecimal(valorPlano - desconto); TabBuscarCliente.totalMensalidadesVeiculos = Info .formataDecimal( TabBuscarCliente.totalMensalidadesVeiculos + valorMensalidade); } } } } veicPlacas.setDataSource(dataSource); flagDrawGrid = true; if (veiculos.size() < 50) { if (flagDrawGrid) { GWT.log("flagDrawGrid"); //veicPlacas.setDataSource(dataSource); veicPlacas.fetchData(); veicPlacas.focus(); GWT.log("flagDrawGrid"); } } else { new Timer() { @Override public void run() { if (flagDrawGrid) { GWT.log("flagDrawGrid"); //veicPlacas.setDataSource(dataSource); veicPlacas.fetchData(); veicPlacas.focus(); GWT.log("flagDrawGrid"); } } }.schedule(1000); } /////////////////////////////////////////////////////////////////////////////////////// Info.dbService.buscarTodasTaxas( new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException( "Not supported yet. buscarTodasTaxas"); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess( ArrayList<TreeMap<String, String>> taxas) { GWT.log("buscarTodasTaxas - Linha 01"); if (taxas != null) { multa = 0; juros = 0; for (TreeMap<String, String> txs : taxas) { if (Integer.parseInt( txs.get("codTaxa")) == 1) { multa = Double .parseDouble(txs.get("valor")); } else if (Integer.parseInt( txs.get("codTaxa")) == 2) { juros = Double .parseDouble(txs.get("valor")); } } } } }); ///************************************************************************************************************************************************************//// Info.dbService.buscarFaturaPorCliente( Integer.parseInt(clienteAuxiliar.get(0).get("codCliente")), new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException( "Not supported yet. buscarFaturaPorCliente"); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess( ArrayList<TreeMap<String, String>> faturasCliente) { GWT.log("buscarFaturaPorCliente - Linha 01"); //////////////////////////////////////////////////////////////////****************************************\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Date dataAtual = new Date( System.currentTimeMillis()); long diaAtual = dataAtual.getTime(); long diferencaDeDatas = 0; long diaVencimento = 0; arrayFaturasBD.clear(); setTotalLancamentos(0); setSaldo(0); setTotalFaturas(0); labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; \">Saldo Atual: R$00,00\n</strong>"); TreeMap<String, String> faturaAuxiliar = new TreeMap<>(); if (faturasCliente != null) { for (TreeMap<String, String> fats : faturasCliente) { if (faturasCliente.get(0) .get("codFatura") != null && faturaAuxiliar.get(fats.get( "codFatura")) == null) { Date dataDeVencimento = new Date( Long.parseLong(fats.get( "dataVencimento"))); diaVencimento = dataDeVencimento .getTime(); diferencaDeDatas = diaAtual - diaVencimento; TreeMap<String, String> faturaBD = new TreeMap<>(); faturaBD.put("codFatura", fats.get("codFatura")); faturaBD.put("codCliente", fats.get("codCliente")); faturaBD.put("dataVencimento", fats.get("dataVencimento")); faturaBD.put("valor", String.valueOf( Info.formataSaldo(Double .parseDouble(fats.get( "valor"))))); faturaBD.put("estado", fats.get("estado")); faturaBD.put("valorPago", (fats.get( "totalLancamentos") == null) ? String.valueOf(Info .formataSaldo( 0)) : String.valueOf(Info .formataSaldo( Double.parseDouble( fats.get( "totalLancamentos"))))); faturaBD.put("mesReferencia", fats.get("mes")); faturaBD.put("count", "0"); double totalPago = (fats.get( "totalLancamentos") == null) ? 0 : (Double.parseDouble( fats.get( "totalLancamentos"))); if (diferencaDeDatas <= 0) { double valor = Double.parseDouble( fats.get("valor")); double valorAtualFatura = (totalPago == 0) ? Info.formataDecimal(valor) : Info.formataDecimal(Double .parseDouble(fats .get("valor")) - (totalPago)); faturaBD.put("jurosEmulta", String .valueOf(Info.formataSaldo( Double.parseDouble( "0")))); faturaBD.put("valorApagar", String .valueOf(Info.formataSaldo( Info.formataDecimal( (valorAtualFatura))))); faturaBD.put("valorTotal", String .valueOf(Info.formataSaldo( Info.formataDecimal( Double.parseDouble( fats.get( "valor")))))); diferencaDeDatas = 0; } else if (diferencaDeDatas > 0 && diferencaDeDatas < 86400000) { double valor = Double.parseDouble( fats.get("valor")); double valorAtualFatura = (totalPago == 0) ? Info.formataDecimal(valor) + (valor * multa) : Info.formataDecimal(Double .parseDouble(fats .get("valor")) - (totalPago) + (valor * multa)); faturaBD.put("jurosEmulta", String .valueOf(Info.formataSaldo( (Info.formataDecimal( valor * multa))))); faturaBD.put("valorApagar", String .valueOf(Info.formataSaldo( Info.formataDecimal( valorAtualFatura)))); faturaBD.put("valorTotal", String .valueOf(Info.formataSaldo( Info.formataDecimal( Double.parseDouble( fats.get( "valor")) + ((Double .parseDouble( fats.get( "valor")) * multa)))))); diferencaDeDatas = 0; } else if (diferencaDeDatas > 86400000) { double valor = Double.parseDouble( fats.get("valor")); double valorAtualFatura = (totalPago == 0) ? Info.formataDecimal(valor) + (valor * multa) + ((diferencaDeDatas / 86400000) * (juros * valor)) : Info.formataDecimal(Double .parseDouble(fats .get("valor")) - (totalPago) + (valor * multa) + ((diferencaDeDatas / 86400000) * (juros * valor))); faturaBD.put("jurosEmulta", String .valueOf(Info.formataSaldo( Info.formataDecimal( (valor * multa) + ((diferencaDeDatas / 86400000) * (juros * valor)))))); faturaBD.put("valorApagar", String .valueOf(Info.formataSaldo( Info.formataDecimal( valorAtualFatura)))); faturaBD.put("valorTotal", String .valueOf(Info.formataSaldo( Info.formataDecimal( Double.parseDouble( fats.get( "valor")) + ((Double .parseDouble( fats.get( "valor")) * multa)) + ((diferencaDeDatas / 86400000) * (juros * Double .parseDouble( fats.get( "valor")))))))); diferencaDeDatas = 0; } arrayFaturasBD.add(faturaBD); faturaAuxiliar.put( fats.get("codFatura"), fats.get("codFatura")); } } } //////////////////////////////////////////////////*******************************************\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ for (TreeMap<String, String> fats : arrayFaturasBD) { setTotalFaturas(getTotalFaturas() + ((Double .parseDouble(fats.get("valorPago") .replaceAll("\\.", "") .replaceAll(",", ".")) > 0 && Boolean.parseBoolean(fats.get( "estado")) == true) ? Double .parseDouble(fats.get( "valorPago") .replaceAll( "\\.", "") .replaceAll(",", ".")) : (Double.parseDouble( fats.get( "valorPago") .replaceAll( "\\.", "") .replaceAll( ",", ".")) + Double.parseDouble( fats.get( "valorApagar") .replaceAll( "\\.", "") .replaceAll( ",", "."))))); } ////////////////////////////////////////////////////////****************************************************//////////////////////////////////// Info.dbService.buscarTotalLancamentos( Integer.parseInt(clienteAuxiliar.get(0) .get("codCliente")), new AsyncCallback<Double>() { @Override public void onFailure( Throwable caught) { throw new UnsupportedOperationException( "Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(Double totLanc) { GWT.log("buscarTotalLancamentos - Linha 01"); setTotalLancamentos(totLanc); setSaldo(getTotalLancamentos() - getTotalFaturas()); if (getSaldo() == 0) { labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; \">" + Info.titulosMsg .get("saldoAtual") + "00,00\n</strong>"); } else if (getSaldo() > 0) { labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; color:green; \">" + Info.titulosMsg .get("creditoAtual") + Info.formataSaldo( Info.formataDecimal( getSaldo())) + "\n</strong>"); } else { labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; color:red; \">" + Info.titulosMsg .get("debitoAtual") + Info.formataSaldo( Info.formataDecimal( getSaldo())) + "\n</strong>"); } } }); } }); /////////////////////////////////////////////////////////////////////////////////////// } else { //rastrearVeiculo.setDisabled(true); //editVeiculo.setDisabled(true); //addComando.setDisabled(true); historicoVeiculo.setDisabled(true); rastrearVeiculo.setDisabled(true); gerarContrato.setDisabled(true); editVeiculo.setDisabled(true); addComando.setDisabled(true); veicPlacas.setData(new Record[0]); flagDrawGrid = false; veicPlacas.markForRedraw(); tabelaVeiculos.setContents(tabelaVazia); tabelaVeiculos.redraw(); indexVeiculoPlaca = 0; //GWT.log("Linha buscarVeiculoPorCliente 03"); /////////////////////////////////////////////////////////////////////////////////////// Info.dbService.buscarTodasTaxas( new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException( "Not supported yet. buscarTodasTaxas"); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess( ArrayList<TreeMap<String, String>> taxas) { if (taxas != null) { multa = 0; juros = 0; for (TreeMap<String, String> txs : taxas) { if (Integer.parseInt( txs.get("codTaxa")) == 1) { multa = Double .parseDouble(txs.get("valor")); } else if (Integer.parseInt( txs.get("codTaxa")) == 2) { juros = Double .parseDouble(txs.get("valor")); } } } } }); ///************************************************************************************************************************************************************//// Info.dbService.buscarFaturaPorCliente( Integer.parseInt(clienteAuxiliar.get(0).get("codCliente")), new AsyncCallback<ArrayList<TreeMap<String, String>>>() { @Override public void onFailure(Throwable caught) { throw new UnsupportedOperationException( "Not supported yet. buscarFaturaPorCliente"); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess( ArrayList<TreeMap<String, String>> faturasCliente) { //////////////////////////////////////////////////////////////////****************************************\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Date dataAtual = new Date( System.currentTimeMillis()); long diaAtual = dataAtual.getTime(); long diferencaDeDatas = 0; long diaVencimento = 0; arrayFaturasBD.clear(); setTotalLancamentos(0); setSaldo(0); setTotalFaturas(0); labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; \">Saldo Atual: R$00,00\n</strong>"); TreeMap<String, String> faturaAuxiliar = new TreeMap<>(); if (faturasCliente != null) { for (TreeMap<String, String> fats : faturasCliente) { if (faturasCliente.get(0) .get("codFatura") != null && faturaAuxiliar.get(fats.get( "codFatura")) == null) { Date dataDeVencimento = new Date( Long.parseLong(fats.get( "dataVencimento"))); diaVencimento = dataDeVencimento .getTime(); diferencaDeDatas = diaAtual - diaVencimento; TreeMap<String, String> faturaBD = new TreeMap<>(); faturaBD.put("codFatura", fats.get("codFatura")); faturaBD.put("codCliente", fats.get("codCliente")); faturaBD.put("dataVencimento", fats.get("dataVencimento")); faturaBD.put("valor", String.valueOf( Info.formataSaldo(Double .parseDouble(fats.get( "valor"))))); faturaBD.put("estado", fats.get("estado")); faturaBD.put("valorPago", (fats.get( "totalLancamentos") == null) ? String.valueOf(Info .formataSaldo( 0)) : String.valueOf(Info .formataSaldo( Double.parseDouble( fats.get( "totalLancamentos"))))); faturaBD.put("mesReferencia", fats.get("mes")); faturaBD.put("count", "0"); double totalPago = (fats.get( "totalLancamentos") == null) ? 0 : (Double.parseDouble( fats.get( "totalLancamentos"))); if (diferencaDeDatas <= 0) { double valor = Double.parseDouble( fats.get("valor")); double valorAtualFatura = (totalPago == 0) ? Info.formataDecimal(valor) : Info.formataDecimal(Double .parseDouble(fats .get("valor")) - (totalPago)); faturaBD.put("jurosEmulta", String .valueOf(Info.formataSaldo( Double.parseDouble( "0")))); faturaBD.put("valorApagar", String .valueOf(Info.formataSaldo( Info.formataDecimal( (valorAtualFatura))))); faturaBD.put("valorTotal", String .valueOf(Info.formataSaldo( Info.formataDecimal( Double.parseDouble( fats.get( "valor")))))); diferencaDeDatas = 0; } else if (diferencaDeDatas > 0 && diferencaDeDatas < 86400000) { double valor = Double.parseDouble( fats.get("valor")); double valorAtualFatura = (totalPago == 0) ? Info.formataDecimal(valor) + (valor * multa) : Info.formataDecimal(Double .parseDouble(fats .get("valor")) - (totalPago) + (valor * multa)); faturaBD.put("jurosEmulta", String .valueOf(Info.formataSaldo( (Info.formataDecimal( valor * multa))))); faturaBD.put("valorApagar", String .valueOf(Info.formataSaldo( Info.formataDecimal( valorAtualFatura)))); faturaBD.put("valorTotal", String .valueOf(Info.formataSaldo( Info.formataDecimal( Double.parseDouble( fats.get( "valor")) + ((Double .parseDouble( fats.get( "valor")) * multa)))))); diferencaDeDatas = 0; } else if (diferencaDeDatas > 86400000) { double valor = Double.parseDouble( fats.get("valor")); double valorAtualFatura = (totalPago == 0) ? Info.formataDecimal(valor) + (valor * multa) + ((diferencaDeDatas / 86400000) * (juros * valor)) : Info.formataDecimal(Double .parseDouble(fats .get("valor")) - (totalPago) + (valor * multa) + ((diferencaDeDatas / 86400000) * (juros * valor))); faturaBD.put("jurosEmulta", String .valueOf(Info.formataSaldo( Info.formataDecimal( (valor * multa) + ((diferencaDeDatas / 86400000) * (juros * valor)))))); faturaBD.put("valorApagar", String .valueOf(Info.formataSaldo( Info.formataDecimal( valorAtualFatura)))); faturaBD.put("valorTotal", String .valueOf(Info.formataSaldo( Info.formataDecimal( Double.parseDouble( fats.get( "valor")) + ((Double .parseDouble( fats.get( "valor")) * multa)) + ((diferencaDeDatas / 86400000) * (juros * Double .parseDouble( fats.get( "valor")))))))); diferencaDeDatas = 0; } arrayFaturasBD.add(faturaBD); faturaAuxiliar.put( fats.get("codFatura"), fats.get("codFatura")); } } } //////////////////////////////////////////////////*******************************************\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ for (TreeMap<String, String> fats : arrayFaturasBD) { setTotalFaturas(getTotalFaturas() + ((Double .parseDouble(fats.get("valorPago") .replaceAll("\\.", "") .replaceAll(",", ".")) > 0 && Boolean.parseBoolean(fats.get( "estado")) == true) ? Double .parseDouble(fats.get( "valorPago") .replaceAll( "\\.", "") .replaceAll(",", ".")) : (Double.parseDouble( fats.get( "valorPago") .replaceAll( "\\.", "") .replaceAll( ",", ".")) + Double.parseDouble( fats.get( "valorApagar") .replaceAll( "\\.", "") .replaceAll( ",", "."))))); } ////////////////////////////////////////////////////////****************************************************//////////////////////////////////// Info.dbService.buscarTotalLancamentos( Integer.parseInt(clienteAuxiliar.get(0) .get("codCliente")), new AsyncCallback<Double>() { @Override public void onFailure( Throwable caught) { throw new UnsupportedOperationException( "Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @Override public void onSuccess(Double totLanc) { setTotalLancamentos(totLanc); setSaldo(getTotalLancamentos() - getTotalFaturas()); if (getSaldo() == 0) { labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; \">" + Info.titulosMsg .get("saldoAtual") + "00,00\n</strong>"); } else if (getSaldo() > 0) { labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; color:green; \">" + Info.titulosMsg .get("creditoAtual") + Info.formataSaldo( Info.formataDecimal( getSaldo())) + "\n</strong>"); } else { labelSaldoCliente.redraw(); labelSaldoCliente.setContents( "<strong style=\"font-size:15px; color:red; \">" + Info.titulosMsg .get("debitoAtual") + Info.formataSaldo( Info.formataDecimal( getSaldo())) + "\n</strong>"); } } }); } }); /////////////////////////////////////////////////////////////////////////////////////// } } }); } else { // errro ao consultar os veiculos do cliente // editCliente.setDisabled(true); //rastrearVeiculo.setDisabled(true); Info.registrarLog(Integer.parseInt(Info.usuarioLogado.get("codUsuario")), 282, new Timestamp(System.currentTimeMillis()), "cliente: " + buscaCliente.getValueAsString()); SC.warn(Info.titulosMsg.get("erroConsultaCliente")); } } }); } public TreeMap<String, ArrayList<TreeMap<String, String>>> getClienteEdicao() { return clienteEdicao; } public void setClienteEdicao(TreeMap<String, ArrayList<TreeMap<String, String>>> clienteEdicao) { this.clienteEdicao = clienteEdicao; } }