<?php 
	require "_header.php";
	require "data/combo_semester.php";
?>
<div id="main-content">
<script type="text/javascript">
function validate(path)
{
	path=path.replace(/\\/g,'/');
	var vexp=/^[a-zA-Z]:\/[a-zA-Z0-9][^\/]+/;
	if(vexp.test(path))
		return(true);
	else
		return(false);
}
var labelArray;
labelArray = [
	['Branch :<span class="comp">*</span>'],
	['Semester :<span class="comp">*</span>'],
	['Dir Path :<span class="comp">*</span>'],
	['Result Type :<span class="comp">*</span>']
	];


var branchstore = new Ext.data.ArrayStore({		
	fields: ['branch_id','branch_name'],
	data:Ext.semester.branch
});

var semesterstore = new Ext.data.ArrayStore({		
	fields: ['semester_id','semester_name'],
	data:Ext.semester.semester
});


var branch = new Ext.form.ComboBox({
	name:'branch_name',
	id:'branch_name',
	hiddenName:'branch_hidden',
	labelSeparator:'',	
	fieldLabel :labelArray[0] ,
	displayField:'branch_name',
	width:198,
	valueField: 'branch_id',
	editable:true,
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:branchstore,
    listeners:{'select': function(cmb, rec, idx){
		
	}}
});


var semester = new Ext.form.ComboBox({
	name:'semester_name',
	id:'semester_name',
	hiddenName:'semester_hidden',
	labelSeparator:'',	
	fieldLabel:labelArray[1],
	width:198,
	displayField:'semester_name',
	valueField:'semester_id',
	editable:true,
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:semesterstore,
    listeners:{'select': function(cmb, rec, idx){
	
		if(Ext.getCmp('branch_name').getValue()=="")
		{
			alert('Select Branch First');
			this.reset();
			
		}
	}}
});


var resulttypestore = new Ext.data.ArrayStore({		
	fields: ['resulttype'],
	data:[['General'],['Retest']]
});
var resulttype = new Ext.form.ComboBox({
	name:'resulttype',
	id:'resulttype',
	hiddenName:'resulttype',
	labelSeparator:'',	
	fieldLabel :labelArray[3] ,
	displayField:'resulttype',
	width:198,
	valueField: 'resulttype',
	editable:true,
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:resulttypestore,
    listeners:{'select': function(cmb, rec, idx){
		
	}}
});

var uploadfile = new Ext.form.TextField({
		fieldLabel: labelArray[2],
		labelSeparator: '',
		name: 'uploadfile',
		id:'uploadfile',
		width:200,
		emptyText:'K:/temp',
		allowBlank: false
	});
	
	
Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var uploadgturesultForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'save-upload-gturesultpdf.php',
		frame:true,
		autoHeight:true,
		standardSubmit:false,
        title: '',
		fileUpload: false,
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[branch,semester,resulttype,uploadfile]
		
    });
	 
	var uploadgtuWindow = new Ext.Window({
        title: 'Upload GTU Result PDFs',
       	width: 330,
		modal:true,
        layout: 'fit',
		border: false,
		autoHeight:true,
		closeAction:'close',
		collapsible:'true',
		items: uploadgturesultForm,
		buttonAlign: 'center',
	    buttons: [	
			{
			text:'Upload',iconCls: 'new-tab',
			handler: function(b, e){
					
			if(validate(Ext.getCmp('uploadfile').getValue()))
			{
				uploadgturesultForm.getForm().submit({
										waitMsg: 'Saving...',
										success: function (resp) { 
										
										Ext.MessageBox.show({
												title: 'Message',
												msg: 'Files has been uploaded!',
												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
											});									
										}
										
										});	
			}
			else
				{
					Ext.MessageBox.show({
										title: 'Message',
										msg: 'Directory Path is not Valid!',
										buttons: Ext.MessageBox.OK,
										icon:Ext.MessageBox.INFO
									});
				}}
		},{
			text: 'Reset', iconCls: 'icon-reset',
			handler: function () {   
				uploadgturesultForm.getForm().reset();
				Ext.getCmp('branch_name').focus(true,500);
			}
		},{
			text: 'Close',iconCls: 'icon-close',
			handler: function () {    
				uploadgtuWindow.close();
			}
      	}]
 	});
	
	
	var varWidth = (screen.width - uploadgtuWindow.width)/2;
	uploadgtuWindow.setPosition(varWidth,((screen.height/4)-85));
	uploadgtuWindow.show();
	
	
	Ext.getCmp('branch_name').focus(true,1000);

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