<?php 
	require "_header.php";
	
?>
<script type="text/javascript">


var districtsore = new Ext.data.Store({
			url: 'data/getdistrictcode.php',          
	        reader: new Ext.data.JsonReader({			
                fields: ['dist_id','dist_nameeng'],
                root: 'rows'
            }),autoLoad:true
});
var customersore = new Ext.data.Store({
		url: 'data/getcustomername.php',          
		reader: new Ext.data.JsonReader({			
			fields: ['customer_id','customer_orgname','district_id'],
			root: 'rows'
		}),autoLoad:true
	});
	
var startdate = new Ext.form.DateField({
    id: 'startdate',
	labelSeparator:'',	
	fieldLabel :'Date :<span class="comp"></span>' ,
	name: 'startdate',
	emptyText :'From',
	allowBlank:true,
	vtype: 'daterange',
	endDateField:'enddate'
});	


var enddate = new Ext.form.DateField({
    id: 'enddate',
	fieldLabel: '',
	name: 'enddate',
	emptyText :'To',
	allowBlank:true,
	vtype: 'daterange',
	startDateField: 'startdate' 
});	
	
	
Ext.onReady(function(){
    Ext.QuickTips.init();
    
  
 	
    var customerbill_summary = new Ext.FormPanel({
        labelWidth: 70, // label settings here cascade unless overridden
        url:'report-customer-duepayment-result.php',
		method:'post',
        frame:true,
		standardSubmit:true,
        autoHeight: true,
		layout:'form',
        items :[{
					   xtype: 'combo',
					   name: 'district_id',
					   id:'district_id',
					   hiddenName: 'hiddendist_code',
					   tabIndex:2,
					   labelSeparator:'',	
					   fieldLabel :'District :<span class="comp">*</span>',
					   displayField:'dist_nameeng',
					   valueField: 'dist_id',
					   width: 200,
					   blankText: '',
					   emptyText:'',
					   value:'All',
					   allowBlank:false,
					   triggerAction:'all',
					   mode:'local',			
					   selectOnFocus: true,	
					   store: districtsore,
					   forceSelection:true,
					   editable:true,
					   listeners:{select:{fn:function(combo, value) 
			   			{
							customersore.load({params:{
									district_id :combo.getValue()
									}});
						}}}
					},{
						xtype: 'combo',
						name: 'customer_id',
						id:'customer_id',
						hiddenName: 'customer_idhedden',
						tabIndex:3,
						labelSeparator:'',	
						fieldLabel :'Customer:<span class="comp"></span>',
						displayField:'customer_orgname',
						tabIndex:3,
						valueField: 'customer_id',
						width: 200,
						blankText: '',
						emptyText:'',
						allowBlank:true,
						triggerAction:'all',
						mode:'local',			
						selectOnFocus: true,	
						store: customersore,
						forceSelection:true,
						editable:true,
						/*listeners:{select:{fn:function(combo, value) 
						{
							Ext.getCmp('cust_name').setValue(combo.getRawValue());
						
							
						}}}*/
					},{
						xtype       : 'container',
						autoEl      : {},
						border      : false,
						layout      : 'column',
						anchor      : '100%',
						defaultType : 'field',
						items       : [{
										xtype  : 'container',
										autoEl : {},
										layout : 'form',
										columnWidth : .65,
										items  : [startdate]
									   },
									   {
										xtype       : 'container',
										autoEl      : {},
										layout      : 'form',
										columnWidth : .35,
										labelWidth  : 1,
										items       : [enddate]
									   }]
		             }]		
    });
	
	 var customerbillWindow = new Ext.Window({
        title: 'Customer Due Payment Report',
        autoHeight: true,
        width: 340,
		border: false,
		modal:true,
        layout: 'fit',
		closeAction:'close',
   	 	collapsible:'true',
		items: customerbill_summary,
		buttonAlign: 'center',
	    buttons: [{
							text:'View Report',
							iconCls:'icon-view',
							handler: function()
							{ 
							  var startdate=customerbill_summary.getForm().findField('startdate').getValue().format('d/m/Y');
							var enddate=customerbill_summary.getForm().findField('enddate').getValue().format('d/m/Y');
							var hiddendist_code=customerbill_summary.getForm().findField('hiddendist_code').getValue();
							var customer_idhedden=customerbill_summary.getForm().findField('customer_idhedden').getValue();
							
							  var redirect = 'report-customer-duepayment-result.php?startdate='+startdate + '&enddate='+enddate + '&hiddendist_code='+hiddendist_code + '&customer_idhedden='+customer_idhedden; 
							  window.location = redirect;	
							}
				  },
				  {
							text: 'Reset', 
							iconCls:'icon-reset',
							handler: function () {   
			                customerbill_summary.getForm().reset();
							
							Ext.getCmp('district_id').setValue('All');
							Ext.getCmp('district_id').focus(true,500);
		                    }
			      },
				  {
		   		           text: 'Close',
						   iconCls:'icon-close',
					       handler: function () {    
						   
						   customerbillWindow.close();
				           }
                  }
				 ]
    });



var varWidth =  (screen.width - customerbillWindow.width)/2;
customerbillWindow.setPosition(varWidth,((screen.height/4)-110));
customerbillWindow.show();

});
</script>
<div id="main-content" align="center"></div>
<?php require "_footer.php";?>