<?php 
	require "_header.php";
	require "data/combo_semester.php";
?>
<div id="main-content"> 
<script type="text/javascript">
var labelArray;
labelArray = [
	['Branch:<span class="comp">*</span>'],
	['Semester:<span class="comp">*</span>'],
	['Exam:<span class="comp">*</span>'],
	['Subject:'],
	['Result:<span class="comp">*</span>']];

var resultstore = new Ext.data.ArrayStore({		
	fields: ['result'],
	data:[['Both(Pass-Fail)'],['Pass'],['Fail']]
});

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 divisionstore = new Ext.data.ArrayStore({
    	fields:['division_id','division_name'],
		data: Ext.semester.division
	});	
	
var subjectstore = new Ext.data.JsonStore({
	url:'data/get-subject.php',
    root: 'data',
	totalProperty: 'total',
	fields: ['subject_id','subject_name'] 
});

var examstore = new Ext.data.ArrayStore({		
	fields: ['exam_id','exam_name'],
	data:Ext.semester.exam
});


var teststore = new Ext.data.ArrayStore({		
	fields: ['test_val','test_disp'],
	data:[['firsttest','First Test'],['retest','Retest']]
});


var shortStore = new Ext.data.ArrayStore({		
	fields: ['short_type'],
	data:[['Both'],['Max Mark'],['Pass-Fail']]
});

var shorttype = new Ext.form.ComboBox({
	name: 'short_type',
	id:'short_type',
	labelSeparator:'',	
	fieldLabel :'Short Type:<span class="comp"></span>' ,
	displayField:'short_type',
	valueField: 'short_type',
	editable:true,
	triggerAction:'all',
	forceSelection:true,
	mode:'local',
	allowBlank:true,
	store: shortStore,
    listeners:{'select': function(cmb, rec, idx){
	}}
});


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

var result = new Ext.form.ComboBox({
	name:'result',
	id:'result',
	labelSeparator:'',	
	fieldLabel :labelArray[4] ,
	displayField:'result',
	valueField: 'result',
	editable:true,
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:resultstore,
	value:'Both(Pass-Fail)'
});

var semester = new Ext.form.ComboBox({
	name:'semester_name',
	id:'semester_name',
	hiddenName:'semester_hidden',
	labelSeparator:'',	
	fieldLabel:labelArray[1] ,
	displayField:'semester_name',
	valueField:'semester_id',
	editable:true,
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:semesterstore,
    listeners:{'select': function(cmb, rec, idx){
		Ext.getCmp('semester_disp').setValue(this.getRawValue());
		LoadData();
		Ext.getCmp('division_id').reset();
		var branch=Ext.getCmp('branch_name').getValue();
		divisionstore.filter('division_id',branch+cmb.getValue(),false,true,true);
		var cnt=divisionstore.getCount();
		if(cnt==1)
		{
			Ext.getCmp('division_id').setValue(divisionstore.getAt(0).data.division_name);
		}
	}}
});

var divisionCombo = {		
				xtype: 'combo',
				name: 'division_id',
				id:'division_id',
				labelSeparator:'',	
				fieldLabel :'Division :<span class="comp">*</span>' ,
				forceSelection:true,				
				displayField:'division_name',
				valueField: 'division_name'
				,lastQuery:''
				,allowBlank:false
				,triggerAction:'all'
				,mode:'local'
				,store:divisionstore
				,selectOnFocus: true,
				listeners: {'select': function(cmb, rec, idx) {
				}
}}

var subject = new Ext.form.ComboBox({
	name: 'subject_name',
	id:'subject_name',
	hiddenName:'subject_hidden',
	labelSeparator:'',	
	fieldLabel :labelArray[3] ,
	displayField:'subject_name',
	valueField: 'subject_id',
	editable:true,
	forceSelection:true,	
	triggerAction:'all',
	mode:'local',
	allowBlank:true,
	store: subjectstore,
    listeners:{'select': function(cmb, rec, idx){
		Ext.getCmp('subject_disp').setValue(this.getRawValue());
	}}
});

var exam = new Ext.form.ComboBox({
	name: 'exam_name',
	id:'exam_name',
	hiddenName:'exam_hidden',
	labelSeparator:'',	
	fieldLabel :labelArray[2] ,
	displayField:'exam_name',
	valueField: 'exam_id',
	editable:true,
	triggerAction:'all',
	forceSelection:true,
	mode:'local',
	allowBlank:false,
	store: examstore,
    listeners:{'select': function(cmb, rec, idx){
		Ext.getCmp('exam_disp').setValue(this.getRawValue());
	}}
});	

