Project

General

Profile

Support #1983 » controllerperformance.js

Tri Rizqiaty, 02/24/2023 09:45 AM

 
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
		
708
		var Sum48 = Ext.StoreMgr.lookup("storePHRPA0048"); //// add by Tri nwh 202023 untuk validasi weight start 
709
		var DataSum48 = Ext.encode(Ext.pluck(Sum48.data.items, 'data'));
710
		var SumKPIWeight48 = 0;
711
		var SumQualWeight48 = 0;
712
		Ext.Array.each(Ext.decode(DataSum48), function (rec) {
713
			SumKPIWeight48 = parseFloat(SumKPIWeight48) + parseFloat(rec.KPIWeight);
714
			SumQualWeight48 = parseFloat(SumQualWeight48) + parseFloat(rec.QualificationWeight);
715
		}); 
716
	
717
		var SumWeight49 = 0;
718
		var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
719
		var treestore = undefined;
720
		if (treepnl != undefined) {
721
			treepnl.expandAll();
722
			treestore = treepnl.store;
723
			Ext.Array.each(treestore.data.items, function (rec) {
724
				rec.expand(true);
725
				SumWeight49 = parseFloat(SumWeight49) + parseFloat(rec.data.Weight);
726
			})
727
		}
728
		console.log(SumWeight49);
729
		var SumWeight51 = 0;
730
		var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
731
		var storequal = undefined;
732
		if (pnlqual != undefined) {
733
			pnlqual.expandAll();
734
			storequal = pnlqual.store;
735
			Ext.Array.each(storequal.data.items, function (rec) {
736
				rec.expand(true); 
737
				SumWeight51 = parseFloat(SumWeight51) + parseFloat(rec.data.Weight); 
738
			})
739
		}
740
		console.log(SumWeight51);
741
		if(SumKPIWeight48 > 100 || SumKPIWeight48 < 100)
742
		{
743
			MinovaMessage('', 'PMSE005', '', 'E');
744
		}
745
		else if(SumQualWeight48 > 100 || SumQualWeight48 < 100)
746
		{
747
			MinovaMessage('', 'PMSE006', '', 'E');
748
		}
749
		else if(SumWeight49 > 100 || SumWeight49 < 100 )
750
		{
751
			MinovaMessage('', 'PMSE007', '', 'E'); 
752
		}
753
		else if(SumWeight51 > 100 || SumWeight51 < 100)
754
		{
755
			MinovaMessage('', 'PMSE008', '', 'E'); 
756
		}
757
		else //// add by Tri nwh 202023 untuk validasi weight end		
758
		{
759
			form.mask('Loading...');
760
			var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
761
			var PA0049 = Ext.StoreMgr.lookup("storePHRPA0049");
762
			var PA0049A = Ext.StoreMgr.lookup("storePHRPA0049A");
763
			var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
764
			var PA0048_dATA = null;
765
			var PA0049_dATA = null;
766
			var PA0049A_dATA = null;
767
			var PA0051_dATA = null;
768
			var TREE_dATA = null;
769
		
770
			if (PA0048 != undefined)
771
				PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
772
			if (PA0049 != undefined)
773
				PA0049_dATA = Ext.encode(Ext.pluck(PA0049.data.items, 'data'));
774
			if (PA0049A != undefined)
775
				PA0049A_dATA = Ext.encode(Ext.pluck(PA0049A.data.items, 'data'));
776
			if (storequal != undefined) {
777
				var _data = Ext.pluck(storequal.data.items, 'data');
778
				Ext.Array.each(_data, function (rec) {
779
					rec.children = null
780
				})
781
				PA0051_dATA = Ext.encode(_data);
782
			}
783
			if (treepnl != undefined)
784
				TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
785

    
786
			if (data.AppraisalType != "G") {
787
				var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
788
				var form_ = form.getForm();
789
				var data = form_.getValues();
790
				var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
791
				if (Sum.data.items.length > 0) {
792
					var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
793
					Ext.Array.each(Ext.decode(DataSum), function (rec) {
794
						if (rec.Type == "KPI") {
795
							data["AdjustedKPI"] = rec.AdjustedScore;
796
							data["CalculatedKPI"] = rec.CalculatedScore;
797
							data["KPIFinalScore"] = rec.FinalScore;
798
							data["KPITotalScore"] = rec.TotalScore;
799
							data["KPITotalWeight"] = rec.Weight;
800
						} else {
801
							data["AdjustedCompetency"] = rec.AdjustedScore;
802
							data["CalculatedCompetency"] = rec.CalculatedScore;
803
							data["QualFinalScore"] = rec.FinalScore;
804
							data["QualTotalScore"] = rec.TotalScore;
805
							data["QualTotalWeight"] = rec.Weight;
806
						}
807
					})
808
				}
809
				var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
810
				var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
811
				if (dataTotalSum.length > 0) {
812
					data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
813
					data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
814
					data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
815
					data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
816
				}
817
			}
818
			var params = {		//// add by Tri nwh 20220602
819
				serviceName : 'Performance.asmx',
820
				methodName : 'savePerformance',
821
				parameter :
822
				'header=' + Ext.encode(data)
823
				 + '&PA0048=' + PA0048_dATA
824
				 + '&PA0049=' + TREE_dATA
825
				 + '&PA0049A=' + TREE_dATA
826
				 + '&PA0051=' + PA0051_dATA
827
				 + '&Token=' + MinovaUtil.SESSIONS.Token
828
			};
829
			MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
830
				var result = Ext.decode(xhr.responseText);
831
				console.log(result.success);
832
				var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
833
				card_.getLayout().setActiveItem(0);
834
				MinovaMessage('', '000006', '', 'S');
835
				if (data.AppraisalType == "F") {
836
					//me.SaveToMDHistory();
837
					//me.saveToMDProfile();
838
				}
839
				me.afterRenderOverview();
840
				form.unmask();
841
			});
