<?php 
	require "_header.php";
		//require "data/combo_report.php";

?>
<style>
.excel_help{
}
.excel_help li{
font-size:13px;
color:#009;
padding-top:5px;
margin-top:5px;
margin-bottom:10px;
}
.upload{
text-align:center;
background-color: #09F;
border: 0 none;
border-radius: 10px;
color: #ffffff;
cursor: pointer;
display: block;
font-family: Arial,Helvetica Neue,Helvetica,sans-serif;
font-size: 16px;
height: auto;
margin: 0 auto;
outline: medium none;
padding: 8px;
position: relative;
text-align: center;
text-decoration: none;
text-transform: capitalize !important;

}
</style>
<script language="javascript" type="text/javascript">
Ext.onReady(function(){
	Ext.QuickTips.init();
	
	 Ext.apply(Ext.form.VTypes, {
             fileUpload: function(val, field) {                              
                                 var fileName = /^.*\.(xls|xlsx|XLS|XLSX)$/i;
								return fileName.test(val);
                           },                 
             fileUploadText: 'File must be in .xls,.xlsx format'
  });

    

    
	
	var newPic = new Ext.form.FileUploadField({
	fieldLabel: 'File <span class="comp"></span>',
	name: 'enrollment_upload',					
	id:'enrollment_upload',
	allowBlank: true,
	vtype:'fileUpload',
	buttonText: 'Select Excel File',
	tabIndex:3,
	width:175,
	listeners:{
		fileselected:stdUploadFileSelected
	}
});
 
	
	var Recordentry = new Ext.FormPanel({
		id: 'Recordentry',
    	url:'save_upload_invoice_master.php',
		method:'post',
		fileUpload: true,
		//standardSubmit:true,
        frame:true,
		autoHeight:true,
		layout: 'form',
        items: [

			newPic,{
				xtype:'box',										       
				autoEl:{ 
					tag:'div',
					html:'<br/><div class="excel_help"><ul><li>Select Only Excel File </li><li>Donwload data format file te check sample of excel file</li><li>Remove header row from Excel file</li><li>Date Format Must Be YYYY-MM-DD Format</li></ul><a class="upload" href="invoice_data.xls"> Data Format File </a></div>'
				}
			}]
	});
	
	function stdUploadFileSelected(fileBrowser,fileName){
		var ext=fileName.split('.').pop();
		if(ext!='xls' && ext!='xlsx' && ext!='XLS' && ext!='XLSX')
		{ 
		 	Ext.MessageBox.show({
			   title: 'Error',
			   msg: 'Only Excle File Allowed',
			   buttons: Ext.MessageBox.OK,
			   icon:Ext.MessageBox.ERROR
			  });
		    Ext.getCmp('enrollment_upload').reset();
		
		}else
		{
		
			
			
		}
		
	}
	
    var RecordWindow = new Ext.Window({
		title: 'Upload Invoice  Data',
		width:400,		
		autoHeight:true,
		modal:true,
		shadow:false,
		border: false,
		closeAction:'close',
		collapsible:true,
		items: Recordentry,
		buttonAlign: 'center',
					buttons:[
					{
      		text: 'Upload',
			iconCls:'icon-save',
			tabIndex:60,
			handler: function(){				
			Recordentry.getForm().submit({
						waitMsg: 'Saving...',
						timeout: 1200000, // 10min
						success: function (fp, o) {	
							Recordentry.getForm().reset();
							Ext.getCmp('enrollment_upload').focus(true,500);
							Ext.MessageBox.show({
							   title: 'Info',
							   msg: o.result.msg,
							   buttons: Ext.MessageBox.OK,
							   icon:Ext.MessageBox.INFO
							  });
													  
						},
						failure: function () {
							Ext.MessageBox.show({
								title: 'Error',
								msg: 'Please fill up complete form.',
								buttons: Ext.MessageBox.OK,
								icon:Ext.MessageBox.ERROR
							});									
						}
					});
							
			
			}
      	},{
		  	text: 'Reset',
			iconCls:'icon-reset',
			tabIndex:62,
			handler: function(){
				RecordStore.load();
				Recordentry.getForm().reset();
				Ext.getCmp('enrollment_upload').focus(true,500);
			}	
        },
		{
        	text: 'Close',
			iconCls:'icon-close',
			tabIndex:63,
			handler: function () {
				RecordWindow.close();	
			}
        }]
		
	});
	
	var varWidth =  (screen.width - RecordWindow.width)/2;
	RecordWindow.setPosition(varWidth,((screen.height/4)-100));
	RecordWindow.show();
	Ext.getCmp('enrollment_upload').focus(true,500);
});
</script>
<?php require "_footer.php";?>