Project

General

Profile

Feature #1710 » controllerperformance.js

Tri Rizqiaty, 02/02/2023 03:25 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 AppraisalType = form.findField("AppraisalType").getValue();
246
		var SDate = form.findField("StartDate").getValue();
247
		var EDate = form.findField("EndDate").getValue();
248
		if (SDate == '' || SDate == undefined || EDate == '' || EDate == undefined) {
249
			MinovaMessage('', 'PMS0003', '', 'E');
250
			Ext.ComponentQuery.query('[name=AppraisalType]')[0].setValue('');
251
			return;
252
		}
253
		this.setGridPerformance('0');
254

    
255
		var appType = rec.getValue();
256

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

    
280
		// add by Tri nwh 20221123 start	
281
		MinovaUtil.ExecuteParamQuery({ 
282
			ID: "PMSGETDEFAULTKPI",
283
			EmployeeID: getParam('EmployeeID'),
284
			StartDate : SDate,
285
			EndDate : EDate,
286
			AppraisalType : AppraisalType
287
		}, function (s) {
288
			var result = Ext.decode(s.responseText);  console.log(result);
289
			var dt = Ext.decode(Ext.decode(result.data)); console.log(dt);
290
			var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
291
			var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
292
			pnl.store.setRootNode({
293
				expanded : true,
294
				nodetype : 'async',
295
				children : dt
296
			});
297
		}, function (f) {});
298
		setTimeout( () =>{
299
		var grid49 = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
300
		grid49.getView().refresh();
301
		}, 1000);
302
		// add by Tri nwh 20221123 end	
303
		
304
		// add by Tri nwh 20221228 start	
305
		MinovaUtil.ExecuteParamQuery({ 
306
			ID: "PMSGETDEFAULTQUALIFICATION",
307
			EmployeeID: getParam('EmployeeID'),
308
			StartDate : SDate,
309
			EndDate : EDate,
310
			AppraisalType : AppraisalType
311
		}, function (s) {
312
			var result = Ext.decode(s.responseText);  console.log(result);
313
			var dt = Ext.decode(Ext.decode(result.data)); console.log(dt);
314
			var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
315
			var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
316
			pnl.store.setRootNode({
317
				expanded : true,
318
				nodetype : 'async',
319
				children : dt
320
			});
321
		}, function (f) {});
322
		setTimeout( () =>{
323
		var grid51 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
324
		grid51.getView().refresh();
325
		}, 1000);
326
		// add by Tri nwh 20221228 end	
327

    
328
		/* if (appType != 'G') { // comment by Tri nwh 20221123
329
			var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
330
			var form = main.getForm();
331
			var SDate = form.findField("StartDate").getValue();
332
			var EDate = form.findField("EndDate").getValue();
333
			var Data = undefined;
334
		
335
			var params = {	// comment by Tri nwh 20221115
336
				serviceName : 'Performance.asmx',
337
				methodName : 'SetDefaultAppraiser',
338
				parameter : 'EmployeeID=' + getParam('EmployeeID')
339
				 + '&StartDate=' + SDate
340
				 + '&EndDate=' + EDate
341
			};
342
			MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
343
				var result = Ext.decode(xhr.responseText);
344
				Data = result;
345
				var overView = Ext.StoreMgr.lookup('storePHRPA0048');
346
				if (overView != undefined) {
347
					overView.removeAll();
348
					overView.loadData(Ext.decode(Data.data));
349
				}
350
				if (result.success) {
351
					MinovaMessage('', 'PMS0001', '', 'S');
352
				} else {}
353
			});
354

    
355
			var params = {
356
				serviceName : 'Performance.asmx',
357
				methodName : 'SetDefaultKPI',
358
				parameter : 'EmployeeID=' + getParam('EmployeeID')
359
				 + '&StartDate=' + SDate
360
				 + '&EndDate=' + EDate
361
			};
362
			MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
363
				var result = Ext.decode(xhr.responseText);
364
				Data = result;
365
				var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
366
				if (pnl != undefined) {
367
					pnl.store.removeAll()
368
					pnl.store.load()
369
					pnl.store.setRootNode({
370
						expanded : true,
371
						nodetype : 'async',
372
						children : Ext.decode(Data.data)
373
					});
374
				}
375
				if (result.success) {}
376
				else {}
377
			});
378
		} 
379
		else { // comment by Tri nwh 20221115
380
			me.setDefaultAppbyOM();
381
		}*/ 
382
	},