842
		}
843
	},
844

    
845
	btnGoToother : function () {
846
		var menu_ = [];
847
		var Y = 180;
848

    
849
		menu_.push({
850
			text : 'Employee Search',
851
			handler : function () {
852
				Ext.create('Ext.window.Window', {
853
					title : 'Lookup - Employee',
854
					height : 530,
855
					width : 500,
856
					name : 'lookupMain',
857
					modal : true,
858
					items : [{
859
							xtype : 'minovaform',
860
							bodyBorder : false,
861
							MaxHeigth : '100',
862
							cls : 'borderLookup',
863
							border : false,
864
							MaxHeigth : '30',
865
							scroll : true,
866
							isLookup : true,
867
							name : "formLookupFilter",
868
							tableName : 'PDSEMP0002',
869
							buttons : [{
870
									text : 'Search',
871
									handler : function () {
872
										var store = Ext.data.StoreManager.lookup('lookupStore');
873
										var form = Ext.ComponentQuery.query('[name=formLookupFilter]')[0].getForm();
874
										grid = Ext.ComponentQuery.query('[name=gridLookup]')[0];
875
										var values_ = form.getValues();
876
										var fields_ = form.getFields().items;
877
										var param_ = '';
878
										for (var i = 0; i < fields_.length; i++) {
879
											var val_ = form.getFields().items[i].getValue();
880
											var xtype_ = form.getFields().items[i].xtype;
881
											var oprator_ = '[like]';
882
											if (xtype_ == 'combobox' || xtype_ == 'combo' || xtype_ == 'minovacombo' || xtype_ == 'minovacombobox') {
883
												oprator_ = '[Equal]';
884
											}
885
											if (xtype_ == 'datefield') {
886
												if (form.getFields().items[i].name == 'StartDate' || form.getFields().items[i].name == 'ValidForm') {
887
													oprator_ = '[LessThanEqual]';
888
												} else {
889
													oprator_ = '[GreaterThanEqual]';
890
												}
891
											}
892
											if (val_ != 'undefined' && val_ != "" && val_ != null) {
893
												param_ = param_ + ',' + form.getFields().items[i].name + oprator_ + val_;
894
											}
895
										}
896
										store.proxy.extraParams = {
897
											tableName : grid.tableName,
898
											param : param_,
899
											menuId : MinovaUtil.GetMenuID()
900
										};
901
										store.removeAll();
902
										store.reload();
903
										store.loadPage(1);
904
									}
905

    
906
								}
907
							],
908
						}, {
909
							xtype : 'minovagrid1',
910
							isLookup : 1,
911
							minHeight : 280,
912
							height : 280,
913
							tableName : 'PDSEMP0002',
914
							param : '',
915
							isLookup : true,
916
							autoLoad : false,
917
							name : 'gridLookup',
918
							hidebutton : 0,
919
							pagesize : 25,
920
							storename : 'lookupStore',
921
							listeners : {
922
								itemdblclick : function (g) {
923
									var dataSelection = this.getView().getSelectionModel().getSelection()[0].data;
924
									//console.log(dataSelection)
925
									var url = MinovaUtil.GetMenuID() + '&EmployeeID=' + dataSelection.EmployeeID + '&FullName=' + dataSelection.FullName + '&Lang=' + localStorage.LangId;
926
									var mb = new minovaBlowfish();
927
									e = mb.minovaEncryptUrl(url);
928
									window.open('masterdataperformancedetail?' + e, "_self");
929

    
930
								},
931
								beforeedit : function (grid) {
932
									return false;
933
								}
934
							},
935
							dockedItems : [{
936
									xtype : 'pagingtoolbar',
937
									store : 'lookupStore',
938
									dock : 'bottom',
939
									pageSize : 25,
940
									displayInfo : true
941
								}
942
							]
943

    
944
						}, ]
945
				}).show();
946
			}
947
		});
948
		menu_.push({
949
			text : 'Back',
950
			handler : function () {
951
				window.history.back();
952
			}
953
		});
954
		Ext.create('Ext.menu.Menu', {
955
			name : 'panelMenu',
956
			width : 240,
957
			height : 100,
958
			margin : '0 0 10 0',
959

    
960
			items : menu_
961
		}).showAt([1239, Y]);
962
	},
963

    
964
	deletePerformance : function () {
965
		var me = this;
966
		var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0];
967
		var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0];
968
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
969
		var Sequence = Ext.ComponentQuery.query('[name=Sequence]')[0];
970
		var _empID = getParam('EmployeeID');
971

    
972
		Ext.Ajax.request({
973
			async : false,
974
			method : 'POST',
975
			url : '/Performance/deleteData',
976
			params : {
977
				EmpID : _empID,
978
				Seq : Sequence.getValue(),
979
				AppType : appType.getValue(),
980
				StDate : StartDate.getValue(),
981
				EnDate : EndDate.getValue()
982
			},
983
			waitMsg : 'Deleting Data...',
984
			success : function (response) {
985

    
986
				var result = Ext.decode(response.responseText);
987
				if (result.success) {
988
					var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
989
					card_.getLayout().setActiveItem(0);
990
					MinovaMessage('', '000006', '', 'S');
991
					me.afterRenderOverview();
992
					//pnl.unmask();
993
				} else {
994
					//.unmask();
995
					//MinovaMessage('', result.message.id, result.message.text, "E");
996
					MinovaMessage('', '000005', result.message.text, "E")
997
				}
998
			},
999
			failure : function (response) {
1000
				var result = Ext.decode(response.responseText);
1001
				//pnl.unmask();
1002
				// MinovaMessage('', result.message.id, result.message.text, "E")
1003
				MinovaMessage('', '000005', result.message.text, "E")
1004
			}
1005
		});