var test = new Ext.form.ComboBox({
	name: 'test_type',
	id:'test_type',
	hiddenName:'test_hidden',
	labelSeparator:'',	
	fieldLabel :'Test:<span class="comp">*</span>' ,
	displayField:'test_disp',
	valueField: 'test_val',
	editable:true,
	triggerAction:'all',
	forceSelection:true,
	mode:'local',
	//width: 100,
	tabIndex:'5',
	allowBlank:false,
	store: teststore,
    listeners:{'select': function(cmb, rec, idx){
	}}
});

var branch_disp = new Ext.form.TextField({
	name: 'branch_disp',
	id:'branch_disp',
	hidden:true
});

var semester_disp = new Ext.form.TextField({
	name: 'semester_disp',
	id:'semester_disp',
	hidden:true
});

var exam_disp = new Ext.form.TextField({
	name: 'exam_disp',
	id:'exam_disp',
	hidden:true
});

var subject_disp = new Ext.form.TextField({
	name: 'subject_disp',
	id:'subject_disp',
	hidden:true
});

function LoadData(){
	var branch_name = Ext.getCmp('branch_name').getValue();
	var semester_name = Ext.getCmp('semester_name').getValue();
	
	if(branch_name != '' && semester_name != ''){	
		Ext.getCmp('subject_name').reset();
		subjectstore.load({params:{
			branch_name:branch_name,
			semester_name:semester_name
		}});
	}}

Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var ExamPassForm = new Ext.FormPanel({
    	labelWidth: 95,
		autoHeight: true,
        url:'report-exampass-result.php',
		frame:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
        items :[branch,semester,divisionCombo,exam,test,
		result,subject,
		shorttype,
		{xtype:'checkbox',
		name: 'show_pass_marks',
		id:'show_pass_marks',
		labelSeparator:'',	
		checked:true,
		fieldLabel :'Show Pass Mark:'		
		},{xtype:'checkbox',
		name: 'show_retest_fees',
		id:'show_retest_fees',
		labelSeparator:'',	
		checked:true,
		fieldLabel :'Retest Fees:'		
		},{
		html:'<span style="color:red;">Retest Fees will only display if you have fees setup.</span><a href="addedit-GTUfeessetup.php">See</a>'
		},
		branch_disp,semester_disp,exam_disp,subject_disp]
    });
	 
	var ExamPassWindow = new Ext.Window({
        title: 'Exam Result Report',
        autoHeight: true,
        width: 320,
		modal:true,
        layout: 'fit',
		border: false,
		closeAction:'close',
		collapsible:'true',
		items: ExamPassForm,
		buttonAlign: 'center',
	    buttons: [{
			text:'View Report',iconCls: 'new-tab',
			handler: function(b, e){	
				
			var branch_hidden=ExamPassForm.getForm().findField('branch_hidden').getValue();
			var semester_hidden=ExamPassForm.getForm().findField('semester_hidden').getValue();
			var division_id=ExamPassForm.getForm().findField('division_id').getValue();
			var exam_hidden=ExamPassForm.getForm().findField('exam_hidden').getValue();
			var subject_hidden=ExamPassForm.getForm().findField('subject_hidden').getValue();
			var result=ExamPassForm.getForm().findField('result').getValue();
			var branch_disp=ExamPassForm.getForm().findField('branch_disp').getValue();
			var semester_disp=ExamPassForm.getForm().findField('semester_disp').getValue();
			var exam_disp=ExamPassForm.getForm().findField('exam_disp').getValue();
			var subject_disp=ExamPassForm.getForm().findField('subject_disp').getValue();
			var test_hidden=ExamPassForm.getForm().findField('test_hidden').getValue();
			var show_pass_marks=ExamPassForm.getForm().findField('show_pass_marks').getValue();
			var show_retest_fees=ExamPassForm.getForm().findField('show_retest_fees').getValue();
			var short_type=ExamPassForm.getForm().findField('short_type').getValue();
			
		//	alert(show_mobile_no);
			
var redirect = 'report-exampass-result.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + 
'&division_id='+division_id + '&exam_hidden='+exam_hidden + '&subject_hidden='+subject_hidden + 
'&result='+result + '&branch_disp='+branch_disp + '&semester_disp='+semester_disp + '&exam_disp='+exam_disp
+ '&subject_disp='+subject_disp + '&test_hidden='+test_hidden + '&show_pass_marks='+show_pass_marks  + '&show_retest_fees='+show_retest_fees + '&short_type='+short_type; 
                window.location = redirect;
				
			}
		},{
			text: 'Reset', iconCls: 'icon-reset',
			handler: function () {   
				ExamPassForm.getForm().reset();
				Ext.getCmp('branch_name').focus(true,500);
			}
		},{
			text: 'Close',iconCls: 'icon-close',
			handler: function () {    
				ExamPassWindow.close();
			}
      	}]
 	});
	
	var varWidth = (screen.width - ExamPassWindow.width)/2;
	ExamPassWindow.setPosition(varWidth,((screen.height/4)-85));
	ExamPassWindow.show();
	
	Ext.getCmp('branch_name').focus(true,1000);

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