383

    
384
	setGridPerformance : function (_a) {
385
		var me = this;
386
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
387
		var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
388
		var _empID = getParam('EmployeeID');
389
		grid.removeAll();
390

    
391
		try {
392
			var hasil = null;
393
			Ext.Ajax.request({
394
				async : false,
395
				method : 'POST',
396
				url : '/Performance/getListTableRef',
397
				params : {
398
					AppType : appType.getValue(),
399
					EmpID : _empID
400
				},
401
				success : function (response) {
402
					var results = Ext.decode(response.responseText);
403
					hasil = Ext.decode(results.data);
404
				}
405
			});
406

    
407
			if (hasil.length > 0) {
408
				Ext.Array.each(hasil, function (rec) {
409

    
410
					var _title = undefined;
411
					Ext.Ajax.request({
412
						async : false,
413
						//method : 'POST',
414
						url : '/UserControl/GetStore',
415
						params : {
416
							tableName : 'SDATATABLE',
417
							param : 'TableName[=]' + rec
418
						},
419

    
420
						success : function (response) {
421
							var results = Ext.decode(response.responseText);
422
							var dt = results.data[0];
423
							_title = dt.TableDescription;
424
						}
425
					});
426
					
427
					if (rec != 'PHRPA0049' && rec != 'PHRPA0051') {
428
						var _GridDetail = {
429
							xtype : 'fieldset',
430
							columnWidth : 0.5,
431
							title : _title,
432
							collapsible : true,
433
							defaultType : 'textfield',
434
							defaults : {
435
								anchor : '100%'
436
							},
437
							height : 400,
438
							layout : 'anchor',
439
							bbar : [{
440
									xtype : 'textfield',
441
									name : 'TotalScore' + rec,
442
									label : 'Total Score'
443
								}
444
							],
445
							items : [{
446
									xtype : 'minovapmseditablegrid',
447
									height : 300,
448
									autoLoad : false,
449
									autoScroll : true,
450
									tableName : rec,
451
									storeName : 'store' + rec,
452
									name : rec,
453
									hideButton : false,
454
									pagesize : 10,
455
									empID : getParam('EmployeeID'),
456
									apprasalType : appType.getValue(),
457
									listeners : {}
458
								}
459
							]
460
						};
461
						grid.add(_GridDetail);
462

    
463
						if (_a == '1') {
464
							me.getDataAppraiser(rec);
465
						}
466
					} else {
467
						var _GridDetail = {
468
							xtype : 'fieldset',
469
							columnWidth : 0.5,
470
							title : _title,
471
							collapsible : true,
472
							//defaultType : 'textfield',
473
							//autoScroll : true,
474
							defaults : {
475
								anchor : '100%'
476
							},
477
							height : 420,
478
							layout : 'anchor',
479
							items : [{
480
									xtype : 'Minovapmstreeeditablegrid',
481
											tableName : rec,
482
											height : 280,
483
											apprasalType : appType.getValue(),
484
											empID : getParam('EmployeeID'),
485
											autoScroll : true,
486
											hideButton : false,
487
											multiSelect : false,
488
									/*xtype : 'panel',
489
									name : 'Pnl' + rec,
490
									height : 380,
491
									width : '100%',
492
									autoScroll : true,
493
									/*items : [{
494
											xtype : 'Minovapmstreeeditablegrid',
495
											tableName : rec,
496
											height : 280,
497
											apprasalType : appType.getValue(),
498
											empID : getParam('EmployeeID'),
499
											autoScroll : true,
500
											hideButton : false,
501
											multiSelect : false
502
										}
503
									],*/
504
									tbar : [{
505
											xtype : 'toolbar',
506
											items : [{
507
													text : 'Add',
508
													name : rec + 'Add',
509
													iconCls : 'fa-plus-circle',
510
													style : 'font-family: FontAwesome'
511
												}, {
512
													text : 'Delete',
513
													name : rec + 'DeleteText',
514
													iconCls : 'fa-trash-o',
515
													style : 'font-family: FontAwesome',
516
													//disabled: true
517
													handler : function () {
518
														var me = this;
519
														var grid = Ext.ComponentQuery.query('[name=grid'+rec+']')[0]; //add by Tri nwh 20221116 start
520
														Ext.MessageBox.show({
521
															title : 'Remove tab',
522
															msg : "This will remove. Do you want to continue?",
523
															buttons : Ext.MessageBox.YESNO,
524
															fn : function (choice) {
525
																console.log(choice);
526
																if (choice === 'yes') {
527
																	var record = grid.getView().selection;
528
																	record.remove();
529
																}
530
															}
531
														});  //add by Tri nwh 20221116 end
532
														/*store = Ext.StoreMgr.lookup(storeID); //comment by Tri nwh 20221116 start
533
														var grid = Ext.getCmp(gridName);
534
														Ext.MessageBox.show({
535
															title : 'Remove tab',
536
															msg : "This will remove. Do you want to continue?",
537
															buttons : Ext.MessageBox.YESNO,
538
															fn : function (choice) {
539
																console.log(choice);
540
																if (choice === 'yes') {
541
																	var selection = grid.getView().getSelectionModel().getSelection()[0]; 
542
																	if (selection) {
543
																		store.remove(selection);
544
																	}
545
																}
546
															}
547
														});*/ //comment by Tri nwh 20221116 end
548
													}
549
												}
550
											]
551
										}
552
									]
553
								}
554

    
555
							]
556
						};
557
						grid.add(_GridDetail);
558

    
559
						if (_a == '1') {
560
							var pnl = Ext.ComponentQuery.query('[name=grid' + rec + ']')[0];
561
							var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
562
							var data_kpi = null;
563
							var url = null;
564
							if (rec == 'PHRPA0049') {
565
								url = '/Performance/getKPI';
566

    
567
								Ext.Ajax.request({
568
									//method : 'POST',
569
									async : false,
570
									url : url,
571
									params : {
572
										EmpID : getParam('EmployeeID'),
573
										Seq : seq.getValue(),
574
										AppType : appType.getValue()
575
									},
576
									success : function (response) {
577
										var results = Ext.decode(response.responseText);
578
										data_kpi = Ext.decode(results.data);
579
									}
580
								});
581

    
582
								pnl.store.setRootNode({
583
									expanded : true,
584
									nodetype : 'async',
585
									children : data_kpi
586
									//[]
587
								});
588
							} 
589
							else if (rec == 'PHRPA0051') { 
590
								//// -- add by Tri nwh 20220531
591
								param = 'EmployeeID[=]' + getParam('EmployeeID')
592
									 + ',HeaderSequence[=]' + seq.getValue()
593
									 + ',AppraisalType[=]' + appType.getValue();
594
								Ext.Ajax.request({
595
									async : false,
596
									url : '/UserControl/GetStore',
597
									params : {
598
										tableName : 'PHRPA0051',
599
										param : param
600
									},
601
									success : function (response) {
602
										var results = Ext.decode(response.responseText);
603
										var data_ = results.data;
604
										var pnl2 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0]; 
605
										pnl2.store.setRootNode({
606
											expanded : true,
607
											nodetype : 'async',
608
											children : data_
609
										});
610
									}
611
								});
612
								//// -- end add by Tri nwh 20220531
613
							}
614
							//me.loadQualification();
615
						}
616
					}
617
				});
618
			} else {}
619

    
620
			if (appType.getValue() == 'P' || appType.getValue() == 'F') {
621
				var _title = undefined;
622
				Ext.Ajax.request({
623
					async : false,
624
					//method : 'POST',
625
					url : '/UserControl/GetStore',
626
					params : {
627
						tableName : 'SDATATABLE',
628
						param : 'TableName[=]' + 'PDSPMSUMMARY'
629
					},
630

    
631
					success : function (response) {
632
						var results = Ext.decode(response.responseText);
633
						var dt = results.data[0];
634
						_title = dt.TableDescription;
635
					}
636
				});
637

    
638
				var _GridDetail = {
639
					xtype : 'fieldset',
640
					columnWidth : 0.5,
641
					title : _title,
642
					collapsible : true,
643
					defaultType : 'textfield',
644
					defaults : {
645
						anchor : '100%'
646
					},
647
					height : 420,
648
					layout : 'anchor',
649
					items : [{
650
							xtype : 'Minovaeditablegrid',
651
							autoLoad : false,
652
							hideButton : true,
653
							autoScroll : true,
654
							height : 200,
655
							layout : 'fit',
656
							tableName : 'PDSPMSUMMARY',
657
							storeName : 'store' + 'PDSPMSUMMARY',
658
							name : 'PDSPMSUMMARY',
659
							empID : getParam('EmployeeID'),
660
							apprasalType : appType.getValue(),
661
							tbar : [{
662
									xtype : 'toolbar',
663
									docked : 'top',
664
									items : [{
665
											xtype : 'button',
666
											text : 'Calculate',
667
											name : 'Calculate',
668
											handler : function () {
669
												me.calculatePMS()
670
											}
671
										}
672
										/*,{
673
										xtype : 'button',
674
										text : 'Save to Profile',
675
										name : 'SaveProfile',
676
										handler : function () {
677
										me.SaveToMDHistory()
678
										}
679
										}*/
680
									]
681
								}
682
							]
683
						}, {
684
							xtype : 'Minovaeditablegrid',
685
							autoLoad : false,
686
							hideButton : true,
687
							autoScroll : true,
688
							height : 200,
689
							layout : 'fit',
690
							tableName : 'PDSPMSUMTOTAL',
691
							storeName : 'store' + 'PDSPMSUMTOTAL',
692
							name : 'PDSPMSUMTOTAL'
693
						}
694
					]
695
				};
696
				grid.add(_GridDetail);
697
			}
698

    
699
		} catch (exc) {}
700
	},
