var <?php echo $filterName;?> = new Ext.form.FormPanel({
	bodyStyle: 'padding: 20px',
	border: false,
	defaults: {anchor: '100%'},
	layout:'form',
	items:[{
		xtype: 'datefield',
		editable: false,
		format: 'd.m.Y',
		name: 'dateFrom',
		id: 'dateFrom',
		fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "date_from_title","Datum od");?>'
	},{
		xtype: 'datefield',
		format: 'd.m.Y',
		name: 'dateTo',
		id: 'dateTo',
		editable: false,
		fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "date_to_title","Datum do");?>'
	},{
		xtype:'textfield',
		name:'newValueSearch',
		id:'newValueSearch',
		fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "new_value_title","Nova vrednost");?>'
	},{
        xtype:'textfield',
        name:'postValueSearch',
        id:'postValueSearch',
        fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "post_value_title","POST vrednost");?>'
    },new Ext.form.ComboBox({
	    fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "user_title","Uporabnik");?>', 
	    mode: 'remote',
	    triggerAction: 'all',
	    width: 150,
	    hiddenName: 'UserId',
	    name: 'UserId',
	    id: 'UserId',
	    lazyRender: true,
	    store: new Ext.data.JsonStore({
            url : '<?php echo $ajax; ?>',
            autoLoad: true,
            root : 'rows',
            baseParams: {
                action: 'getUsers'
            },
            fields:[
                 { name:"id", type: 'int' },
                 { name:"username", type: 'string' }
            ]
        }),
	    valueField: 'id',
		displayField: 'username' 
	}),new Ext.form.ComboBox({
	    fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "changetype_title","Način spremembe");?>', 
	    mode: 'remote',
	    triggerAction: 'all',
	    width: 150,
	    hiddenName: 'ChangeType',
	    id: 'ChangeType',
	    lazyRender: true,
	    store: new Ext.data.JsonStore({
            url : '<?php echo $ajax; ?>',
            autoLoad: true,
            root : 'rows',
            baseParams: {
                action: 'getChangeType'
            },
            fields:[
                 { name:"id", type: 'int' },
                 { name:"text", type: 'string' }
            ]
        }),
	    valueField: 'id',
		displayField: 'text' 
	}),new Ext.form.ComboBox({
	    fieldLabel: '<?php echo $LangPack->GetLabel("CRM_logger_panel", "area_title","Območje");?>', 
	    mode: 'remote',
	    triggerAction: 'all',
	    width: 150,
	    hiddenName: 'area',
	    id: 'area',
	    lazyRender: true,
	    store: new Ext.data.JsonStore({
            url : '<?php echo $ajax; ?>',
            autoLoad: true,
            root : 'rows',
            baseParams: {
                action: 'getArea'
            },
            fields:[
                 { name:"id", type: 'int' },
                 { name:"text", type: 'string' }
            ]
        }),
	    valueField: 'id',
		displayField: 'text' 
	}),{
		xtype:'button',
		text: '<?php echo $LangPack->GetLabel("CRM_all", "CRM_filter_button","Filter");?>',
		handler: function(){
			var form = Ext.getCmp('<?php echo $filterName;?>').getForm().getFieldValues();
			
			if(form.dateFrom != "")
				var dateFrom = form.dateFrom.format('d.m.Y');
			else
				var dateFrom = "";
			if(form.dateTo != "")
				var dateTo = form.dateTo.format('d.m.Y');
			else
				var dateTo = "";
			var UserId = form.UserId;
			var ChangeType = Ext.getCmp('ChangeType').getRawValue();
			var area = Ext.getCmp('area').getRawValue();
			var newValueSearch = Ext.getCmp('newValueSearch').getValue();
			var postValueSearch = Ext.getCmp('postValueSearch').getValue();
			Ext.getCmp('<?php echo $gridName;?>').getEl().mask('<?php echo $LangPack->GetLabel("CRM_all", "loading_mask_text","Posodabljanje...");?>');
			Ext.getCmp('<?php echo $gridName;?>').getStore().reload({ params: {
				dateFrom: dateFrom,
				dateTo: dateTo,
				userId: UserId,
				area: area,
				newValueSearch: newValueSearch,
				postValueSearch: postValueSearch,
				ChangeType: ChangeType
			}, callback: function(resp, opt, success){
				if(success){
					Ext.getCmp('<?php echo $gridName;?>').getEl().unmask();
				}
			}})
		}
	}],
    id: '<?php echo $filterName;?>'
});
