Project

General

Profile

Bug #1728 » controllerperformance.js

Tri Rizqiaty, 11/17/2022 03:31 PM

 
1
Ext.define('MinovaES.controller.performance.controllerperformance', {
2
	//extend: 'MinovaES.controller.masterdata.basemasterdata',
3
	extend : 'Ext.app.ViewController',
4
	alias : 'controller.performancemaintenance-controller',
5
	init : function () {
6
		this.control({
7
			'[name=addPerformance]' : {
8
				click : this.addPerformance,
9
			},
10
			'[name=editPerformance]' : {
11
				click : this.editPerformance,
12
			},
13
			'[name=cancelPerformance]' : {
14
				click : this.cancelPerformance,
15
			},
16
			'[name=PA0047]' : {
17
				itemdblclick : this.editPerformance,
18
				afterrender : this.afterRenderOverview
19
			},
20
			'[name=savePerformance]' : {
21
				click : this.savePerformance,
22
			},
23
			'[name=gotoother]' : {
24
				click : this.btnGoToother
25
			},
26
			'[name=deletePerformance]' : {
27
				click : this.deletePerformance,
28
			},
29
			'[name=AppraisalType]' : {
30
				select : this.createGridDetail,
31
			},
32
			'[name=gridPHRPA0048]' : {
33
				itemdblclick : this.addAppraiser,
34
			},
35
			'[name=gridPHRPA0049]' : {
36
				afteritemexpand : this.loadChild
37
			},
38
			/*'[name=AddKPI]' : {
39
			click : this.addNewKPI
40
			},*/
41
			'[name=BtnCancelKPI]' : {
42
				click : this.cancelAddNewKPI
43
			},
44
			/*'[name=BtnAddKPI]' : {
45
			click : this.addNewKPI
46
			},*/
47
			'[name=Action]' : {
48
				"onEditClick" : this.loadMenu
49
			},
50
			'[name=PHRPA0048Add]' : {
51
				//click : this.AddAppraiserQ // comment by Tri nwh 20221117
52
				click : this.ValidasiAppWeight // add by Tri nwh 20221117
53
			},
54
			'[name=PHRPA0049Add]' : {
55
				click : this.addNewKPI
56
			},
57
			'[name=PHRPA0051Add]' : {
58
				click : this.addNewQualification
59
			},
60
			'[name=PHRPA0051Delete]' : {
61
				click : this.deleteQualification
62
			},
63
			'[name=PHRPA0049Delete]' : {
64
				click : this.deleteKPI
65
			},
66
			/*'[id=PHRPA0049Unit]': {
67
				change: this.CalculateWeightedScore,
68
			}*/
69
		});
70
	},
71

    
72
	getRowIndex_ : function () {
73
		return this.rowIndex_;
74
	},
75
	setRowIndex_ : function (value) {
76
		var me = this;
77
		me.rowIndex_ = value;
78
		return me;
79
	},
80
	getRec : function () {
81
		return this.rec;
82
	},
83
	setRec : function (value) {
84
		var me = this;
85
		me.rec = value;
86
		return me;
87
	},
88

    
89
	/*CalculateWeightedScore : function () { ////-- add by Tri nwh 20220523 
90
		var Weight = Ext.ComponentQuery.query('[name=Weight][nameTable=PHRPA0049]')[0]; console.log(Weight.getValue);
91
		var Cal = Ext.ComponentQuery.query('[id=phrpa0049WeightedScore]')[0].setValue(Weight.getValue());
92
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
93
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
94
		var leafCount = 0;
95
		pnl.getRootNode().cascadeBy(function (node) {
96
			if (!node.isLeaf())
97
				leafCount++;
98
		});
99
		var data = '';
100
		var Sequence = 0;
101
		if (leafCount == 0) {
102
			Sequence = 1;
103
		} else {
104
			Sequence = 1 + leafCount;
105
		}
106

    
107

    
108
		var C = '';
109
		
110
		data = {
111
			KPIGroup : c,
112
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
113
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
114
			KPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
115
			Sequence : Sequence,
116
			ObjectDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
117
			SubKPI : "-",
118
			HeaderSequence : seq,
119
			SequenceSubKPI : "0",
120
			IsSubKPI : "0",
121
			leaf : false,
122
			Target : 1,
123
			expanded : true
124
		};
125

    
126
		var task = pnl.getRootNode();
127
		task.appendChild(data);
128
	},
129
	},*/
130
	
131
	afterRenderOverview : function () {
132
		var overView = Ext.StoreMgr.lookup("PerformanceOverview");
133

    
134
		overView.proxy.extraParams = {
135
			tableName : 'PHRPA0047',
136
			param : 'EmployeeID[=]' + getParam('EmployeeID')
137
		};
138
		overView.removeAll();
139
		overView.reload();
140
		overView.loadPage(1);
141
	},
142

    
143
	addPerformance : function () {
144
		var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
145
		card_.getLayout().setActiveItem(1);
146
		var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
147
		form_.getForm().reset();
148
		form_.getForm().findField('EmployeeID').setValue(getParam('EmployeeID'));
149
		var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
150
		delBtn_.setHidden(true);
151
		var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
152
		grid.removeAll();
153
		//form_.setActionSubmit(0);
154
		//this.setHeaderSeqEmpForm(0);
155

    
156
		var me = this;
157
		me._action = "0";
158
	},
159

    
160
	editPerformance : function () {
161
		var me = Ext.ComponentQuery.query('[name=PA0047]')[0];
162
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0]; // edit proses
163
		form.setActionSubmit(1);
164
		var selection = me.getView().getSelectionModel().getSelection()[0];
165
		var form_ = form.getForm();
166
		form_.setValues(selection.data);
167

    
168
		var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
169
		card_.getLayout().setActiveItem(1);
170
		var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
171
		delBtn_.setHidden(false);
172

    
173
		this.setGridPerformance('1');
174

    
175
		data = {
176
			AdjustedIndex : '',
177
			AdjustedScore : selection.data.AdjustedKPI,
178
			CalculatedScore : selection.data.CalculatedKPI,
179
			FinalScore : selection.data.KPIFinalScore,
180
			IndexScore : '',
181
			TotalScore : selection.data.KPITotalScore,
182
			Type : 'KPI',
183
			Weight : selection.data.KPITotalWeight
184
		};
185

    
186
		data2 = [];
187
		data2[0] = data;
188

    
189
		data = {
190
			AdjustedIndex : '',
191
			AdjustedScore : selection.data.AdjustedCompetency,
192
			CalculatedScore : selection.data.CalculatedCompetency,
193
			FinalScore : selection.data.QualFinalScore,
194
			IndexScore : '',
195
			TotalScore : selection.data.QualTotalScore,
196
			Type : 'Qualification',
197
			Weight : selection.data.QualTotalWeight //selection.data.QualificationPercen //// comment by Tri nwh 20220531
198
		};
199

    
200
		data2[1] = data;
201

    
202
		var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
203
		if (overView != undefined) {
204
			overView.removeAll();
205
			overView.loadData(data2);
206
		}
207

    
208
		dataTotal = {
209
			AdjustedIndex : selection.data.AdjustedIndex,
210
			AdjustedScore : selection.data.AdjustedScore,
211
			CalculatedScore : selection.data.CalculatedScore,
212
			IndexScore : selection.data.CalculatedIndex
213
		};
214

    
215
		dataTotalList = [];
216
		dataTotalList[0] = dataTotal;
217

    
218
		var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
219
		if (overView != undefined) {
220
			overView.removeAll();
221
			overView.loadData(dataTotalList);
222
		}
223
		setTimeout( () =>{ //// add by Tri nwh & saswanto 20220603 agar combobox keluar description
224
		var grid49 = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
225
		grid49.getView().refresh();
226
		
227
		var grid51 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
228
		grid51.getView().refresh();
229
		
230
		var gridSumTotal = Ext.ComponentQuery.query('[name=gridPDSPMSUMTOTAL]')[0];
231
		gridSumTotal.getView().refresh();
232
		
233
		}, 1000);
234
	},
235

    
236
	cancelPerformance : function () {
237
		var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
238
		card_.getLayout().setActiveItem(0);
239
	},
240

    
241
	createGridDetail : function (rec) {
242
		var me = this;
243
		var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
244
		var form = main.getForm();
245
		var SDate = form.findField("StartDate").getValue();
246
		var EDate = form.findField("EndDate").getValue();
247
		if (SDate == '' || SDate == undefined || EDate == '' || EDate == undefined) {
248
			MinovaMessage('', 'PMS0003', '', 'E');
249
			Ext.ComponentQuery.query('[name=AppraisalType]')[0].setValue('');
250
			return;
251
		}
252
		this.setGridPerformance('0');
253

    
254
		var appType = rec.getValue();
255
		
256
		// add by Tri nwh 20221115 start			
257
		MinovaUtil.ExecuteParamQuery({ 
258
			ID: "PMSAPPRAISER1",
259
			EmployeeID: getParam('EmployeeID')
260
		}, function (s) {
261
			var result = Ext.decode(s.responseText);
262
			var dt = Ext.decode(Ext.decode(result.data));
263
			var overView = Ext.StoreMgr.lookup('storePHRPA0048');
264
			if (overView != undefined) {
265
				overView.removeAll();
266
				overView.loadData(dt);
267
			}
268
			if (result.success) {
269
				MinovaMessage('', 'PMS0001', '', 'S');
270
			} else {}
271
		}, function (f) {});
272
		setTimeout( () =>{
273
		var grid48 = Ext.ComponentQuery.query('[name=gridPHRPA0048]')[0];
274
		grid48.getView().refresh();
275
		}, 1000);
276
		// add by Tri nwh 20221115 end	
277

    
278
		if (appType != 'G') {
279
			var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
280
			var form = main.getForm();
281
			var SDate = form.findField("StartDate").getValue();
282
			var EDate = form.findField("EndDate").getValue();
283
			var Data = undefined;
284
			
285
			/*var params = {	// comment by Tri nwh 20221115
286
				serviceName : 'Performance.asmx',
287
				methodName : 'SetDefaultAppraiser',
288
				parameter : 'EmployeeID=' + getParam('EmployeeID')
289
				 + '&StartDate=' + SDate
290
				 + '&EndDate=' + EDate
291
			};
292
			MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
293
				var result = Ext.decode(xhr.responseText);
294
				Data = result;
295
				var overView = Ext.StoreMgr.lookup('storePHRPA0048');
296
				if (overView != undefined) {
297
					overView.removeAll();
298
					overView.loadData(Ext.decode(Data.data));
299
				}
300
				if (result.success) {
301
					MinovaMessage('', 'PMS0001', '', 'S');
302
				} else {}
303
			});*/
304

    
305
			var params = {
306
				serviceName : 'Performance.asmx',
307
				methodName : 'SetDefaultKPI',
308
				parameter : 'EmployeeID=' + getParam('EmployeeID')
309
				 + '&StartDate=' + SDate
310
				 + '&EndDate=' + EDate
311
			};
312
			MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
313
				var result = Ext.decode(xhr.responseText);
314
				Data = result;
315
				var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
316
				if (pnl != undefined) {
317
					pnl.store.removeAll()
318
					pnl.store.load()
319
					pnl.store.setRootNode({
320
						expanded : true,
321
						nodetype : 'async',
322
						children : Ext.decode(Data.data)
323
					});
324
				}
325
				if (result.success) {}
326
				else {}
327
			});
328
		} 