1006

    
1007
		me.afterRenderOverview();
1008
	},
1009

    
1010
	addAppraiser : function () {
1011
		var grid = Ext.getCmp('gridPHRPA0048');
1012
		var record = grid.getSelectionModel().getSelection()[0];
1013
		record.set('EmployeeID', getParam('EmployeeID'));
1014
	},
1015

    
1016
	getDataAppraiser : function (tblName) {
1017
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1018
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1019
		var overView = Ext.StoreMgr.lookup('store' + tblName);
1020
		var param = null;
1021
		var data_kpi = null;
1022

    
1023
		if (tblName == 'PHRPA0049') {
1024
			var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
1025
			Ext.Ajax.request({
1026
				//method : 'POST',
1027
				async : false,
1028
				url : '/Performance/getKPI',
1029
				params : {
1030
					EmpID : _empID,
1031
					Seq : seq.getValue(),
1032
					AppType : appType.getValue()
1033
				},
1034
				success : function (response) {
1035
					var results = Ext.decode(response.responseText);
1036
					data_kpi = Ext.decode(results.data);
1037
				}
1038
			});
1039
			pnl.store.setRootNode({
1040
				expanded : true,
1041
				nodetype : 'async',
1042
				children : data_kpi
1043
				//[]
1044
			});
1045
		} else {
1046
			param = 'EmployeeID[=]' + getParam('EmployeeID')
1047
				 + ',HeaderSequence[=]' + seq.getValue()
1048
				 + ',AppraisalType[=]' + appType.getValue();
1049
			Ext.Ajax.request({
1050
				//method : 'POST',
1051
				async : false,
1052
				url : '/UserControl/GetStore',
1053
				params : {
1054
					tableName : tblName,
1055
					param : param
1056
				},
1057
				success : function (response) {
1058
					var results = Ext.decode(response.responseText);
1059

    
1060
					if (tblName != 'PHRPA0049') {
1061
						overView.removeAll();
1062
						overView.loadData(results.data);
1063
					} else {
1064
						var data_ = results.data;
1065
						var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
1066
						pnl.store.setRootNode({
1067
							expanded : true,
1068
							nodetype : 'async',
1069
							children : data_
1070
							//[]
1071
						});
1072
					}
1073
				}
1074
			});
1075
		}
1076
		//overView.removeAll();
1077
		//overView.reload();
1078
		//overView.loadPage(1);
1079
	},
1080

    
1081
	loadChild : function (node, index, item, eOpts) {
1082
		var me = this;
1083
		var _empID = getParam('EmployeeID');
1084
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1085
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1086
		var data_ = null;
1087
		var idx = 0;
1088
		var tree_ = Ext.ComponentQuery.query('treepanel[name=gridPHRPA0049]')[0];
1089
		var v = tree_.getView();
1090

    
1091
		if (node.data.IsSubKPI == '1') {
1092
			return;
1093
		}
1094

    
1095
		tree_.mask('Expanding tree...');
1096

    
1097
		Ext.Ajax.request({
1098
			//method : 'POST',
1099
			async : false,
1100
			url : '/Performance/getSubKPI',
1101
			params : {
1102
				EmpID : _empID,
1103
				Seq : seq.getValue(),
1104
				AppType : appType.getValue(),
1105
				KPIID : node.data.KPI,
1106
				KPISeq : node.data.Sequence
1107
			},
1108
			success : function (response) {
1109
				var results = Ext.decode(response.responseText);
1110
				data_ = Ext.decode(results.data);
1111
			}
1112
		});
1113

    
1114
		if (data_.length > 0) {
1115
			data_.forEach(function (rec) {
1116
				if (v.store.data.find('SequenceSubKPI', rec.SequenceSubKPI) == null) {
1117
					node.appendChild(data_[idx])
1118
				}
1119
				idx++;
1120
			})
1121
		}
1122

    
1123
		tree_.unmask();
1124
	},
1125

    
1126
	addNewKPI : function () {
1127
		var me = this;
1128
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewKPI]').length;
1129
		if (count_lookup == 1) {
1130
			Ext.ComponentQuery.query('[name=AddNewKPI]')[0].show();
1131
		} else {
1132
			Ext.create('Ext.window.Window', {
1133
				title : 'Add KPI',
1134
				name : 'AddNewKPI',
1135
				layout : 'fit',
1136
				items : [{
1137
						xtype : 'form',
1138
						name : 'formAddKPI',
1139
						items : [{
1140
								xtype : 'minovaForm',
1141
								bodyBorder : false,
1142
								cls : 'borderLookup',
1143
								border : false,
1144
								isLookup : false,
1145
								name : "mainformAddKPI",
1146
								tableName : 'PDSPMLOOKUPKPI'
1147
							}
1148
						]
1149
					}
1150
				],
1151
				buttons : [{
1152
						text : 'Add KPI',
1153
						name : 'BtnAddKPI',
1154
						iconCls : 'fa-save',
1155
						style : 'font-family: FontAwesome',
1156
						margin : '3 3 10 3',
1157
						handler : function () {
1158
							me.addNewKPItoGrid();
1159
						}
1160
					}, {
1161
						text : 'Cancel',
1162
						name : 'BtnCancelKPI',
1163
						iconCls : 'fa-reply',
1164
						style : 'font-family: FontAwesome',
1165
						margin : '3 3 10 3',
1166
						handler : function () {
1167
							me.cancelAddNewKPI();
1168
						}
1169
					}
1170
				]
1171
			}).show();
1172
		}
1173
	},
1174

    
1175
	cancelAddNewKPI : function () {
1176
		Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1177
	},
