2261 - Aplicar filtros nos indicadores
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
<initScript language="JavaScript">
|
||||
<![CDATA[
|
||||
importClass(Packages.br.com.davinti.base.vaadin.components.icons.IconFactory);
|
||||
importClass(Packages.br.com.davinti.base.vaadin.components.resources.icons16x16.IconLibraryAPISmall);
|
||||
importClass(Packages.java.util.Calendar);
|
||||
importClass(Packages.br.com.davinti.base.vaadin.components.resources.icons16x16.IconLibraryAPISmall);
|
||||
importClass(Packages.java.util.Calendar);
|
||||
|
||||
function fncLimpaCampos(){
|
||||
|
||||
@@ -27,9 +27,17 @@
|
||||
if (!engine.getField('dataInicio').getValue()) {
|
||||
engine.getField('dataInicio').setValue(data);
|
||||
engine.getField('dataFinal').setValue(d);
|
||||
if (!engine.getField('ftFrotaTerceiro').getValue()) {
|
||||
engine.getField('ftFrotaTerceiro').setValue('A');
|
||||
}
|
||||
if (!engine.getField('ftCaminhaoCarreta').getValue()) {
|
||||
engine.getField('ftCaminhaoCarreta').setValue('A');
|
||||
}
|
||||
}
|
||||
engine.getField('tbLancamentos').refresh();
|
||||
} else {
|
||||
engine.getField('ftFrotaTerceiro').setValue('A');
|
||||
engine.getField('ftCaminhaoCarreta').setValue('A');
|
||||
engine.getField('dataInicio').setValue(data);
|
||||
engine.getField('dataFinal').setValue(d);
|
||||
engine.getField('tbLancamentos').refresh();
|
||||
@@ -47,7 +55,8 @@
|
||||
<Panel width="100%" expandRatio="0.1" align="TOP_LEFT" height="100%">
|
||||
<VerticalLayout width="100%" margin="true" spacing="true">
|
||||
<HorizontalLayout width="100%" spacing="true" height="100%">
|
||||
<ImageWidget id="img1" height="75" align="TOP_LEFT">
|
||||
<HorizontalLayout width="100%" expandRatio="0.35" align="TOP_LEFT">
|
||||
<ImageWidget id="img1" height="75" align="TOP_LEFT">
|
||||
<image>
|
||||
<base64 extension="jpg">
|
||||
<![CDATA[
|
||||
@@ -56,60 +65,112 @@
|
||||
</base64>
|
||||
</image>
|
||||
</ImageWidget>
|
||||
<HorizontalLayout width="600" spacing="true" align="BOTTOM_RIGHT" >
|
||||
<DateField type="date" id="dataInicio" caption="Data inicial" width="100%" expandRatio="0.25" description="Data inicial da exibição" format="dd/MM/yyyy" />
|
||||
<DateField type="date" id="dataFinal" caption="Data final" width="100%" expandRatio="0.25" description="Data final da exibição" format="dd/MM/yyyy" />
|
||||
<DBComboBox type="string" id="placa" width="100%" expandRatio="0.3" align="TOP_LEFT" allowNullSelection="true" caption="Placa">
|
||||
<datasource>
|
||||
<freeQuery connection-key="vitruvio">
|
||||
<![CDATA[
|
||||
Select * from veiculo
|
||||
]]>
|
||||
</freeQuery>
|
||||
</datasource>
|
||||
<key-field>CODIGO</key-field>
|
||||
<caption-field>PLACA</caption-field>
|
||||
</DBComboBox>
|
||||
<ButtonWidget id="btnFiltrar" caption="Filtrar" description="Aplica filtro de data" width="100%" expandRatio="0.2">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[
|
||||
function run() {
|
||||
engine.getField('tbLancamentos').refresh();
|
||||
}
|
||||
]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
</HorizontalLayout>
|
||||
<HorizontalLayout width="100%" spacing="true" align="BOTTOM_RIGHT" expandRatio="1" >
|
||||
<VerticalLayout width="100%" spacing="true" expandRatio="0.8" align="TOP_LEFT">
|
||||
<HorizontalLayout width="100%" spacing="true" >
|
||||
<DateField type="date" id="dataInicio" caption="Data inicial" width="100%" expandRatio="0.30" align="TOP_RIGHT" description="Data inicial da exibição" format="dd/MM/yyyy" />
|
||||
<DateField type="date" id="dataFinal" caption="Data final" width="100%" expandRatio="0.30" align="TOP_RIGHT" description="Data final da exibição" format="dd/MM/yyyy" />
|
||||
<DBComboBox type="string" id="placa" width="100%" expandRatio="0.3" align="TOP_RIGHT" allowNullSelection="true" caption="Placa">
|
||||
<datasource>
|
||||
<freeQuery connection-key="vitruvio">
|
||||
<![CDATA[
|
||||
Select * from veiculo
|
||||
]]>
|
||||
</freeQuery>
|
||||
</datasource>
|
||||
<key-field>CODIGO</key-field>
|
||||
<caption-field>PLACA</caption-field>
|
||||
</DBComboBox>
|
||||
</HorizontalLayout>
|
||||
<OptionGroup type="string" id="ftFrotaTerceiro" disposition="horizontal" width="100%" expandRatio="0.3" align="MIDDLE_CENTER">
|
||||
<entry value="Ambos" key="A"/>
|
||||
<entry value="Frota" key="F"/>
|
||||
<entry value="Terceiro" key="T"/>
|
||||
</OptionGroup>
|
||||
|
||||
<OptionGroup type="string" id="ftCaminhaoCarreta" disposition="horizontal" width="100%" expandRatio="0.3" align="MIDDLE_CENTER">
|
||||
<entry value="Todos" key="A"/>
|
||||
<entry value="Caminhão" key="C"/>
|
||||
<entry value="Carreta" key="T"/>
|
||||
<entry value="Outros" key="O"/>
|
||||
</OptionGroup>
|
||||
|
||||
</VerticalLayout>
|
||||
<DBTwinColSelect type="number" id="ftClientes" multivalue="true" allowNullSelection="true" align="TOP_RIGHT" caption="Clientes" rows="5" width="100%" expandRatio="1">
|
||||
<datasource>
|
||||
<freeQuery connection-key="vitruvio">
|
||||
<![CDATA[
|
||||
Select codigo, nome from clientes order by nome
|
||||
]]>
|
||||
</freeQuery>
|
||||
</datasource>
|
||||
<key-field>CODIGO</key-field>
|
||||
<caption-field>NOME</caption-field>
|
||||
<events>
|
||||
<valueChange>
|
||||
<script language="JavaScript">
|
||||
<![CDATA[
|
||||
function run() {
|
||||
engine.getField('clientes').setValue(engine.getField('ftClientes').getValue());
|
||||
}
|
||||
]]>
|
||||
</script>
|
||||
</valueChange>
|
||||
</events>
|
||||
</DBTwinColSelect>
|
||||
<TextField type="number" id="clientes" visible="false" caption="clientes" multivalue="true" />
|
||||
<ButtonWidget id="btnFiltrar" caption="Filtrar" description="Aplica filtro de data" width="100%" expandRatio="0.25">
|
||||
<onClickScript language="JavaScript">
|
||||
<![CDATA[
|
||||
function run() {
|
||||
engine.getField('tbLancamentos').refresh();
|
||||
}
|
||||
]]>
|
||||
</onClickScript>
|
||||
</ButtonWidget>
|
||||
</HorizontalLayout>
|
||||
</HorizontalLayout>
|
||||
</VerticalLayout>
|
||||
</Panel>
|
||||
<Panel width="100%" margin="true" id="pnlGeral" >
|
||||
<VerticalLayout width="100%" spacing="true" align="TOP_LEFT" >
|
||||
<DBTable id="tbLancamentos" type="number" showRowCount="true" width="100%" rows="14" selectable="false" exportXLS="false" editable="false" >
|
||||
<DBTable id="tbLancamentos" type="number" showRowCount="true" width="100%" rows="14" selectable="false" exportXLS="true" editable="false" useGridComponent="true">
|
||||
<datasource>
|
||||
<sqlBuilderDataSource connection-key="vitruvio" language="JavaScript">
|
||||
<![CDATA[
|
||||
function buildSQL(params) {
|
||||
if(engine) {
|
||||
|
||||
var sql = "";
|
||||
if (engine.getField('dataInicio').getValue() && engine.getField('dataFinal').getValue()) {
|
||||
var c = java.util.Calendar.getInstance();
|
||||
var formatter = new java.text.SimpleDateFormat("dd/MM/yyyy");
|
||||
c.setTime(engine.getField('dataInicio').getValue());
|
||||
var data = c.getTime();
|
||||
var dataInicio = formatter.format(data);
|
||||
var f = java.util.Calendar.getInstance();
|
||||
f.setTime(engine.getField('dataFinal').getValue());
|
||||
data = f.getTime();
|
||||
var dataFinal = formatter.format(data);
|
||||
if (engine.getField('placa').getValue()) {
|
||||
sql = "select fnc_geralplaca_pivot(to_date('"+dataInicio+"','dd/MM/yyyy'),to_date('"+dataFinal+"','dd/MM/yyyy')," + engine.getField('placa').getValue() + ") as sql_return ";
|
||||
} else {
|
||||
sql = "select fnc_geralplaca_pivot(to_date('"+dataInicio+"','dd/MM/yyyy'),to_date('"+dataFinal+"','dd/MM/yyyy'),null) as sql_return ";
|
||||
}
|
||||
println(sql);
|
||||
var ds = vQueryService.executeQuery('vitruvio', sql);
|
||||
var sql = "";
|
||||
if (engine.getField('dataInicio').getValue() && engine.getField('dataFinal').getValue()) {
|
||||
var c = java.util.Calendar.getInstance();
|
||||
var formatter = new java.text.SimpleDateFormat("dd/MM/yyyy");
|
||||
c.setTime(engine.getField('dataInicio').getValue());
|
||||
var data = c.getTime();
|
||||
var dataInicio = formatter.format(data);
|
||||
var f = java.util.Calendar.getInstance();
|
||||
f.setTime(engine.getField('dataFinal').getValue());
|
||||
data = f.getTime();
|
||||
var dataFinal = formatter.format(data);
|
||||
var clientes = null;
|
||||
var cli = new java.util.ArrayList();
|
||||
if (engine.getField('clientes').getValue()) {
|
||||
clientes = engine.getField('clientes').getValue();
|
||||
|
||||
} else {
|
||||
clientes = '[null]';
|
||||
}
|
||||
|
||||
var frotaTerceiro = engine.getField('ftFrotaTerceiro').getValue();
|
||||
var caminhaoCarreta = engine.getField('ftCaminhaoCarreta').getValue();
|
||||
var placa = null;
|
||||
if (engine.getField('placa').getValue()) {
|
||||
placa = Number(engine.getField('placa').getValue());
|
||||
}
|
||||
sql = "select fnc_geralplaca_pivot2(to_date('"+dataInicio+"','dd/MM/yyyy'),to_date('"+dataFinal+"','dd/MM/yyyy')," + placa + ",'" + clientes + "','" + frotaTerceiro + "','" + caminhaoCarreta + "') as sql_return ";
|
||||
|
||||
var ds = vQueryService.executeQuery('vitruvio', sql);
|
||||
ds.next();
|
||||
return ds.getString('sql_return');
|
||||
} else {
|
||||
@@ -125,32 +186,19 @@
|
||||
</datasource>
|
||||
<key-field>CHAVE</key-field>
|
||||
<columns>
|
||||
<generated name="VEICULO" caption="Placa" align="CENTER">
|
||||
<scriptColumnGenerator language="JavaScript">
|
||||
<![CDATA[
|
||||
function Generator() {
|
||||
this.generate = function(itemId, columnId, item, container) {
|
||||
if (item.getItemProperty('CHAVE').getValue() != 0) {
|
||||
return item.getItemProperty('PLACA').getValue()
|
||||
} else {
|
||||
return 'TOTAL';
|
||||
}
|
||||
}
|
||||
}
|
||||
var script = new Generator();
|
||||
]]>
|
||||
</scriptColumnGenerator>
|
||||
</generated>
|
||||
<column name="VALOR_FRETE" caption="Valor do Frete" align="CENTER" format="#,##0.00" decimalSeparator="," groupingSeparator="."/>
|
||||
<column name="PLACA" caption="PLACA" align="CENTER"/>
|
||||
<column name="QTD_FRETES" caption="QTD FRETES" align="CENTER"/>
|
||||
<column name="VALOR_FRETE" caption="VALOR DO FRETE (Líquido)" align="CENTER" format="#,##0.00" decimalSeparator="," groupingSeparator="."/>
|
||||
<dynamicColumn matchColumnTag="C_" matchColumnBy="STARTS_WITH" align="CENTER" />
|
||||
<column name="LIQUIDO" caption="Lucro (Frete - Despesas)" align="CENTER" />
|
||||
<column name="VALOR_COMBUSTIVEL" caption="COMBUSTÍVEL" align="CENTER" format="#,##0.00" decimalSeparator="," groupingSeparator="."/>
|
||||
<column name="LIQUIDO" caption="LUCRO (Frete - Despesas)" align="CENTER" />
|
||||
</columns>
|
||||
<styleGenerator>
|
||||
<scriptGenerator language="JavaScript">
|
||||
<![CDATA[
|
||||
function getStyle(itemId, columnId, item) {
|
||||
if(item) {
|
||||
if (item.getItemProperty('CHAVE').getValue() == '0') {
|
||||
if (item.getItemProperty('CHAVE').getValue() == '-999999999999') {
|
||||
var coluna = columnId;
|
||||
if (columnId.substring(0,2) == 'C_') {
|
||||
var coluna = 'DINAMICA';
|
||||
@@ -162,12 +210,14 @@
|
||||
return 'background-light-green';
|
||||
case 'DINAMICA' :
|
||||
return 'background-light-red';
|
||||
case 'VALOR_COMBUSTIVEL' :
|
||||
return 'background-light-red';
|
||||
case 'LIQUIDO' :
|
||||
return 'background-light-blue';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</scriptGenerator>
|
||||
</styleGenerator>
|
||||
|
||||
Reference in New Issue
Block a user