<?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:'],
	['Enrollment Reg No:'],
	['Order By:']
];

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

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 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 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,
	triggerAction:'all',
	width:198,
	mode:'local',
	allowBlank:false,
	store: branchstore,
    listeners: {'select': function(cmb, rec, idx){
		Ext.getCmp('branch_disp').setValue(this.getRawValue());
		Ext.getCmp('semester_name').reset();
		Ext.getCmp('division_id').reset();
	}}
});

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 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,
	triggerAction:'all',
	width:198,
	mode:'local',
	store: semesterstore,
    listeners: {'select': function(cmb, rec, idx){
		Ext.getCmp('semester_disp').setValue(this.getRawValue());
		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'
						,width:198
						,tabIndex:3
						,lastQuery:''
						,allowBlank:true
						,triggerAction:'all'
						,mode:'local'
						,store:divisionstore
						,selectOnFocus: true,
						listeners: {'select': function(cmb, rec, idx) {
						}
    }}


var exam = new Ext.form.ComboBox({
	name: 'exam_name',
	id:'exam_name',
	hiddenName:'exam_hidden',
	labelSeparator:'',	
	fieldLabel :'Exam:<span class="comp">*</span>' ,
	displayField:'exam_name',
	valueField: 'exam_id',
	editable:true,
	triggerAction:'all',
	forceSelection:true,
	mode:'local',
	width:198,
	allowBlank:false,
	store: examstore,
    listeners:{'select': function(cmb, rec, idx){
	}}
});	

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,
	width:198,
	triggerAction:'all',
	forceSelection:true,
	mode:'local',
	//width: 100,
	tabIndex:'5',
	allowBlank:true,
	store: teststore,
    listeners:{'select': function(cmb, rec, idx){
	}}
});



Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var StudentListForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'report-student-mark-result.php',
		frame:true,
		autoHeight: true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[branch,semester,divisionCombo,exam,test,branch_disp,semester_disp]
 	});
	
	var StudentListWindow = new Ext.Window({
        title: 'Student Marksheet Report',
        autoHeight: true,
        width: 330,
		modal:true,
        layout: 'fit',
		border: false,
		closeAction:'close',
		collapsible:'true',
		items: StudentListForm,
		buttonAlign: 'center',
	    buttons: [{
			text:'View Report',
			iconCls: 'new-tab',
			handler: function(b, e){	
				var branch_hidden=StudentListForm.getForm().findField('branch_hidden').getValue();
			var semester_hidden=StudentListForm.getForm().findField('semester_hidden').getValue();
			var division_id=StudentListForm.getForm().findField('division_id').getValue();
			var exam_hidden=StudentListForm.getForm().findField('exam_hidden').getValue();
			
			var branch_disp=StudentListForm.getForm().findField('branch_disp').getValue();
			var semester_disp=StudentListForm.getForm().findField('semester_disp').getValue();
			
			var test_hidden=StudentListForm.getForm().findField('test_hidden').getValue();
			
			
			
		//	alert(show_mobile_no);
			
var redirect = 'report-student-mark-result.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + '&division_id='+division_id 

 + '&semester_disp='+semester_disp + '&exam_hidden='+exam_hidden + '&branch_disp='+branch_disp + '&test_hidden='+test_hidden; 
                window.location = redirect;
			}
		},{
			text: 'Reset', 
			iconCls: 'icon-reset',
			handler: function(){   
			  	StudentListForm.getForm().reset();
				Ext.getCmp('branch_name').focus(true,500);
			}
		},{
		  	text: 'Close',
			iconCls: 'icon-close',
			handler: function () {    
				StudentListWindow.close();
			}
      	}]
	});
	
	var varWidth =  (screen.width - StudentListWindow.width)/2;
	StudentListWindow.setPosition(varWidth,((screen.height/4)-85));
	StudentListWindow.show();
	Ext.getCmp('branch_name').focus(true,1000);
});
</script>
<div id="abcd"></div>
</div>
<?php require "_footer.php";?>