1178

    
1179
	addNewKPItoGrid : function () {
1180
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1181
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1182
		var leafCount = 0;
1183
		pnl.getRootNode().cascadeBy(function (node) {
1184
			if (!node.isLeaf())
1185
				leafCount++;
1186
		});
1187
		var data = '';
1188
		var Sequence = 0;
1189
		if (leafCount == 0) {
1190
			Sequence = 1;
1191
		} else {
1192
			Sequence = 1 + leafCount;
1193
		}
1194

    
1195
		var a = Ext.ComponentQuery.query('[name=mainformAddKPI]')[0];
1196
		var b = a.getValues();
1197
		var C = '';
1198

    
1199
		Ext.Ajax.request({
1200
			method : 'POST',
1201
			async : false,
1202
			url : '/UserControl/GetStore',
1203
			params : {
1204
				tableName : 'PHROM0002',
1205
				param : 'ObjectClass[=]KG,RelationshipClass[=]K,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=KPI]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1206
			},
1207
			success : function (response) {
1208
				var results = Ext.decode(response.responseText);
1209
				if (results.data != null && results.data.length > 0) {
1210
					c = results.data[0].ObjectID;
1211
				}
1212
			}
1213
		});
1214

    
1215
		data = {
1216
			KPIGroup : c,
1217
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1218
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1219
			KPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1220
			Sequence : Sequence,
1221
			ObjectDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1222
			SubKPI : "-",
1223
			HeaderSequence : seq,
1224
			SequenceSubKPI : "0",
1225
			IsSubKPI : "0",
1226
			leaf : false,
1227
			Target : 1,
1228
			expanded : true
1229
			,App2Value : 0			//// ---- add by Tri nwh 20221114
1230
			,App3Value : 0		
1231
			,App4Value : 0		
1232
			,App5Value : 0
1233
			,App1Score : 0			
1234
			,App2Score : 0		
1235
			,App3Score : 0		
1236
			,App4Score : 0
1237
			,App5Score : 0				
1238
		};
1239

    
1240
		var task = pnl.getRootNode();
1241
		task.appendChild(data);
1242
		Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1243
	},
1244

    
1245
	addNewsubKPI : function (record) {
1246
		var me = this;
1247
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewsubKPI]').length;
1248
		if (count_lookup == 1) {
1249
			Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].show();
1250
		} else {
1251
			Ext.create('Ext.window.Window', {
1252
				title : 'Add subKPI',
1253
				name : 'AddNewsubKPI',
1254
				layout : 'fit',
1255
				items : [{
1256
						xtype : 'form',
1257
						name : 'formAddsubKPI',
1258
						items : [{
1259
								xtype : 'minovaForm',
1260
								bodyBorder : false,
1261
								cls : 'borderLookup',
1262
								border : false,
1263
								isLookup : false,
1264
								name : "mainformAddsubKPI",
1265
								tableName : 'PDSPMLOOKUPKPI'
1266
							}
1267
						]
1268
					}
1269
				],
1270
				buttons : [{
1271
						text : 'Add subKPI',
1272
						name : 'BtnAddsubKPI',
1273
						iconCls : 'fa-save',
1274
						style : 'font-family: FontAwesome',
1275
						margin : '3 3 10 3',
1276
						handler : function () {
1277
							me.addNewsubKPItoGrid(record);
1278
						}
1279
					}, {
1280
						text : 'Cancel',
1281
						name : 'BtnCancelsubKPI',
1282
						iconCls : 'fa-reply',
1283
						style : 'font-family: FontAwesome',
1284
						margin : '3 3 10 3',
1285
						handler : function () {
1286
							Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1287
						}
1288
					}
1289
				]
1290
			}).show();
1291
		}
1292
	},
1293

    
1294
	addNewsubKPItoGrid : function (record) {
1295
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1296
		var leafCount = 0;
1297
		var _empID = getParam('EmployeeID');
1298
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1299
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1300
		var i = 0;
1301
		var data_ = null;
1302
		Ext.Ajax.request({
1303
			async : false,
1304
			url : '/Performance/getSubKPI',
1305
			params : {
1306
				EmpID : _empID,
1307
				Seq : seq.getValue(),
1308
				AppType : appType.getValue(),
1309
				KPIID : record.data.KPI,
1310
				KPISeq : record.data.Sequence
1311
			},
1312
			success : function (response) {
1313
				var results = Ext.decode(response.responseText);
1314
				data_ = Ext.decode(results.data);
1315
			}
1316
		});
1317
		if (data_.length == 0) {
1318
			i = 1;
1319
		} else {
1320
			i += data_.length;
1321
		}
1322

    
1323
		var data = {
1324
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1325
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1326
			KPI : record.data.KPI,
1327
			ObjectDescription : record.data.ObjectDescription,
1328
			Sequence : record.data.Sequence,
1329
			HeaderSequence : seq.getValue(),
1330
			SequenceSubKPI : i,
1331
			IsSubKPI : "1",
1332
			SubKPI : Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1333
			SubKPIDescription : Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1334
			leaf : true
1335
		};
1336

    
1337
		record.appendChild(data);
1338
		Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1339
	},
1340

    
1341
	loadMenu : function () {
1342
		var me = this;
1343
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1344
		var record = main_.getView().selection;
1345
		var _a = record.data.leaf;
1346
		var _kpi = record.data.KPI;
1347
		var rowIndex = record.data.index;
1348
		var n = rowIndex * 50;
1349
		var Y = 180 + n;
1350
		var menu_ = []
1351

    
1352
		if (!_a) {
1353
			menu_.push({
1354
				text : 'Delete KPI',
1355
				handler : function () {
1356
					me.deleteSubKPI(record);
1357
				}
1358
			})
1359
			menu_.push({
1360
				text : 'Add subKPI',
1361
				handler : function () {
1362
					me.addNewsubKPI(record);
1363
				}
1364
			})
1365
			menu_.push({
1366
				text : 'Delete All subKPI',
1367
				handler : function () {}
1368
			})
1369
		} else {
1370
			menu_.push({
1371
				text : 'Delete subKPI',
1372
				handler : function () {
1373
					me.deleteSubKPI(record);
1374
				}
1375
			})
1376
		}
1377

    
1378
		Ext.create('Ext.menu.Menu', {
1379
			name : 'panelMenu',
1380
			width : 240,
1381
			height : 150,
1382
			margin : '0 0 10 0',
1383
			items : menu_
1384
		}).showAt([1239, Y]);
1385
	},
