<?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 = [
			['Enrollment Reg No '],
			['Course<span class="comp">*</span> '],
			['Batch Year<span class="comp">*</span> '],
			//['Course Year '],
			//['Semester '],
			['Student Name<span class="comp">*</span> '],
		];

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

	

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

		Ext.onReady(function () {
			Ext.QuickTips.init();
			var StudentPerfomanceForm = new Ext.FormPanel({
				labelWidth: 90,
				url: 'report-student-fees-records-result.php',
				frame: true,
				autoHeight: true,
				standardSubmit: true,
				title: '',
				bodyStyle: 'padding:6px 6px 0',
				layout: 'form',
				items: [{
					xtype: 'textfield',
					name: 'student_gturegno',
					id: 'student_gturegno',
					tabIndex: 1,
					fieldLabel: labelArray[0],
					allowBlank: true,
					allowNegative: false,
					allowDecimals: false,
					width: 180,
					listeners: {
						specialkey: function (f, e) {
							if (e.getKey() == e.ENTER) {
								StudentPerfomanceForm.getForm().submit();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'branch_name',
					id: 'branch_name',
					hiddenName: 'branch_hidden',
					fieldLabel: labelArray[1],
					displayField: 'branch_name',
					valueField: 'branch_id',
					width: 180,
					tabIndex: 2,
					forceSelection: true,
					selectOnFocus: true,
					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();
							Ext.getCmp('student_id').reset();
                            studentstore.load({ params: { 'branch_id': Ext.getCmp('branch_name').getValue()}});
						
							//studentstore.removeAll();
							//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[2],
					displayField: 'year_name',
					valueField: 'year_id',
					lastQuery: '',
					forceSelection: true,
					selectOnFocus: true,
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					tabIndex: 3,
					allowBlank: true,
					store: batchyearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {
								// Ext.getCmp('student_name').reset();
								studentstore.load({ params: { 'branch_id': Ext.getCmp('branch_name').getValue(), 'year_id': Ext.getCmp('year_name').getValue() } });
							} else {
								this.reset();
							}
						}
					}
				}, 
				/*{
					xtype: 'combo',
					name: 'branchyear_name',
					id: 'branchyear_name',
					hiddenName: 'branchyear_hidden',
					fieldLabel: labelArray[3],
					displayField: 'branchyear_name',
					valueField: 'branchyear_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					tabIndex: 4,
					allowBlank: true,
					store: yearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('student_id').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				}, 
                {
					xtype: 'combo',
					name: 'semester_name',
					id: 'semester_name',
					hiddenName: 'semester_hidden',
					fieldLabel: labelArray[4],
					displayField: 'semester_name',
					valueField: 'semester_id',
					lastQuery: '',
					tabIndex:5,
					disabled: true,
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank: true,
					store: semesterstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "") {
								Ext.getCmp('student_id').reset();
							} else {
								alert('Select Branch First')
								this.reset();
							}
						}
					}
				},*/
                 {
					xtype: 'combo',
					name: 'student_id',
					id: 'student_id',
					hiddenName: 'student_hidden',
					fieldLabel: labelArray[3],
					displayField: 'student_name',
					valueField: 'student_id',
					editable: true,
					forceSelection: true,
					selectOnFocus: true,
					width: 180,
					tabIndex: 6,
					triggerAction: 'all',
					mode: 'local',
					allowBlank: true,
					store: studentstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							if (Ext.getCmp('branch_name').getValue() != "" ) {

							}else{
								alert('Select Branch First')
									this.reset();
							}
							}
						}
					

				}, 
				/*{
				xtype: 'checkbox',
				name: 'show_detail',
				id: 'show_detail',
				labelSeparator: '',
				tabIndex: 7,
				fieldLabel: 'Show Detail :'
			}*/
				]
			});

		var StudentPerfomanceWindow = new Ext.Window({
			title: 'Student Fees Records',
			autoHeight: true,
			width: 320,
			modal: true,
			layout: 'fit',
			border: false,
			closeAction: 'close',
			collapsible: 'true',
			items: StudentPerfomanceForm,
			buttonAlign: 'center',
			buttons: [{
				text: 'View Report',
				tabIndex: 8,
				iconCls: 'new-tab',
				handler: function (b, e) {
					
					var branch_hidden = StudentPerfomanceForm.getForm().findField('branch_hidden').getValue();
					var year_hidden = StudentPerfomanceForm.getForm().findField('year_hidden').getValue();
					//var branchyear_hidden = StudentPerfomanceForm.getForm().findField('branchyear_hidden').getValue();
					//var semester_hidden = StudentPerfomanceForm.getForm().findField('semester_hidden').getValue();
					var student_gturegno = StudentPerfomanceForm.getForm().findField('student_gturegno').getValue();
					var student_hidden = StudentPerfomanceForm.getForm().findField('student_hidden').getValue();
					//var show_detail = StudentPerfomanceForm.getForm().findField('show_detail').getValue() ? 1 : 0; // Get value of show_detail checkbox
			
					var redirect = 'fees-360-report-result.php?branch_hidden=' + branch_hidden  + '&year_hidden=' + year_hidden +'&student_gturegno=' + student_gturegno + '&student_hidden=' + student_hidden ;
				window.location = redirect;
			}
			}, {
				text: 'Reset',
				tabIndex: 9,
				iconCls: 'icon-reset',
				handler: function () {
					StudentPerfomanceForm.getForm().reset();
					Ext.getCmp('student_gturegno').focus(true, 500);
				}
			}, {
				text: 'Close',
				tabIndex: 10,
				iconCls: 'icon-close',
				handler: function () {
					StudentPerfomanceWindow.close();
				}
			}]
		});
		var varWidth = (screen.width - StudentPerfomanceWindow.width) / 2;
		StudentPerfomanceWindow.setPosition(varWidth, ((screen.height / 4) - 85));
		StudentPerfomanceWindow.show();
		Ext.getCmp('student_gturegno').focus(true, 1000);
		});
	</script>
</div>
<?php require "_footer.php"; ?>