<?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 <span class="comp"></span>'],
			['Course Year <span class="comp"></span>'],
			['Semester <span class="comp"></span>'],
			['Student <span class="comp"></span>'],
			['Date <span class="comp"></span>'],
			['Receipt-No <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 student_feesreceipt = new Ext.FormPanel({
				labelWidth: 80, // label settings here cascade unless overridden
				url: 'report-form-student-feereceipt-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,
					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.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[1],
					displayField: 'year_name',
					valueField: 'year_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					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[2],
					displayField: 'branchyear_name',
					valueField: 'branchyear_id',
					lastQuery: '',
					triggerAction: 'all',
					mode: 'local',
					width: 200,
					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[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) {
							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[4],
					displayField: 'student_name',
					valueField: 'student_id',
					editable: true,
					width: 200,
					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: 'container',
					autoEl: {},
					border: false,
					layout: 'column',
					anchor: '100%',
					defaultType: 'field',
					items: [{
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .56,
						items: [{
							xtype: 'datefield',
							id: 'feesrec_startdate',
							fieldLabel: labelArray[5],
							name: 'feesrec_startdate',
							allowBlank: true,
							width: 99,

							endDateField: 'feesrec_enddate',
							value: new Date(),
						}]
					},
					{
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .44,
						labelWidth: 1,
						items: [{
							xtype: 'datefield',
							id: 'feesrec_enddate',
							name: 'feesrec_enddate',
							allowBlank: true,
							width: 99,

							endDateField: 'feesrec_startdate',
							value: new Date(),
						}]
					}]
				}, 
				/*{
					xtype: 'container',
					autoEl: {},
					border: false,
					layout: 'column',
					anchor: '100%',
					defaultType: 'field',
					items: [{
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .55,
						items: [{
							xtype: 'textfield',
							fieldLabel: labelArray[6],
							name: 'feesrec_startno',
							id: 'feesrec_startno',
							width: 95,
							allowBlank: true,
							allowNegative: false,
							allowDecimals: false

						}]
					}, {
						xtype: 'container',
						autoEl: {},
						layout: 'form',
						columnWidth: .40,
						labelWidth: 1,
						items: [{
							xtype: 'textfield',
							fieldLabel: '',
							name: 'feesrec_endno',
							id: 'feesrec_endno',
							width: 99,
							allowBlank: true,
							allowNegative: false,
							allowDecimals: false
						}]
					}]
				}*/]
			});

			var FeesReceiptReportWindow = new Ext.Window({
				title: 'Student Fees-Receipt Report',
				height: 280,
				width: 365,
				modal: true,
				layout: 'fit',
				border: false,
				closeAction: 'close',
				collapsible: 'true',
				items: student_feesreceipt,
				buttonAlign: 'center',
				buttons: [{
					text: 'View Report', iconCls: 'new-tab',
					handler: function (b, e) {

						var branch_hidden = student_feesreceipt.getForm().findField('branch_hidden').getValue();
						var year_hidden = student_feesreceipt.getForm().findField('year_hidden').getValue();
						var branchyear_hidden = student_feesreceipt.getForm().findField('branchyear_hidden').getValue();
						var semester_hidden = student_feesreceipt.getForm().findField('semester_hidden').getValue();
						var student_hidden = student_feesreceipt.getForm().findField('student_hidden').getValue();
						var feesrec_startdate = student_feesreceipt.getForm().findField('feesrec_startdate').getValue();
						var feesrec_enddate = student_feesreceipt.getForm().findField('feesrec_enddate').getValue();
					//	var feesrec_startno = student_feesreceipt.getForm().findField('feesrec_startno').getValue();
					//	var feesrec_endno = student_feesreceipt.getForm().findField('feesrec_endno').getValue();

						var redirect = 'report-form-student-feereceipt-result.php?branch_hidden=' + branch_hidden
							+ '&year_hidden=' + year_hidden + '&branchyear_hidden=' + branchyear_hidden
							+ '&semester_hidden=' + semester_hidden + '&student_hidden=' + student_hidden
							+ '&feesrec_startdate=' + feesrec_startdate + '&feesrec_enddate=' + feesrec_enddate;
						window.location = redirect;

					}
				},
				{
					text: 'Reset', iconCls: 'icon-reset',
					handler: function () {
						student_feesreceipt.getForm().reset();
						Ext.getCmp('section_name').focus(true, 500);

					}
				},
				{
					text: 'Close', iconCls: 'icon-close',
					handler: function () {
						FeesReceiptReportWindow.close();

					}
				}
				]
			});
			var varWidth = (screen.width - FeesReceiptReportWindow.width) / 2;
			FeesReceiptReportWindow.setPosition(varWidth, ((screen.height / 4) - 85));
			FeesReceiptReportWindow.show();
			Ext.getCmp('branch_name').focus(true, 1000);

		});
	</script>
</div>
<?php require "_footer.php"; ?>