<?php
require "_header.php";
require "data/combo_student.php";
require "data/combo_semester.php";
require "data/combo_branchyear.php";
?>
<div id="main-content">
<script type="text/javascript">
var labelArray;
labelArray = [
	['Course <span class="comp">*</span>'],
	['Batch Year '],
	['Course Year '],
	['Semester '],
	['Order By ']
];

var branchstore = new Ext.data.ArrayStore({
			fields: ['branch_id', 'branch_name'],
			data: Ext.semester.branch
		});
		var batchyearstore = new Ext.data.ArrayStore({
			fields: ['year_id', 'year_name'],
			data: Ext.semester.yearname
		});
		var semesterstore = new Ext.data.ArrayStore({
			fields: ['branch_id', 'semester_id', 'semester_name'],
			data: Ext.semester.semester
		});
		var yearstore = new Ext.data.ArrayStore({
			fields: ['branch_id', 'branchyear_id', 'branchyear_name'],
			data: Ext.year.year
		});
		
	
	
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 orderbystore = new Ext.data.ArrayStore({
	fields: ['order_by2','order_by1'],
	data: [['student_gturegno','Enrollment Reg No'],
		   ['student_surname','Surname'],
		   ['student_firstname','First Name'],
		   ['student_gender,student_surname','Gender,Surname'],
		   ['student_gender,student_gturo','Gender,Enrollment Reg No']]
}); 

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:false,
	store: teststore,
    listeners:{'select': function(cmb, rec, idx){
	}}
});



Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var StudentListForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'report-student-retest-result.php',
		frame:true,
		autoHeight: true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[{
					xtype: 'combo',
					name: 'branch_name',
					id: 'branch_name',
					hiddenName: 'branch_hidden',
					fieldLabel: labelArray[0],
					displayField: 'branch_name',
					valueField: 'branch_id',
					width: 200,
					triggerAction: 'all',
					mode: 'local',
					allowBlank: true,
					store: branchstore,
					listeners: {
						'select': function (cmb, rec, idx) {

							Ext.getCmp('semester_name').reset();
							Ext.getCmp('year_name').reset();
							Ext.getCmp('branchyear_name').reset();

							semesterstore.filter('branch_id', cmb.getValue(), false, true, true);
							yearstore.filter('branch_id', cmb.getValue(), false, true, true);
							var semesterCombo = Ext.getCmp('semester_name');
							if (cmb.getValue() == 3 || cmb.getValue() == 5) {
								semesterCombo.enable();
							} else {
								semesterCombo.disable();
								semesterCombo.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'year_name',
					id: 'year_name',
					hiddenName: 'year_hidden',
					fieldLabel: labelArray[1],
					displayField: 'year_name',
					valueField: 'year_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					allowBlank: true,
					store: batchyearstore
				}, {
					xtype: 'combo',
					name: 'branchyear_name',
					id: 'branchyear_name',
					hiddenName: 'branchyear_hidden',
					fieldLabel: labelArray[2],
					displayField: 'branchyear_name',
					valueField: 'branchyear_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					allowBlank: true,
					store: yearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('semester_name').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'semester_name',
					id: 'semester_name',
					hiddenName: 'semester_hidden',
					fieldLabel: labelArray[3],
					displayField: 'semester_name',
					valueField: 'semester_id',
					lastQuery: '',
					disabled: true,
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					allowBlank: true,
					store: semesterstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('branchyear_name').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'orderby',
					id: 'orderby',
					hiddenName: 'hid_orderby',
					fieldLabel: labelArray[4],
					displayField: 'order_by1',
					valueField: 'order_by12',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					allowBlank: true,
					store: orderbystore,
				},exam,test]
 	});
	
	var StudentListWindow = new Ext.Window({
        title: 'Retest Student List',
        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 year_hidden = StudentListForm.getForm().findField('year_hidden').getValue();
						var branchyear_hidden = StudentListForm.getForm().findField('branchyear_hidden').getValue();
						var semester_hidden = StudentListForm.getForm().findField('semester_hidden').getValue();
			var exam_hidden=StudentListForm.getForm().findField('exam_hidden').getValue();
			var test_hidden=StudentListForm.getForm().findField('test_hidden').getValue();
			var hid_orderby=StudentListForm.getForm().findField('hid_orderby').getValue();
			
		//	alert(show_mobile_no);
			
var redirect = 'report-student-retest-result.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + 
'&division_id='+division_id  + '&branch_disp='+branch_disp + 
'&semester_disp='+semester_disp + '&exam_hidden='+exam_hidden + '&test_hidden='+test_hidden + '&hid_orderby='+hid_orderby ; 
                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";?>