1386

    
1387
	ValidasiAppWeight : function () { // add by Tri nwh 20221117
1388
		var me = this;
1389
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1390
		var form_ = form.getForm();
1391
		var data = form_.getValues();
1392
		var Sum = Ext.StoreMgr.lookup("storePHRPA0048");
1393
		var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1394
		var SumKPIWeight = 0;
1395
		var SumQualWeight = 0;
1396
		var idx = Sum.getCount();
1397
		var data = '';
1398
		Ext.Array.each(Ext.decode(DataSum), function (rec) {
1399
			SumKPIWeight = parseFloat(SumKPIWeight) + parseFloat(rec.KPIWeight);
1400
			SumQualWeight = parseFloat(SumQualWeight) + parseFloat(rec.QualificationWeight);
1401
			if(SumKPIWeight >= 100)
1402
			{
1403
				MinovaMessage('', 'PMSE005', '', 'E');
1404
				rec.remove()
1405
			}
1406
			if(SumQualWeight >= 100)
1407
			{
1408
				MinovaMessage('', 'PMSE006', '', 'E');
1409
				rec.remove()
1410
			}
1411
		})
1412
	},
1413

    
1414
	AddAppraiserQ : function () { },
1415

    
1416
	deleteSubKPI : function (a) {
1417
		/*var main_ = Ext.ComponentQuery.query('[name=PHRPA0049]')[0];
1418
		var record = main_.getView().selection;
1419
		var _empID = getParam('EmployeeID');
1420
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1421
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1422
		var kpiseq = record.data.Sequence;
1423
		var skpiseq = record.data.SequenceSubKPI;
1424
		var params = {
1425
		serviceName : 'Performance.asmx',
1426
		methodName : 'deleteSubKPI',
1427
		parameter : 'empID=' + _empID
1428
		+ '&HeaderSeq=' + seq.getValue()
1429
		+ '&appType=' + appType.getValue()
1430
		+ '&KPISeq=' + kpiseq
1431
		+ '&sKPISeq=' + skpiseq
1432
		};
1433
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1434
		var result = Ext.decode(xhr.responseText);
1435
		if (result.success) {
1436
		MinovaMessage('', 'PMS0001', '', 'S');
1437
		record.remove();
1438
		} else {
1439
		MinovaMessage('', '000005', result.message.text, 'E');
1440
		}
1441
		});*/
1442
		a.remove();
1443
	},
1444

    
1445
	calculatePMS : function () {
1446
		var pnl = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1447
		var form_ = pnl.getForm();
1448
		var data = form_.getValues();
1449
		var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1450
		var treestore = treepnl.store;
1451
		var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1452
		var storequal = undefined;
1453
		if (pnlqual != undefined) {
1454
			pnlqual.expandAll();
1455
			storequal = pnlqual.store;
1456
		}
1457
		var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1458
		var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
1459
		var PA0048_dATA = null;
1460
		var PA0051_dATA = null;
1461
		var TREE_dATA = null;
1462
		var Head = null;
1463
		var Child = null;
1464

    
1465
		if (data.AppraisalType != "G") {
1466
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1467
			var form_ = form.getForm();
1468
			var data = form_.getValues();
1469
			var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1470
			if (Sum.data.items.length > 0) {
1471
				var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1472
				Ext.Array.each(Ext.decode(DataSum), function (rec) {
1473
					if (rec.Type == "KPI") {
1474
						data["AdjustedKPI"] = rec.AdjustedScore;
1475
						data["CalculatedKPI"] = rec.CalculatedScore;
1476
						data["KPIFinalScore"] = rec.FinalScore;
1477
						data["KPITotalScore"] = rec.TotalScore;
1478
					} else {
1479
						data["AdjustedCompetency"] = rec.AdjustedScore;
1480
						data["CalculatedCompetency"] = rec.CalculatedScore;
1481
						data["QualFinalScore"] = rec.FinalScore;
1482
						data["QualTotalScore"] = rec.TotalScore;
1483
					}
1484
				})
1485
			}
1486
			var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1487
			var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1488
			if (dataTotalSum.length > 0) {
1489
				data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1490
				data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1491
				data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1492
				data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1493
			}
1494
		}
1495

    
1496
		if (PA0048 != undefined)
1497
			PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
1498
		if (storequal != undefined) {
1499
			var _data = Ext.pluck(storequal.data.items, 'data');
1500
			Ext.Array.each(_data, function (rec) {
1501
				rec.children = null
1502
			})
1503
			PA0051_dATA = Ext.encode(_data);
1504
		}
1505
		if (treepnl != undefined)
1506
			TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
1507

    
1508
		var dataresult = null;
1509
		var data47 = null;
1510

    
1511
		var params = {
1512
			serviceName : 'Performance.asmx',
1513
			methodName : 'CalculatePerformance',
1514
			parameter :
1515
			'header=' + Ext.encode(data)
1516
			 + '&PA0048=' + PA0048_dATA
1517
			 + '&PA0049=' + TREE_dATA
1518
			 + '&PA0051=' + PA0051_dATA
1519
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1520
		};
1521
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1522
			var result = Ext.decode(xhr.responseText);
1523
			dataresult = result.data;
1524
			Head = $.grep(Ext.decode(dataresult), function (r) {
1525
					return r.Tablename == '0047'
1526
				});
1527
			data47 = Head;
1528
			var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1529
			var form_ = form.getForm();
1530
			form_.setValues(Head[0]);
1531
			var dataPA0048 = $.grep(Ext.decode(dataresult), function (r) {
1532
					return r.Tablename == '0048'
1533
				});
1534
			var overView = Ext.StoreMgr.lookup('storePHRPA0048');
1535
			if (overView != undefined) {
1536
				overView.removeAll();
1537
				overView.loadData(dataPA0048);
1538
			}
1539
			
1540
			//// comment by Tri 
1541
			var dataPA0049 = $.grep(Ext.decode(dataresult), function (r) {
1542
					return r.Tablename == '0049'
1543
				}); console.log(dataPA0049);
1544
			var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1545
			if (pnl != undefined) {
1546
				pnl.store.load()
1547
				var taskkpi = pnl.getRootNode();
1548
				taskkpi.appendChild(dataPA0049);
1549
			}
1550
			
1551
			var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1552
					return r.Tablename == '0051'
1553
				});
