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


var customersore = new Ext.data.Store({
		url: 'data/getcustomername.php',          
		reader: new Ext.data.JsonReader({			
			fields: ['customer_id','customer_orgname'],
			root: 'rows'
		}),autoLoad:true
	});

var labelArray;
	
	labelArray = [
			 	['Customer Name :<span class="comp">*</span>'],
				['Date :<span class="comp"></span>']
		];
	Ext.QuickTips.init();
	
	
var startdate = new Ext.form.DateField({
    id: 'startdate',
	labelSeparator:'',	
	fieldLabel :labelArray[1] ,
	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() {
	
	 var customerSupportReport_form = new Ext.FormPanel({
        labelWidth: 105, // label settings here cascade unless overridden
        url:'report-from-customer-order-result.php',
		method:'post',
        frame:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 0px 0',
        defaultType: 'textfield',
        items :[{
				xtype: 'combo',
			   	name: 'customer_id',
			   	id:'customer_id',
				hiddenName: 'customer_idhedden',
				tabIndex:3,
				labelSeparator:'',	
				fieldLabel :labelArray[0] ,
				displayField:'customer_orgname',
				tabIndex:3,
				valueField: 'customer_id',
				width: 195,
				blankText: '',
				emptyText:'',
				allowBlank:false,
				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]
									   }]
		             },{
				xtype: 'textfield',
			   	name: 'cust_name',
			   	id:'cust_name',
				hidden:true
			}]	
    });
	


var customerSupportReportwin = new Ext.Window({
		title: 'Customer Order Report',
		width:350,		
		height:140,
		modal:true,
		scrollable:true,
		shadow: false,
		border: false,
		layout: 'fit',
		closeAction:'close',
		collapsible:true,
		items: customerSupportReport_form,
		buttonAlign: 'center',
	    buttons: [{
         			 text:'View Report',
					 iconCls:'icon-view',
							handler: function()
							{ 
							   var startdate=customerSupportReport_form.getForm().findField('startdate').getValue().format('d/m/Y');
							var enddate=customerSupportReport_form.getForm().findField('enddate').getValue().format('d/m/Y');
							var customer_idhedden=customerSupportReport_form.getForm().findField('customer_idhedden').getValue();
							
							
							  var redirect = 'report-from-customer-order-result.php?startdate='+startdate + '&enddate='+enddate + '&customer_idhedden='+customer_idhedden; 
							  window.location = redirect;	
							}
          },{
           					 text: 'Reset', 
							 iconCls:'icon-reset',
							handler: function () {   
			                customerSupportReport_form.getForm().reset();
							Ext.getCmp('customer_id').focus(true,500);
		                    }
        },{
            text: 'Close',
			iconCls:'icon-close',
			handler: function () {
									   customerSupportReportwin.close();

			}
        }
	 ]

	});
	
	var varWidth =  (screen.width - customerSupportReportwin.width)/2;
	customerSupportReportwin.setPosition(varWidth,((screen.height/4)-110));
	customerSupportReportwin.show();
	Ext.getCmp('customer_id').focus(true,500);
});

</script>
<!-- end custom CSS/JS -->
<div id="main-content" align="center"></div>
<?php require "_footer.php";?>