329
		/*else { // comment by Tri nwh 20221115
330
			me.setDefaultAppbyOM();
331
		}*/ 
332
	},
333

    
334
	setGridPerformance : function (_a) {
335
		var me = this;
336
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
337
		var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
338
		var _empID = getParam('EmployeeID');
339
		grid.removeAll();
340

    
341
		try {
342
			var hasil = null;
343
			Ext.Ajax.request({
344
				async : false,
345
				method : 'POST',
346
				url : '/Performance/getListTableRef',
347
				params : {
348
					AppType : appType.getValue(),
349
					EmpID : _empID
350
				},
351
				success : function (response) {
352
					var results = Ext.decode(response.responseText);
353
					hasil = Ext.decode(results.data);
354
				}
355
			});
356

    
357
			if (hasil.length > 0) {
358
				Ext.Array.each(hasil, function (rec) {
359

    
360
					var _title = undefined;
361
					Ext.Ajax.request({
362
						async : false,
363
						//method : 'POST',
364
						url : '/UserControl/GetStore',
365
						params : {
366
							tableName : 'SDATATABLE',
367
							param : 'TableName[=]' + rec
368
						},
369

    
370
						success : function (response) {
371
							var results = Ext.decode(response.responseText);
372
							var dt = results.data[0];
373
							_title = dt.TableDescription;
374
						}
375
					});
376
					
377
					if (rec != 'PHRPA0049' && rec != 'PHRPA0051') {
378
						var _GridDetail = {
379
							xtype : 'fieldset',
380
							columnWidth : 0.5,
381
							title : _title,
382
							collapsible : true,
383
							defaultType : 'textfield',
384
							defaults : {
385
								anchor : '100%'
386
							},
387
							height : 400,
388
							layout : 'anchor',
389
							bbar : [{
390
									xtype : 'textfield',
391
									name : 'TotalScore' + rec,
392
									label : 'Total Score'
393
								}
394
							],
395
							items : [{
396
									xtype : 'minovapmseditablegrid',
397
									height : 300,
398
									autoLoad : false,
399
									autoScroll : true,
400
									tableName : rec,
401
									storeName : 'store' + rec,
402
									name : rec,
403
									hideButton : false,
404
									pagesize : 10,
405
									empID : getParam('EmployeeID'),
406
									apprasalType : appType.getValue(),
407
									listeners : {}
408
								}
409
							]
410
						};
411
						grid.add(_GridDetail);
412

    
413
						if (_a == '1') {
414
							me.getDataAppraiser(rec);
415
						}
416
					} else {
417
						var _GridDetail = {
418
							xtype : 'fieldset',
419
							columnWidth : 0.5,
420
							title : _title,
421
							collapsible : true,
422
							//defaultType : 'textfield',
423
							//autoScroll : true,
424
							defaults : {
425
								anchor : '100%'
426
							},
427
							height : 420,
428
							layout : 'anchor',
429
							items : [{
430
									xtype : 'Minovapmstreeeditablegrid',
431
											tableName : rec,
432
											height : 280,
433
											apprasalType : appType.getValue(),
434
											empID : getParam('EmployeeID'),
435
											autoScroll : true,
436
											hideButton : false,
437
											multiSelect : false,
438
									/*xtype : 'panel',
439
									name : 'Pnl' + rec,
440
									height : 380,
441
									width : '100%',
442
									autoScroll : true,
443
									/*items : [{
444
											xtype : 'Minovapmstreeeditablegrid',
445
											tableName : rec,
446
											height : 280,
447
											apprasalType : appType.getValue(),
448
											empID : getParam('EmployeeID'),
449
											autoScroll : true,
450
											hideButton : false,
451
											multiSelect : false
452
										}
453
									],*/
454
									tbar : [{
455
											xtype : 'toolbar',
456
											items : [{
457
													text : 'Add',
458
													name : rec + 'Add',
459
													iconCls : 'fa-plus-circle',
460
													style : 'font-family: FontAwesome'
461
												}, {
462
													text : 'Delete',
463
													name : rec + 'DeleteText',
464
													iconCls : 'fa-trash-o',
465
													style : 'font-family: FontAwesome',
466
													//disabled: true
467
													handler : function () {
468
														var me = this;
469
														var grid = Ext.ComponentQuery.query('[name=grid'+rec+']')[0]; //add by Tri nwh 20221116 start
470
														Ext.MessageBox.show({
471
															title : 'Remove tab',
472
															msg : "This will remove. Do you want to continue?",
473
															buttons : Ext.MessageBox.YESNO,
474
															fn : function (choice) {
475
																console.log(choice);
476
																if (choice === 'yes') {
477
																	var record = grid.getView().selection;
478
																	record.remove();
479
																}
480
															}
481
														});  //add by Tri nwh 20221116 end
482
														/*store = Ext.StoreMgr.lookup(storeID); //comment by Tri nwh 20221116 start
483
														var grid = Ext.getCmp(gridName);
484
														Ext.MessageBox.show({
485
															title : 'Remove tab',
486
															msg : "This will remove. Do you want to continue?",
487
															buttons : Ext.MessageBox.YESNO,
488
															fn : function (choice) {
489
																console.log(choice);
490
																if (choice === 'yes') {
491
																	var selection = grid.getView().getSelectionModel().getSelection()[0]; 
492
																	if (selection) {
493
																		store.remove(selection);
494
																	}
495
																}
496
															}
497
														});*/ //comment by Tri nwh 20221116 end
498
													}
499
												}
500
											]
501
										}
502
									]
503
								}
504

    
505
							]
506
						};
507
						grid.add(_GridDetail);
508

    
509
						if (_a == '1') {
510
							var pnl = Ext.ComponentQuery.query('[name=grid' + rec + ']')[0];
511
							var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
512
							var data_kpi = null;
513
							var url = null;
514
							if (rec == 'PHRPA0049') {
515
								url = '/Performance/getKPI';
516

    
517
								Ext.Ajax.request({
518
									//method : 'POST',
519
									async : false,
520
									url : url,
521
									params : {
522
										EmpID : getParam('EmployeeID'),
523
										Seq : seq.getValue(),
524
										AppType : appType.getValue()
525
									},
526
									success : function (response) {
527
										var results = Ext.decode(response.responseText);
528
										data_kpi = Ext.decode(results.data);
529
									}
530
								});
531

    
532
								pnl.store.setRootNode({
533
									expanded : true,
534
									nodetype : 'async',
535
									children : data_kpi
536
									//[]
537
								});
538
							} 
539
							else if (rec == 'PHRPA0051') { 
540
								//// -- add by Tri nwh 20220531
541
								param = 'EmployeeID[=]' + getParam('EmployeeID')
542
									 + ',HeaderSequence[=]' + seq.getValue()
543
									 + ',AppraisalType[=]' + appType.getValue();
544
								Ext.Ajax.request({
545
									async : false,
546
									url : '/UserControl/GetStore',
547
									params : {
548
										tableName : 'PHRPA0051',
549
										param : param
550
									},
551
									success : function (response) {
552
										var results = Ext.decode(response.responseText);
553
										var data_ = results.data;
554
										var pnl2 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0]; 
555
										pnl2.store.setRootNode({
556
											expanded : true,
557
											nodetype : 'async',
558
											children : data_
559
										});
560
									}
561
								});
562
								//// -- end add by Tri nwh 20220531
563
							}
564
							//me.loadQualification();
565
						}
566
					}
567
				});
568
			} else {}
569

    
570
			if (appType.getValue() == 'P' || appType.getValue() == 'F') {
571
				var _title = undefined;
572
				Ext.Ajax.request({
573
					async : false,
574
					//method : 'POST',
575
					url : '/UserControl/GetStore',
576
					params : {
577
						tableName : 'SDATATABLE',
578
						param : 'TableName[=]' + 'PDSPMSUMMARY'
579
					},
580

    
581
					success : function (response) {
582
						var results = Ext.decode(response.responseText);
583
						var dt = results.data[0];
584
						_title = dt.TableDescription;
585
					}
586
				});
587

    
588
				var _GridDetail = {
589
					xtype : 'fieldset',
590
					columnWidth : 0.5,
591
					title : _title,
592
					collapsible : true,
593
					defaultType : 'textfield',
594
					defaults : {
595
						anchor : '100%'
596
					},
597
					height : 420,
598
					layout : 'anchor',
599
					items : [{
600
							xtype : 'Minovaeditablegrid',
601
							autoLoad : false,
602
							hideButton : true,
603
							autoScroll : true,
604
							height : 200,
605
							layout : 'fit',
606
							tableName : 'PDSPMSUMMARY',
607
							storeName : 'store' + 'PDSPMSUMMARY',
608
							name : 'PDSPMSUMMARY',
609
							empID : getParam('EmployeeID'),
610
							apprasalType : appType.getValue(),
611
							tbar : [{
612
									xtype : 'toolbar',
613
									docked : 'top',
614
									items : [{
615
											xtype : 'button',
616
											text : 'Calculate',
617
											name : 'Calculate',
618
											handler : function () {
619
												me.calculatePMS()
620
											}
621
										}
622
										/*,{
623
										xtype : 'button',
624
										text : 'Save to Profile',
625
										name : 'SaveProfile',
626
										handler : function () {
627
										me.SaveToMDHistory()
628
										}
629
										}*/
630
									]
631
								}
632
							]
633
						}, {
634
							xtype : 'Minovaeditablegrid',
635
							autoLoad : false,
636
							hideButton : true,
637
							autoScroll : true,
638
							height : 200,
639
							layout : 'fit',
640
							tableName : 'PDSPMSUMTOTAL',
641
							storeName : 'store' + 'PDSPMSUMTOTAL',
642
							name : 'PDSPMSUMTOTAL'
643
						}
644
					]
645
				};
646
				grid.add(_GridDetail);
647
			}
648

    
649
		} catch (exc) {}