1554
			var pnl51 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
1555
			if (pnl51 != undefined) {
1556
				pnl51.store.load()
1557
				var qual = pnl51.getRootNode();
1558
				qual.appendChild(dataPA0051);
1559
			}
1560

    
1561
			/* var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1562
					return r.Tablename == '0051'
1563
				});
1564
			var pnl2 = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
1565
			if (pnl2 != undefined) {
1566
				//pnl.store.removeAll()
1567
				pnl2.store.load()
1568
				// pnl.store.setRootNode({
1569
				// expanded : true,
1570
				// nodetype : 'async',
1571
				// children : dataKPI
1572
				// });
1573
				var taskqual = pnl2.getRootNode();
1574
				taskqual.appendChild(dataPA0051);
1575
			}*/
1576
			
1577
			/*var pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0]; //// comment by Tri nwh 20220527
1578
			Head = $.grep(dataPA0051, function (r) {
1579
					return r.SequenceSub == 0
1580
				});
1581
			Child = $.grep(dataPA0051, function (r) {
1582
					return r.SequenceSub != 0
1583
				});
1584
			Ext.Array.each(Child, function (rec) {
1585
				rec['leaf'] = true;
1586
			});
1587
			if (pnl2 != undefined) {
1588
				pnl2.store.load();
1589
				var task = pnl2.getRootNode();
1590
				//task.appendChild(Head);
1591
				//pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1592
				//storequal = pnl2.store;
1593
				//Ext.Array.each(storequal.data.items, function (rec) {
1594
				//var t = rec.data;
1595
				//var QChild = $.grep(Child, function (r) {
1596
				//return r.QualificationID == t.QualificationID
1597
				//});
1598
				//var index = t.index;
1599
				//rec.appendChild(QChild);
1600
				//})
1601
				Ext.Array.each(Head, function (rec) {
1602
					var QChild = $.grep(Child, function (r) {
1603
							return r.QualificationID == rec.QualificationID
1604
						});
1605
					rec['children'] = QChild;
1606
					rec['expanded'] = true;
1607
					task.appendChild(rec);
1608
				})
1609
				pnl2.getView().refresh();
1610
			}*/
1611
			if (result.success) {
1612
				MinovaMessage('', 'PMS0002', '', 'S');
1613
			} else {
1614
				MinovaMessage('', '000005', '', 'E');
1615
			}
1616

    
1617
			data = {
1618
				AdjustedIndex : '',
1619
				AdjustedScore : data47[0].AdjustedKPI,
1620
				CalculatedScore : data47[0].CalculatedKPI,
1621
				FinalScore : data47[0].KPIFinalScore,
1622
				IndexScore : '',
1623
				TotalScore : data47[0].KPITotalScore,
1624
				Type : 'KPI',
1625
				Weight : data47[0].KPITotalWeight//'80'
1626
			};
1627

    
1628
			data2 = [];
1629
			data2[0] = data;
1630

    
1631
			data = {
1632
				AdjustedIndex : '',
1633
				AdjustedScore : data47[0].AdjustedCompetency,
1634
				CalculatedScore : data47[0].CalculatedCompetency,
1635
				FinalScore : data47[0].QualFinalScore,
1636
				IndexScore : '',
1637
				TotalScore : data47[0].QualTotalScore,
1638
				Type : 'Qualification',
1639
				Weight : data47[0].QualTotalWeight//'20'
1640
			};
1641

    
1642
			data2[1] = data;
1643

    
1644
			var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
1645
			if (overView != undefined) {
1646
				overView.removeAll();
1647
				overView.loadData(data2);
1648
			}
1649

    
1650
			dataTotal = {
1651
				AdjustedIndex : data47[0].AdjustedIndex,
1652
				AdjustedScore : data47[0].AdjustedScore,
1653
				CalculatedScore : data47[0].CalculatedScore,
1654
				IndexScore : data47[0].CalculatedIndex
1655
			};
1656

    
1657
			dataTotalList = [];
1658
			dataTotalList[0] = dataTotal;
1659

    
1660
			var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
1661
			if (overView != undefined) {
1662
				overView.removeAll();
1663
				overView.loadData(dataTotalList);
1664
			}
1665
		});
1666
	},
