Lançar Valor Regras Contábeis Subtotal R' + r.total + ''); } else { engine.getLabel('sub').setValue('Subtotal R$ 0,00'); } }); } function fncSubTotalPessoal() { var params = {id: 0}; var db = vScriptService.loadScript('db', 'javascript'); var vitruvio = new db('vitruvio'); var sql = "Select replace(replace(replace(to_char(sum(cdp.valor), 'L9G999G990D99'),',','-' ),'.',','),'-','.') total from controle_despesas_pessoais cdp where cdp.data between '" + engine.getField('dataInicioPessoal') + "' and '" + engine.getField('dataFinalPessoal') + "'"; if (engine.getField('ftResponsavelPessoal').getValue()) { sql += " and cdp.chave_responsavel = " + engine.getField('ftResponsavelPessoal').getValue(); } vitruvio.query(sql).each(function (r) { if (r.total) { engine.getLabel('subPessoal').setValue('Subtotal R' + r.total + ''); } else { engine.getLabel('subPessoal').setValue('Subtotal R$ 0,00'); } }); } function fncSubTotalCombustivel() { var params = {id: 0}; var db = vScriptService.loadScript('db', 'javascript'); var vitruvio = new db('vitruvio'); var sql = "Select replace(replace(replace(to_char(sum(cdc.total_combustivel), 'L9G999G990D99'),',','-' ),'.',','),'-','.') total from controle_despesas_combustiveis cdc where cdc.data between '" + engine.getField('dataInicioCombustivel') + "' and '" + engine.getField('dataFinalCombustivel') + "'"; if (engine.getField('ftPlacaCombustivel').getValue()) { sql += " and cdc.chave_veiculo = " + engine.getField('ftPlacaCombustivel').getValue(); } if (engine.getField('ftCombustivel').getValue()) { sql += " and cdc.chave_combustivel = " + engine.getField('ftCombustivel').getValue(); } if (engine.getField('ftClienteCombustivel').getValue()) { sql += " and cdc.chave_cliente = " + engine.getField('ftClienteCombustivel').getValue(); } vitruvio.query(sql).each(function (r) { if (r.total) { engine.getLabel('subCombustivel').setValue('Subtotal R' + r.total + ''); } else { engine.getLabel('subCombustivel').setValue('Subtotal R$ 0,00'); } }); } function run() { engine.getField('totalCombustivel').setEnabled(false); engine.getField('kmRodado').setEnabled(false); engine.getField('mediaCombustivel').setEnabled(false); var d = new java.util.Date(); engine.setGlobalVariable('fncLimpaCampos', fncLimpaCampos); engine.setGlobalVariable('fncSubTotal', fncSubTotal); engine.setGlobalVariable('fncSubTotalPessoal', fncSubTotalPessoal); engine.setGlobalVariable('fncSubTotalCombustivel', fncSubTotalCombustivel); engine.getField('dataInicio').setValue(d); engine.getField('dataFinal').setValue(d); engine.getField('dataInicioPessoal').setValue(d); engine.getField('dataFinalPessoal').setValue(d); engine.getField('dataInicioCombustivel').setValue(d); engine.getField('dataFinalCombustivel').setValue(d); engine.getField('tbLancamentos').refresh(); engine.getField('tbPessoal').refresh(); engine.getField('tbTotalSocios').refresh(); engine.getField('tbCombustivel').refresh(); engine.getField('tbTotalCombustivel').refresh(); engine.getGlobalVariable('fncSubTotal')(); engine.getGlobalVariable('fncSubTotalPessoal')(); engine.getGlobalVariable('fncSubTotalCombustivel')(); // Registrando icones engine.getWidgetController('btnGravar').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.SALVAR)); engine.getWidgetController('btnFiltrar').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.FILTRAR)); engine.getWidgetController('btnLimparFiltro').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.LIMPAR)); engine.getWidgetController('btnGravarPessoal').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.SALVAR)); engine.getWidgetController('btnFiltrarPessoal').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.FILTRAR)); engine.getWidgetController('btnLimparFiltroPessoal').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.LIMPAR)); engine.getWidgetController('btnGravarCombustivel').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.SALVAR)); engine.getWidgetController('btnFiltrarCombustivel').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.FILTRAR)); engine.getWidgetController('btnLimparFiltroCombustivel').getButton().setIcon(IconFactory.instance().getIconAsResource(IconLibraryAPISmall.LIMPAR)); } ]]> CODIGO PLACA CODIGO NOME CODIGO DESCRICAO CODIGO DESCRICAO CODIGO NOME CODIGO NOME CODIGO RAZAO_SOCIAL CODIGO NOME CODIGO PLACA CODIGO NOME CODIGO RAZAO_SOCIAL chave_despesa_operacional importClass(Packages.br.com.davinti.vitruvio.ui.core.VitruvioTheme); importClass(Packages.com.vaadin.ui.VerticalLayout); function Generator() { var com = libService.loadScript('vaadinComponents'); this.generate = function(itemId, columnId, item, container) { var titulo = item.getItemProperty('OBSERVACOES').getValue(); if (titulo.length() >= 20) { titulo = titulo.substring(0,19) + '...'; } var btn = com.linkButton(titulo, function(){ var subContent = new VerticalLayout(); subContent.setId('teste'); subContent.setMargin(true); var linha = item; var textArea = com.textArea(null, item.getItemProperty('OBSERVACOES').getValue()); var instGravar = function run() { var sqlAtualiza = 'UPDATE controle_despesas_operacionais SET observacoes = ? ' + ' WHERE CHAVE_DESPESA_OPERACIONAL = ? '; var params = new java.util.ArrayList(); params.add(textArea.getValue()); params.add(linha.getItemProperty('CHAVE_DESPESA_OPERACIONAL').getValue().longValue()); vQueryService.executePSUpdateQuery('vitruvio', sqlAtualiza, params.toArray()); engine.getField('tbLancamentos').refresh(); window.close(); }; var gravar = com.button('Gravar',instGravar,null); subContent.addComponent(textArea); subContent.addComponent(gravar); var window = com.openWindow(item.getItemProperty('CLIENTE').getValue(), subContent,500,200); textArea.setSizeFull(); textArea.addStyleName(com.theme().TEXTAREA_BORDERLESS); window.setModal(true); }); btn.setDescription(item.getItemProperty('OBSERVACOES').getValue()); var container = com.horizontalLayout([btn]); container.setSpacing(false); return container; } } var script = new Generator(); CODIGO DESCRICAO CODIGO NOME CODIGO NOME chave_pessoal importClass(Packages.br.com.davinti.vitruvio.ui.core.VitruvioTheme); importClass(Packages.com.vaadin.ui.VerticalLayout); function Generator() { var com = libService.loadScript('vaadinComponents'); this.generate = function(itemId, columnId, item, container) { var titulo = item.getItemProperty('OBSERVACOES').getValue(); if (titulo.length() >= 20) { titulo = titulo.substring(0,19) + '...'; } var btn = com.linkButton(titulo, function(){ var subContent = new VerticalLayout(); subContent.setId('teste'); subContent.setMargin(true); var linha = item; var textArea = com.textArea(null, item.getItemProperty('OBSERVACOES').getValue()); var instGravar = function run() { var sqlAtualiza = 'UPDATE controle_despesas_pessoais SET observacoes = ? ' + ' WHERE CHAVE_PESSOAL = ? '; var params = new java.util.ArrayList(); params.add(textArea.getValue()); params.add(linha.getItemProperty('CHAVE_PESSOAL').getValue().longValue()); vQueryService.executePSUpdateQuery('vitruvio', sqlAtualiza, params.toArray()); engine.getField('tbPessoal').refresh(); window.close(); }; var gravar = com.button('Gravar',instGravar,null); subContent.addComponent(textArea); subContent.addComponent(gravar); var window = com.openWindow(item.getItemProperty('CATEGORIA').getValue(), subContent,500,200); textArea.setSizeFull(); textArea.addStyleName(com.theme().TEXTAREA_BORDERLESS); window.setModal(true); }); btn.setDescription(item.getItemProperty('OBSERVACOES').getValue()); var container = com.horizontalLayout([btn]); container.setSpacing(false); return container; } } var script = new Generator(); NOME CODIGO PLACA CODIGO NOME CODIGO DESCRICAO CODIGO PLACA CODIGO DESCRICAO CODIGO NOME chave_despesa_combustivel importClass(Packages.br.com.davinti.vitruvio.ui.core.VitruvioTheme); importClass(Packages.com.vaadin.ui.VerticalLayout); function Generator() { var com = libService.loadScript('vaadinComponents'); this.generate = function(itemId, columnId, item, container) { var titulo = item.getItemProperty('OBSERVACOES').getValue(); if (titulo.length() >= 20) { titulo = titulo.substring(0,19) + '...'; } var btn = com.linkButton(titulo, function(){ var subContent = new VerticalLayout(); subContent.setId('teste'); subContent.setMargin(true); var linha = item; var textArea = com.textArea(null, item.getItemProperty('OBSERVACOES').getValue()); var instGravar = function run() { var sqlAtualiza = 'UPDATE controle_despesas_combustiveis SET observacoes = ? ' + ' WHERE CHAVE_DESPESA_COMBUSTIVEL = ? '; var params = new java.util.ArrayList(); params.add(textArea.getValue()); params.add(linha.getItemProperty('CHAVE_DESPESA_COMBUSTIVEL').getValue().longValue()); vQueryService.executePSUpdateQuery('vitruvio', sqlAtualiza, params.toArray()); engine.getField('tbCombustivel').refresh(); engine.getField('tbTotalCombustivel').refresh(); engine.getGlobalVariable('fncSubTotalCombustivel')(); window.close(); }; var gravar = com.button('Gravar',instGravar,null); subContent.addComponent(textArea); subContent.addComponent(gravar); var window = com.openWindow(item.getItemProperty('CLIENTE').getValue(), subContent,500,200); textArea.setSizeFull(); textArea.addStyleName(com.theme().TEXTAREA_BORDERLESS); window.setModal(true); }); btn.setDescription(item.getItemProperty('OBSERVACOES').getValue()); var container = com.horizontalLayout([btn]); container.setSpacing(false); return container; } } var script = new Generator(); DESCRICAO