701

    
702
	savePerformance : function () {
703
		var me = this;
704
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
705
		var form_ = form.getForm();
706
		var data = form_.getValues();
707
		var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
708
		var treestore = undefined;
709
		if (treepnl != undefined) {
710
			treepnl.expandAll();
711
			treestore = treepnl.store;
712
			Ext.Array.each(treestore.data.items, function (rec) {
713
				rec.expand(true);
714
			})
715
		}
716
		var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
717
		var storequal = undefined;
718
		if (pnlqual != undefined) {
719
			pnlqual.expandAll();
720
			storequal = pnlqual.store;
721
			Ext.Array.each(storequal.data.items, function (rec) {
722
				rec.expand(true);
723
			})
724
		}
725
		form.mask('Loading...');
726
		var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
727
		var PA0049 = Ext.StoreMgr.lookup("storePHRPA0049");
728
		var PA0049A = Ext.StoreMgr.lookup("storePHRPA0049A");
729
		var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
730
		var PA0048_dATA = null;
731
		var PA0049_dATA = null;
732
		var PA0049A_dATA = null;
733
		var PA0051_dATA = null;
734
		var TREE_dATA = null;
735

    
736
		if (PA0048 != undefined)
737
			PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
738
		if (PA0049 != undefined)
739
			PA0049_dATA = Ext.encode(Ext.pluck(PA0049.data.items, 'data'));
740
		if (PA0049A != undefined)
741
			PA0049A_dATA = Ext.encode(Ext.pluck(PA0049A.data.items, 'data'));
742
		if (storequal != undefined) {
743
			var _data = Ext.pluck(storequal.data.items, 'data');
744
			Ext.Array.each(_data, function (rec) {
745
				rec.children = null
746
			})
747
			PA0051_dATA = Ext.encode(_data);
748
		}
749
		if (treepnl != undefined)
750
			TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
751

    
752
		if (data.AppraisalType != "G") {
753
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
754
			var form_ = form.getForm();
755
			var data = form_.getValues();
756
			var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
757
			if (Sum.data.items.length > 0) {
758
				var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
759
				Ext.Array.each(Ext.decode(DataSum), function (rec) {
760
					if (rec.Type == "KPI") {
761
						data["AdjustedKPI"] = rec.AdjustedScore;
762
						data["CalculatedKPI"] = rec.CalculatedScore;
763
						data["KPIFinalScore"] = rec.FinalScore;
764
						data["KPITotalScore"] = rec.TotalScore;
765
						data["KPITotalWeight"] = rec.Weight;
766
					} else {
767
						data["AdjustedCompetency"] = rec.AdjustedScore;
768
						data["CalculatedCompetency"] = rec.CalculatedScore;
769
						data["QualFinalScore"] = rec.FinalScore;
770
						data["QualTotalScore"] = rec.TotalScore;
771
						data["QualTotalWeight"] = rec.Weight;
772
					}
773
				})
774
			}
775
			var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
776
			var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
777
			if (dataTotalSum.length > 0) {
778
				data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
779
				data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
780
				data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
781
				data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
782
			}
783
		}
784
		var params = {		//// add by Tri nwh 20220602
785
			serviceName : 'Performance.asmx',
786
			methodName : 'savePerformance',
787
			parameter :
788
			'header=' + Ext.encode(data)
789
			 + '&PA0048=' + PA0048_dATA
790
			 + '&PA0049=' + TREE_dATA
791
			 + '&PA0049A=' + TREE_dATA
792
			 + '&PA0051=' + PA0051_dATA
793
			 + '&Token=' + MinovaUtil.SESSIONS.Token
794
		};
795
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
796
			var result = Ext.decode(xhr.responseText);
797
			console.log(result.success);
798
			var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
799
			card_.getLayout().setActiveItem(0);
800
			MinovaMessage('', '000006', '', 'S');
801
			if (data.AppraisalType == "F") {
802
				//me.SaveToMDHistory();
803
				//me.saveToMDProfile();
804
			}
805
			me.afterRenderOverview();
806
			form.unmask();
807
		});
808
	},
809

    
810
	btnGoToother : function () {
811
		var menu_ = [];
812
		var Y = 180;
813

    
814
		menu_.push({
815
			text : 'Employee Search',
816
			handler : function () {
817
				Ext.create('Ext.window.Window', {
818
					title : 'Lookup - Employee',
819
					height : 530,
820
					width : 500,
821
					name : 'lookupMain',
822
					modal : true,
823
					items : [{
824
							xtype : 'minovaform',
825
							bodyBorder : false,
826
							MaxHeigth : '100',
827
							cls : 'borderLookup',
828
							border : false,
829
							MaxHeigth : '30',
830
							scroll : true,
831
							isLookup : true,
832
							name : "formLookupFilter",
833
							tableName : 'PDSEMP0002',
834
							buttons : [{
835
									text : 'Search',
836
									handler : function () {
837
										var store = Ext.data.StoreManager.lookup('lookupStore');
838
										var form = Ext.ComponentQuery.query('[name=formLookupFilter]')[0].getForm();
839
										grid = Ext.ComponentQuery.query('[name=gridLookup]')[0];
840
										var values_ = form.getValues();
841
										var fields_ = form.getFields().items;
842
										var param_ = '';
843
										for (var i = 0; i < fields_.length; i++) {
844
											var val_ = form.getFields().items[i].getValue();
845
											var xtype_ = form.getFields().items[i].xtype;
846
											var oprator_ = '[like]';
847
											if (xtype_ == 'combobox' || xtype_ == 'combo' || xtype_ == 'minovacombo' || xtype_ == 'minovacombobox') {
848
												oprator_ = '[Equal]';
849
											}
850
											if (xtype_ == 'datefield') {
851
												if (form.getFields().items[i].name == 'StartDate' || form.getFields().items[i].name == 'ValidForm') {
852
													oprator_ = '[LessThanEqual]';
853
												} else {
854
													oprator_ = '[GreaterThanEqual]';
855
												}
856
											}
857
											if (val_ != 'undefined' && val_ != "" && val_ != null) {
858
												param_ = param_ + ',' + form.getFields().items[i].name + oprator_ + val_;
859
											}
860
										}
861
										store.proxy.extraParams = {
862
											tableName : grid.tableName,
863
											param : param_,
864
											menuId : MinovaUtil.GetMenuID()
865
										};
866
										store.removeAll();
867
										store.reload();
868
										store.loadPage(1);
869
									}
870

    
871
								}
872
							],
873
						}, {
874
							xtype : 'minovagrid1',
875
							isLookup : 1,
876
							minHeight : 280,
877
							height : 280,
878
							tableName : 'PDSEMP0002',
879
							param : '',
880
							isLookup : true,
881
							autoLoad : false,
882
							name : 'gridLookup',
883
							hidebutton : 0,
884
							pagesize : 25,
885
							storename : 'lookupStore',
886
							listeners : {
887
								itemdblclick : function (g) {
888
									var dataSelection = this.getView().getSelectionModel().getSelection()[0].data;
889
									//console.log(dataSelection)
890
									var url = MinovaUtil.GetMenuID() + '&EmployeeID=' + dataSelection.EmployeeID + '&FullName=' + dataSelection.FullName + '&Lang=' + localStorage.LangId;
891
									var mb = new minovaBlowfish();
892
									e = mb.minovaEncryptUrl(url);
893
									window.open('masterdataperformancedetail?' + e, "_self");
894

    
895
								},
896
								beforeedit : function (grid) {
897
									return false;
898
								}
899
							},
900
							dockedItems : [{
901
									xtype : 'pagingtoolbar',
902
									store : 'lookupStore',
903
									dock : 'bottom',
904
									pageSize : 25,
905
									displayInfo : true
906
								}
907
							]
908

    
909
						}, ]
910
				}).show();
911
			}
912
		});
913
		menu_.push({
914
			text : 'Back',
915
			handler : function () {
916
				window.history.back();
917
			}
918
		});
919
		Ext.create('Ext.menu.Menu', {
920
			name : 'panelMenu',
921
			width : 240,
922
			height : 100,
923
			margin : '0 0 10 0',
924

    
925
			items : menu_
926
		}).showAt([1239, Y]);
927
	},
