<?php
require "_header.php";
/*require "../includeLanguageBar.php";*/
require "data/combo_employee.php";
?>
<!-- start custom CSS/JS -->
<script type="text/javascript" src="js/view-allowances.js"></script>
<script language="javascript" type="text/javascript">
	var labelArray;
	labelArray = [
		['Employee Name :<span class="comp">*</span>'],
		['Employee Salary No :<span class="comp">*</span>'],
		['Year :<span class="comp">*</span>'],
		['Month :<span class="comp">*</span>'],
		['Total Present Days :<span class="comp">*</span>']
	];

	Ext.onReady(function () {
		var payscalestore = new Ext.data.ArrayStore({
			fields: ['payscale_id', 'payscale'],
			data: Ext.employee.payscale
		});

		Ext.namespace('Ext.month');
		Ext.month.list = [
			[1, 'January'], [2, 'February'], [3, 'March'], [4, 'April'], [5, 'May'], [6, 'June'], [7, 'July'],
			[8, 'August'], [9, 'September'], [10, 'October'], [11, 'November'], [12, 'December']
		];

		var monthliststore = new Ext.data.SimpleStore({
			fields: [{ name: 'monthid', type: 'int' }, 'monthname'],
			data: Ext.month.list
		});

		var yearstore = new Ext.data.ArrayStore({
			fields: ['year_name'],
			data: Ext.employee.year
		});

		var sectionstore = new Ext.data.ArrayStore({
			fields: ['section_id', 'section_name'],
			data: Ext.employee.section
		});

		var employeestore = new Ext.data.ArrayStore({
			fields: ['section_id', 'employee_id', 'employee_no', 'employee_name', 'employee_basicsalary', 'loan_amount', 'employee_loan', 'loan_date', 'loan_month', 'employee_payscale'],
			data: Ext.employee.salinfo
		});

		var income = {
			xtype: 'fieldset',
			border: false,
			labelWidth: 50,
			items: [
				{
					xtype: 'container',
					border: false,
					layout: 'column',
					defaultType: 'field',
					items: [
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Basic',
									anchor: '-20',
									name: 'Basic',
									allowNegative: false,
									enableKeyEvents: true,
									//readOnly:true,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'All/Family Planning',
									hidden: true,
									anchor: '-30',
									name: 'All/Family Planning',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Grade Pay/Dp',
									anchor: '-20',
									name: 'Grade Pay/Dp',
									//readOnly:true,
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									//fieldLabel : 'Handicap All',
									hidden: true,
									anchor: '-30',
									name: 'Handicap All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'DA',
									//readOnly:true,
									anchor: '-20',
									name: 'DA',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.48,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Transport All',
									anchor: '-30',
									name: 'Transport All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'HRA',
									//readOnly:true,
									anchor: '-20',
									name: 'HRA',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Leave Encash',
									hidden: false,
									anchor: '-30',
									name: 'Leave Encash',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Medical',
									anchor: '-20',
									//readOnly:true,
									name: 'Medical',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'LTC',
									hidden: false,
									anchor: '-30',
									name: 'LTC',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'CCA/CLA',
									//readOnly:true,
									anchor: '-20',
									name: 'CCA/CLA',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.48,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Special Pay',
									hidden: false,
									anchor: '-30',
									name: 'Special Pay',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'P.T.ALL',
									anchor: '-20',
									hidden: false,
									name: 'PTA',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}
								}
							]

						},

						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									//fieldLabel : 'Principal All',
									//readOnly:true,
									hidden: true,
									anchor: '-20',
									name: 'Principal All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Arias',
									hidden: false,
									anchor: '-30',
									name: 'Arias',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {
												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Supervisor All',
									hidden: false,
									//readOnly:true,
									anchor: '-20',
									name: 'Supervisor All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' }
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Additional DA',
									hidden: false,
									anchor: '-30',
									name: 'Additional DA',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'H.S.All',
									hidden: false,
									anchor: '-20',
									name: 'H.S.All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'IR-I',
									hidden: false,
									anchor: '-30',
									name: 'IR',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Wash All',
									hidden: false,
									anchor: '-20',
									name: 'Wash All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Other',
									hidden: false,
									anchor: '-30',
									name: 'Other',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.48,
							labelWidth: 80,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Bonus',
									hidden: false,
									anchor: '-30',
									name: 'Bonus',
									enableKeyEvents: true,
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 80,
							width: 170,
							height: 40,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Cas All',
									hidden: false,
									anchor: '-20',
									name: 'Cash All',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updateincometotal();

											}
										}
									}
								}
							]

						}, {
							xtype: 'container',
							layout: 'form',
							border: true,
							columnWidth: 0.7,
							labelWidth: 100,

							width: 100,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Gross Income',
									labelStyle: 'font-weight: bold; color:#23518D',
									anchor: '-50',
									name: 'Gross Income',
									emptyText: '0'
									//,readOnly:true

								}
							]
						}]
				}]
		};

		function updateincometotal() {

			var total = Number(allowancesentryform.getForm().findField('Basic').getValue()) +
				Number(allowancesentryform.getForm().findField('Grade Pay/Dp').getValue()) +
				Number(allowancesentryform.getForm().findField('DA').getValue()) +
				Number(allowancesentryform.getForm().findField('HRA').getValue()) +
				Number(allowancesentryform.getForm().findField('Medical').getValue()) +
				Number(allowancesentryform.getForm().findField('CCA/CLA').getValue()) +
				Number(allowancesentryform.getForm().findField('Principal All').getValue()) +
				Number(allowancesentryform.getForm().findField('Supervisor All').getValue()) +
				Number(allowancesentryform.getForm().findField('LTC').getValue()) +
				Number(allowancesentryform.getForm().findField('PTA').getValue()) +
				Number(allowancesentryform.getForm().findField('H.S.All').getValue()) +
				Number(allowancesentryform.getForm().findField('Wash All').getValue()) +
				Number(allowancesentryform.getForm().findField('Cash All').getValue()) +
				Number(allowancesentryform.getForm().findField('All/Family Planning').getValue()) +
				Number(allowancesentryform.getForm().findField('Handicap All').getValue()) +
				Number(allowancesentryform.getForm().findField('Transport All').getValue()) +
				Number(allowancesentryform.getForm().findField('Leave Encash').getValue()) +
				Number(allowancesentryform.getForm().findField('Special Pay').getValue()) +
				Number(allowancesentryform.getForm().findField('Bonus').getValue()) +
				Number(allowancesentryform.getForm().findField('Arias').getValue()) +
				Number(allowancesentryform.getForm().findField('Additional DA').getValue()) +
				Number(allowancesentryform.getForm().findField('IR').getValue()) +
				Number(allowancesentryform.getForm().findField('Other').getValue());

			allowancesentryform.getForm().findField('Gross Income').setValue(total);

			/* Start Professional Tax */
			if (total > 0 && total <= 5999) {
				allowancesentryform.getForm().findField('Prof Tax').setValue('0')
			}

			else if (total >= 6000 && total <= 8999) {
				allowancesentryform.getForm().findField('Prof Tax').setValue('80')
			}
			else if (total >= 9000 && total <= 11999) {
				allowancesentryform.getForm().findField('Prof Tax').setValue('150')
			}
			else if (total >= 12000) {
				allowancesentryform.getForm().findField('Prof Tax').setValue('200');
			}
			/* End Professional Tax */


			updatnettotal();
		}

		var deduction = {
			xtype: 'fieldset',
			border: false,
			labelWidth: 50,
			items: [
				{
					xtype: 'container',
					border: false,
					layout: 'column',
					defaultType: 'field',
					items: [
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'GPF',
									hidden: false,
									anchor: '-20',
									name: 'GPF',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.48,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Fes Adv',
									hidden: false,
									anchor: '-30',
									name: 'Fest Adv',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'CPF',
									hidden: false,
									anchor: '-20',
									name: 'CPF',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Cr.Society',
									anchor: '-30',
									name: 'Society',
									hidden: false,
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},

						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.48,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'PF',
									anchor: '-30',
									name: 'Society-2',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}


							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'GPF Adv',
									hidden: false,
									anchor: '-20',
									name: 'GPF Loan',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'CM Fund',
									hidden: false,
									anchor: '-20',
									name: 'CPF Loan',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Sec.Deposit',
									anchor: '-30',
									name: 'PLI',
									hidden: false,
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									// fieldLabel : 'House Loan',
									hidden: true,
									anchor: '-20',
									name: 'House Loan',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									//fieldLabel : 'Transport',
									anchor: '-30',
									hidden: true,
									name: 'Recovery',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Prof Tax',
									anchor: '-20',
									name: 'Prof Tax',
									//readOnly:true,
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									//fieldLabel : 'Other',
									anchor: '-30',
									hidden: true,
									name: 'Group Ins',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'LIC',
									hidden: false,
									anchor: '-20',
									name: 'LIC',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.48,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'MIS-R-1',
									anchor: '-30',
									name: 'Mis.Rec.-1',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'I.Tax',
									anchor: '-20',
									hidden: false,
									name: 'Income Tax',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.47,
							labelWidth: 70,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'MIS-R-2 ',
									anchor: '-30',
									name: 'Mis.Rec.-2',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 70,
							width: 170,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Fan Adv',

									anchor: '-20',
									name: 'Food Adv',
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}
								}
							]

						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.55,
							labelWidth: 70,
							height: 130,
							items: [
								{
									xtype: 'numberfield',
									//fieldLabel : 'LWP',
									anchor: '-30',
									name: 'OtherD',
									hidden: true,
									allowNegative: false,
									emptyText: '0',
									autoCreate: { tag: 'input', type: 'text', maxlength: '5' },
									enableKeyEvents: true,
									listeners: {
										'keyup': {
											fn: function () {

												updatedeductiontotal();

											}
										}
									}

								}
							]
						},


						{
							xtype: 'container',
							layout: 'form',
							border: true,
							columnWidth: 0.7,
							labelWidth: 120,
							items: [
								{
									xtype: 'numberfield',
									fieldLabel: 'Gross Deduction',
									labelStyle: 'font-weight: bold; color:#23518D',
									anchor: '-30',
									name: 'Gross Deduction',
									emptyText: '0'
									//,readOnly:true

								}
							]
						}]
				}]
		};

		function updatedeductiontotal() {
			var total =
				Number(allowancesentryform.getForm().findField('GPF').getValue()) +
				Number(allowancesentryform.getForm().findField('CPF').getValue()) +
				Number(allowancesentryform.getForm().findField('GPF Loan').getValue()) +
				Number(allowancesentryform.getForm().findField('CPF Loan').getValue()) +
				Number(allowancesentryform.getForm().findField('House Loan').getValue()) +
				Number(allowancesentryform.getForm().findField('Prof Tax').getValue()) +
				Number(allowancesentryform.getForm().findField('LIC').getValue()) +
				Number(allowancesentryform.getForm().findField('Income Tax').getValue()) +
				Number(allowancesentryform.getForm().findField('Food Adv').getValue()) +
				Number(allowancesentryform.getForm().findField('Fest Adv').getValue()) +
				Number(allowancesentryform.getForm().findField('Society').getValue()) +
				Number(allowancesentryform.getForm().findField('Society-2').getValue()) +
				Number(allowancesentryform.getForm().findField('PLI').getValue()) +
				Number(allowancesentryform.getForm().findField('Recovery').getValue()) +
				Number(allowancesentryform.getForm().findField('Group Ins').getValue()) +
				Number(allowancesentryform.getForm().findField('Mis.Rec.-1').getValue()) +
				Number(allowancesentryform.getForm().findField('Mis.Rec.-2').getValue());





			allowancesentryform.getForm().findField('Gross Deduction').setValue(total);
			updatnettotal();

		}

		function updatnettotal() {
			var net = Number(allowancesentryform.getForm().findField('Gross Income').getValue()) -
				Number(allowancesentryform.getForm().findField('Gross Deduction').getValue());

			allowancesentryform.getForm().findField('Net Income').setValue(net);

		}

		var allowancesentryform = new Ext.FormPanel({
			url: 'save-employee-salary.php',
			method: 'post',
			labelWidth: 125,
			frame: true,
			items: [{
				layout: 'column',
				items: [
					{
						columnWidth: 0.5,
						layout: 'form',
						items: [{
							xtype: 'numberfield',
							name: 'employee_salno',
							id: 'employee_salno',
							labelSeparator: '',
							fieldLabel: labelArray[0],
							labelWidth: 100,
							allowBlank: false,
							disabled: false,
							width: 180,
							allowNegative: false,
							allowDecimals: false,
							autoCreate: { tag: 'input', type: 'text', maxlength: '10' }
						}]
					},
					{
						columnWidth: 0.5,
						layout: 'form',
						labelWidth: 125,
						items: [{

							xtype: 'combo',
							name: 'employee_name',
							id: 'employee_name',
							disabled: false,
							labelSeparator: '',
							fieldLabel: labelArray[1],
							forceSelection: true,
							hiddenName: 'salaryno_id',
							displayField: 'employee_name',
							valueField: 'employee_no',
							width: 180,
							emptyText: 'Please select Name',
							allowBlank: false,
							triggerAction: 'all',
							lastQuery: '',
							mode: 'remote',
							editable: false,
							store: employeestore,
							listeners: {
								select: {
									fn: function (combo, value) {
										allowancesentryform.getForm().findField('month_name').enable();
										allowancesentryform.getForm().findField('Year').enable();
										allowancesentryform.getForm().findField('month_name').reset();
										allowancesentryform.getForm().findField('Year').reset();

										////reaset
										resetbelow();
										allowancesentryform.getForm().findField('Gross Income').reset();
										allowancesentryform.getForm().findField('Gross Deduction').reset();
										allowancesentryform.getForm().findField('Net Income').reset();
										var salary = combo.getValue('salaryno_id');
										allowancesentryform.getForm().findField('employee_salno').setValue(salary);

										var i = employeestore.find('employee_no', salary);
										var record = employeestore.getAt(i);
										var basic=parseFloat(record.data.employee_basicsalary);

										var empid = record.data.employee_id;


										//payscale

										if (record.data.employee_payscale != 0) {
											var p = payscalestore.find('payscale_id', record.data.employee_payscale);
											var recordpayscale = payscalestore.getAt(p);
											var totalpayscale = recordpayscale.data.payscale;
											var payscale = parseFloat(totalpayscale.substring(totalpayscale.length - 8, totalpayscale.length - 3)); allowancesentryform.getForm().findField('Grade Pay/Dp').setValue(payscale);
										}
										allowancesentryform.getForm().findField('Basic').setValue(basic);
										allowancesentryform.getForm().findField('employee_id').setValue(empid);

										getallowancesdata(empid);
										getallowances();
										updateincometotal();
										updatedeductiontotal();


									}
								}
							}
						}]

					},
					{
						/////month


						xtype: 'container',
						layout: 'column',
						columnWidth: .50,
						defaultType: 'field',
						items: [{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.40,
							labelWidth: 45,
							items: [{
								xtype: 'combo',
								name: 'Year',
								id: 'Year',
								store: yearstore,
								labelSeparator: '',
								fieldLabel: labelArray[2],
								displayField: 'year_name',
								valueField: 'year_name',
								disabled: true,
								width: 90,
								typeAhead: true,
								selectOnFocus: true,
								forceSelection: true,
								triggerAction: 'all',
								emptyText: 'Year',
								editable: false,
								allowBlank: false,
								mode: 'local',
								listeners: {
									select: {
										fn: function (combo, value) {
											allowancesentryform.getForm().findField('month_name').reset();
											resetbelow();

										}
									}
								}
							}]
						},
						{
							xtype: 'container',
							layout: 'form',
							columnWidth: 0.45,
							labelWidth: 50,
							items: [{
								xtype: 'combo',
								name: 'month_name',
								id: 'month_name',
								labelSeparator: '',
								fieldLabel: labelArray[3],
								forceSelection: true,
								hiddenName: 'month_id',
								displayField: 'monthname',
								disabled: true,
								valueField: 'monthid',
								typeAhead: true,
								width: 106,
								emptyText: 'select Month',
								allowBlank: false,
								triggerAction: 'all',
								mode: 'local',
								editable: false,
								store: monthliststore,
								listeners: {
									select: {
										fn: function (combo, value) {
											resetbelow();
											var cnt = 0;
											var year = allowancesentryform.getForm().findField('Year').getValue();
											var month_id = combo.getValue('month_id');
											var employeeid = allowancesentryform.getForm().findField('employee_id').getValue();


											resetbelow();
											var varsalno = allowancesentryform.getForm().findField('employee_salno').getValue();
											var i = employeestore.find('employee_no', varsalno);
											var record = employeestore.getAt(i);
											var basic = record.data.employee_basicsalary;
											var name = record.data.employee_name;
											var empid = record.data.employee_id;
											var loan = record.data.loan_amount;
											var emploan = record.data.employee_loan;
											var emploandate = record.data.loan_date;
											var emploanmonth = record.data.loan_month;

											var fields = emploandate.split('-');
											var name = fields[1];
											var value = Math.round((name * 1) + 1);

											if (emploan == 'Loan') {

												var cal = Math.round((loan / emploanmonth));
												var intres = Math.round((loan * 1) / 100);
												var sum = Math.round((cal + intres));
												alert(sum);
											}

											if (emploan == 'Advanced') {

												if (month_id == value) {
													allowancesentryform.getForm().findField('Group Ins').setValue(loan);
												}
												else if (month_id == 1 && value == 13) {
													allowancesentryform.getForm().findField('Group Ins').setValue(loan);
												}
												else {
													allowancesentryform.getForm().findField('Group Ins').setValue(0);
												}

											}



											if (employeeid != "") {
												Ext.Ajax.request(
													{
														loadMask: true,
														sync: true,
														url: 'data/getprevioussalary.php',
														params: { month_id: month_id, employee_id: employeeid, year: year },
														success: function (resp) {

															var obj = Ext.decode(resp.responseText);
															recordset = obj.rows;

															if (recordset[0].basic != 0) { updatefields(recordset); }


															if (month_id == 7 && recordset[0].july_increment == 0 && recordset[0].basic == 0) {
																// alert(employeeid);
																Ext.MessageBox.confirm('Confirmation', 'Do u want to Update Basic Salary?', updatebasic);
															}
															else if (month_id == 7 && recordset[0].july_increment == 0 && recordset[0].basic != 0) {
																Ext.MessageBox.confirm('Confirmation', 'Do u want to Update Basic Salary?', updatebasic);

															}


														}
													});
											}
											else {
												Ext.MessageBox.show({
													title: 'Error',
													msg: 'Select Employee Name..',
													buttons: Ext.MessageBox.OK,
													icon: Ext.MessageBox.ERROR
												});
												allowancesentryform.getForm().findField('month_name').reset();

											}

											///for month and year


											Ext.Ajax.request(
												{
													loadMask: true,
													sync: true,
													url: 'data/checksalarydate.php',
													params: { month: month_id, employee_id: employeeid, year: year },
													success: function (resp) {
														var obj = Ext.decode(resp.responseText);
														recordset = obj.success;
														if (recordset == true) {

															Ext.MessageBox.show({
																title: 'Error',
																msg: 'Employee Salary Date Should Be Greter Than Joining Date',
																buttons: Ext.MessageBox.OK,
																icon: Ext.MessageBox.ERROR

															});

															allowancesentryform.getForm().findField('Year').reset();
															allowancesentryform.getForm().findField('month_name').reset();
															allowancesentryform.getForm().findField('Basic').reset();
															allowancesentryform.getForm().findField('DA').reset();
															allowancesentryform.getForm().findField('HRA').reset();
															allowancesentryform.getForm().findField('Grade Pay/Dp').reset();
															allowancesentryform.getForm().findField('Medical').reset();
															allowancesentryform.getForm().findField('CCA/CLA').reset();
															allowancesentryform.getForm().findField('Principal All').reset();
															allowancesentryform.getForm().findField('Supervisor All').reset();

															allowancesentryform.getForm().findField('Gross Income').reset();
															allowancesentryform.getForm().findField('Gross Deduction').reset();
															allowancesentryform.getForm().findField('Net Income').reset();

															allowancesentryform.getForm().findField('Prof Tax').reset();
															resetbelow();
														}
														else {
															var salary = allowancesentryform.getForm().findField('employee_name').getValue();
															allowancesentryform.getForm().findField('employee_salno').setValue(salary);

															var i = employeestore.find('employee_no', salary);
															var record = employeestore.getAt(i);
															var basic=parseFloat(record.data.employee_basicsalary);
															var empid = record.data.employee_id;





															//payscale
															var p = payscalestore.find('payscale_id', record.data.employee_payscale);
															var recordpayscale = payscalestore.getAt(p);
															var totalpayscale = recordpayscale.data.payscale;
															var payscale = parseFloat(totalpayscale.substring(totalpayscale.length - 8, totalpayscale.length - 3)); allowancesentryform.getForm().findField('Grade Pay/Dp').setValue(payscale);
															allowancesentryform.getForm().findField('Basic').setValue(basic);
															//getallowancesdata(employeeid);
															getallowances();
															updateincometotal();
															updatedeductiontotal();

														}

													}

												});
											///for month and year
										}
									}
								}

							}]
						}]


						////endmonth
					},{
						columnWidth: 0.5,
						layout: 'form',
						labelWidth: 125,
						items: [{

							xtype: 'numberfield',
							name: 'total_present',
							id: 'total_present',
							labelSeparator: '',
							fieldLabel: labelArray[4],
							labelWidth: 100,
							allowBlank: false,
							disabled: false,
							width: 180,
							value:'31',
							allowNegative: false,
							allowDecimals: false,
							autoCreate: { tag: 'input', type: 'text', maxlength: '31' }
						}]

					},]
			},
			{
				xtype: 'container',
				layout: 'column',
				defaultType: 'field',
				items: [{
					xtype: 'container',
					layout: 'form',
					columnWidth: .5,
					labelWidth: 100,
					items: [{
						id: 'Income',
						border: false,
						height: 430,
						frame: true,
						labelWidth: 100,
						width: 380,
						autoScroll: true,
						title: 'Income',
						items: [income]
					}]
				},
				{
					xtype: 'container',
					layout: 'form',
					columnWidth: .5,
					labelWidth: 100,
					items: [{
						id: 'deduction',
						border: false,
						height: 430,
						frame: true,
						labelWidth: 100,
						width: 380,
						autoScroll: true,
						title: 'Deduction',
						items: [deduction]
					}]
				}]
			}, {
				xtype: 'textfield',
				height: 10,
				name: 'employeesalary_id',
				id: 'employeesalary_id',
				hidden: true
			},
			{
				xtype: 'textfield',
				height: 10,
				name: 'employee_id',
				id: 'employee_id',
				hidden: true
			}
				, {
					xtype: 'textfield',
				height: 1,
				name: 'julycount',
				id: 'julycount',
				value: 0,
				hidden: true
			},
			{
				xtype: 'container',
				layout: 'form',
				border: true,
				columnWidth: 0.8,
				height: 10,
				labelWidth: 120,
				width: 300,
				items: [
					{
						xtype: 'numberfield',
						fieldLabel: 'Net Income',
						labelStyle: 'font-weight: bold; color:#F12536',
						anchor: '-10',
						name: 'Net Income',
						emptyText: '0'
						//,readOnly:true


					}
				]
			}
			]
		});

		function updatebasic(btn) {

			var section = Ext.getCmp('employee_section').getValue();
			var i = employeestore.find('employee_no', Ext.getCmp('employee_name').getValue());
			var record = employeestore.getAt(i);
			var basic = parseFloat(record.data.employee_basicsalary);
			var empid = record.data.employee_id;
			var payscale = (allowancesentryform.getForm().findField('Grade Pay/Dp').getValue());

			if (btn == 'yes') {

				newpayscale = Math.round((basic + payscale) * 0.03);
				newbasic = basic + (Math.round(newpayscale * 0.10) / 0.10);
				allowancesentryform.getForm().findField('Basic').setValue(newbasic);
				allowancesentryform.getForm().findField('julycount').setValue(1);
				getallowances()
				updateincometotal();
				updatedeductiontotal();
			}
			else {
				allowancesentryform.getForm().findField('julycount').setValue(0);
			}
		}
		function getallowances() {
			var basic = allowancesentryform.getForm().findField('Basic').getValue();
			allowancesstore.reload();
			for (var i = 0, len = allowancesstore.getCount(); i < len; i++) {
				var rc = allowancesstore.getAt(i);
				var name = rc.data.allowances_name;
				var da = parseFloat(rc.data.allowances_value);

				if (rc.data.allowances_percentage == 1) {
					value = Math.round((basic * da) / 100);
					allowancesentryform.getForm().findField(name).setValue(value);
				}
				else {
					allowancesentryform.getForm().findField
					{

						var dpay = (allowancesentryform.getForm().findField('Grade Pay/Dp').getValue());

						var da = parseFloat(rc.data.allowances_value);
						(name).setValue(da);
					}

					if (name == 'DA')
						if (rc.data.allowances_percentage == 1) {
							value = Math.round(((basic + dpay) * da) / 100);
							allowancesentryform.getForm().findField(name).setValue(value);
						}
						else {
							allowancesentryform.getForm().findField(name).setValue(da);
						}

				}

				if (name == 'HRA') {

					var dpay = (allowancesentryform.getForm().findField('Grade Pay/Dp').getValue());

					var da = parseFloat(rc.data.allowances_value);

					if (rc.data.allowances_percentage == 1) {
						value = Math.round(((basic + dpay) * da) / 100);
						allowancesentryform.getForm().findField(name).setValue(value);
					}
					else {
						allowancesentryform.getForm().findField(name).setValue(da);
					}

				}


			}
		}


		function resetbelow() {
			allowancesentryform.getForm().findField('Basic').reset();
			//allowancesentryform.getForm().findField('DA').reset();
			//allowancesentryform.getForm().findField('HRA').reset();
			//allowancesentryform.getForm().findField('Grade Pay/Dp').reset();
			//allowancesentryform.getForm().findField('Medical').reset();
			//allowancesentryform.getForm().findField('CCA/CLA').reset();
			//allowancesentryform.getForm().findField('Principal All').reset();
			//allowancesentryform.getForm().findField('Supervisor All').reset();
			allowancesentryform.getForm().findField('LTC').reset();
			allowancesentryform.getForm().findField('PTA').reset();
			allowancesentryform.getForm().findField('H.S.All').reset();
			allowancesentryform.getForm().findField('Wash All').reset();
			allowancesentryform.getForm().findField('Cash All').reset();
			allowancesentryform.getForm().findField('All/Family Planning').reset();
			allowancesentryform.getForm().findField('Handicap All').reset();
			allowancesentryform.getForm().findField('Transport All').reset();
			allowancesentryform.getForm().findField('Leave Encash').reset();
			allowancesentryform.getForm().findField('Special Pay').reset();
			allowancesentryform.getForm().findField('Bonus').reset();
			allowancesentryform.getForm().findField('Arias').reset();
			allowancesentryform.getForm().findField('Additional DA').reset();
			allowancesentryform.getForm().findField('IR').reset();
			allowancesentryform.getForm().findField('Other').reset();
			//allowancesentryform.getForm().findField('Gross Income').reset();
			//allowancesentryform.getForm().findField('Gross Deduction').reset();	
			//allowancesentryform.getForm().findField('Net Income').reset();					

			// deduction


			allowancesentryform.getForm().findField('GPF').reset();
			allowancesentryform.getForm().findField('CPF').reset();
			allowancesentryform.getForm().findField('GPF Loan').reset();
			allowancesentryform.getForm().findField('CPF Loan').reset();
			allowancesentryform.getForm().findField('House Loan').reset();
			//allowancesentryform.getForm().findField('Prof Tax').reset();
			allowancesentryform.getForm().findField('LIC').reset();
			allowancesentryform.getForm().findField('Income Tax').reset();
			allowancesentryform.getForm().findField('Food Adv').reset();
			allowancesentryform.getForm().findField('Fest Adv').reset();
			allowancesentryform.getForm().findField('Society').reset();
			allowancesentryform.getForm().findField('Society-2').reset();
			allowancesentryform.getForm().findField('PLI').reset();
			allowancesentryform.getForm().findField('Recovery').reset();
			allowancesentryform.getForm().findField('Group Ins').reset();
			allowancesentryform.getForm().findField('Mis.Rec.-1').reset();
			allowancesentryform.getForm().findField('Mis.Rec.-2').reset();
			allowancesentryform.getForm().findField('OtherD').reset();

			//allowancesentryform.getForm().findField('Gross Deduction').reset();	
			//allowancesentryform.getForm().findField('Net Income').reset();	
		}



		function updatefields(recordset) {

			allowancesentryform.getForm().findField('Basic').setValue(recordset[0].basic);
			allowancesentryform.getForm().findField('DA').setValue(recordset[0].da);
			allowancesentryform.getForm().findField('Grade Pay/Dp').setValue(recordset[0].dpay);
			allowancesentryform.getForm().findField('HRA').setValue(recordset[0].hra);
			allowancesentryform.getForm().findField('Medical').setValue(recordset[0].medical_all);
			allowancesentryform.getForm().findField('CCA/CLA').setValue(recordset[0].cla);
			allowancesentryform.getForm().findField('Principal All').setValue(recordset[0].princi_all);
			allowancesentryform.getForm().findField('Supervisor All').setValue(recordset[0].sup_all);
			allowancesentryform.getForm().findField('LTC').setValue(recordset[0].ltc);
			allowancesentryform.getForm().findField('PTA').setValue(recordset[0].pta);
			allowancesentryform.getForm().findField('H.S.All').setValue(recordset[0].hs_all);
			allowancesentryform.getForm().findField('Wash All').setValue(recordset[0].wash_all);
			allowancesentryform.getForm().findField('Cash All').setValue(recordset[0].cash_all);
			allowancesentryform.getForm().findField('All/Family Planning').setValue(recordset[0].family_all);
			allowancesentryform.getForm().findField('Handicap All').setValue(recordset[0].handicap_all);
			allowancesentryform.getForm().findField('Transport All').setValue(recordset[0].ta);
			allowancesentryform.getForm().findField('Leave Encash').setValue(recordset[0].leaveencash);
			allowancesentryform.getForm().findField('Special Pay').setValue(recordset[0].sp_pay);
			allowancesentryform.getForm().findField('Bonus').setValue(recordset[0].bonus);
			allowancesentryform.getForm().findField('Arias').setValue(recordset[0].arias_all);
			allowancesentryform.getForm().findField('Additional DA').setValue(recordset[0].add_da);
			allowancesentryform.getForm().findField('IR').setValue(recordset[0].ir1);
			allowancesentryform.getForm().findField('Other').setValue(recordset[0].oincome1);
			//allowancesentryform.getForm().findField('Gross Income').setValue(recordset[0].grosspay);


			// deduction


			allowancesentryform.getForm().findField('GPF').setValue(recordset[0].gpf);
			allowancesentryform.getForm().findField('CPF').setValue(recordset[0].cpf);
			allowancesentryform.getForm().findField('GPF Loan').setValue(recordset[0].gpfloan);
			allowancesentryform.getForm().findField('CPF Loan').setValue(recordset[0].cpfloan);
			allowancesentryform.getForm().findField('House Loan').setValue(recordset[0].houseloan);
			//allowancesentryform.getForm().findField('Prof Tax').setValue(recordset[0].pftax);
			allowancesentryform.getForm().findField('LIC').setValue(recordset[0].lic);
			allowancesentryform.getForm().findField('Income Tax').setValue(recordset[0].incometax);
			allowancesentryform.getForm().findField('Food Adv').setValue(recordset[0].foodadv);
			allowancesentryform.getForm().findField('Fest Adv').setValue(recordset[0].festadv);
			allowancesentryform.getForm().findField('Society').setValue(recordset[0].society);
			allowancesentryform.getForm().findField('Society-2').setValue(recordset[0].society_2);
			allowancesentryform.getForm().findField('PLI').setValue(recordset[0].pli);
			allowancesentryform.getForm().findField('Recovery').setValue(recordset[0].recadj);
			//	allowancesentryform.getForm().findField('Group Ins').setValue('5000');
			allowancesentryform.getForm().findField('Mis.Rec.-1').setValue(recordset[0].misec1);
			allowancesentryform.getForm().findField('Mis.Rec.-2').setValue(recordset[0].misrec2);
			allowancesentryform.getForm().findField('OtherD').setValue(recordset[0].odeduct1);
			allowancesentryform.getForm().findField('julycount').setValue(recordset[0].july_increment);

			//allowancesentryform.getForm().findField('Gross Deduction').setValue(recordset[0].grossdeduction);	
			//allowancesentryform.getForm().findField('Net Income').setValue(recordset[0].netpay);		
			updateincometotal();
			updatedeductiontotal();

		}

		function getallowancesdata(empid) {
			Ext.Ajax.request(
				{
					loadMask: true,
					sync: true,
					url: 'data/getprevioussalarymain.php',
					params: { employee_id: empid },
					success: function (resp) {

						var obj = Ext.decode(resp.responseText);
						recordset = obj.rows;
						if (recordset[0].basic != 0) {
							allowancesentryform.getForm().findField('Year').setValue(recordset[0].year);
							allowancesentryform.getForm().findField('month_name').setValue(recordset[0].month);
							updatefields(recordset);


						}
					}
				});

		}
		AllowancesWindow.on('hide', function () {
			getallowances();
			updateincometotal();
			updatedeductiontotal();
		});

		var AllowancesSalaryWindow = new Ext.Window({
			//	tbar: languageToolbar, 
			title: 'Employee Salary Muster',
			layout: 'fit',
			width: 800,
			autoScroll: true,
			border: false,
			height: 640,
			y: 100,
			x: 100,
			autoHeight: false,
			modal: true,
			border: false,
			closeAction: 'close',
			collapsible: 'true',
			bodyStyle: 'padding: 5px',
			items: allowancesentryform,
			buttons: [{
				text: 'To Change Percantage Of D.A,HRA Etc.',
				handler: function () {
					AllowancesWindow.show();
					Ext.getCmp('btnallowancesClose').hide();
				}
			},
			{
				text: 'Save',
				handler: function () {
					allowancesentryform.getForm().submit({
						waitMsg: 'Saving...',// Wait Message					
						success: function () {

							// When saving data success	
							Ext.MessageBox.show({
								title: 'Message',
								msg: 'Data has been saved',
								buttons: Ext.MessageBox.OK,
								icon: Ext.MessageBox.INFO
							});
							allowancesentryform.getForm().reset();

						},
						failure: function () {
							// when saving data failed
							Ext.MessageBox.show({
								title: 'Error',
								msg: 'Please fill complete form',
								buttons: Ext.MessageBox.OK,
								icon: Ext.MessageBox.ERROR
							});

						}
					});
				}
			},
			{
				text: 'Reset',
				handler: function () {

					allowancesentryform.getForm().reset();
					Ext.getCmp('employee_section').focus(true, 500);
				}
			},
			{
				text: 'Close',
				handler: function () {
					AllowancesSalaryWindow.close();

				}
			}]
		});

		allowancesentryform.getForm().findField('employee_salno').on('blur', function () {

			var varsalno = allowancesentryform.getForm().findField('employee_salno').getValue();

			//if(varsalno!="" && employeestore.findExact('employee_no',varsalno) != -1 )
			if (varsalno != "" && employeestore.find('employee_no', varsalno) != -1) {


				resetbelow();
				var i = employeestore.find('employee_no', varsalno);
				var record = employeestore.getAt(i);
				//  var basic=record.data.employee_basicsalary;
				var name = record.data.employee_name;
				var empid = record.data.employee_id;
				var loan = record.data.loan_amount;
				var emploan = record.data.employee_loan;
				var emploandate = record.data.loan_date;






				getallowancesdata(empid)
				//  allowancesentryform.getForm().findField('Basic').setValue(basic);
				allowancesentryform.getForm().findField('employee_name').setValue(name);
				allowancesentryform.getForm().findField('employee_id').setValue(empid);
				allowancesentryform.getForm().findField('month_name').enable();
				allowancesentryform.getForm().findField('Year').enable();



				var p = payscalestore.find('payscale_id', record.data.employee_payscale);
				var recordpayscale = payscalestore.getAt(p);
				var totalpayscale = recordpayscale.data.payscale;
				var payscale = parseFloat(totalpayscale.substring(totalpayscale.length - 8, totalpayscale.length - 3)); allowancesentryform.getForm().findField('Grade Pay/Dp').setValue(payscale);


				//  getallowances(basic);

				updateincometotal();
				updatedeductiontotal();


			}
			else if (varsalno == "") {
				allowancesentryform.getForm().findField('employee_name').reset();
				allowancesentryform.getForm().findField('employee_salno').reset();
				// allowancesentryform.getForm().findField('Basic').reset();
				allowancesentryform.getForm().findField('month_name').reset();
				allowancesentryform.getForm().findField('Year').reset();
				resetbelow();
			}
			else {
				allowancesentryform.getForm().findField('employee_name').reset();
				allowancesentryform.getForm().findField('employee_salno').reset();
				//  allowancesentryform.getForm().findField('Basic').reset();
				allowancesentryform.getForm().findField('month_name').reset();
				allowancesentryform.getForm().findField('Year').reset();
				resetbelow();
				Ext.MessageBox.show({
					title: 'Error',
					msg: 'Employee Salary No Does Not Exist',
					buttons: Ext.MessageBox.OK,
					icon: Ext.MessageBox.ERROR
				});
			}
		});

		var varWidth = (screen.width - AllowancesSalaryWindow.width) / 2;
		AllowancesSalaryWindow.setPosition(varWidth, ((screen.height / 4) - 190));
		AllowancesSalaryWindow.show();
		initIndicIME();
		SetSectionValue('add', sectionstore, 'employee_section', 'section_id');
		allowancesentryform.render('main-content');
	});
</script>
<!-- end custom CSS/JS -->
<div align="center">
	<div id="main-content" style="width:680px" align="left"></div>
</div>
<table align="center" width="600px">
	<tr>
		<td></td>
	</tr>
</table>
<?php require "_footer.php"; ?>