<?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>'],
	['Subject:']
];

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

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

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',
	mode:'local',
	//width:205,
	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[2] ,
	displayField:'subject_name',
	valueField: 'subject_id',
	editable:true,
	triggerAction:'all',
	mode:'local',
	//width:205,
	allowBlank:true,
	store: subjectstore,
    listeners: {'select': function(cmb, rec, idx){
		Ext.getCmp('subject_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 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 ATKTForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'report-atktlist-result.php',
		frame:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[branch,semester,divisionCombo,subject,branch_disp,semester_disp,subject_disp]
 	});
	
	var ATKTWindow = new Ext.Window({
        title: 'Student ATKT List Report',
        height: 190,
        width: 350,
		modal:true,
        layout: 'fit',
		border: false,
		closeAction:'close',
		collapsible:'true',
		items: ATKTForm,
		buttonAlign: 'center',
	    buttons: [{
			text:'View Report',
			iconCls: 'new-tab',
			handler: function(b, e){	
				var branch_hidden=ATKTForm.getForm().findField('branch_hidden').getValue();
			var semester_hidden=ATKTForm.getForm().findField('semester_hidden').getValue();
			var division_id=ATKTForm.getForm().findField('division_id').getValue();
			var subject_hidden=ATKTForm.getForm().findField('subject_hidden').getValue();
			var branch_disp=ATKTForm.getForm().findField('branch_disp').getValue();
			var semester_disp=ATKTForm.getForm().findField('semester_disp').getValue();
			var subject_disp=ATKTForm.getForm().findField('subject_disp').getValue();
			
			
			
		//	alert(show_mobile_no);
			
var redirect = 'report-atktlist-result.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + '&division_id='+division_id + '&subject_hidden='+subject_hidden + '&branch_disp='+branch_disp + '&semester_disp='+semester_disp + '&subject_disp='+subject_disp; 
                window.location = redirect;
			}
		},{
			text: 'Reset', 
			iconCls: 'icon-reset',
			handler: function(){   
			  	ATKTForm.getForm().reset();
				Ext.getCmp('branch_name').focus(true,500);
			}
		},{
		  	text: 'Close',
			iconCls: 'icon-close',
			handler: function () {    
				ATKTWindow.close();
			}
      	}]
	});
	
	var varWidth =  (screen.width - ATKTWindow.width)/2;
	ATKTWindow.setPosition(varWidth,((screen.height/4)-85));
	ATKTWindow.show();
	Ext.getCmp('branch_name').focus(true,1000);
});
</script>
<div id="abcd"></div>
</div>
<?php require "_footer.php";?>