928

    
929
	deletePerformance : function () {
930
		var me = this;
931
		var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0];
932
		var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0];
933
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
934
		var Sequence = Ext.ComponentQuery.query('[name=Sequence]')[0];
935
		var _empID = getParam('EmployeeID');
936

    
937
		Ext.Ajax.request({
938
			async : false,
939
			method : 'POST',
940
			url : '/Performance/deleteData',
941
			params : {
942
				EmpID : _empID,
943
				Seq : Sequence.getValue(),
944
				AppType : appType.getValue(),
945
				StDate : StartDate.getValue(),
946
				EnDate : EndDate.getValue()
947
			},
948
			waitMsg : 'Deleting Data...',
949
			success : function (response) {
950

    
951
				var result = Ext.decode(response.responseText);
952
				if (result.success) {
953
					var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
954
					card_.getLayout().setActiveItem(0);
955
					MinovaMessage('', '000006', '', 'S');
956
					me.afterRenderOverview();
957
					//pnl.unmask();
958
				} else {
959
					//.unmask();
960
					//MinovaMessage('', result.message.id, result.message.text, "E");
961
					MinovaMessage('', '000005', result.message.text, "E")
962
				}
963
			},
964
			failure : function (response) {
965
				var result = Ext.decode(response.responseText);
966
				//pnl.unmask();
967
				// MinovaMessage('', result.message.id, result.message.text, "E")
968
				MinovaMessage('', '000005', result.message.text, "E")
969
			}
970
		});
971

    
972
		me.afterRenderOverview();
973
	},
974

    
975
	addAppraiser : function () {
976
		var grid = Ext.getCmp('gridPHRPA0048');
977
		var record = grid.getSelectionModel().getSelection()[0];
978
		record.set('EmployeeID', getParam('EmployeeID'));
979
	},
980

    
981
	getDataAppraiser : function (tblName) {
982
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
983
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
984
		var overView = Ext.StoreMgr.lookup('store' + tblName);
985
		var param = null;
986
		var data_kpi = null;
987

    
988
		if (tblName == 'PHRPA0049') {
989
			var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
990
			Ext.Ajax.request({
991
				//method : 'POST',
992
				async : false,
993
				url : '/Performance/getKPI',
994
				params : {
995
					EmpID : _empID,
996
					Seq : seq.getValue(),
997
					AppType : appType.getValue()
998
				},
999
				success : function (response) {
1000
					var results = Ext.decode(response.responseText);
1001
					data_kpi = Ext.decode(results.data);
1002
				}
1003
			});
1004
			pnl.store.setRootNode({
1005
				expanded : true,
1006
				nodetype : 'async',
1007
				children : data_kpi
1008
				//[]
1009
			});
1010
		} else {
1011
			param = 'EmployeeID[=]' + getParam('EmployeeID')
1012
				 + ',HeaderSequence[=]' + seq.getValue()
1013
				 + ',AppraisalType[=]' + appType.getValue();
1014
			Ext.Ajax.request({
1015
				//method : 'POST',
1016
				async : false,
1017
				url : '/UserControl/GetStore',
1018
				params : {
1019
					tableName : tblName,
1020
					param : param
1021
				},
1022
				success : function (response) {
1023
					var results = Ext.decode(response.responseText);
1024

    
1025
					if (tblName != 'PHRPA0049') {
1026
						overView.removeAll();
1027
						overView.loadData(results.data);
1028
					} else {
1029
						var data_ = results.data;
1030
						var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
1031
						pnl.store.setRootNode({
1032
							expanded : true,
1033
							nodetype : 'async',
1034
							children : data_
1035
							//[]
1036
						});
1037
					}
1038
				}
1039
			});
1040
		}
1041
		//overView.removeAll();
1042
		//overView.reload();
1043
		//overView.loadPage(1);
1044
	},
1045

    
1046
	loadChild : function (node, index, item, eOpts) {
1047
		var me = this;
1048
		var _empID = getParam('EmployeeID');
1049
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1050
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1051
		var data_ = null;
1052
		var idx = 0;
1053
		var tree_ = Ext.ComponentQuery.query('treepanel[name=gridPHRPA0049]')[0];
1054
		var v = tree_.getView();
1055

    
1056
		if (node.data.IsSubKPI == '1') {
1057
			return;
1058
		}
1059

    
1060
		tree_.mask('Expanding tree...');
1061

    
1062
		Ext.Ajax.request({
1063
			//method : 'POST',
1064
			async : false,
1065
			url : '/Performance/getSubKPI',
1066
			params : {
1067
				EmpID : _empID,
1068
				Seq : seq.getValue(),
1069
				AppType : appType.getValue(),
1070
				KPIID : node.data.KPI,
1071
				KPISeq : node.data.Sequence
1072
			},
1073
			success : function (response) {
1074
				var results = Ext.decode(response.responseText);
1075
				data_ = Ext.decode(results.data);
1076
			}
1077
		});
1078

    
1079
		if (data_.length > 0) {
1080
			data_.forEach(function (rec) {
1081
				if (v.store.data.find('SequenceSubKPI', rec.SequenceSubKPI) == null) {
1082
					node.appendChild(data_[idx])
1083
				}
1084
				idx++;
1085
			})
1086
		}
1087

    
1088
		tree_.unmask();
1089
	},
1090

    
1091
	addNewKPI : function () {
1092
		var me = this;
1093
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewKPI]').length;
1094
		if (count_lookup == 1) {
1095
			Ext.ComponentQuery.query('[name=AddNewKPI]')[0].show();
1096
		} else {
1097
			Ext.create('Ext.window.Window', {
1098
				title : 'Add KPI',
1099
				name : 'AddNewKPI',
1100
				layout : 'fit',
1101
				items : [{
1102
						xtype : 'form',
1103
						name : 'formAddKPI',
1104
						items : [{
1105
								xtype : 'minovaForm',
1106
								bodyBorder : false,
1107
								cls : 'borderLookup',
1108
								border : false,
1109
								isLookup : false,
1110
								name : "mainformAddKPI",
1111
								tableName : 'PDSPMLOOKUPKPI'
1112
							}
1113
						]
1114
					}
1115
				],
1116
				buttons : [{
1117
						text : 'Add KPI',
1118
						name : 'BtnAddKPI',
1119
						iconCls : 'fa-save',
1120
						style : 'font-family: FontAwesome',
1121
						margin : '3 3 10 3',
1122
						handler : function () {
1123
							me.addNewKPItoGrid();
1124
						}
1125
					}, {
1126
						text : 'Cancel',
1127
						name : 'BtnCancelKPI',
1128
						iconCls : 'fa-reply',
1129
						style : 'font-family: FontAwesome',
1130
						margin : '3 3 10 3',
1131
						handler : function () {
1132
							me.cancelAddNewKPI();
1133
						}
1134
					}
1135
				]
1136
			}).show();
1137
		}