650
	},
651

    
652
	savePerformance : function () {
653
		var me = this;
654
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
655
		var form_ = form.getForm();
656
		var data = form_.getValues();
657
		var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
658
		var treestore = undefined;
659
		if (treepnl != undefined) {
660
			treepnl.expandAll();
661
			treestore = treepnl.store;
662
			Ext.Array.each(treestore.data.items, function (rec) {
663
				rec.expand(true);
664
			})
665
		}
666
		var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
667
		var storequal = undefined;
668
		if (pnlqual != undefined) {
669
			pnlqual.expandAll();
670
			storequal = pnlqual.store;
671
			Ext.Array.each(storequal.data.items, function (rec) {
672
				rec.expand(true);
673
			})
674
		}
675
		form.mask('Loading...');
676
		var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
677
		var PA0049 = Ext.StoreMgr.lookup("storePHRPA0049");
678
		var PA0049A = Ext.StoreMgr.lookup("storePHRPA0049A");
679
		var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
680
		var PA0048_dATA = null;
681
		var PA0049_dATA = null;
682
		var PA0049A_dATA = null;
683
		var PA0051_dATA = null;
684
		var TREE_dATA = null;
685

    
686
		if (PA0048 != undefined)
687
			PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
688
		if (PA0049 != undefined)
689
			PA0049_dATA = Ext.encode(Ext.pluck(PA0049.data.items, 'data'));
690
		if (PA0049A != undefined)
691
			PA0049A_dATA = Ext.encode(Ext.pluck(PA0049A.data.items, 'data'));
692
		if (storequal != undefined) {
693
			var _data = Ext.pluck(storequal.data.items, 'data');
694
			Ext.Array.each(_data, function (rec) {
695
				rec.children = null
696
			})
697
			PA0051_dATA = Ext.encode(_data);
698
		}
699
		if (treepnl != undefined)
700
			TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
701

    
702
		if (data.AppraisalType != "G") {
703
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
704
			var form_ = form.getForm();
705
			var data = form_.getValues();
706
			var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
707
			if (Sum.data.items.length > 0) {
708
				var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
709
				Ext.Array.each(Ext.decode(DataSum), function (rec) {
710
					if (rec.Type == "KPI") {
711
						data["AdjustedKPI"] = rec.AdjustedScore;
712
						data["CalculatedKPI"] = rec.CalculatedScore;
713
						data["KPIFinalScore"] = rec.FinalScore;
714
						data["KPITotalScore"] = rec.TotalScore;
715
						data["KPITotalWeight"] = rec.Weight;
716
					} else {
717
						data["AdjustedCompetency"] = rec.AdjustedScore;
718
						data["CalculatedCompetency"] = rec.CalculatedScore;
719
						data["QualFinalScore"] = rec.FinalScore;
720
						data["QualTotalScore"] = rec.TotalScore;
721
						data["QualTotalWeight"] = rec.Weight;
722
					}
723
				})
724
			}
725
			var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
726
			var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
727
			if (dataTotalSum.length > 0) {
728
				data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
729
				data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
730
				data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
731
				data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
732
			}
733
		}
734
		var params = {		//// add by Tri nwh 20220602
735
			serviceName : 'Performance.asmx',
736
			methodName : 'savePerformance',
737
			parameter :
738
			'header=' + Ext.encode(data)
739
			 + '&PA0048=' + PA0048_dATA
740
			 + '&PA0049=' + TREE_dATA
741
			 + '&PA0049A=' + TREE_dATA
742
			 + '&PA0051=' + PA0051_dATA
743
			 + '&Token=' + MinovaUtil.SESSIONS.Token
744
		};
745
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
746
			var result = Ext.decode(xhr.responseText);
747
			console.log(result.success);
748
			var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
749
			card_.getLayout().setActiveItem(0);
750
			MinovaMessage('', '000006', '', 'S');
751
			if (data.AppraisalType == "F") {
752
				//me.SaveToMDHistory();
753
				//me.saveToMDProfile();
754
			}
755
			me.afterRenderOverview();
756
			form.unmask();
757
		});
