<?php 
	require "_header.php";
	
?>
<script type="text/javascript">
var productstore = new Ext.data.Store({
		url: 'data/get-product-data.php',          
		reader: new Ext.data.JsonReader({			
			fields: ['product_id','product_name'],
			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-productwise-duepayment-result.php',
		method:'post',
        frame:true,
		standardSubmit:true,
        autoHeight: true,
		layout:'form',
        items :[{
					   xtype: 'combo',
					   name: 'product_id',
					   id:'product_id',
					   hiddenName: 'hiddenproduct_id',
					   tabIndex:2,
					   labelSeparator:'',	
					   fieldLabel :'Product :',
					   displayField:'product_name',
					   valueField: 'product_id',
					   width: 200,
					   blankText: '',
					   emptyText:'',
					   //value:'All',
					   allowBlank:true,
					   triggerAction:'all',
					   mode:'local',			
					   selectOnFocus: true,	
					   store: productstore,
					   forceSelection:true,
					   editable:true
					},{
						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 enddate=customerbill_summary.getForm().findField('enddate').getValue().format('d/m/Y');
							var startdate=customerbill_summary.getForm().findField('startdate').getValue().format('d/m/Y');
							
							var hiddenproduct_id=customerbill_summary.getForm().findField('hiddenproduct_id').getValue();
							
							  var redirect = 'report-productwise-duepayment-result.php?enddate='+enddate + '&startdate='+startdate + '&hiddenproduct_id='+hiddenproduct_id; 
							  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";?>