<?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:'],
	['GTU Reg No:'],
	['Report Type:']
];

var dt = new Date();

var shiftstore = new Ext.data.ArrayStore({
           fields: ['shift'],
	       data: [['Shift-1'],['Shift-2']]
        });
		
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 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('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('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();
			}
		}}
});
studentstore = new Ext.data.JsonStore({
		url:'data/getstudent-feesrecive2.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 :'Student :<span class="comp">*</span>',
		displayField:'student_name',
		valueField: 'student_id',
		editable:true,
		width:200,
		triggerAction:'all',
		mode:'local',
		allowBlank:false,
		store: studentstore,
		listeners: {'select': function(cmb, rec, idx){
			
		
			
			if(Ext.getCmp('branch_name').getValue() == "" && Ext.getCmp('semester_name').getValue() == ""){
				alert('Select Branch And Semester First')
				this.reset();
			}
		}}
	});
	
var orderbystore = new Ext.data.ArrayStore({
	fields: ['order_by2','order_by1'],
	data: [['gender','Gender Summary'],
		   ['addmission','Addmission Type Summary'],
		   ['categary','Categary Summary'],
		   ['tfws','TFWS Summary'],
		   ['status','Student Status Summary']]
}); 

var orderby = new Ext.form.ComboBox({
	name: 'orderby',
	id:'orderby',
	hiddenName:'hid_orderby',
	labelSeparator:'',	
	fieldLabel :labelArray[3] ,
	displayField:'order_by1',
	valueField: 'order_by2',
	editable:true,
	width:198,
	triggerAction:'all',
	mode:'local',
	store:orderbystore
});

Ext.onReady(function(){
	Ext.QuickTips.init();
	
	var StudentListForm = new Ext.FormPanel({
    	labelWidth: 80,
        url:'student_report.php',
		frame:true,
		standardSubmit:true,
        title: '',
        bodyStyle:'padding:6px 6px 0',
        layout:'form',
		defaultType: 'textfield',
        items :[branch,semester,{		
					xtype: 'combo',
					name: 'division_id',
					id:'division_id',
					labelSeparator:'',	
					fieldLabel :'Division :' ,
					forceSelection:true,				
					displayField:'division_name',
					valueField: 'division_name'
					,lastQuery:''
					,allowBlank:true
					,triggerAction:'all'
					,mode:'local'
					,store:divisionstore
					,width:198
					,selectOnFocus: true,
					listeners: {'select': function(cmb, rec, idx){
										if(Ext.getCmp('branch_name').getValue()!="" && Ext.getCmp('semester_name').getValue()!=""){
				studentstore.load({params: {'branch_id': Ext.getCmp('branch_name').getValue(),'semester_id': Ext.getCmp('semester_name').getValue(),'division_id': this.getValue()}});
				
			}
										else{
				alert('Select Branch And Semester First')
				this.reset();
			}
		}}
					
				},student,{		
					xtype: 'combo',
					name: 'shift',
					id:'shift',
					labelSeparator:'',	
					fieldLabel :'Shift :' ,
					forceSelection:true,				
					displayField:'shift',
					valueField: 'shift',
					lastQuery:'',
					allowBlank:true,
					triggerAction:'all',
					mode:'local',
					store:shiftstore,
					width:198,
					selectOnFocus: true,
				}/*,{
				  xtype: 'datefield',
					name: 'date',
					id: 'date',
					width:198,
					labelSeparator:'',	
					fieldLabel :'Date :' ,
					value:dt.format('m-d-Y'),
					vtype: 'daterange',
					allowBlank:false
				}*/
				,branch_disp,semester_disp]
 	});
	
	var StudentListWindow = new Ext.Window({
        title: 'Student Report',
        height:230,
        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 branch_disp=StudentListForm.getForm().findField('branch_disp').getValue();
			var semester_disp=StudentListForm.getForm().findField('semester_disp').getValue();
			
			var student_hidden=StudentListForm.getForm().findField('student_hidden').getValue();
			var shift=StudentListForm.getForm().findField('shift').getValue();
			
			
		//	alert(show_mobile_no);
			
var redirect = 'student_report.php?branch_hidden='+branch_hidden + '&semester_hidden='+semester_hidden + 
'&division_id='+division_id  + '&branch_disp='+branch_disp + 
'&semester_disp='+semester_disp + '&student_hidden='+student_hidden + '&shift='+shift ; 
                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";?>