758
	},
759

    
760
	btnGoToother : function () {
761
		var menu_ = [];
762
		var Y = 180;
763

    
764
		menu_.push({
765
			text : 'Employee Search',
766
			handler : function () {
767
				Ext.create('Ext.window.Window', {
768
					title : 'Lookup - Employee',
769
					height : 530,
770
					width : 500,
771
					name : 'lookupMain',
772
					modal : true,
773
					items : [{
774
							xtype : 'minovaform',
775
							bodyBorder : false,
776
							MaxHeigth : '100',
777
							cls : 'borderLookup',
778
							border : false,
779
							MaxHeigth : '30',
780
							scroll : true,
781
							isLookup : true,
782
							name : "formLookupFilter",
783
							tableName : 'PDSEMP0002',
784
							buttons : [{
785
									text : 'Search',
786
									handler : function () {
787
										var store = Ext.data.StoreManager.lookup('lookupStore');
788
										var form = Ext.ComponentQuery.query('[name=formLookupFilter]')[0].getForm();
789
										grid = Ext.ComponentQuery.query('[name=gridLookup]')[0];
790
										var values_ = form.getValues();
791
										var fields_ = form.getFields().items;
792
										var param_ = '';
793
										for (var i = 0; i < fields_.length; i++) {
794
											var val_ = form.getFields().items[i].getValue();
795
											var xtype_ = form.getFields().items[i].xtype;
796
											var oprator_ = '[like]';
797
											if (xtype_ == 'combobox' || xtype_ == 'combo' || xtype_ == 'minovacombo' || xtype_ == 'minovacombobox') {
798
												oprator_ = '[Equal]';
799
											}
800
											if (xtype_ == 'datefield') {
801
												if (form.getFields().items[i].name == 'StartDate' || form.getFields().items[i].name == 'ValidForm') {
802
													oprator_ = '[LessThanEqual]';
803
												} else {
804
													oprator_ = '[GreaterThanEqual]';
805
												}
806
											}
807
											if (val_ != 'undefined' && val_ != "" && val_ != null) {
808
												param_ = param_ + ',' + form.getFields().items[i].name + oprator_ + val_;
809
											}
810
										}
811
										store.proxy.extraParams = {
812
											tableName : grid.tableName,
813
											param : param_,
814
											menuId : MinovaUtil.GetMenuID()
815
										};
816
										store.removeAll();
817
										store.reload();
818
										store.loadPage(1);
819
									}
820

    
821
								}
822
							],
823
						}, {
824
							xtype : 'minovagrid1',
825
							isLookup : 1,
826
							minHeight : 280,
827
							height : 280,
828
							tableName : 'PDSEMP0002',
829
							param : '',
830
							isLookup : true,
831
							autoLoad : false,
832
							name : 'gridLookup',
833
							hidebutton : 0,
834
							pagesize : 25,
835
							storename : 'lookupStore',
836
							listeners : {
837
								itemdblclick : function (g) {
838
									var dataSelection = this.getView().getSelectionModel().getSelection()[0].data;
839
									//console.log(dataSelection)
840
									var url = MinovaUtil.GetMenuID() + '&EmployeeID=' + dataSelection.EmployeeID + '&FullName=' + dataSelection.FullName + '&Lang=' + localStorage.LangId;
841
									var mb = new minovaBlowfish();
842
									e = mb.minovaEncryptUrl(url);
843
									window.open('masterdataperformancedetail?' + e, "_self");
844

    
845
								},
846
								beforeedit : function (grid) {
847
									return false;
848
								}
849
							},
850
							dockedItems : [{
851
									xtype : 'pagingtoolbar',
852
									store : 'lookupStore',
853
									dock : 'bottom',
854
									pageSize : 25,
855
									displayInfo : true
856
								}
857
							]
858

    
859
						}, ]
860
				}).show();
861
			}
862
		});
863
		menu_.push({
864
			text : 'Back',
865
			handler : function () {
866
				window.history.back();
867
			}
868
		});
869
		Ext.create('Ext.menu.Menu', {
870
			name : 'panelMenu',
871
			width : 240,
872
			height : 100,
873
			margin : '0 0 10 0',
874

    
875
			items : menu_
876
		}).showAt([1239, Y]);
877
	},
878

    
879
	deletePerformance : function () {
880
		var me = this;
881
		var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0];
882
		var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0];
883
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
884
		var Sequence = Ext.ComponentQuery.query('[name=Sequence]')[0];
885
		var _empID = getParam('EmployeeID');
886

    
887
		Ext.Ajax.request({
888
			async : false,
889
			method : 'POST',
890
			url : '/Performance/deleteData',
891
			params : {
892
				EmpID : _empID,
893
				Seq : Sequence.getValue(),
894
				AppType : appType.getValue(),
895
				StDate : StartDate.getValue(),
896
				EnDate : EndDate.getValue()
897
			},
898
			waitMsg : 'Deleting Data...',
899
			success : function (response) {
900

    
901
				var result = Ext.decode(response.responseText);
902
				if (result.success) {
903
					var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
904
					card_.getLayout().setActiveItem(0);
905
					MinovaMessage('', '000006', '', 'S');
906
					me.afterRenderOverview();
907
					//pnl.unmask();
908
				} else {
909
					//.unmask();
910
					//MinovaMessage('', result.message.id, result.message.text, "E");
911
					MinovaMessage('', '000005', result.message.text, "E")
912
				}
913
			},
914
			failure : function (response) {
915
				var result = Ext.decode(response.responseText);
916
				//pnl.unmask();
917
				// MinovaMessage('', result.message.id, result.message.text, "E")
918
				MinovaMessage('', '000005', result.message.text, "E")
919
			}
920
		});
921

    
922
		me.afterRenderOverview();
923
	},
924

    
925
	addAppraiser : function () {
926
		var grid = Ext.getCmp('gridPHRPA0048');
927
		var record = grid.getSelectionModel().getSelection()[0];
928
		record.set('EmployeeID', getParam('EmployeeID'));
929
	},
930

    
931
	getDataAppraiser : function (tblName) {
932
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
933
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
934
		var overView = Ext.StoreMgr.lookup('store' + tblName);
935
		var param = null;
936
		var data_kpi = null;
937

    
938
		if (tblName == 'PHRPA0049') {
939
			var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
940
			Ext.Ajax.request({
941
				//method : 'POST',
942
				async : false,
943
				url : '/Performance/getKPI',
944
				params : {
945
					EmpID : _empID,
946
					Seq : seq.getValue(),
947
					AppType : appType.getValue()
948
				},
949
				success : function (response) {
950
					var results = Ext.decode(response.responseText);
951
					data_kpi = Ext.decode(results.data);
952
				}
953
			});
954
			pnl.store.setRootNode({
955
				expanded : true,
956
				nodetype : 'async',
957
				children : data_kpi
958
				//[]
959
			});
960
		} else {
961
			param = 'EmployeeID[=]' + getParam('EmployeeID')
962
				 + ',HeaderSequence[=]' + seq.getValue()
963
				 + ',AppraisalType[=]' + appType.getValue();
964
			Ext.Ajax.request({
965
				//method : 'POST',
966
				async : false,
967
				url : '/UserControl/GetStore',
968
				params : {
969
					tableName : tblName,
970
					param : param
971
				},
972
				success : function (response) {
973
					var results = Ext.decode(response.responseText);
974

    
975
					if (tblName != 'PHRPA0049') {
976
						overView.removeAll();
977
						overView.loadData(results.data);
978
					} else {
979
						var data_ = results.data;
980
						var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
981
						pnl.store.setRootNode({
982
							expanded : true,
983
							nodetype : 'async',
984
							children : data_
985
							//[]
986
						});
987
					}
988
				}
989
			});
990
		}
991
		//overView.removeAll();
992
		//overView.reload();
993
		//overView.loadPage(1);
994
	},