1138
	},
1139

    
1140
	cancelAddNewKPI : function () {
1141
		Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1142
	},
1143

    
1144
	addNewKPItoGrid : function () {
1145
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1146
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1147
		var leafCount = 0;
1148
		pnl.getRootNode().cascadeBy(function (node) {
1149
			if (!node.isLeaf())
1150
				leafCount++;
1151
		});
1152
		var data = '';
1153
		var Sequence = 0;
1154
		if (leafCount == 0) {
1155
			Sequence = 1;
1156
		} else {
1157
			Sequence = 1 + leafCount;
1158
		}
1159

    
1160
		var a = Ext.ComponentQuery.query('[name=mainformAddKPI]')[0];
1161
		var b = a.getValues();
1162
		var C = '';
1163

    
1164
		Ext.Ajax.request({
1165
			method : 'POST',
1166
			async : false,
1167
			url : '/UserControl/GetStore',
1168
			params : {
1169
				tableName : 'PHROM0002',
1170
				param : 'ObjectClass[=]KG,RelationshipClass[=]K,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=KPI]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1171
			},
1172
			success : function (response) {
1173
				var results = Ext.decode(response.responseText);
1174
				if (results.data != null && results.data.length > 0) {
1175
					c = results.data[0].ObjectID;
1176
				}
1177
			}
1178
		});
1179

    
1180
		data = {
1181
			KPIGroup : c,
1182
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1183
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1184
			KPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1185
			Sequence : Sequence,
1186
			ObjectDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1187
			SubKPI : "-",
1188
			HeaderSequence : seq,
1189
			SequenceSubKPI : "0",
1190
			IsSubKPI : "0",
1191
			leaf : false,
1192
			Target : 1,
1193
			expanded : true
1194
			,App2Value : 0			//// ---- add by Tri nwh 20221114
1195
			,App3Value : 0		
1196
			,App4Value : 0		
1197
			,App5Value : 0
1198
			,App1Score : 0			
1199
			,App2Score : 0		
1200
			,App3Score : 0		
1201
			,App4Score : 0
1202
			,App5Score : 0				
1203
		};
1204

    
1205
		var task = pnl.getRootNode();
1206
		task.appendChild(data);
1207
		Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1208
	},
1209

    
1210
	addNewsubKPI : function (record) {
1211
		var me = this;
1212
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewsubKPI]').length;
1213
		if (count_lookup == 1) {
1214
			Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].show();
1215
		} else {
1216
			Ext.create('Ext.window.Window', {
1217
				title : 'Add subKPI',
1218
				name : 'AddNewsubKPI',
1219
				layout : 'fit',
1220
				items : [{
1221
						xtype : 'form',
1222
						name : 'formAddsubKPI',
1223
						items : [{
1224
								xtype : 'minovaForm',
1225
								bodyBorder : false,
1226
								cls : 'borderLookup',
1227
								border : false,
1228
								isLookup : false,
1229
								name : "mainformAddsubKPI",
1230
								tableName : 'PDSPMLOOKUPKPI'
1231
							}
1232
						]
1233
					}
1234
				],
1235
				buttons : [{
1236
						text : 'Add subKPI',
1237
						name : 'BtnAddsubKPI',
1238
						iconCls : 'fa-save',
1239
						style : 'font-family: FontAwesome',
1240
						margin : '3 3 10 3',
1241
						handler : function () {
1242
							me.addNewsubKPItoGrid(record);
1243
						}
1244
					}, {
1245
						text : 'Cancel',
1246
						name : 'BtnCancelsubKPI',
1247
						iconCls : 'fa-reply',
1248
						style : 'font-family: FontAwesome',
1249
						margin : '3 3 10 3',
1250
						handler : function () {
1251
							Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1252
						}
1253
					}
1254
				]
1255
			}).show();
1256
		}
1257
	},
1258

    
1259
	addNewsubKPItoGrid : function (record) {
1260
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1261
		var leafCount = 0;
1262
		var _empID = getParam('EmployeeID');
1263
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1264
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1265
		var i = 0;
1266
		var data_ = null;
1267
		Ext.Ajax.request({
1268
			async : false,
1269
			url : '/Performance/getSubKPI',
1270
			params : {
1271
				EmpID : _empID,
1272
				Seq : seq.getValue(),
1273
				AppType : appType.getValue(),
1274
				KPIID : record.data.KPI,
1275
				KPISeq : record.data.Sequence
1276
			},
1277
			success : function (response) {
1278
				var results = Ext.decode(response.responseText);
1279
				data_ = Ext.decode(results.data);
1280
			}
1281
		});
1282
		if (data_.length == 0) {
1283
			i = 1;
1284
		} else {
1285
			i += data_.length;
1286
		}
1287

    
1288
		var data = {
1289
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1290
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1291
			KPI : record.data.KPI,
1292
			ObjectDescription : record.data.ObjectDescription,
1293
			Sequence : record.data.Sequence,
1294
			HeaderSequence : seq.getValue(),
1295
			SequenceSubKPI : i,
1296
			IsSubKPI : "1",
1297
			SubKPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1298
			SubKPIDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1299
			leaf : true
1300
		};
1301

    
1302
		record.appendChild(data);
1303
		Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1304
	},
1305

    
1306
	loadMenu : function () {
1307
		var me = this;
1308
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1309
		var record = main_.getView().selection;
1310
		var _a = record.data.leaf;
1311
		var _kpi = record.data.KPI;
1312
		var rowIndex = record.data.index;
1313
		var n = rowIndex * 50;
1314
		var Y = 180 + n;
1315
		var menu_ = []
1316

    
1317
		if (!_a) {
1318
			menu_.push({
1319
				text : 'Delete KPI',
1320
				handler : function () {
1321
					me.deleteSubKPI(record);
1322
				}
1323
			})
1324
			menu_.push({
1325
				text : 'Add subKPI',
1326
				handler : function () {
1327
					me.addNewsubKPI(record);
1328
				}
1329
			})
1330
			menu_.push({
1331
				text : 'Delete All subKPI',
1332
				handler : function () {}
1333
			})
1334
		} else {
1335
			menu_.push({
1336
				text : 'Delete subKPI',
1337
				handler : function () {
1338
					me.deleteSubKPI(record);
1339
				}
1340
			})
1341
		}
1342

    
1343
		Ext.create('Ext.menu.Menu', {
1344
			name : 'panelMenu',
1345
			width : 240,
1346
			height : 150,
1347
			margin : '0 0 10 0',
1348
			items : menu_
1349
		}).showAt([1239, Y]);
1350
	},