1667

    
1668
	addNewQualification : function () {
1669
		var me = this;
1670
		var count_lookup = Ext.ComponentQuery.query('[name=AddNewQualification]').length;
1671
		if (count_lookup == 1) {
1672
			Ext.ComponentQuery.query('[name=AddNewQualification]')[0].show();
1673
		} else {
1674
			Ext.create('Ext.window.Window', {
1675
				title : 'Add Qualification',
1676
				name : 'AddNewQualification',
1677
				layout : 'fit',
1678
				items : [{
1679
						xtype : 'form',
1680
						name : 'formAddQualification',
1681
						items : [{
1682
								xtype : 'minovaForm',
1683
								bodyBorder : false,
1684
								cls : 'borderLookup',
1685
								border : false,
1686
								isLookup : false,
1687
								name : "mainformAddQualification",
1688
								tableName : 'PDSPMLOOKUPQUAL'
1689
							}
1690
						]
1691
					}
1692
				],
1693
				buttons : [{
1694
						text : 'Add Qualification',
1695
						name : 'BtnAddKPI',
1696
						iconCls : 'fa-save',
1697
						style : 'font-family: FontAwesome',
1698
						margin : '3 3 10 3',
1699
						handler : function () {
1700
							me.addNewQualificationtoGrid();
1701
						}
1702
					}, {
1703
						text : 'Cancel',
1704
						name : 'BtnCancelQualification',
1705
						iconCls : 'fa-reply',
1706
						style : 'font-family: FontAwesome',
1707
						margin : '3 3 10 3',
1708
						handler : function () {
1709
							Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1710
						}
1711
					}
1712
				]
1713
			}).show();
1714
		}
1715
	},
1716

    
1717
	addNewQualificationtoGrid : function () { 
1718
		var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1719
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1720
		var str = pnl.store;
1721
		
1722
		if (str.findRecord('QualificationID', Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()) != null) {
1723
			return;
1724
		}
1725

    
1726
		var leafCount = 0;
1727
		pnl.getRootNode().cascadeBy(function (node) {
1728
			if (!node.isLeaf())
1729
				leafCount++;
1730
		});
1731
		var data = '';
1732
		var Sequence = 0;
1733
		if (leafCount == 0) {
1734
			Sequence = 1;
1735
		} else {
1736
			Sequence = 1 + leafCount;
1737
		}
1738
		
1739
		var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1740
		var formdata_ = form_.getForm();
1741

    
1742
		var data = {
1743
			"EmployeeID" : formdata_.findField('EmployeeID').getValue(),
1744
			"HeaderSequence" : formdata_.findField('Sequence').getValue(),
1745
			"Sequence" : Sequence,
1746
			"AppraisalType" : formdata_.findField('AppraisalType').getValue()
1747
		}; 		
1748
		var data2 = null;
1749
		/*var params = {
1750
			serviceName : 'Performance.asmx',
1751
			methodName : 'SetQualification',
1752
			parameter : 'TableName=' + 'PHRPA0051'
1753
			 + '&Qualification=' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()
1754
			 + '&data=' + Ext.encode(data)
1755
		};
1756
		MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
1757
			var result = Ext.decode(xhr.responseText);
1758
			data2 = result.data;
1759
			if (result.success) {console.log(data2);}
1760
			else {
1761
				MinovaMessage('', '000005', result.message.text, 'E');
1762
			}
1763
		});*/
1764
		
1765
		var a = Ext.ComponentQuery.query('[name=mainformAddQualification]')[0];
1766
        var b = a.getValues();
1767
		var d = '';
1768
		Ext.Ajax.request({
1769
            method: 'POST',
1770
            async: false,
1771
            url: '/UserControl/GetStore',
1772
            params: {
1773
                //tableName: 'PHROM0001',
1774
                //param: 'ObjectClass[=]Q,ObjectID[=]' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue() + ',EndDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1775
				tableName : 'PHROM0002',
1776
				param : 'ObjectClass[=]QG,RelationshipClass[=]Q,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1777
            },
1778
            success: function (response) {
1779
                var results = Ext.decode(response.responseText);
1780
                if (results.data != null && results.data.length > 0) {
1781
                    d = results.data[0].ObjectID;
1782
					//data2 = results.data; console.log(data2);
1783
                }
1784
            }
1785
        });
1786
				
1787
		//var children = eval("children:" + data2);
1788
		data = {
1789
			QualificationGroup: d, //// add by Tri nwh 
1790
			EmployeeID : Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1791
			AppraisalType : Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1792
			QualificationID : Ext.ComponentQuery.query('[name=Qualification]')[0].getValue(),
1793
			Sequence : Sequence,
1794
			Description : Ext.ComponentQuery.query('[name=Qualification]')[0].value.split('-')[1].substr(1),
1795
			HeaderSequence : seq,
1796
			SequenceSub : "0",
1797
			Weight : 0,
1798
			leaf : false,
1799
			Target : 1,
1800
			//children,
1801
			expanded : true	
1802
			,App2Level : 0			//// ---- add by Tri nwh 20221114
1803
			,App3Level : 0		
1804
			,App4Level : 0		
1805
			,App5Level : 0
1806
			,App1Score : 0			
1807
			,App2Score : 0		
1808
			,App3Score : 0		
1809
			,App4Score : 0
1810
			,App5Score : 0
1811
		};
1812
		
1813
		var task = pnl.getRootNode();
1814
		task.appendChild(data); 
1815
		Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1816
	},
1817

    
1818
	loadQualification : function () {
1819
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1820
		var _result = undefined;
1821
		var Head = undefined;
1822
		
1823
		Ext.Ajax.request({
1824
			async : false,
1825
			//method : 'POST',
1826
			url : '/UserControl/GetStore',
1827
			params : {
1828
				tableName : 'PHRPA0051',
1829
				param : 'EmployeeID[=]' + Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue()
1830
				 + ',AppraisalType[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()
1831
				 + ',HeaderSequence[=]' + Ext.ComponentQuery.query('[name=Sequence]')[0].getValue()
1832
			},
1833
			success : function (response) {
1834
				_result = Ext.decode(response.responseText);
1835
				if (_result.success) {
1836
					var data = _result.data;
1837
					Head = $.grep(data, function (r) {
1838
							return r.SequenceSub == 0
1839
						});
1840
					var Child = $.grep(data, function (r) {
1841
							return r.SequenceSub != 0
1842
						});
1843
					Ext.Array.each(Child, function (rec) {
1844
						rec['leaf'] = true;
1845
					})
1846
					pnl.store.load();
1847
					var task = pnl.getRootNode();
1848
					Ext.Array.each(Head, function (rec) {
1849
						var QChild = $.grep(Child, function (r) {
1850
								return r.QualificationID == rec.QualificationID
1851
							});
1852
						rec['children'] = QChild;
1853
						rec['expanded'] = true;
1854
						task.appendChild(rec);
1855
					})
1856
				}
1857
			}
1858
		});
1859
	},