995

    
996
	loadChild : function (node, index, item, eOpts) {
997
		var me = this;
998
		var _empID = getParam('EmployeeID');
999
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1000
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1001
		var data_ = null;
1002
		var idx = 0;
1003
		var tree_ = Ext.ComponentQuery.query('treepanel[name=gridPHRPA0049]')[0];
1004
		var v = tree_.getView();
1005

    
1006
		if (node.data.IsSubKPI == '1') {
1007
			return;
1008
		}
1009

    
1010
		tree_.mask('Expanding tree...');
1011

    
1012
		Ext.Ajax.request({
1013
			//method : 'POST',
1014
			async : false,
1015
			url : '/Performance/getSubKPI',
1016
			params : {
1017
				EmpID : _empID,
1018
				Seq : seq.getValue(),
1019
				AppType : appType.getValue(),
1020
				KPIID : node.data.KPI,
1021
				KPISeq : node.data.Sequence
1022
			},
1023
			success : function (response) {
1024
				var results = Ext.decode(response.responseText);
1025
				data_ = Ext.decode(results.data);
1026
			}
1027
		});
1028

    
1029
		if (data_.length > 0) {
1030
			data_.forEach(function (rec) {
1031
				if (v.store.data.find('SequenceSubKPI', rec.SequenceSubKPI) == null) {
1032
					node.appendChild(data_[idx])
1033
				}
1034
				idx++;
1035
			})
1036
		}
1037

    
1038
		tree_.unmask();
1039
	},
1040

    
1041
	addNewKPI : function () {
1042
		var me = this;
1043
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewKPI]').length;
1044
		if (count_lookup == 1) {
1045
			Ext.ComponentQuery.query('[name=AddNewKPI]')[0].show();
1046
		} else {
1047
			Ext.create('Ext.window.Window', {
1048
				title : 'Add KPI',
1049
				name : 'AddNewKPI',
1050
				layout : 'fit',
1051
				items : [{
1052
						xtype : 'form',
1053
						name : 'formAddKPI',
1054
						items : [{
1055
								xtype : 'minovaForm',
1056
								bodyBorder : false,
1057
								cls : 'borderLookup',
1058
								border : false,
1059
								isLookup : false,
1060
								name : "mainformAddKPI",
1061
								tableName : 'PDSPMLOOKUPKPI'
1062
							}
1063
						]
1064
					}
1065
				],
1066
				buttons : [{
1067
						text : 'Add KPI',
1068
						name : 'BtnAddKPI',
1069
						iconCls : 'fa-save',
1070
						style : 'font-family: FontAwesome',
1071
						margin : '3 3 10 3',
1072
						handler : function () {
1073
							me.addNewKPItoGrid();
1074
						}
1075
					}, {
1076
						text : 'Cancel',
1077
						name : 'BtnCancelKPI',
1078
						iconCls : 'fa-reply',
1079
						style : 'font-family: FontAwesome',
1080
						margin : '3 3 10 3',
1081
						handler : function () {
1082
							me.cancelAddNewKPI();
1083
						}
1084
					}
1085
				]
1086
			}).show();
1087
		}
1088
	},
1089

    
1090
	cancelAddNewKPI : function () {
1091
		Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1092
	},
1093

    
1094
	addNewKPItoGrid : function () {
1095
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1096
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1097
		var leafCount = 0;
1098
		pnl.getRootNode().cascadeBy(function (node) {
1099
			if (!node.isLeaf())
1100
				leafCount++;
1101
		});
1102
		var data = '';
1103
		var Sequence = 0;
1104
		if (leafCount == 0) {
1105
			Sequence = 1;
1106
		} else {
1107
			Sequence = 1 + leafCount;
1108
		}
1109

    
1110
		var a = Ext.ComponentQuery.query('[name=mainformAddKPI]')[0];
1111
		var b = a.getValues();
1112
		var C = '';
1113

    
1114
		Ext.Ajax.request({
1115
			method : 'POST',
1116
			async : false,
1117
			url : '/UserControl/GetStore',
1118
			params : {
1119
				tableName : 'PHROM0002',
1120
				param : 'ObjectClass[=]KG,RelationshipClass[=]K,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=KPI]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1121
			},
1122
			success : function (response) {
1123
				var results = Ext.decode(response.responseText);
1124
				if (results.data != null && results.data.length > 0) {
1125
					c = results.data[0].ObjectID;
1126
				}
1127
			}
1128
		});
1129

    
1130
		data = {
1131
			KPIGroup : c,
1132
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1133
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1134
			KPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1135
			Sequence : Sequence,
1136
			ObjectDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1137
			SubKPI : "-",
1138
			HeaderSequence : seq,
1139
			SequenceSubKPI : "0",
1140
			IsSubKPI : "0",
1141
			leaf : false,
1142
			Target : 1,
1143
			expanded : true
1144
			,App2Value : 0			//// ---- add by Tri nwh 20221114
1145
			,App3Value : 0		
1146
			,App4Value : 0		
1147
			,App5Value : 0
1148
			,App1Score : 0			
1149
			,App2Score : 0		
1150
			,App3Score : 0		
1151
			,App4Score : 0
1152
			,App5Score : 0				
1153
		};
1154

    
1155
		var task = pnl.getRootNode();
1156
		task.appendChild(data);
1157
		Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1158
	},
1159

    
1160
	addNewsubKPI : function (record) {
1161
		var me = this;
1162
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewsubKPI]').length;
1163
		if (count_lookup == 1) {
1164
			Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].show();
1165
		} else {
1166
			Ext.create('Ext.window.Window', {
1167
				title : 'Add subKPI',
1168
				name : 'AddNewsubKPI',
1169
				layout : 'fit',
1170
				items : [{
1171
						xtype : 'form',
1172
						name : 'formAddsubKPI',
1173
						items : [{
1174
								xtype : 'minovaForm',
1175
								bodyBorder : false,
1176
								cls : 'borderLookup',
1177
								border : false,
1178
								isLookup : false,
1179
								name : "mainformAddsubKPI",
1180
								tableName : 'PDSPMLOOKUPKPI'
1181
							}
1182
						]
1183
					}
1184
				],
1185
				buttons : [{
1186
						text : 'Add subKPI',
1187
						name : 'BtnAddsubKPI',
1188
						iconCls : 'fa-save',
1189
						style : 'font-family: FontAwesome',
1190
						margin : '3 3 10 3',
1191
						handler : function () {
1192
							me.addNewsubKPItoGrid(record);
1193
						}
1194
					}, {
1195
						text : 'Cancel',
1196
						name : 'BtnCancelsubKPI',
1197
						iconCls : 'fa-reply',
1198
						style : 'font-family: FontAwesome',
1199
						margin : '3 3 10 3',
1200
						handler : function () {
1201
							Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1202
						}
1203
					}
1204
				]
1205
			}).show();
1206
		}
1207
	},