1351

    
1352
	ValidasiAppWeight : function () { // add by Tri nwh 20221117
1353
		var me = this;
1354
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1355
		var form_ = form.getForm();
1356
		var data = form_.getValues();
1357
		var Sum = Ext.StoreMgr.lookup("storePHRPA0048");
1358
		var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1359
		var SumKPIWeight = 0;
1360
		var SumQualWeight = 0;
1361
		var idx = Sum.getCount();
1362
		var data = '';
1363
		Ext.Array.each(Ext.decode(DataSum), function (rec) {
1364
			SumKPIWeight = parseFloat(SumKPIWeight) + parseFloat(rec.KPIWeight);
1365
			SumQualWeight = parseFloat(SumQualWeight) + parseFloat(rec.QualificationWeight);
1366
			if(SumKPIWeight >= 100)
1367
			{
1368
				MinovaMessage('', 'PMSE005', '', 'E');
1369
				rec.remove()
1370
			}
1371
			if(SumQualWeight >= 100)
1372
			{
1373
				MinovaMessage('', 'PMSE006', '', 'E');
1374
				rec.remove()
1375
			}
1376
		})
1377
	},
1378

    
1379
	AddAppraiserQ : function () { },
1380

    
1381
	deleteSubKPI : function (a) {
1382
		/*var main_ = Ext.ComponentQuery.query('[name=PHRPA0049]')[0];
1383
		var record = main_.getView().selection;
1384
		var _empID = getParam('EmployeeID');
1385
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1386
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1387
		var kpiseq = record.data.Sequence;
1388
		var skpiseq = record.data.SequenceSubKPI;
1389
		var params = {
1390
		serviceName : 'Performance.asmx',
1391
		methodName : 'deleteSubKPI',
1392
		parameter : 'empID=' + _empID
1393
		+ '&HeaderSeq=' + seq.getValue()
1394
		+ '&appType=' + appType.getValue()
1395
		+ '&KPISeq=' + kpiseq
1396
		+ '&sKPISeq=' + skpiseq
1397
		};
1398
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1399
		var result = Ext.decode(xhr.responseText);
1400
		if (result.success) {
1401
		MinovaMessage('', 'PMS0001', '', 'S');
1402
		record.remove();
1403
		} else {
1404
		MinovaMessage('', '000005', result.message.text, 'E');
1405
		}
1406
		});*/
1407
		a.remove();
1408
	},
1409

    
1410
	calculatePMS : function () {
1411
		var pnl = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1412
		var form_ = pnl.getForm();
1413
		var data = form_.getValues();
1414
		var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1415
		var treestore = treepnl.store;
1416
		var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1417
		var storequal = undefined;
1418
		if (pnlqual != undefined) {
1419
			pnlqual.expandAll();
1420
			storequal = pnlqual.store;
1421
		}
1422
		var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1423
		var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
1424
		var PA0048_dATA = null;
1425
		var PA0051_dATA = null;
1426
		var TREE_dATA = null;
1427
		var Head = null;
1428
		var Child = null;
1429

    
1430
		if (data.AppraisalType != "G") {
1431
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1432
			var form_ = form.getForm();
1433
			var data = form_.getValues();
1434
			var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1435
			if (Sum.data.items.length > 0) {
1436
				var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1437
				Ext.Array.each(Ext.decode(DataSum), function (rec) {
1438
					if (rec.Type == "KPI") {
1439
						data["AdjustedKPI"] = rec.AdjustedScore;
1440
						data["CalculatedKPI"] = rec.CalculatedScore;
1441
						data["KPIFinalScore"] = rec.FinalScore;
1442
						data["KPITotalScore"] = rec.TotalScore;
1443
					} else {
1444
						data["AdjustedCompetency"] = rec.AdjustedScore;
1445
						data["CalculatedCompetency"] = rec.CalculatedScore;
1446
						data["QualFinalScore"] = rec.FinalScore;
1447
						data["QualTotalScore"] = rec.TotalScore;
1448
					}
1449
				})
1450
			}
1451
			var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1452
			var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1453
			if (dataTotalSum.length > 0) {
1454
				data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1455
				data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1456
				data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1457
				data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1458
			}
1459
		}
1460

    
1461
		if (PA0048 != undefined)
1462
			PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
1463
		if (storequal != undefined) {
1464
			var _data = Ext.pluck(storequal.data.items, 'data');
1465
			Ext.Array.each(_data, function (rec) {
1466
				rec.children = null
1467
			})
1468
			PA0051_dATA = Ext.encode(_data);
1469
		}
1470
		if (treepnl != undefined)
1471
			TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
1472

    
1473
		var dataresult = null;
1474
		var data47 = null;
1475

    
1476
		var params = {
1477
			serviceName : 'Performance.asmx',
1478
			methodName : 'CalculatePerformance',
1479
			parameter :
1480
			'header=' + Ext.encode(data)
1481
			 + '&PA0048=' + PA0048_dATA
1482
			 + '&PA0049=' + TREE_dATA
1483
			 + '&PA0051=' + PA0051_dATA
1484
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1485
		};
1486
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1487
			var result = Ext.decode(xhr.responseText);
1488
			dataresult = result.data;
1489
			Head = $.grep(Ext.decode(dataresult), function (r) {
1490
					return r.Tablename == '0047'
1491
				});
1492
			data47 = Head;
1493
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1494
			var form_ = form.getForm();
1495
			form_.setValues(Head[0]);
1496
			var dataPA0048 = $.grep(Ext.decode(dataresult), function (r) {
1497
					return r.Tablename == '0048'
1498
				});
1499
			var overView = Ext.StoreMgr.lookup('storePHRPA0048');
1500
			if (overView != undefined) {
1501
				overView.removeAll();
1502
				overView.loadData(dataPA0048);
1503
			}
1504
			
1505
			//// comment by Tri 
1506
			var dataPA0049 = $.grep(Ext.decode(dataresult), function (r) {
1507
					return r.Tablename == '0049'
1508
				}); console.log(dataPA0049);
1509
			var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1510
			if (pnl != undefined) {
1511
				pnl.store.load()
1512
				var taskkpi = pnl.getRootNode();
1513
				taskkpi.appendChild(dataPA0049);
1514
			}
1515
			
1516
			var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1517
					return r.Tablename == '0051'
1518
				});
1519
			var pnl51 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
1520
			if (pnl51 != undefined) {
1521
				pnl51.store.load()
1522
				var qual = pnl51.getRootNode();
1523
				qual.appendChild(dataPA0051);
1524
			}
1525

    
1526
			/* var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1527
					return r.Tablename == '0051'
1528
				});
1529
			var pnl2 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
1530
			if (pnl2 != undefined) {
1531
				//pnl.store.removeAll()
1532
				pnl2.store.load()
1533
				// pnl.store.setRootNode({
1534
				// expanded : true,
1535
				// nodetype : 'async',
1536
				// children : dataKPI
1537
				// });
1538
				var taskqual = pnl2.getRootNode();
1539
				taskqual.appendChild(dataPA0051);
1540
			}*/
1541
			
1542
			/*var pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0]; //// comment by Tri nwh 20220527
1543
			Head = $.grep(dataPA0051, function (r) {
1544
					return r.SequenceSub == 0
1545
				});
1546
			Child = $.grep(dataPA0051, function (r) {
1547
					return r.SequenceSub != 0
1548
				});
1549
			Ext.Array.each(Child, function (rec) {
1550
				rec['leaf'] = true;
1551
			});
1552
			if (pnl2 != undefined) {
1553
				pnl2.store.load();
1554
				var task = pnl2.getRootNode();
1555
				//task.appendChild(Head);
1556
				//pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1557
				//storequal = pnl2.store;
1558
				//Ext.Array.each(storequal.data.items, function (rec) {
1559
				//var t = rec.data;
1560
				//var QChild = $.grep(Child, function (r) {
1561
				//return r.QualificationID == t.QualificationID
1562
				//});
1563
				//var index = t.index;
1564
				//rec.appendChild(QChild);
1565
				//})
1566
				Ext.Array.each(Head, function (rec) {
1567
					var QChild = $.grep(Child, function (r) {
1568
							return r.QualificationID == rec.QualificationID
1569
						});
1570
					rec['children'] = QChild;
1571
					rec['expanded'] = true;
1572
					task.appendChild(rec);
1573
				})
1574
				pnl2.getView().refresh();
1575
			}*/