1860

    
1861
	deleteQualification : function () {
1862
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1863
		var record = main_.getView().selection;
1864

    
1865
		if (record == null) {
1866
			MinovaMessage('', 'PMSE003', '', 'E');
1867
			return;
1868
		}
1869

    
1870
		var _d = record.data;
1871
		if (_d.SequenceSub != 0) {
1872
			MinovaMessage('', 'PMSE003', '', 'E');
1873
			return;
1874
		}
1875
		record.remove();
1876
	},
1877

    
1878
	deleteKPI : function () {
1879
		var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1880
		var record = main_.getView().selection;
1881

    
1882
		if (record == null) {
1883
			MinovaMessage('', 'PMSE003', '', 'E');
1884
			return;
1885
		}
1886
		
1887
		var _d = record.data;
1888
		if (_d.SequenceSubKPI != 0) {
1889
			MinovaMessage('', 'PMSE003', '', 'E');
1890
			return;
1891
		}
1892
		record.remove();
1893
	},
1894

    
1895
	setDefaultAppbyOM : function () {
1896
		var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1897
		var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1898
		var AppraisalType = Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue();
1899
		var EmployeeID = getParam("EmployeeID");
1900
		var Result = null;
1901
		var params = {
1902
			serviceName : 'Performance.asmx',
1903
			methodName : 'GetDefaultAppraiser',
1904
			parameter :
1905
			'EmployeeID=' + EmployeeID
1906
			 + '&StartDate=' + StartDate
1907
			 + '&EndDate=' + EndDate
1908
			 + '&AppraisalType=' + AppraisalType
1909
		};
1910
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1911
			Result = Ext.decode(xhr.responseText);
1912
			if (Result.success) {
1913
				var pnl0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1914
				pnl0048.add(Ext.decode(Result.data));
1915
			} else {}
1916
		})
1917
	},
1918

    
1919
	saveToMDProfile : function () {
1920
		var me = this;
1921
		var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];//Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1922
		var storequal = pnl.store;
1923
		var PA0051_dATA = null;
1924
		var dataMD8002 = null;
1925
		if (storequal != undefined) {
1926
			pnl.expandAll();
1927
			var _data = Ext.pluck(storequal.data.items, 'data');
1928
			Ext.Array.each(_data, function (rec) {
1929
				rec.children = null
1930
			})
1931
			PA0051_dATA = Ext.encode(_data);
1932
			dataMD8002 = $.grep(Ext.decode(PA0051_dATA), function (r) {
1933
					r['StartDate'] = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1934
					r['EndDate'] = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1935
					r['QualificationLevel'] = r.AppraiserScore
1936
						return r.SequenceSub == 0
1937
				});
1938
		}
1939
		var Result = null;
1940
		var params = {
1941
			serviceName : 'Performance.asmx',
1942
			methodName : 'SaveToMD',
1943
			parameter :
1944
			'TableName=' + 'PHRPA0045'
1945
			 + '&dataDetail=' + Ext.encode(dataMD8002)
1946
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1947
		};
1948
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1949
			Result = Ext.decode(xhr.responseText);
1950
			if (Result.success) {
1951
				MinovaMessage('', 'PY0000', '', 'S');
1952
			} else {
1953
				MinovaMessage('', '000005', Result.message.text, 'E');
1954
			}
1955
		})
1956
	},
1957

    
1958
	SaveToMDHistory : function () {
1959
		var me = this;
1960
		var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1961
		var form_ = form.getForm();
1962
		var data = form_.getValues();
1963
		var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1964
		var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1965
		Ext.Array.each(Ext.decode(DataSum), function (rec) {
1966
			if (rec.Type == "KPI") {
1967
				data["AdjustedKPI"] = rec.AdjustedScore;
1968
				data["CalculatedKPI"] = rec.CalculatedScore;
1969
				data["KPIFinalScore"] = rec.FinalScore;
1970
				data["KPITotalScore"] = rec.TotalScore;
1971
				data["KPITotalWeight"] = rec.Weight;
1972
			} else {
1973
				data["AdjustedCompetency"] = rec.AdjustedScore;
1974
				data["CalculatedCompetency"] = rec.CalculatedScore;
1975
				data["QualFinalScore"] = rec.FinalScore;
1976
				data["QualTotalScore"] = rec.TotalScore;
1977
				data["QualTotalWeight"] = rec.Weight;
1978
			}
1979
		})
1980
		var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1981
		var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1982
		data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1983
		data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1984
		data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1985
		data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1986

    
1987
		var Result = null;
1988
		var params = {
1989
			serviceName : 'Performance.asmx',
1990
			methodName : 'SaveToMD',
1991
			parameter :
1992
			'TableName=' + 'PHRPA0029'
1993
			 + '&dataDetail=' + '[' + Ext.encode(data) + ']'
1994
			 + '&Token=' + MinovaUtil.SESSIONS.Token
1995
		};
1996
		MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1997
			Result = Ext.decode(xhr.responseText);
1998
			if (Result.success) {
1999
				MinovaMessage('', 'PY0000', '', 'S');
2000
			} else {
2001
				MinovaMessage('', '000005', Result.message.text, 'E');
2002
			}
2003
		})
2004
	}
2005
});
    (1-1/1)