1208

    
1209
	addNewsubKPItoGrid : function (record) {
1210
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1211
		var leafCount = 0;
1212
		var _empID = getParam('EmployeeID');
1213
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1214
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1215
		var i = 0;
1216
		var data_ = null;
1217
		Ext.Ajax.request({
1218
			async : false,
1219
			url : '/Performance/getSubKPI',
1220
			params : {
1221
				EmpID : _empID,
1222
				Seq : seq.getValue(),
1223
				AppType : appType.getValue(),
1224
				KPIID : record.data.KPI,
1225
				KPISeq : record.data.Sequence
1226
			},
1227
			success : function (response) {
1228
				var results = Ext.decode(response.responseText);
1229
				data_ = Ext.decode(results.data);
1230
			}
1231
		});
1232
		if (data_.length == 0) {
1233
			i = 1;
1234
		} else {
1235
			i += data_.length;
1236
		}
1237

    
1238
		var data = {
1239
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1240
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1241
			KPI : record.data.KPI,
1242
			ObjectDescription : record.data.ObjectDescription,
1243
			Sequence : record.data.Sequence,
1244
			HeaderSequence : seq.getValue(),
1245
			SequenceSubKPI : i,
1246
			IsSubKPI : "1",
1247
			SubKPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1248
			SubKPIDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1249
			leaf : true
1250
		};
1251

    
1252
		record.appendChild(data);
1253
		Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1254
	},
1255

    
1256
	loadMenu : function () {
1257
		var me = this;
1258
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1259
		var record = main_.getView().selection;
1260
		var _a = record.data.leaf;
1261
		var _kpi = record.data.KPI;
1262
		var rowIndex = record.data.index;
1263
		var n = rowIndex * 50;
1264
		var Y = 180 + n;
1265
		var menu_ = []
1266

    
1267
		if (!_a) {
1268
			menu_.push({
1269
				text : 'Delete KPI',
1270
				handler : function () {
1271
					me.deleteSubKPI(record);
1272
				}
1273
			})
1274
			menu_.push({
1275
				text : 'Add subKPI',
1276
				handler : function () {
1277
					me.addNewsubKPI(record);
1278
				}
1279
			})
1280
			menu_.push({
1281
				text : 'Delete All subKPI',
1282
				handler : function () {}
1283
			})
1284
		} else {
1285
			menu_.push({
1286
				text : 'Delete subKPI',
1287
				handler : function () {
1288
					me.deleteSubKPI(record);
1289
				}
1290
			})
1291
		}
1292

    
1293
		Ext.create('Ext.menu.Menu', {
1294
			name : 'panelMenu',
1295
			width : 240,
1296
			height : 150,
1297
			margin : '0 0 10 0',
1298
			items : menu_
1299
		}).showAt([1239, Y]);
1300
	},
1301

    
1302
	ValidasiAppWeight : function () { // add by Tri nwh 20221117
1303
		var me = this;
1304
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1305
		var form_ = form.getForm();
1306
		var data = form_.getValues();
1307
		var Sum = Ext.StoreMgr.lookup("storePHRPA0048");
1308
		var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1309
		var SumKPIWeight = 0;
1310
		var SumQualWeight = 0;
1311
		var idx = Sum.getCount();
1312
		var data = '';
1313
		Ext.Array.each(Ext.decode(DataSum), function (rec) {
1314
			SumKPIWeight = parseFloat(SumKPIWeight) + parseFloat(rec.KPIWeight);
1315
			SumQualWeight = parseFloat(SumQualWeight) + parseFloat(rec.QualificationWeight);
1316
			if(SumKPIWeight >= 100)
1317
			{
1318
				MinovaMessage('', 'PMSE005', '', 'E');
1319
				store.remove(idx, data);
1320
			}
1321
			if(SumQualWeight >= 100)
1322
			{
1323
				MinovaMessage('', 'PMSE006', '', 'E');
1324
				store.remove(idx, data);
1325
			}
1326
		})
1327
	},
1328

    
1329
	AddAppraiserQ : function () { },
1330

    
1331
	deleteSubKPI : function (a) {
1332
		/*var main_ = Ext.ComponentQuery.query('[name=PHRPA0049]')[0];
1333
		var record = main_.getView().selection;
1334
		var _empID = getParam('EmployeeID');
1335
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1336
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1337
		var kpiseq = record.data.Sequence;
1338
		var skpiseq = record.data.SequenceSubKPI;
1339
		var params = {
1340
		serviceName : 'Performance.asmx',
1341
		methodName : 'deleteSubKPI',
1342
		parameter : 'empID=' + _empID
1343
		+ '&HeaderSeq=' + seq.getValue()
1344
		+ '&appType=' + appType.getValue()
1345
		+ '&KPISeq=' + kpiseq
1346
		+ '&sKPISeq=' + skpiseq
1347
		};
1348
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1349
		var result = Ext.decode(xhr.responseText);
1350
		if (result.success) {
1351
		MinovaMessage('', 'PMS0001', '', 'S');
1352
		record.remove();
1353
		} else {
1354
		MinovaMessage('', '000005', result.message.text, 'E');
1355
		}
1356
		});*/
1357
		a.remove();
1358
	},
1359

    
1360
	calculatePMS : function () {
1361
		var pnl = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1362
		var form_ = pnl.getForm();
1363
		var data = form_.getValues();
1364
		var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1365
		var treestore = treepnl.store;
1366
		var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1367
		var storequal = undefined;
1368
		if (pnlqual != undefined) {
1369
			pnlqual.expandAll();
1370
			storequal = pnlqual.store;
1371
		}
1372
		var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1373
		var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
1374
		var PA0048_dATA = null;
1375
		var PA0051_dATA = null;
1376
		var TREE_dATA = null;
1377
		var Head = null;
1378
		var Child = null;
1379

    
1380
		if (data.AppraisalType != "G") {
1381
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1382
			var form_ = form.getForm();
1383
			var data = form_.getValues();
1384
			var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1385
			if (Sum.data.items.length > 0) {
1386
				var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1387
				Ext.Array.each(Ext.decode(DataSum), function (rec) {
1388
					if (rec.Type == "KPI") {
1389
						data["AdjustedKPI"] = rec.AdjustedScore;
1390
						data["CalculatedKPI"] = rec.CalculatedScore;
1391
						data["KPIFinalScore"] = rec.FinalScore;
1392
						data["KPITotalScore"] = rec.TotalScore;
1393
					} else {
1394
						data["AdjustedCompetency"] = rec.AdjustedScore;
1395
						data["CalculatedCompetency"] = rec.CalculatedScore;
1396
						data["QualFinalScore"] = rec.FinalScore;
1397
						data["QualTotalScore"] = rec.TotalScore;
1398
					}
1399
				})
1400
			}
1401
			var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1402
			var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1403
			if (dataTotalSum.length > 0) {
1404
				data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1405
				data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1406
				data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1407
				data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1408
			}
1409
		}
1410

    
1411
		if (PA0048 != undefined)
1412
			PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
1413
		if (storequal != undefined) {
1414
			var _data = Ext.pluck(storequal.data.items, 'data');
1415
			Ext.Array.each(_data, function (rec) {
1416
				rec.children = null
1417
			})
1418
			PA0051_dATA = Ext.encode(_data);
1419
		}
1420
		if (treepnl != undefined)
1421
			TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
1422

    
1423
		var dataresult = null;
1424
		var data47 = null;
1425

    
1426
		var params = {
1427
			serviceName : 'Performance.asmx',
1428
			methodName : 'CalculatePerformance',
1429
			parameter :
1430
			'header=' + Ext.encode(data)
1431
			 + '&PA0048=' + PA0048_dATA
1432
			 + '&PA0049=' + TREE_dATA
1433
			 + '&PA0051=' + PA0051_dATA
1434
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1435
		};
1436
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1437
			var result = Ext.decode(xhr.responseText);
1438
			dataresult = result.data;
1439
			Head = $.grep(Ext.decode(dataresult), function (r) {
1440
					return r.Tablename == '0047'
1441
				});
1442
			data47 = Head;
1443
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1444
			var form_ = form.getForm();
1445
			form_.setValues(Head[0]);
1446
			var dataPA0048 = $.grep(Ext.decode(dataresult), function (r) {
1447
					return r.Tablename == '0048'
1448
				});
1449
			var overView = Ext.StoreMgr.lookup('storePHRPA0048');
1450
			if (overView != undefined) {
1451
				overView.removeAll();
1452
				overView.loadData(dataPA0048);
1453
			}
1454
			
1455
			//// comment by Tri 
1456
			var dataPA0049 = $.grep(Ext.decode(dataresult), function (r) {
1457
					return r.Tablename == '0049'
1458
				}); console.log(dataPA0049);
1459
			var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1460
			if (pnl != undefined) {
1461
				pnl.store.load()
1462
				var taskkpi = pnl.getRootNode();
1463
				taskkpi.appendChild(dataPA0049);
1464
			}
1465
			
1466
			var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1467
					return r.Tablename == '0051'
1468
				});