1576
			if (result.success) {
1577
				MinovaMessage('', 'PMS0002', '', 'S');
1578
			} else {
1579
				MinovaMessage('', '000005', '', 'E');
1580
			}
1581

    
1582
			data = {
1583
				AdjustedIndex : '',
1584
				AdjustedScore : data47[0].AdjustedKPI,
1585
				CalculatedScore : data47[0].CalculatedKPI,
1586
				FinalScore : data47[0].KPIFinalScore,
1587
				IndexScore : '',
1588
				TotalScore : data47[0].KPITotalScore,
1589
				Type : 'KPI',
1590
				Weight : data47[0].KPITotalWeight//'80'
1591
			};
1592

    
1593
			data2 = [];
1594
			data2[0] = data;
1595

    
1596
			data = {
1597
				AdjustedIndex : '',
1598
				AdjustedScore : data47[0].AdjustedCompetency,
1599
				CalculatedScore : data47[0].CalculatedCompetency,
1600
				FinalScore : data47[0].QualFinalScore,
1601
				IndexScore : '',
1602
				TotalScore : data47[0].QualTotalScore,
1603
				Type : 'Qualification',
1604
				Weight : data47[0].QualTotalWeight//'20'
1605
			};
1606

    
1607
			data2[1] = data;
1608

    
1609
			var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
1610
			if (overView != undefined) {
1611
				overView.removeAll();
1612
				overView.loadData(data2);
1613
			}
1614

    
1615
			dataTotal = {
1616
				AdjustedIndex : data47[0].AdjustedIndex,
1617
				AdjustedScore : data47[0].AdjustedScore,
1618
				CalculatedScore : data47[0].CalculatedScore,
1619
				IndexScore : data47[0].CalculatedIndex
1620
			};
1621

    
1622
			dataTotalList = [];
1623
			dataTotalList[0] = dataTotal;
1624

    
1625
			var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
1626
			if (overView != undefined) {
1627
				overView.removeAll();
1628
				overView.loadData(dataTotalList);
1629
			}
1630
		});
1631
	},
1632

    
1633
	addNewQualification : function () {
1634
		var me = this;
1635
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewQualification]').length;
1636
		if (count_lookup == 1) {
1637
			Ext.ComponentQuery.query('[name=AddNewQualification]')[0].show();
1638
		} else {
1639
			Ext.create('Ext.window.Window', {
1640
				title : 'Add Qualification',
1641
				name : 'AddNewQualification',
1642
				layout : 'fit',
1643
				items : [{
1644
						xtype : 'form',
1645
						name : 'formAddQualification',
1646
						items : [{
1647
								xtype : 'minovaForm',
1648
								bodyBorder : false,
1649
								cls : 'borderLookup',
1650
								border : false,
1651
								isLookup : false,
1652
								name : "mainformAddQualification",
1653
								tableName : 'PDSPMLOOKUPQUAL'
1654
							}
1655
						]
1656
					}
1657
				],
1658
				buttons : [{
1659
						text : 'Add Qualification',
1660
						name : 'BtnAddKPI',
1661
						iconCls : 'fa-save',
1662
						style : 'font-family: FontAwesome',
1663
						margin : '3 3 10 3',
1664
						handler : function () {
1665
							me.addNewQualificationtoGrid();
1666
						}
1667
					}, {
1668
						text : 'Cancel',
1669
						name : 'BtnCancelQualification',
1670
						iconCls : 'fa-reply',
1671
						style : 'font-family: FontAwesome',
1672
						margin : '3 3 10 3',
1673
						handler : function () {
1674
							Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1675
						}
1676
					}
1677
				]
1678
			}).show();
1679
		}
1680
	},
1681

    
1682
	addNewQualificationtoGrid : function () { 
1683
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1684
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1685
		var str = pnl.store;
1686
		
1687
		if (str.findRecord('QualificationID', Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()) != null) {
1688
			return;
1689
		}
1690

    
1691
		var leafCount = 0;
1692
		pnl.getRootNode().cascadeBy(function (node) {
1693
			if (!node.isLeaf())
1694
				leafCount++;
1695
		});
1696
		var data = '';
1697
		var Sequence = 0;
1698
		if (leafCount == 0) {
1699
			Sequence = 1;
1700
		} else {
1701
			Sequence = 1 + leafCount;
1702
		}
1703
		
1704
		var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1705
		var formdata_ = form_.getForm();
1706

    
1707
		var data = {
1708
			"EmployeeID" : formdata_.findField('EmployeeID').getValue(),
1709
			"HeaderSequence" : formdata_.findField('Sequence').getValue(),
1710
			"Sequence" : Sequence,
1711
			"AppraisalType" : formdata_.findField('AppraisalType').getValue()
1712
		}; 		
1713
		var data2 = null;
1714
		/*var params = {
1715
			serviceName : 'Performance.asmx',
1716
			methodName : 'SetQualification',
1717
			parameter : 'TableName=' + 'PHRPA0051'
1718
			 + '&Qualification=' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()
1719
			 + '&data=' + Ext.encode(data)
1720
		};
1721
		MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
1722
			var result = Ext.decode(xhr.responseText);
1723
			data2 = result.data;
1724
			if (result.success) {console.log(data2);}
1725
			else {
1726
				MinovaMessage('', '000005', result.message.text, 'E');
1727
			}
1728
		});*/
1729
		
1730
		var a = Ext.ComponentQuery.query('[name=mainformAddQualification]')[0];
1731
        var b = a.getValues();
1732
		var d = '';
1733
		Ext.Ajax.request({
1734
            method: 'POST',
1735
            async: false,
1736
            url: '/UserControl/GetStore',
1737
            params: {
1738
                //tableName: 'PHROM0001',
1739
                //param: 'ObjectClass[=]Q,ObjectID[=]' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue() + ',EndDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1740
				tableName : 'PHROM0002',
1741
				param : 'ObjectClass[=]QG,RelationshipClass[=]Q,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1742
            },
1743
            success: function (response) {
1744
                var results = Ext.decode(response.responseText);
1745
                if (results.data != null && results.data.length > 0) {
1746
                    d = results.data[0].ObjectID;
1747
					//data2 = results.data; console.log(data2);
1748
                }
1749
            }
1750
        });
1751
				
1752
		//var children = eval("children:" + data2);
1753
		data = {
1754
			QualificationGroup: d, //// add by Tri nwh 
1755
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1756
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1757
			QualificationID : Ext.ComponentQuery.query('[name=Qualification]')[0].getValue(),
1758
			Sequence : Sequence,
1759
			Description : Ext.ComponentQuery.query('[name=Qualification]')[0].value.split('-')[1].substr(1),
1760
			HeaderSequence : seq,
1761
			SequenceSub : "0",
1762
			Weight : 0,
1763
			leaf : false,
1764
			Target : 1,
1765
			//children,
1766
			expanded : true	
1767
			,App2Level : 0			//// ---- add by Tri nwh 20221114
1768
			,App3Level : 0		
1769
			,App4Level : 0		
1770
			,App5Level : 0
1771
			,App1Score : 0			
1772
			,App2Score : 0		
1773
			,App3Score : 0		
1774
			,App4Score : 0
1775
			,App5Score : 0
1776
		};
1777
		
1778
		var task = pnl.getRootNode();
1779
		task.appendChild(data); 
1780
		Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1781
	},
