<?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 '],
			['GTU Reg No '],
			['Gender <span class="comp">*</span>'],
			['Cast '],
			['Adm Year <span class="comp"></span>'],
			['Adm Type <span class="comp"></span>'],
			['Fees Paid '],
			['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 genderstore = new Ext.data.ArrayStore({
			fields: ['gender'],
			data: [['Male'], ['Female']]
		});

		var categorystore = new Ext.data.ArrayStore({
			fields: ['category'],
			data: [['GENERAL'], ['VICHARIT VIMUKTI'], ['OBC'], ['SC'], ['ST'], ['MINORITY'], ['EWS']]
		});

		var admbystore = new Ext.data.ArrayStore({
			fields: ['student_admby'],
			data: [['ACPC'], ['MQ'], ['VACENT QUOTA'], ['NRI'], ['Other']]
		});

		var admyearstore = new Ext.data.ArrayStore({
			fields: ['AYEAR'],
			data: Ext.semester.admyear
		});

		var feespaidstore = new Ext.data.ArrayStore({
			fields: ['feespaid'],
			data: [['Yes'], ['No']]
		});

		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_gturegno', 'Gender,Enrollment Reg No']]
		});

		Ext.onReady(function () {
			Ext.QuickTips.init();
			var StudentListForm = new Ext.FormPanel({
				labelWidth: 80,
				url: 'report-student-list-result.php',
				frame: 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('branch_disp').setValue(this.getRawValue());
							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,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('year_disp').setValue(this.getRawValue());	
						}
					}
				}, {
					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) {
							Ext.getCmp('branchyear_disp').setValue(this.getRawValue());
							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) {
							Ext.getCmp('semester_disp').setValue(this.getRawValue());
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('branchyear_name').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				},
				{
					xtype: 'container',
					autoEl: {},
					border: false,
					layout: 'column',
					anchor: '100%',
					defaultType: 'field',
					items: [{
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .62,
						items: [{
							xtype: 'numberfield',
							name: 'gturegno_start',
							id: 'gturegno_start',
							width: 95,
							emptyText: 'Start From',
							fieldLabel: labelArray[4],
							allowBlank: true
						}]
					}, {
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .38,
						labelWidth: 1,
						items: [{
							xtype: 'numberfield',
							name: 'gturegno_end',
							id: 'gturegno_end',
							width: 95,
							emptyText: 'End To',
							allowBlank: true
						}]
					}]
				}, {
					xtype: 'combo',
					name: 'gender',
					id: 'gender',
					fieldLabel: labelArray[5],
					forceSelection: true,
					displayField: 'gender',
					valueField: 'gender',
					width: 160,
					triggerAction: 'all',
					mode: 'local',
					store: genderstore
				}, {
					xtype: 'combo',
					name: 'cast',
					id: 'cast',
					fieldLabel: labelArray[6],
					displayField: 'category',
					valueField: 'category',
					forceSelection: false,
					width: 150
					, triggerAction: 'all'
					, mode: 'local'
					, selectOnFocus: true,
					store: categorystore,
					editable: true
				}, {
					xtype: 'combo',
					name: 'AYEAR',
					id: 'AYEAR',
					fieldLabel: labelArray[7],
					forceSelection: true,
					displayField: 'AYEAR',
					valueField: 'AYEAR',
					width: 150,
					triggerAction: 'all',
					mode: 'local',
					store: admyearstore
				}, {
					xtype: 'combo',
					name: 'student_admby',
					id: 'student_admby',
					fieldLabel: labelArray[8],
					forceSelection: true,
					displayField: 'student_admby',
					valueField: 'student_admby',
					width: 150,
					triggerAction: 'all',
					mode: 'local',
					store: admbystore
				},
				{
					xtype: 'combo',
					name: 'feespaid',
					id: 'feespaid',
					fieldLabel: labelArray[9],
					forceSelection: true,
					displayField: 'feespaid',
					valueField: 'feespaid',
					width: 150,
					triggerAction: 'all',
					mode: 'local',
					store: feespaidstore
				}, {
					xtype: 'combo',
					name: 'orderby',
					id: 'orderby',
					hiddenName: 'hid_orderby',
					fieldLabel: labelArray[10],
					displayField: 'order_by1',
					valueField: 'order_by2',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					allowBlank: true,
					store: orderbystore
				},
				{
					xtype: 'displayfield',
					name: 'branch_disp',
                    id: 'branch_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'year_disp',
                    id: 'year_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'branchyear_disp',
                    id: 'branchyear_disp',
                   hidden:true,
				},
				{
					xtype: 'displayfield',
					name: 'semester_disp',
                    id: 'semester_disp',
                   hidden:true,
				},
				]
			});

			var StudentListWindow = new Ext.Window({
				title: 'Student List Report',
				height: 400,
				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 gturegno_start = StudentListForm.getForm().findField('gturegno_start').getValue();
						var gturegno_end = StudentListForm.getForm().findField('gturegno_end').getValue();
						var gender = StudentListForm.getForm().findField('gender').getValue();
						var cast = StudentListForm.getForm().findField('cast').getValue();
						var AYEAR = StudentListForm.getForm().findField('AYEAR').getValue();
						var student_admby = StudentListForm.getForm().findField('student_admby').getValue();
						var feespaid = StudentListForm.getForm().findField('feespaid').getValue();
						var hid_orderby = StudentListForm.getForm().findField('hid_orderby').getValue();
						var branch_disp=StudentListForm.getForm().findField('branch_disp').getValue();
						var year_disp=StudentListForm.getForm().findField('year_disp').getValue();
						var branchyear_disp=StudentListForm.getForm().findField('branchyear_disp').getValue();
						var semester_disp=StudentListForm.getForm().findField('semester_disp').getValue();
						

						var redirect = 'report-student-list-result.php?branch_hidden=' + branch_hidden +
							'&year_hidden=' + year_hidden + '&branchyear_hidden=' + branchyear_hidden +
							'&semester_hidden=' + semester_hidden + '&gturegno_start=' + gturegno_start +
							'&gender=' + gender + '&cast=' + cast + '&AYEAR=' + AYEAR +
							'&student_admby=' + student_admby + '&feespaid=' + feespaid +
							'&hid_orderby=' + hid_orderby+ '&branch_disp='+branch_disp+ '&year_disp='+year_disp+ '&branchyear_disp='+branchyear_disp 
							+ '&semester_disp='+semester_disp  ;
						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"; ?>