1469
			var pnl51 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
1470
			if (pnl51 != undefined) {
1471
				pnl51.store.load()
1472
				var qual = pnl51.getRootNode();
1473
				qual.appendChild(dataPA0051);
1474
			}
1475

    
1476
			/* var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1477
					return r.Tablename == '0051'
1478
				});
1479
			var pnl2 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
1480
			if (pnl2 != undefined) {
1481
				//pnl.store.removeAll()
1482
				pnl2.store.load()
1483
				// pnl.store.setRootNode({
1484
				// expanded : true,
1485
				// nodetype : 'async',
1486
				// children : dataKPI
1487
				// });
1488
				var taskqual = pnl2.getRootNode();
1489
				taskqual.appendChild(dataPA0051);
1490
			}*/
1491
			
1492
			/*var pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0]; //// comment by Tri nwh 20220527
1493
			Head = $.grep(dataPA0051, function (r) {
1494
					return r.SequenceSub == 0
1495
				});
1496
			Child = $.grep(dataPA0051, function (r) {
1497
					return r.SequenceSub != 0
1498
				});
1499
			Ext.Array.each(Child, function (rec) {
1500
				rec['leaf'] = true;
1501
			});
1502
			if (pnl2 != undefined) {
1503
				pnl2.store.load();
1504
				var task = pnl2.getRootNode();
1505
				//task.appendChild(Head);
1506
				//pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1507
				//storequal = pnl2.store;
1508
				//Ext.Array.each(storequal.data.items, function (rec) {
1509
				//var t = rec.data;
1510
				//var QChild = $.grep(Child, function (r) {
1511
				//return r.QualificationID == t.QualificationID
1512
				//});
1513
				//var index = t.index;
1514
				//rec.appendChild(QChild);
1515
				//})
1516
				Ext.Array.each(Head, function (rec) {
1517
					var QChild = $.grep(Child, function (r) {
1518
							return r.QualificationID == rec.QualificationID
1519
						});
1520
					rec['children'] = QChild;
1521
					rec['expanded'] = true;
1522
					task.appendChild(rec);
1523
				})
1524
				pnl2.getView().refresh();
1525
			}*/
1526
			if (result.success) {
1527
				MinovaMessage('', 'PMS0002', '', 'S');
1528
			} else {
1529
				MinovaMessage('', '000005', '', 'E');
1530
			}
1531

    
1532
			data = {
1533
				AdjustedIndex : '',
1534
				AdjustedScore : data47[0].AdjustedKPI,
1535
				CalculatedScore : data47[0].CalculatedKPI,
1536
				FinalScore : data47[0].KPIFinalScore,
1537
				IndexScore : '',
1538
				TotalScore : data47[0].KPITotalScore,
1539
				Type : 'KPI',
1540
				Weight : data47[0].KPITotalWeight//'80'
1541
			};
1542

    
1543
			data2 = [];
1544
			data2[0] = data;
1545

    
1546
			data = {
1547
				AdjustedIndex : '',
1548
				AdjustedScore : data47[0].AdjustedCompetency,
1549
				CalculatedScore : data47[0].CalculatedCompetency,
1550
				FinalScore : data47[0].QualFinalScore,
1551
				IndexScore : '',
1552
				TotalScore : data47[0].QualTotalScore,
1553
				Type : 'Qualification',
1554
				Weight : data47[0].QualTotalWeight//'20'
1555
			};
1556

    
1557
			data2[1] = data;
1558

    
1559
			var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
1560
			if (overView != undefined) {
1561
				overView.removeAll();
1562
				overView.loadData(data2);
1563
			}
1564

    
1565
			dataTotal = {
1566
				AdjustedIndex : data47[0].AdjustedIndex,
1567
				AdjustedScore : data47[0].AdjustedScore,
1568
				CalculatedScore : data47[0].CalculatedScore,
1569
				IndexScore : data47[0].CalculatedIndex
1570
			};
1571

    
1572
			dataTotalList = [];
1573
			dataTotalList[0] = dataTotal;
1574

    
1575
			var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
1576
			if (overView != undefined) {
1577
				overView.removeAll();
1578
				overView.loadData(dataTotalList);
1579
			}
1580
		});
1581
	},
1582

    
1583
	addNewQualification : function () {
1584
		var me = this;
1585
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewQualification]').length;
1586
		if (count_lookup == 1) {
1587
			Ext.ComponentQuery.query('[name=AddNewQualification]')[0].show();
1588
		} else {
1589
			Ext.create('Ext.window.Window', {
1590
				title : 'Add Qualification',
1591
				name : 'AddNewQualification',
1592
				layout : 'fit',
1593
				items : [{
1594
						xtype : 'form',
1595
						name : 'formAddQualification',
1596
						items : [{
1597
								xtype : 'minovaForm',
1598
								bodyBorder : false,
1599
								cls : 'borderLookup',
1600
								border : false,
1601
								isLookup : false,
1602
								name : "mainformAddQualification",
1603
								tableName : 'PDSPMLOOKUPQUAL'
1604
							}
1605
						]
1606
					}
1607
				],
1608
				buttons : [{
1609
						text : 'Add Qualification',
1610
						name : 'BtnAddKPI',
1611
						iconCls : 'fa-save',
1612
						style : 'font-family: FontAwesome',
1613
						margin : '3 3 10 3',
1614
						handler : function () {
1615
							me.addNewQualificationtoGrid();
1616
						}
1617
					}, {
1618
						text : 'Cancel',
1619
						name : 'BtnCancelQualification',
1620
						iconCls : 'fa-reply',
1621
						style : 'font-family: FontAwesome',
1622
						margin : '3 3 10 3',
1623
						handler : function () {
1624
							Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1625
						}
1626
					}
1627
				]
1628
			}).show();
1629
		}
1630
	},
1631

    
1632
	addNewQualificationtoGrid : function () { 
1633
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1634
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1635
		var str = pnl.store;
1636
		
1637
		if (str.findRecord('QualificationID', Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()) != null) {
1638
			return;
1639
		}
1640

    
1641
		var leafCount = 0;
1642
		pnl.getRootNode().cascadeBy(function (node) {
1643
			if (!node.isLeaf())
1644
				leafCount++;
1645
		});
1646
		var data = '';
1647
		var Sequence = 0;
1648
		if (leafCount == 0) {
1649
			Sequence = 1;
1650
		} else {
1651
			Sequence = 1 + leafCount;
1652
		}
1653
		
1654
		var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1655
		var formdata_ = form_.getForm();
1656

    
1657
		var data = {
1658
			"EmployeeID" : formdata_.findField('EmployeeID').getValue(),
1659
			"HeaderSequence" : formdata_.findField('Sequence').getValue(),
1660
			"Sequence" : Sequence,
1661
			"AppraisalType" : formdata_.findField('AppraisalType').getValue()
1662
		}; 		
1663
		var data2 = null;
1664
		/*var params = {
1665
			serviceName : 'Performance.asmx',
1666
			methodName : 'SetQualification',
1667
			parameter : 'TableName=' + 'PHRPA0051'
1668
			 + '&Qualification=' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()
1669
			 + '&data=' + Ext.encode(data)
1670
		};
1671
		MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
1672
			var result = Ext.decode(xhr.responseText);
1673
			data2 = result.data;
1674
			if (result.success) {console.log(data2);}
1675
			else {
1676
				MinovaMessage('', '000005', result.message.text, 'E');
1677
			}
1678
		});*/
1679
		
1680
		var a = Ext.ComponentQuery.query('[name=mainformAddQualification]')[0];
1681
        var b = a.getValues();
1682
		var d = '';
1683
		Ext.Ajax.request({
1684
            method: 'POST',
1685
            async: false,
1686
            url: '/UserControl/GetStore',
1687
            params: {
1688
                //tableName: 'PHROM0001',
1689
                //param: 'ObjectClass[=]Q,ObjectID[=]' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue() + ',EndDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1690
				tableName : 'PHROM0002',
1691
				param : 'ObjectClass[=]QG,RelationshipClass[=]Q,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1692
            },
1693
            success: function (response) {
1694
                var results = Ext.decode(response.responseText);
1695
                if (results.data != null && results.data.length > 0) {
1696
                    d = results.data[0].ObjectID;
1697
					//data2 = results.data; console.log(data2);
1698
                }
1699
            }
1700
        });
1701
				
1702
		//var children = eval("children:" + data2);
1703
		data = {
1704
			QualificationGroup: d, //// add by Tri nwh 
1705
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1706
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1707
			QualificationID : Ext.ComponentQuery.query('[name=Qualification]')[0].getValue(),
1708
			Sequence : Sequence,
1709
			Description : Ext.ComponentQuery.query('[name=Qualification]')[0].value.split('-')[1].substr(1),
1710
			HeaderSequence : seq,
1711
			SequenceSub : "0",
1712
			Weight : 0,
1713
			leaf : false,
1714
			Target : 1,
1715
			//children,
1716
			expanded : true	
1717
			,App2Level : 0			//// ---- add by Tri nwh 20221114
1718
			,App3Level : 0		
1719
			,App4Level : 0		
1720
			,App5Level : 0
1721
			,App1Score : 0			
1722
			,App2Score : 0		
1723
			,App3Score : 0		
1724
			,App4Score : 0
1725
			,App5Score : 0
1726
		};
1727
		
1728
		var task = pnl.getRootNode();
1729
		task.appendChild(data); 
1730
		Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1731
	},
