<?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>'],
	['Test:<span class="comp">*</span>'],
	['Student:'],
	['Enrollment Reg No:']
];

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

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 examstore = new Ext.data.ArrayStore({		
	fields: ['exam_id','exam_name'],
	data:Ext.semester.exam
});

 var typestore = new Ext.data.ArrayStore({
           fields: ['subject_type'],
	       data: [['Both'],['Theory'],['Practical']]
     }); 
		
var divisionstore = new Ext.data.ArrayStore({
    	fields:['division_id','division_name'],
		data: Ext.semester.division
	});	
	
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){
		Ext.getCmp('branch_disp').setValue(this.getRawValue());
		Ext.getCmp('division_id').reset();
	}}
});

var test = new Ext.form.ComboBox({
	name:'test',
	id:'test',
	labelSeparator:'',	
	fieldLabel :labelArray[3] ,
	displayField:'test',
	width:198,
	valueField: 'test',
	editable:true,
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:teststore
});


var type = new Ext.form.ComboBox({
	name:'subject_type',
	id:'subject_type',
	labelSeparator:'',	
	fieldLabel :'Type:' ,
	displayField:'subject_type',
	width:198,
	valueField: 'subject_type',
	editable:true,
	value:'Both',
	forceSelection:true,
	triggerAction:'all',
	mode:'local',
	allowBlank:false,
	store:typestore
});

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){
		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);
		}
		if(Ext.getCmp('branch_name').getValue()!=""){
			studentstore.load({params: {'branch_id': Ext.getCmp('branch_name').getValue(),'semester_id': Ext.getCmp('semester_name').getValue()}});
			
		}else{
			alert('Select Branch First')
			this.reset();
		}
	}}
});


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
						,lastQuery:''
						,allowBlank:false
						,triggerAction:'all'
						,mode:'local'
						,store:divisionstore
						,selectOnFocus: true,
						listeners: {'select': function(cmb, rec, idx) {
							if(Ext.getCmp('semester_name').getValue()!=""){
								studentstore.load({params: {'branch_id': Ext.getCmp('branch_name').getValue(),'semester_id': Ext.getCmp('semester_name').getValue(),'division_id': cmb.getValue()}});
							
						}else{
							alert('Select Semester First')
							this.reset();
						}
						}
    }}
	
studentstore = new Ext.data.JsonStore({
	url:'data/getstudent-feesrecive.php',
    root: 'data',
	totalProperty: 'total',
	fields: [{
		name: 'student_id',
		type:'int'
	},{
		name: 'student_name',
		type: 'string'
	},{
		name: 'student_gturegno',
		type: 'int'
	}] 
});

var student = new Ext.form.ComboBox({
	name: 'student_id',
	id:'student_id',
	hiddenName:'student_hidden',
	labelSeparator:'',	
	fieldLabel :labelArray[4] ,
	displayField:'student_name',
	valueField: 'student_id',
	editable:true,
	triggerAction:'all',
	mode:'local',
	width:198,
	allowBlank:true,
	store: studentstore,
	listeners: {'select': function(cmb, rec, idx){
	if(Ext.getCmp('branch_name').getValue()!="" && Ext.getCmp('semester_name').getValue()!=""){
				
		}else{
			alert('Select Branch And Semester First')
			this.reset();
		}
	}}
});

var gturegno_start = new Ext.form.NumberField({
    labelSeparator:'',	
	fieldLabel :labelArray[5] ,
	name: 'gturegno_start',
	id:'gturegno_start',
	width:95,
	emptyText:'Start From',
	allowNegative: false,
	allowDecimals: false
});	

var gturegno_end = new Ext.form.NumberField({
    fieldLabel: '',
	name: 'gturegno_end',
	id:'gturegno_end',
	width:95,
	emptyText:'End To',
	allowNegative: false,
	allowDecimals: false
});

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',
	width:198,
	allowBlank:false,
	store: examstore,
    listeners:{'select': function(cmb, rec, idx){
		Ext.getCmp('exam_disp').setValue(this.getRawValue());
	}}
});	

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
});

Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var ExamPassForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'report-hallticket-result.php',
		frame:true,
		autoHeight:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[branch,semester,divisionCombo,exam,test,type,student,{
			xtype:'container',
			autoEl:{},
			border:false,
			layout:'column',
			anchor:'100%',
			defaultType:'field',
			items:[{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.62,
				items:[gturegno_start]
			},{
				xtype:'container',
				autoEl:{},
				layout:'form',
				columnWidth:.38,
				labelWidth:1,
				items:[gturegno_end]
			}]
		},branch_disp,semester_disp,exam_disp]
    });
	 
	var ExamPassWindow = new Ext.Window({
        title: 'Hall Ticket Report',
       width: 330,
		modal:true,
        layout: 'fit',
		border: false,
		autoHeight:true,
		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 student_hidden=ExamPassForm.getForm().findField('student_hidden').getValue();
			var test=ExamPassForm.getForm().findField('test').getValue();
			var gturegno_start=ExamPassForm.getForm().findField('gturegno_start').getValue();
			var gturegno_end=ExamPassForm.getForm().findField('gturegno_end').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_type=ExamPassForm.getForm().findField('subject_type').getValue();
			
			
			
			
		//	alert(show_mobile_no);
			
var redirect = 'report-hallticket-result.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + 
'&division_id='+division_id + '&exam_hidden='+exam_hidden + '&student_hidden='+student_hidden +
'&semester_disp='+semester_disp + '&exam_disp='+exam_disp + '&subject_type='+subject_type +
 '&test='+test + '&gturegno_start='+gturegno_start + '&gturegno_end='+gturegno_end + '&branch_disp='+branch_disp; 
                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";?>