<?xml version="1.0" encoding="UTF-8"?>
<panel-form xmlns="http://www.davinti.com.br/vitruvio/form/mobile/panel" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://www.davinti.com.br/vitruvio/form/mobile/panel vitruvio-mobile-panel-form.xsd">

	<form formKey="mobile2">
		<name>Geral X Dia</name>

		<initScript language="JavaScript">
			<![CDATA[
				function run() {
					engine.getWidgetController('btnFilter').getButton().setIcon("FILTRAR");
					engine.getWidgetController('btnApply').getButton().setIcon("APLICAR");
					var hoje = moment().format();
					var primeiro = moment().startOf("month");
					engine.getField("f_data").setValue(primeiro);
					engine.getField("f_data2").setValue(hoje); 
				}			
			]]>
		</initScript>

		<components>
			<VerticalLayout>

				<ButtonWidget id="btnFilter" caption="">
					<onClickScript language="JavaScript">
						<![CDATA[
							function run() {
								engine.getWidgetController('btnFilter').getButton().setVisible(false);
								engine.getField("f_data").setVisible(true);
								engine.getField("f_data2").setVisible(true);
								engine.getWidgetController('btnApply').getButton().setVisible(true);
							}
						]]>
					</onClickScript>
				</ButtonWidget>

				<DateField id="f_data" caption="Data início" type="date" visible="false" required="false" format="dd/MM/yyyy" resolution="DAY"/>
				<DateField id="f_data2" caption="Data final" type="date" visible="false" required="false" format="dd/MM/yyyy" resolution="DAY"/>
				
				<ButtonWidget id="btnApply" visible="false" caption=" Aplicar">
					<onClickScript language="JavaScript">
						<![CDATA[
							function run() {

								engine.getWidgetController('btnApply').getButton().setVisible(false);
								engine.getField("f_data").setVisible(false);
								engine.getField("f_data2").setVisible(false);
								
								engine.getWidgetController('btnFilter').getButton().setVisible(true);								

								var data = moment(engine.getField('f_data').getValue()).valueOf();
								var data2 = moment(engine.getField('f_data2').getValue()).valueOf();
                        
								engine.getDesktopPanel("listaGraficoSemana").addFieldId("dataInicio", data);
								engine.getDesktopPanel("listaGraficoSemana").addFieldId("dataFinal", data2);
								engine.getDesktopPanel("listaGraficoSemana").reload();
							}
						]]>
					</onClickScript>
				</ButtonWidget>
				<DesktopPanel  height="400px" id="listaGraficoSemana" panelKey="geraldia" layoutId="pnlGeral" forceFieldsRender="dataInicio, dataFinal"/>
			</VerticalLayout>
		</components>
	</form>
	
</panel-form>