1782

    
1783
	loadQualification : function () {
1784
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1785
		var _result = undefined;
1786
		var Head = undefined;
1787
		
1788
		Ext.Ajax.request({
1789
			async : false,
1790
			//method : 'POST',
1791
			url : '/UserControl/GetStore',
1792
			params : {
1793
				tableName : 'PHRPA0051',
1794
				param : 'EmployeeID[=]' + Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue()
1795
				 + ',AppraisalType[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()
1796
				 + ',HeaderSequence[=]' + Ext.ComponentQuery.query('[name=Sequence]')[0].getValue()
1797
			},
1798
			success : function (response) {
1799
				_result = Ext.decode(response.responseText);
1800
				if (_result.success) {
1801
					var data = _result.data;
1802
					Head = $.grep(data, function (r) {
1803
							return r.SequenceSub == 0
1804
						});
1805
					var Child = $.grep(data, function (r) {
1806
							return r.SequenceSub != 0
1807
						});
1808
					Ext.Array.each(Child, function (rec) {
1809
						rec['leaf'] = true;
1810
					})
1811
					pnl.store.load();
1812
					var task = pnl.getRootNode();
1813
					Ext.Array.each(Head, function (rec) {
1814
						var QChild = $.grep(Child, function (r) {
1815
								return r.QualificationID == rec.QualificationID
1816
							});
1817
						rec['children'] = QChild;
1818
						rec['expanded'] = true;
1819
						task.appendChild(rec);
1820
					})
1821
				}
1822
			}
1823
		});
1824
	},
1825

    
1826
	deleteQualification : function () {
1827
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1828
		var record = main_.getView().selection;
1829

    
1830
		if (record == null) {
1831
			MinovaMessage('', 'PMSE003', '', 'E');
1832
			return;
1833
		}
1834

    
1835
		var _d = record.data;
1836
		if (_d.SequenceSub != 0) {
1837
			MinovaMessage('', 'PMSE003', '', 'E');
1838
			return;
1839
		}
1840
		record.remove();
1841
	},
1842

    
1843
	deleteKPI : function () {
1844
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1845
		var record = main_.getView().selection;
1846

    
1847
		if (record == null) {
1848
			MinovaMessage('', 'PMSE003', '', 'E');
1849
			return;
1850
		}
1851
		
1852
		var _d = record.data;
1853
		if (_d.SequenceSubKPI != 0) {
1854
			MinovaMessage('', 'PMSE003', '', 'E');
1855
			return;
1856
		}
1857
		record.remove();
1858
	},
1859

    
1860
	setDefaultAppbyOM : function () {
1861
		var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1862
		var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1863
		var AppraisalType = Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue();
1864
		var EmployeeID = getParam("EmployeeID");
1865
		var Result = null;
1866
		var params = {
1867
			serviceName : 'Performance.asmx',
1868
			methodName : 'GetDefaultAppraiser',
1869
			parameter :
1870
			'EmployeeID=' + EmployeeID
1871
			 + '&StartDate=' + StartDate
1872
			 + '&EndDate=' + EndDate
1873
			 + '&AppraisalType=' + AppraisalType
1874
		};
1875
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1876
			Result = Ext.decode(xhr.responseText);
1877
			if (Result.success) {
1878
				var pnl0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1879
				pnl0048.add(Ext.decode(Result.data));
1880
			} else {}
1881
		})
1882
	},
1883

    
1884
	saveToMDProfile : function () {
1885
		var me = this;
1886
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1887
		var storequal = pnl.store;
1888
		var PA0051_dATA = null;
1889
		var dataMD8002 = null;
1890
		if (storequal != undefined) {
1891
			pnl.expandAll();
1892
			var _data = Ext.pluck(storequal.data.items, 'data');
1893
			Ext.Array.each(_data, function (rec) {
1894
				rec.children = null
1895
			})
1896
			PA0051_dATA = Ext.encode(_data);
1897
			dataMD8002 = $.grep(Ext.decode(PA0051_dATA), function (r) {
1898
					r['StartDate'] = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1899
					r['EndDate'] = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1900
					r['QualificationLevel'] = r.AppraiserScore
1901
						return r.SequenceSub == 0
1902
				});
1903
		}
1904
		var Result = null;
1905
		var params = {
1906
			serviceName : 'Performance.asmx',
1907
			methodName : 'SaveToMD',
1908
			parameter :
1909
			'TableName=' + 'PHRPA0045'
1910
			 + '&dataDetail=' + Ext.encode(dataMD8002)
1911
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1912
		};
1913
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1914
			Result = Ext.decode(xhr.responseText);
1915
			if (Result.success) {
1916
				MinovaMessage('', 'PY0000', '', 'S');
1917
			} else {
1918
				MinovaMessage('', '000005', Result.message.text, 'E');
1919
			}
1920
		})
1921
	},
1922

    
1923
	SaveToMDHistory : function () {
1924
		var me = this;
1925
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1926
		var form_ = form.getForm();
1927
		var data = form_.getValues();
1928
		var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1929
		var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1930
		Ext.Array.each(Ext.decode(DataSum), function (rec) {
1931
			if (rec.Type == "KPI") {
1932
				data["AdjustedKPI"] = rec.AdjustedScore;
1933
				data["CalculatedKPI"] = rec.CalculatedScore;
1934
				data["KPIFinalScore"] = rec.FinalScore;
1935
				data["KPITotalScore"] = rec.TotalScore;
1936
				data["KPITotalWeight"] = rec.Weight;
1937
			} else {
1938
				data["AdjustedCompetency"] = rec.AdjustedScore;
1939
				data["CalculatedCompetency"] = rec.CalculatedScore;
1940
				data["QualFinalScore"] = rec.FinalScore;
1941
				data["QualTotalScore"] = rec.TotalScore;
1942
				data["QualTotalWeight"] = rec.Weight;
1943
			}
1944
		})
1945
		var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1946
		var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1947
		data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1948
		data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1949
		data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1950
		data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1951

    
1952
		var Result = null;
1953
		var params = {
1954
			serviceName : 'Performance.asmx',
1955
			methodName : 'SaveToMD',
1956
			parameter :
1957
			'TableName=' + 'PHRPA0029'
1958
			 + '&dataDetail=' + '[' + Ext.encode(data) + ']'
1959
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1960
		};
1961
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1962
			Result = Ext.decode(xhr.responseText);
1963
			if (Result.success) {
1964
				MinovaMessage('', 'PY0000', '', 'S');
1965
			} else {
1966
				MinovaMessage('', '000005', Result.message.text, 'E');
1967
			}
1968
		})
1969
	}
1970
});
(6-6/6)