<?php
require "_header.php";
require "data/combo_semester.php";

?>

<div id="main-content">
	<script type="text/javascript" src="jquery/ux/CheckColumn.js"></script>
	<link rel="stylesheet" type="text/css" href="css/Ext.css">
	<script type="text/javascript" src="js/Ext.js"></script>
	<script type="text/javascript" src="js/Ext_002.js"></script>
	<script type="text/javascript">

		Ext.override(Ext.ux.form.LovCombo, {
			beforeBlur: Ext.emptyFn
		});

		var labelArray;
		labelArray = [
			['Course <span class="comp">*</span>'],
			['Batch Year <span class="comp">*</span>'],
			['Student '],
			['Head ']
		];

		var headstore = new Ext.data.ArrayStore({
			fields: ['head_id', 'head_name'],
			data: Ext.semester.headall
		});

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



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


		var branch_disp = new Ext.form.TextField({
			name: 'branch_disp',
			id: 'branch_disp',
			hidden: true
		});

		var year_disp = new Ext.form.TextField({
			name: 'year_disp',
			id: 'year_disp',
			hidden: true
		});

		var head_disp = new Ext.form.TextField({
			name: 'head_disp',
			id: 'head_disp',
			hidden: true
		});




		Ext.onReady(function () {
			Ext.QuickTips.init();
			var student_feesreceipt = new Ext.FormPanel({
				labelWidth: 80,
				url: 'report-fees-all-dueamt-result.php',
				frame: true,
				standardSubmit: true,
				autoHeight: 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: 180,
					triggerAction: 'all',
					mode: 'local',
					allowBlank:false,
					store: branchstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('branch_disp').setValue(this.getRawValue());
							Ext.getCmp('year_name').reset();
							Ext.getCmp('student_id').reset();
							studentstore.removeAll();

						}
					}
				}, {
					xtype: 'combo',
					name: 'year_name',
					id: 'year_name',
					hiddenName: 'year_hidden',
					fieldLabel: labelArray[1],
					displayField: 'year_name',
					valueField: 'year_id',
					triggerAction: 'all',
					mode: 'local',
					width: 180,
					allowBlank:false,
					store: batchyearstore,
					listeners: {
						'select': function (cmb, rec, idx) {
							Ext.getCmp('year_disp').setValue(this.getRawValue());
							if (Ext.getCmp('branch_name').getValue() != "") {

								studentstore.load({ params: { 'branch_id': Ext.getCmp('branch_name').getValue(), 'year_id': Ext.getCmp('year_name').getValue() } });
							} else {
								this.reset();
							}
						}
					}
				}, {
					xtype: 'combo',
					name: 'student_id',
					id: 'student_id',
					hiddenName: 'student_hidden',
					fieldLabel: labelArray[2],
					displayField: 'student_name',
					valueField: 'student_id',
					editable: true,
					width: 180,
					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: 'lovcombo',
					name: 'head_name',
					id: 'head_name',
					hiddenName: 'head_hidden',
					fieldLabel: labelArray[3],
					displayField: 'head_name',
					valueField: 'head_id',
					editable:true,
					width: 200,
					triggerAction: 'all',
					mode: 'local',
					store: headstore,
					allowBlank: true,
					navigateItemsWithTab: false,
					listeners: {'select': function(cmb, rec, idx){
		Ext.getCmp('head_disp').setValue(this.getRawValue());
		
  	}}
				}, branch_disp,year_disp, head_disp]
			});
			var FeesReceiptReportWindow = new Ext.Window({
				title: 'All Student Due Fees Report',
				autoHeight: true,
				width: 340,
				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 student_hidden = student_feesreceipt.getForm().findField('student_hidden').getValue();
						var head_hidden = student_feesreceipt.getForm().findField('head_hidden').getValue();
						var branch_disp = student_feesreceipt.getForm().findField('branch_disp').getValue();
						var year_disp = student_feesreceipt.getForm().findField('year_disp').getValue();
						var head_disp = student_feesreceipt.getForm().findField('head_disp').getValue();


						var redirect = 'report-fees-all-dueamt-result.php?branch_hidden=' + branch_hidden + '&year_hidden=' + year_hidden + '&student_hidden=' + student_hidden + '&head_hidden=' + head_hidden
            + '&branch_disp=' + branch_disp + '&year_disp=' + year_disp + '&head_disp=' + head_disp;
        window.location = redirect;
					}
				}, {
					text: 'Reset', iconCls: 'icon-reset',
					handler: function () {
						student_feesreceipt.getForm().reset();
						Ext.getCmp('branch_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"; ?>