1732

    
1733
	loadQualification : function () {
1734
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1735
		var _result = undefined;
1736
		var Head = undefined;
1737
		
1738
		Ext.Ajax.request({
1739
			async : false,
1740
			//method : 'POST',
1741
			url : '/UserControl/GetStore',
1742
			params : {
1743
				tableName : 'PHRPA0051',
1744
				param : 'EmployeeID[=]' + Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue()
1745
				 + ',AppraisalType[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()
1746
				 + ',HeaderSequence[=]' + Ext.ComponentQuery.query('[name=Sequence]')[0].getValue()
1747
			},
1748
			success : function (response) {
1749
				_result = Ext.decode(response.responseText);
1750
				if (_result.success) {
1751
					var data = _result.data;
1752
					Head = $.grep(data, function (r) {
1753
							return r.SequenceSub == 0
1754
						});
1755
					var Child = $.grep(data, function (r) {
1756
							return r.SequenceSub != 0
1757
						});
1758
					Ext.Array.each(Child, function (rec) {
1759
						rec['leaf'] = true;
1760
					})
1761
					pnl.store.load();
1762
					var task = pnl.getRootNode();
1763
					Ext.Array.each(Head, function (rec) {
1764
						var QChild = $.grep(Child, function (r) {
1765
								return r.QualificationID == rec.QualificationID
1766
							});
1767
						rec['children'] = QChild;
1768
						rec['expanded'] = true;
1769
						task.appendChild(rec);
1770
					})
1771
				}
1772
			}
1773
		});
1774
	},
1775

    
1776
	deleteQualification : function () {
1777
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1778
		var record = main_.getView().selection;
1779

    
1780
		if (record == null) {
1781
			MinovaMessage('', 'PMSE003', '', 'E');
1782
			return;
1783
		}
1784

    
1785
		var _d = record.data;
1786
		if (_d.SequenceSub != 0) {
1787
			MinovaMessage('', 'PMSE003', '', 'E');
1788
			return;
1789
		}
1790
		record.remove();
1791
	},
1792

    
1793
	deleteKPI : function () {
1794
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1795
		var record = main_.getView().selection;
1796

    
1797
		if (record == null) {
1798
			MinovaMessage('', 'PMSE003', '', 'E');
1799
			return;
1800
		}
1801
		
1802
		var _d = record.data;
1803
		if (_d.SequenceSubKPI != 0) {
1804
			MinovaMessage('', 'PMSE003', '', 'E');
1805
			return;
1806
		}
1807
		record.remove();
1808
	},
1809

    
1810
	setDefaultAppbyOM : function () {
1811
		var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1812
		var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1813
		var AppraisalType = Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue();
1814
		var EmployeeID = getParam("EmployeeID");
1815
		var Result = null;
1816
		var params = {
1817
			serviceName : 'Performance.asmx',
1818
			methodName : 'GetDefaultAppraiser',
1819
			parameter :
1820
			'EmployeeID=' + EmployeeID
1821
			 + '&StartDate=' + StartDate
1822
			 + '&EndDate=' + EndDate
1823
			 + '&AppraisalType=' + AppraisalType
1824
		};
1825
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1826
			Result = Ext.decode(xhr.responseText);
1827
			if (Result.success) {
1828
				var pnl0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1829
				pnl0048.add(Ext.decode(Result.data));
1830
			} else {}
1831
		})
1832
	},
1833

    
1834
	saveToMDProfile : function () {
1835
		var me = this;
1836
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1837
		var storequal = pnl.store;
1838
		var PA0051_dATA = null;
1839
		var dataMD8002 = null;
1840
		if (storequal != undefined) {
1841
			pnl.expandAll();
1842
			var _data = Ext.pluck(storequal.data.items, 'data');
1843
			Ext.Array.each(_data, function (rec) {
1844
				rec.children = null
1845
			})
1846
			PA0051_dATA = Ext.encode(_data);
1847
			dataMD8002 = $.grep(Ext.decode(PA0051_dATA), function (r) {
1848
					r['StartDate'] = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1849
					r['EndDate'] = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1850
					r['QualificationLevel'] = r.AppraiserScore
1851
						return r.SequenceSub == 0
1852
				});
1853
		}
1854
		var Result = null;
1855
		var params = {
1856
			serviceName : 'Performance.asmx',
1857
			methodName : 'SaveToMD',
1858
			parameter :
1859
			'TableName=' + 'PHRPA0045'
1860
			 + '&dataDetail=' + Ext.encode(dataMD8002)
1861
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1862
		};
1863
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1864
			Result = Ext.decode(xhr.responseText);
1865
			if (Result.success) {
1866
				MinovaMessage('', 'PY0000', '', 'S');
1867
			} else {
1868
				MinovaMessage('', '000005', Result.message.text, 'E');
1869
			}
1870
		})
1871
	},
1872

    
1873
	SaveToMDHistory : function () {
1874
		var me = this;
1875
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1876
		var form_ = form.getForm();
1877
		var data = form_.getValues();
1878
		var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1879
		var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1880
		Ext.Array.each(Ext.decode(DataSum), function (rec) {
1881
			if (rec.Type == "KPI") {
1882
				data["AdjustedKPI"] = rec.AdjustedScore;
1883
				data["CalculatedKPI"] = rec.CalculatedScore;
1884
				data["KPIFinalScore"] = rec.FinalScore;
1885
				data["KPITotalScore"] = rec.TotalScore;
1886
				data["KPITotalWeight"] = rec.Weight;
1887
			} else {
1888
				data["AdjustedCompetency"] = rec.AdjustedScore;
1889
				data["CalculatedCompetency"] = rec.CalculatedScore;
1890
				data["QualFinalScore"] = rec.FinalScore;
1891
				data["QualTotalScore"] = rec.TotalScore;
1892
				data["QualTotalWeight"] = rec.Weight;
1893
			}
1894
		})
1895
		var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1896
		var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1897
		data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1898
		data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1899
		data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1900
		data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1901

    
1902
		var Result = null;
1903
		var params = {
1904
			serviceName : 'Performance.asmx',
1905
			methodName : 'SaveToMD',
1906
			parameter :
1907
			'TableName=' + 'PHRPA0029'
1908
			 + '&dataDetail=' + '[' + Ext.encode(data) + ']'
1909
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1910
		};
1911
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1912
			Result = Ext.decode(xhr.responseText);
1913
			if (Result.success) {
1914
				MinovaMessage('', 'PY0000', '', 'S');
1915
			} else {
1916
				MinovaMessage('', '000005', Result.message.text, 'E');
1917
			}
1918
		})
1919
	}
1920
});
(2-2/3)