Project

General

Profile

Bug #1543 » controllerperformance.js

Tri Rizqiaty, 09/07/2022 02:33 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
            },  '[name=gridCPMSRESPONSIBLE]': {
38
                afterrender: this.TestUy
39
            },
40
			 '[name=gridCPMSUMMARYESSKPI]': {
41
                afterrender: this.TestUy2
42
            },
43
			 '[name=gridCPMSUMTOTALHR]': {
44
                afterrender: this.TestUy3
45
            },
46
            /*'[name=AddKPI]' : {
47
            click : this.addNewKPI
48
            },*/
49
            '[name=BtnCancelKPI]': {
50
                click: this.cancelAddNewKPI
51
            },
52
            /*'[name=BtnAddKPI]' : {
53
            click : this.addNewKPI
54
            },*/
55
            '[name=Action]': {
56
                "onEditClick": this.loadMenu
57
            },
58
            '[name=PHRPA0048Add]': {
59
                click: this.AddAppraiserQ
60
            },
61
            '[name=PHRPA0049Add]': {
62
                click: this.addNewKPI
63
            },
64
            '[name=PHRPA0051Add]': {
65
                click: this.addNewQualification
66
            },
67
            '[name=PHRPA0051Delete]': {
68
                click: this.deleteQualification
69
            },
70
            '[name=PHRPA0049Delete]': {
71
                click: this.deleteKPI
72
            }
73
        });
74
    },
75

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

    
93
    afterRenderOverview: function () {
94
        var overView = Ext.StoreMgr.lookup("PerformanceOverview");
95

    
96
        overView.proxy.extraParams = {
97
            tableName: 'PHRPA0047',
98
            param: 'EmployeeID[=]' + getParam('EmployeeID')
99
        };
100
        overView.removeAll();
101
        overView.reload();
102
        overView.loadPage(1);
103
    },
104

    
105
    addPerformance: function () {
106
        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
107
        card_.getLayout().setActiveItem(1);
108
        var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
109
        form_.getForm().reset();
110
        form_.getForm().findField('EmployeeID').setValue(getParam('EmployeeID'));
111
        var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
112
        delBtn_.setHidden(true);
113
        var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
114
        grid.removeAll();
115
        //form_.setActionSubmit(0);
116
        //this.setHeaderSeqEmpForm(0);
117

    
118
        var me = this;
119
        me._action = "0";
120
    },
121

    
122
    editPerformance: function () {
123
        var me = Ext.ComponentQuery.query('[name=PA0047]')[0];
124
        var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0]; // edit proses
125
        form.setActionSubmit(1);
126
        var selection = me.getView().getSelectionModel().getSelection()[0];
127
        var form_ = form.getForm();
128
        form_.setValues(selection.data);
129

    
130
        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
131
        card_.getLayout().setActiveItem(1);
132
        var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
133
        delBtn_.setHidden(false);
134

    
135
        this.setGridPerformance('1');
136

    
137
        data = {
138
            AdjustedIndex: '',
139
            AdjustedScore: selection.data.AdjustedKPI,
140
            CalculatedScore: selection.data.CalculatedKPI,
141
            FinalScore: selection.data.KPIFinalScore,
142
            IndexScore: '',
143
            TotalScore: selection.data.KPITotalScore,
144
            Type: 'KPI',
145
            Weight: selection.data.KPITotalWeight
146
        };
147

    
148
        data2 = [];
149
        data2[0] = data;
150

    
151
        data = {
152
            AdjustedIndex: '',
153
            AdjustedScore: selection.data.AdjustedCompetency,
154
            CalculatedScore: selection.data.CalculatedCompetency,
155
            FinalScore: selection.data.QualFinalScore,
156
            IndexScore: '',
157
            TotalScore: selection.data.QualTotalScore,
158
            Type: 'Qualification',
159
            Weight: selection.data.QualificationPercen
160
        };
161

    
162
        data2[1] = data;
163

    
164
        var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
165
        if (overView != undefined) {
166
            overView.removeAll();
167
            overView.loadData(data2);
168
        }
169

    
170
        dataTotal = {
171
            AdjustedIndex: selection.data.AdjustedIndex,
172
            AdjustedScore: selection.data.AdjustedScore,
173
            CalculatedScore: selection.data.CalculatedScore,
174
            IndexScore: selection.data.CalculatedIndex
175
        };
176

    
177
        dataTotalList = [];
178
        dataTotalList[0] = dataTotal;
179

    
180
        var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
181
        if (overView != undefined) {
182
            overView.removeAll();
183
            overView.loadData(dataTotalList);
184
        }
185
		
186
		//// add by Tri nwh 20220905 start
187
		var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
188
		console.log(appType.getValue());
189
		Ext.ComponentQuery.query('[name=savePerformance]')[0].setHidden(false);
190
		if(appType.getValue() == 'G')
191
		{
192
			Ext.ComponentQuery.query('[name=PHRPA0048Add]')[0].setHidden(false); 
193
			Ext.ComponentQuery.query('[name=PHRPA0048DeleteText]')[0].setHidden(false); 
194
			Ext.ComponentQuery.query('[name=PHRPA0049Add]')[0].setHidden(true); 
195
			Ext.ComponentQuery.query('[name=PHRPA0049DeleteText]')[0].setHidden(true); 
196
			Ext.ComponentQuery.query('[name=PHRPA0051Add]')[0].setHidden(true); 		
197
			Ext.ComponentQuery.query('[name=PHRPA0051DeleteText]')[0].setHidden(true);
198
		}
199
		if(appType.getValue() == 'F')
200
		{
201
			Ext.ComponentQuery.query('[name=PHRPA0048Add]')[0].setHidden(true); 
202
			Ext.ComponentQuery.query('[name=PHRPA0048DeleteText]')[0].setHidden(true); 
203
			Ext.ComponentQuery.query('[name=PHRPA0049Add]')[0].setHidden(true); 
204
			Ext.ComponentQuery.query('[name=PHRPA0049DeleteText]')[0].setHidden(true); 
205
			Ext.ComponentQuery.query('[name=CRESPONKPIAdd]')[0].setHidden(true); 		
206
			Ext.ComponentQuery.query('[name=CRESPONKPIDeleteText]')[0].setHidden(true);
207
			Ext.ComponentQuery.query('[name=savePerformance]')[0].setHidden(true);
208
		}
209
		if(appType.getValue() != 'G' && appType.getValue() != 'F')
210
		{
211
			Ext.ComponentQuery.query('[name=PHRPA0048Add]')[0].setHidden(true); 
212
			Ext.ComponentQuery.query('[name=PHRPA0048DeleteText]')[0].setHidden(true); 
213
			Ext.ComponentQuery.query('[name=PHRPA0049Add]')[0].setHidden(true); 
214
			Ext.ComponentQuery.query('[name=PHRPA0049DeleteText]')[0].setHidden(true); 
215
			Ext.ComponentQuery.query('[name=CPMSRESPONSIBLEAdd]')[0].setHidden(true); 
216
			Ext.ComponentQuery.query('[name=CPMSRESPONSIBLEDeleteText]')[0].setHidden(true);
217
			Ext.ComponentQuery.query('[name=CPMSUMTOTALHRAdd]')[0].setHidden(true); 
218
			Ext.ComponentQuery.query('[name=CPMSUMTOTALHRDeleteText]')[0].setHidden(true);
219
			Ext.ComponentQuery.query('[name=CPMSUMMARYESSKPIAdd]')[0].setHidden(true); 
220
			Ext.ComponentQuery.query('[name=CPMSUMMARYESSKPIDeleteText]')[0].setHidden(true);
221
			Ext.ComponentQuery.query('[name=savePerformance]')[0].setHidden(true);
222
		}
223
		
224
		//// add by Tri nwh 20220905 end
225
	},
226
		
227
    cancelPerformance: function () {
228
        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
229
        card_.getLayout().setActiveItem(0);
230
    },
231

    
232
    createGridDetail: function (rec) {
233
        var me = this;
234
        var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
235
        var form = main.getForm();
236
        var SDate = form.findField("StartDate").getValue();
237
        var EDate = form.findField("EndDate").getValue();
238
        if (SDate == '' || SDate == undefined || EDate == '' || EDate == undefined) {
239
            MinovaMessage('', 'PMS0003', '', 'E');
240
            Ext.ComponentQuery.query('[name=AppraisalType]')[0].setValue('');
241
            return;
242
        }
243
        this.setGridPerformance('0');
244

    
245
        var appType = rec.getValue();
246

    
247
        if (appType != 'G') {
248
            var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
249
            var form = main.getForm();
250
            var SDate = form.findField("StartDate").getValue();
251
            var EDate = form.findField("EndDate").getValue();
252
            var Data = undefined;
253
            var params = {
254
                serviceName: 'Performance.asmx',
255
                methodName: 'SetDefaultAppraiser',
256
                parameter: 'EmployeeID=' + getParam('EmployeeID')
257
                 + '&StartDate=' + SDate
258
                 + '&EndDate=' + EDate
259
            };
260
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
261
                var result = Ext.decode(xhr.responseText);
262
                Data = result;
263
                if (Data.data != null) {
264
                    var overView = Ext.StoreMgr.lookup('storePHRPA0048');
265
                    if (overView != undefined) {
266
                        overView.removeAll();
267
                        overView.loadData(Ext.decode(Data.data));
268
                    }
269
                }
270
                if (result.success) {
271
                    MinovaMessage('', 'PMS0001', '', 'S');
272
                } else {}
273
            });
274

    
275
            var params = {
276
                serviceName: 'Performance.asmx',
277
                methodName: 'SetDefaultKPI',
278
                parameter: 'EmployeeID=' + getParam('EmployeeID')
279
                 + '&StartDate=' + SDate
280
                 + '&EndDate=' + EDate
281
            };
282
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
283
                var result = Ext.decode(xhr.responseText);
284
                Data = result;
285
                var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
286
                if (pnl != undefined) {
287
                    pnl.store.removeAll()
288
                    pnl.store.load()
289
                    pnl.store.setRootNode({
290
                        expanded: true,
291
                        nodetype: 'async',
292
                        children: Ext.decode(Data.data)
293
                    });
294
                }
295
                if (result.success) {}
296
                else {}
297
            });
298
        } else {
299
            me.setDefaultAppbyOM();
300
        }
301
    },
302

    
303
    setGridPerformance: function (_a) {
304
        var me = this;
305
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
306
        var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
307
        var _empID = getParam('EmployeeID');
308
        grid.removeAll();
309
        try {
310
            var hasil = null;
311
            Ext.Ajax.request({
312
                async: false,
313
                method: 'POST',
314
                url: '/Performance/getListTableRef',
315
                params: {
316
                    AppType: appType.getValue(),
317
                    EmpID: _empID
318
                },
319
                success: function (response) {
320
                    var results = Ext.decode(response.responseText);
321
                    hasil = Ext.decode(results.data);
322
                }
323
            });
324

    
325
            if (hasil.length > 0) {
326
                Ext.Array.each(hasil, function (rec) {
327

    
328
                    var _title = undefined;
329
                    Ext.Ajax.request({
330
                        async: false,
331
                        //method : 'POST',
332
                        url: '/UserControl/GetStore',
333
                        params: {
334
                            tableName: 'SDATATABLE',
335
                            param: 'TableName[=]' + rec
336
                        },
337

    
338
                        success: function (response) {
339
                            var results = Ext.decode(response.responseText);
340
                            var dt = results.data[0];
341
                            _title = dt.TableDescription;
342
                        }
343
                    });
344

    
345
                    if (rec != 'PHRPA0049' /*&& rec != 'PHRPA0051'*/) {
346
                        var _GridDetail = {
347
                            xtype: 'fieldset',
348
                            columnWidth: 0.5,
349
                            title: _title,
350
                            collapsible: true,
351
                            defaultType: 'textfield',
352
                            defaults: {
353
                                anchor: '100%'
354
                            },
355
                            height: 400,
356
                            layout: 'anchor',
357
                            bbar: [{
358
                                    xtype: 'textfield',
359
                                    name: 'TotalScore' + rec,
360
                                    label: 'Total Score'
361
                                }
362
                            ],
363
                            items: [{
364
                                    xtype: 'minovapmseditablegrid',
365
                                    height: 300,
366
                                    autoLoad: false,
367
                                    autoScroll: true,
368
                                    tableName: rec,
369
                                    storeName: 'store' + rec,
370
                                    name: rec,
371
                                    hideButton: false,
372
                                    pagesize: 10,
373
                                    empID: getParam('EmployeeID'),
374
                                    apprasalType: appType.getValue(),									
375
                                    listeners: {}
376
                                }
377
                            ]
378
                        };
379
                        grid.add(_GridDetail);
380

    
381
                        if (_a == '1') {
382
                            me.getDataAppraiser(rec);
383
							 if (rec == 'CPMSRESPONSIBLE') {
384
								MinovaUtil.ExecuteParamQuery({
385
									ID: "WFCPMSRESPONSIBLE",
386
									EmployeeID: getParam('EmployeeID'),
387
								}, function (s) {
388
								}, function (f) {});
389
								 grid.refresh;
390
							
391
								
392
							 }
393
                        }
394
                    } else {
395
                        var _GridDetail = {
396
                            xtype: 'fieldset',
397
                            columnWidth: 0.5,
398
                            title: _title,
399
                            collapsible: true,
400
                            //defaultType : 'textfield',
401
                            //autoScroll : true,
402
                            defaults: {
403
                                anchor: '100%'
404
                            },
405
                            height: 450,
406
                            layout: 'anchor',
407
                            items: [{
408
                                    xtype: 'Minovapmstreeeditablegrid',
409
                                    tableName: rec,
410
                                    height: 300,
411
                                    apprasalType: appType.getValue(),
412
                                    empID: getParam('EmployeeID'),
413
                                    autoScroll: true,
414
                                    hideButton: false,
415
                                    multiSelect: false,
416
                                    /*xtype : 'panel',
417
                                    name : 'Pnl' + rec,
418
                                    height : 380,
419
                                    width : '100%',
420
                                    autoScroll : true,
421
                                    /*items : [{
422
                                    xtype : 'Minovapmstreeeditablegrid',
423
                                    tableName : rec,
424
                                    height : 280,
425
                                    apprasalType : appType.getValue(),
426
                                    empID : getParam('EmployeeID'),
427
                                    autoScroll : true,
428
                                    hideButton : false,
429
                                    multiSelect : false
430
                                    }
431
                                    ],*/
432
                                    dockedItems: [{
433
                                            xtype: 'toolbar',
434
                                            items: [{
435
                                                    text: 'Add',
436
                                                    name: rec + 'Add',
437
                                                    iconCls: 'fa-plus-circle',
438
                                                    style: 'font-family: FontAwesome'
439
                                                }, {
440
                                                    text: 'Delete',
441
                                                    name: rec + 'DeleteText',
442
                                                    iconCls: 'fa-trash-o',
443
                                                    style: 'font-family: FontAwesome',
444
                                                    //disabled: true
445
                                                    handler: function () {
446
                                                        var me = this,
447
                                                        store = Ext.StoreMgr.lookup(storeID)
448

    
449
                                                            var grid = Ext.getCmp(gridName);
450

    
451
                                                        Ext.MessageBox.show({
452
                                                            title: 'Remove tab',
453
                                                            msg: "This will remove. Do you want to continue?",
454
                                                            buttons: Ext.MessageBox.YESNO,
455
                                                            fn: function (choice) {
456
                                                                console.log(choice);
457
                                                                if (choice === 'yes') {
458
                                                                    var selection = grid.getView().getSelectionModel().getSelection()[0];
459
                                                                    if (selection) {
460
                                                                        store.remove(selection);
461
                                                                    }
462
                                                                }
463
                                                            }
464
                                                        });
465
                                                    }
466
                                                }
467
                                            ]
468
                                        }
469
                                    ]
470
                                }
471

    
472
                            ]
473
                        };
474
                        grid.add(_GridDetail);
475

    
476
                        if (_a == '1') {
477
                            var pnl = Ext.ComponentQuery.query('[name=grid' + rec + ']')[0];
478
                            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
479
                            var data_kpi = null;
480
                            var url = null;
481
                            if (rec == 'PHRPA0049') {
482
                                url = '/Performance/getKPI';
483

    
484
                                Ext.Ajax.request({
485
                                    //method : 'POST',
486
                                    async: false,
487
                                    url: url,
488
                                    params: {
489
                                        EmpID: getParam('EmployeeID'),
490
                                        Seq: seq.getValue(),
491
                                        AppType: appType.getValue()
492
                                    },
493
                                    success: function (response) {
494
                                        var results = Ext.decode(response.responseText);
495
                                        data_kpi = Ext.decode(results.data);
496
                                    }
497
                                });
498

    
499
                                pnl.store.setRootNode({
500
                                    expanded: true,
501
                                    nodetype: 'async',
502
                                    children: data_kpi
503
                                    //[]
504
                                });
505
                            } else if (rec == 'PHRPA0051') {}
506
                            //me.loadQualification();
507
                        }
508
                    }
509
                });
510
            } else {}
511

    
512
            if (appType.getValue() == 'P' || appType.getValue() == 'F') {
513
                var _title = undefined;
514
                Ext.Ajax.request({
515
                    async: false,
516
                    //method : 'POST',
517
                    url: '/UserControl/GetStore',
518
                    params: {
519
                        tableName: 'SDATATABLE',
520
                        param: 'TableName[=]' + 'PDSPMSUMMARY'
521
                    },
522

    
523
                    success: function (response) {
524
                        var results = Ext.decode(response.responseText);
525
                        var dt = results.data[0];
526
                        _title = dt.TableDescription;
527
                    }
528
                });
529

    
530
                var _GridDetail = {
531
                    xtype: 'fieldset',
532
                    columnWidth: 0.5,
533
                    title: _title,
534
                    collapsible: true,
535
                    defaultType: 'textfield',
536
                    defaults: {
537
                        anchor: '100%'
538
                    },
539
                    height: 420,
540
                    layout: 'anchor',
541
                    items: [{
542
                            xtype: 'Minovaeditablegrid',
543
                            autoLoad: false,
544
                            hideButton: true,
545
                            autoScroll: true,
546
                            height: 200,
547
                            layout: 'fit',
548
                            tableName: 'PDSPMSUMMARY',
549
                            storeName: 'store' + 'PDSPMSUMMARY',
550
                            name: 'PDSPMSUMMARY',
551
                            empID: getParam('EmployeeID'),
552
                            apprasalType: appType.getValue(),
553
                            tbar: [{
554
                                    xtype: 'toolbar',
555
                                    docked: 'top',
556
                                    items: [{
557
                                            xtype: 'button',
558
                                            text: 'Calculate',
559
                                            name: 'Calculate',
560
                                            handler: function () {
561
                                                me.calculatePMS()
562
                                            }
563
                                        }
564
                                        /*,{
565
                                        xtype : 'button',
566
                                        text : 'Save to Profile',
567
                                        name : 'SaveProfile',
568
                                        handler : function () {
569
                                        me.SaveToMDHistory()
570
                                        }
571
                                        }*/
572
                                    ]
573
                                }
574
                            ]
575
                        }, {
576
                            xtype: 'Minovaeditablegrid',
577
                            autoLoad: false,
578
                            hideButton: true,
579
                            autoScroll: true,
580
                            height: 200,
581
                            layout: 'fit',
582
                            tableName: 'PDSPMSUMTOTAL',
583
                            storeName: 'store' + 'PDSPMSUMTOTAL',
584
                            name: 'PDSPMSUMTOTAL'
585
                        }
586
                    ]
587
                };
588
                grid.add(_GridDetail);
589
            }
590

    
591
        } catch (exc) {}
592
    },
593

    
594
    savePerformance: function () {
595
        var me = this;
596
        var a = me.CheckAppraiserWeight();
597
        /*if (a == "1") {
598
        MinovaMessage('', 'PMSE005', '', 'E');
599
        return;
600
        }*/
601
        var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
602
        var form_ = form.getForm();
603
        var data = form_.getValues();
604
        var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
605
        var treestore = undefined;
606
        if (treepnl != undefined) {
607
            treepnl.expandAll();
608
            treestore = treepnl.store;
609
            Ext.Array.each(treestore.data.items, function (rec) {
610
                rec.expand(true);
611
            })
612
        }
613
        var pnlqual = Ext.ComponentQuery.query('[name=gridPHRPA0051]')[0];
614
        var storequal = undefined;
615
        /*if (pnlqual != undefined) { //// comment by Tri nwh 20220905
616
            pnlqual.expandAll();
617
            storequal = pnlqual.store;
618
            Ext.Array.each(storequal.data.items, function (rec) {
619
                rec.expand(true);
620
            })
621
        }*/
622
        form.mask('Loading...');
623

    
624
        var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
625
        var PA0049 = Ext.StoreMgr.lookup("storePHRPA0049");
626
        var PA0049A = Ext.StoreMgr.lookup("storePHRPA0049A");
627
        var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
628
        var PA00ADD = Ext.StoreMgr.lookup("storeCPMSADDITIONALTASKHR");
629
        var PA00Respon = Ext.StoreMgr.lookup("storeCPMSRESPONSIBLE");
630
        var PA00ESS = Ext.StoreMgr.lookup("storeCPMSUMMARYESSKPI");
631
        var PA00TOTALHR = Ext.StoreMgr.lookup("storeCPMSUMTOTALHR");
632

    
633
        var PA0048_dATA = null;
634
        var PA0048_dATA2 = null;
635
        var PA0049_dATA = null;
636
        var PA0049A_dATA = null;
637
        var PA0051_dATA = null;
638
        var TREE_dATA = null;
639
        var TREE_dATA2 = null;
640
        var PA00ADD_data = null;
641
        var PA00Respon_data = null;
642
        var PA00ESS_data = null;
643
        var PA00TOTALHR_data = null;
644

    
645
        if (PA00ADD != undefined)
646
            PA00ADD_data = Ext.pluck(PA00ADD.data.items, 'data');
647
        if (PA00Respon != undefined)
648
            PA00Respon_data = Ext.pluck(PA00Respon.data.items, 'data');
649
        if (PA00ESS != undefined)
650
            PA00ESS_data = Ext.pluck(PA00ESS.data.items, 'data');
651
        if (PA00TOTALHR != undefined)
652
            PA00TOTALHR_data = Ext.pluck(PA00TOTALHR.data.items, 'data');
653
        if (PA0048 != undefined)
654
            PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
655
        PA0048_dATA2 = Ext.pluck(PA0048.data.items, 'data');
656
        if (PA0049 != undefined)
657
            PA0049_dATA = Ext.encode(Ext.pluck(PA0049.data.items, 'data'));
658
        if (PA0049A != undefined)
659
            PA0049A_dATA = Ext.encode(Ext.pluck(PA0049A.data.items, 'data'));
660
        if (storequal != undefined) {
661
            var _data = Ext.pluck(storequal.data.items, 'data');
662
            Ext.Array.each(_data, function (rec) {
663
                rec.children = null
664
            })
665
            PA0051_dATA = Ext.encode(_data);
666
        }
667
        if (treepnl != undefined)
668
        /*TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
669
        TREE_dATA2 = Ext.pluck(treestore.data.items, 'data');*/ //// comment by Tri nwh 20220907
670

    
671
        if (data.AppraisalType == "a;slkaskld") {
672
            var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
673
            var form_ = form.getForm();
674
            var data = form_.getValues();
675
            var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
676
            if (Sum.data.items.length > 0) {
677
                var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
678
                Ext.Array.each(Ext.decode(DataSum), function (rec) {
679
                    if (rec.Type == "KPI") {
680
                        data["AdjustedKPI"] = rec.AdjustedScore;
681
                        data["CalculatedKPI"] = rec.CalculatedScore;
682
                        data["KPIFinalScore"] = rec.FinalScore;
683
                        data["KPITotalScore"] = rec.TotalScore;
684
                    } else {
685
                        data["AdjustedCompetency"] = rec.AdjustedScore;
686
                        data["CalculatedCompetency"] = rec.CalculatedScore;
687
                        data["QualFinalScore"] = rec.FinalScore;
688
                        data["QualTotalScore"] = rec.TotalScore;
689
                    }
690
                })
691
            }
692
            var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
693
            var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
694
            if (dataTotalSum.length > 0) {
695
                data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
696
                data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
697
                data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
698
                data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
699
            }
700
        }
701

    
702
        // var i;
703
        // for (i = 0; i < PA0048_dATA2.length; i++) {
704
        // Ext.Ajax.request({
705
        // method: 'POST',
706
        // async: false,
707
        // url: '/Devt/SaveTable',
708
        // params: {
709
        // tableName: 'PHRPA0048',
710
        // data: Ext.encode(PA0048_dATA2[i]),
711
        // action: 1
712
        // },
713
        // waitMsg: 'Saving Data...',
714
        // success: function (response) {
715
        // var result = Ext.decode(response.responseText);
716
        // console.log(result);
717
        // if (result.success) {
718
        // console.log('success');
719
        // } else {
720
        // console.log('not success');
721
        // }
722
        // },
723
        // failure: function (response) {
724
        // var result = Ext.decode(response.responseText);
725
        // console.log(result);
726
        // }
727
        // });
728

    
729
        // }
730

    
731
        // for (i = 0; i < TREE_dATA2.length; i++) {
732
        // Ext.Ajax.request({
733
        // method: 'POST',
734
        // async: false,
735
        // url: '/Devt/SaveTable',
736
        // params: {
737
        // tableName: 'PHRPA0049',
738
        // data: Ext.encode(TREE_dATA2[i]),
739
        // action: 1
740
        // },
741
        // waitMsg: 'Saving Data...',
742
        // success: function (response) {
743
        // var result = Ext.decode(response.responseText);
744
        // console.log(result);
745
        // if (result.success) {
746
        // console.log('success');
747
        // } else {
748
        // console.log('not success');
749
        // }
750
        // },
751
        // failure: function (response) {
752
        // var result = Ext.decode(response.responseText);
753
        // console.log(result);
754
        // }
755
        // });
756

    
757
        // }
758

    
759
        // for (i = 0; i < PA00ADD_data.length; i++) {
760
        // Ext.Ajax.request({
761
        // method: 'POST',
762
        // async: false,
763
        // url: '/Devt/SaveTable',
764
        // params: {
765
        // tableName: 'CPMSADDITIONALTASKHR',
766
        // data: Ext.encode(PA00ADD_data[i]),
767
        // action: 1
768
        // },
769
        // waitMsg: 'Saving Data...',
770
        // success: function (response) {
771
        // var result = Ext.decode(response.responseText);
772
        // console.log(result);
773
        // if (result.success) {
774
        // console.log('success');
775
        // } else {
776
        // console.log('not success');
777
        // }
778
        // },
779
        // failure: function (response) {
780
        // var result = Ext.decode(response.responseText);
781
        // console.log(result);
782
        // }
783
        // });
784

    
785
        // }
786

    
787
        // for (i = 0; i < PA00Respon_data.length; i++) {
788
        // Ext.Ajax.request({
789
        // method: 'POST',
790
        // async: false,
791
        // url: '/Devt/SaveTable',
792
        // params: {
793
        // tableName: 'CPMSRESPONSIBLE',
794
        // data: Ext.encode(PA00Respon_data[i]),
795
        // action: 1
796
        // },
797
        // waitMsg: 'Saving Data...',
798
        // success: function (response) {
799
        // var result = Ext.decode(response.responseText);
800
        // console.log(result);
801
        // if (result.success) {
802
        // console.log('success');
803
        // } else {
804
        // console.log('not success');
805
        // }
806
        // },
807
        // failure: function (response) {
808
        // var result = Ext.decode(response.responseText);
809
        // console.log(result);
810
        // }
811
        // });
812

    
813
        // }
814

    
815
        // for (i = 0; i < PA00ESS_data.length; i++) {
816
        // Ext.Ajax.request({
817
        // method: 'POST',
818
        // async: false,
819
        // url: '/Devt/SaveTable',
820
        // params: {
821
        // tableName: 'CPMSUMMARYESSKPI',
822
        // data: Ext.encode(PA00ESS_data[i]),
823
        // action: 1
824
        // },
825
        // waitMsg: 'Saving Data...',
826
        // success: function (response) {
827
        // var result = Ext.decode(response.responseText);
828
        // console.log(result);
829
        // if (result.success) {
830
        // console.log('success');
831
        // } else {
832
        // console.log('not success');
833
        // }
834
        // },
835
        // failure: function (response) {
836
        // var result = Ext.decode(response.responseText);
837
        // console.log(result);
838
        // }
839
        // });
840

    
841
        // }
842

    
843
        // for (i = 0; i < PA00TOTALHR_data.length; i++) {
844
        // Ext.Ajax.request({
845
        // method: 'POST',
846
        // async: false,
847
        // url: '/Devt/SaveTable',
848
        // params: {
849
        // tableName: 'CPMSUMTOTALHR',
850
        // data: Ext.encode(PA00TOTALHR_data[i]),
851
        // action: 1
852
        // },
853
        // waitMsg: 'Saving Data...',
854
        // success: function (response) {
855
        // var result = Ext.decode(response.responseText);
856
        // console.log(result);
857
        // if (result.success) {
858
        // console.log('success');
859
        // } else {
860
        // console.log('not success');
861
        // }
862
        // },
863
        // failure: function (response) {
864
        // var result = Ext.decode(response.responseText);
865
        // console.log(result);
866
        // }
867
        // });
868

    
869
        // }
870
        if (data.AppraisalType == 'G') {
871
            Ext.Ajax.request({
872
                async: false,
873
                method: 'POST',
874
                url: '/Performance/testController',
875
                params: {
876
                    header: Ext.encode(data),
877
                    PA0048: PA0048_dATA,
878
                    PA0049: TREE_dATA,
879
                    PA0049A: PA0049A_dATA,
880
                    PA0051: PA0051_dATA,
881
                    action: this._action
882
                },
883
                waitMsg: 'Saving Data...',
884
                success: function (response) {
885

    
886
                    var result = Ext.decode(response.responseText);
887
                    if (result.success) {
888
                        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
889
                        card_.getLayout().setActiveItem(0);
890
                        MinovaMessage('', '000006', '', 'S');
891
                        if (data.AppraisalType == "F") {
892
                            me.SaveToMDHistory();
893
                            me.saveToMDProfile();
894
                        }
895
                        me.afterRenderOverview();
896
                        form.unmask();
897
                    } else {
898
						MinovaMessage('', '000006', '', 'S');  //// add by Tri nwh 20220905
899
						me.afterRenderOverview();  //// add by Tri nwh 20220905
900
                        form.unmask();
901
                        //MinovaMessage('', result.message.id, result.message.text, "E");
902
                        //MinovaMessage('', '000005', result.message.text, "E") //// comment by Tri nwh 20220905
903
                    }
904
                },
905
                failure: function (response) {
906
                    var result = Ext.decode(response.responseText);
907
                    form.unmask();
908
                    // MinovaMessage('', result.message.id, result.message.text, "E")
909
                    MinovaMessage('', '000005', result.message.text, "E")
910
                }
911
            });
912
        } 
913
		else {
914
            var _empID = getParam('EmployeeID');
915
            var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
916
			var valid = 1;
917
            try {
918
                var hasil = null;
919
                var PA = null;
920
                var PA2 = null;
921
                Ext.Ajax.request({
922
                    async: false,
923
                    method: 'POST',
924
                    url: '/Performance/getListTableRef',
925
                    params: {
926
                        AppType: appType.getValue(),
927
                        EmpID: _empID
928
                    },
929
                    success: function (response) {
930
                        var results = Ext.decode(response.responseText);
931
                        hasil = Ext.decode(results.data);
932
                    }
933
                });
934
				
935
                if (hasil.length > 0) {
936

    
937
                    Ext.Array.each(hasil, function (rec) {
938

    
939
                        PA = Ext.StoreMgr.lookup("store" + rec);
940
                        if (PA != undefined){
941
                            PA2 = Ext.pluck(PA.data.items, 'data');
942
						}
943
if (rec == 'PHRPA0049'){
944
	PA2 =  TREE_dATA2;
945
	
946
}
947
    
948
                        var i;
949
                        for (i = 0; i < PA2.length; i++) {
950
                            Ext.Ajax.request({
951
                                method: 'POST',
952
                                async: false,
953
                                url: '/Devt/SaveTable',
954
                                params: {
955
                                    tableName: rec,
956
                                    data: Ext.encode(PA2[i]),
957
                                    action: 1
958
                                },
959
                                waitMsg: 'Saving Data...',
960
                                success: function (response) {
961
                                    var result = Ext.decode(response.responseText);
962
                                    console.log(result);
963
                                    if (result.success) {
964
                                        console.log('success');
965
                                    } else {
966
                                        console.log('not success');
967
										form.unmask();
968
                                    MinovaMessage('', '000005', result.message.text, "E")
969
                                    }
970
                                },
971
                                failure: function (response) {
972
								
973
                                    var result = Ext.decode(response.responseText);
974
                                    form.unmask();
975
                                    MinovaMessage('', '000005', result.message.text, "E")
976
									valid = result.message.text;
977
                                }
978
                            });
979

    
980
                        }
981

    
982
                    });
983
                    }
984
			if (valid != 1){
985
				 form.unmask();
986
                                    MinovaMessage('', '000005', valid, "E")
987
				
988
			}else{
989
					   var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
990
                        card_.getLayout().setActiveItem(0);
991
                        MinovaMessage('', '000006', '', 'S');
992
						me.afterRenderOverview();
993
                        form.unmask();
994
			}
995
                }
996
				catch (err) {
997
                    form.unmask();
998
                    // MinovaMessage('', result.message.id, result.message.text, "E")
999
                    MinovaMessage('', '000005', err, "E");
1000
                    // Ext.Msg.alert('Eror', err.message, Ext.emptyFn);
1001

    
1002
                }
1003

    
1004
            }
1005

    
1006
        },
1007

    
1008
        btnGoToother: function () {
1009
            var menu_ = [];
1010
            var Y = 180;
1011

    
1012
            menu_.push({
1013
                text: 'Employee Search',
1014
                handler: function () {
1015
                    Ext.create('Ext.window.Window', {
1016
                        title: 'Lookup - Employee',
1017
                        height: 530,
1018
                        width: 500,
1019
                        name: 'lookupMain',
1020
                        modal: true,
1021
                        items: [{
1022
                                xtype: 'minovaform',
1023
                                bodyBorder: false,
1024
                                MaxHeigth: '100',
1025
                                cls: 'borderLookup',
1026
                                border: false,
1027
                                MaxHeigth: '30',
1028
                                scroll: true,
1029
                                isLookup: true,
1030
                                name: "formLookupFilter",
1031
                                tableName: 'PDSEMP0002',
1032
                                buttons: [{
1033
                                        text: 'Search',
1034
                                        handler: function () {
1035
                                            var store = Ext.data.StoreManager.lookup('lookupStore');
1036
                                            var form = Ext.ComponentQuery.query('[name=formLookupFilter]')[0].getForm();
1037
                                            grid = Ext.ComponentQuery.query('[name=gridLookup]')[0];
1038
                                            var values_ = form.getValues();
1039
                                            var fields_ = form.getFields().items;
1040
                                            var param_ = '';
1041
                                            for (var i = 0; i < fields_.length; i++) {
1042
                                                var val_ = form.getFields().items[i].getValue();
1043
                                                var xtype_ = form.getFields().items[i].xtype;
1044
                                                var oprator_ = '[like]';
1045
                                                if (xtype_ == 'combobox' || xtype_ == 'combo' || xtype_ == 'minovacombo' || xtype_ == 'minovacombobox') {
1046
                                                    oprator_ = '[Equal]';
1047
                                                }
1048
                                                if (xtype_ == 'datefield') {
1049
                                                    if (form.getFields().items[i].name == 'StartDate' || form.getFields().items[i].name == 'ValidForm') {
1050
                                                        oprator_ = '[LessThanEqual]';
1051
                                                    } else {
1052
                                                        oprator_ = '[GreaterThanEqual]';
1053
                                                    }
1054
                                                }
1055
                                                if (val_ != 'undefined' && val_ != "" && val_ != null) {
1056
                                                    param_ = param_ + ',' + form.getFields().items[i].name + oprator_ + val_;
1057
                                                }
1058
                                            }
1059
                                            store.proxy.extraParams = {
1060
                                                tableName: grid.tableName,
1061
                                                param: param_,
1062
                                                menuId: MinovaUtil.GetMenuID()
1063
                                            };
1064
                                            store.removeAll();
1065
                                            store.reload();
1066
                                            store.loadPage(1);
1067
                                        }
1068

    
1069
                                    }
1070
                                ],
1071
                            }, {
1072
                                xtype: 'minovagrid1',
1073
                                isLookup: 1,
1074
                                minHeight: 280,
1075
                                height: 280,
1076
                                tableName: 'PDSEMP0002',
1077
                                param: '',
1078
                                isLookup: true,
1079
                                autoLoad: false,
1080
                                name: 'gridLookup',
1081
                                hidebutton: 0,
1082
                                pagesize: 25,
1083
                                storename: 'lookupStore',
1084
                                listeners: {
1085
                                    itemdblclick: function (g) {
1086
                                        var dataSelection = this.getView().getSelectionModel().getSelection()[0].data;
1087
                                        //console.log(dataSelection)
1088
                                        var url = MinovaUtil.GetMenuID() + '&EmployeeID=' + dataSelection.EmployeeID + '&FullName=' + dataSelection.FullName + '&Lang=' + localStorage.LangId;
1089
                                        var mb = new minovaBlowfish();
1090
                                        e = mb.minovaEncryptUrl(url);
1091
                                        window.open('masterdataperformancedetail?' + e, "_self");
1092

    
1093
                                    },
1094
                                    beforeedit: function (grid) {
1095
                                        return false;
1096
                                    }
1097
                                },
1098
                                dockedItems: [{
1099
                                        xtype: 'pagingtoolbar',
1100
                                        store: 'lookupStore',
1101
                                        dock: 'bottom',
1102
                                        pageSize: 25,
1103
                                        displayInfo: true
1104
                                    }
1105
                                ]
1106

    
1107
                            }, ]
1108
                    }).show();
1109
                }
1110
            });
1111
            menu_.push({
1112
                text: 'Back',
1113
                handler: function () {
1114
                    window.history.back();
1115
                }
1116
            });
1117
            Ext.create('Ext.menu.Menu', {
1118
                name: 'panelMenu',
1119
                width: 240,
1120
                height: 100,
1121
                margin: '0 0 10 0',
1122

    
1123
                items: menu_
1124
            }).showAt([1239, Y]);
1125
        },
1126

    
1127
        deletePerformance: function () {
1128
            var me = this;
1129
            var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0];
1130
            var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0];
1131
            var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1132
            var Sequence = Ext.ComponentQuery.query('[name=Sequence]')[0];
1133
            var _empID = getParam('EmployeeID');
1134

    
1135
            Ext.Ajax.request({
1136
                async: false,
1137
                method: 'POST',
1138
                url: '/Performance/deleteData',
1139
                params: {
1140
                    EmpID: _empID,
1141
                    Seq: Sequence.getValue(),
1142
                    AppType: appType.getValue(),
1143
                    StDate: StartDate.getValue(),
1144
                    EnDate: EndDate.getValue()
1145
                },
1146
                waitMsg: 'Deleting Data...',
1147
                success: function (response) {
1148

    
1149
                    var result = Ext.decode(response.responseText);
1150
                    if (result.success) {
1151
                        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
1152
                        card_.getLayout().setActiveItem(0);
1153
                        MinovaMessage('', '000006', '', 'S');
1154
                        me.afterRenderOverview();
1155
                        //pnl.unmask();
1156
                    } else {
1157
                        //.unmask();
1158
                        //MinovaMessage('', result.message.id, result.message.text, "E");
1159
                        MinovaMessage('', '000005', result.message.text, "E")
1160
                    }
1161
                },
1162
                failure: function (response) {
1163
                    var result = Ext.decode(response.responseText);
1164
                    //pnl.unmask();
1165
                    // MinovaMessage('', result.message.id, result.message.text, "E")
1166
                    MinovaMessage('', '000005', result.message.text, "E")
1167
                }
1168
            });
1169

    
1170
            me.afterRenderOverview();
1171
        },
1172

    
1173
        addAppraiser: function () {
1174
            var grid = Ext.getCmp('gridPHRPA0048');
1175
            var record = grid.getSelectionModel().getSelection()[0];
1176
            record.set('EmployeeID', getParam('EmployeeID'));
1177
        },
1178

    
1179
        getDataAppraiser: function (tblName) {
1180
            var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1181
            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1182
            var overView = Ext.StoreMgr.lookup('store' + tblName);
1183
            var param = null;
1184
            var data_kpi = null;
1185

    
1186
            if (tblName == 'PHRPA0049') {
1187
                var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
1188
                Ext.Ajax.request({
1189
                    //method : 'POST',
1190
                    async: false,
1191
                    url: '/Performance/getKPI',
1192
                    params: {
1193
                        EmpID: _empID,
1194
                        Seq: seq.getValue(),
1195
                        AppType: appType.getValue()
1196
                    },
1197
                    success: function (response) {
1198
                        var results = Ext.decode(response.responseText);
1199
                        data_kpi = Ext.decode(results.data);
1200
                    }
1201
                });
1202
                pnl.store.setRootNode({
1203
                    expanded: true,
1204
                    nodetype: 'async',
1205
                    children: data_kpi
1206
                    //[]
1207
                });
1208
            } else {
1209
                param = 'EmployeeID[=]' + getParam('EmployeeID')
1210
                     + ',HeaderSequence[=]' + seq.getValue()
1211
                     + ',AppraisalType[=]' + appType.getValue();
1212

    
1213
                Ext.Ajax.request({
1214
                    //method : 'POST',
1215
                    async: false,
1216
                    url: '/UserControl/GetStore',
1217
                    params: {
1218
                        tableName: tblName,
1219
                        param: param
1220
                    },
1221
                    success: function (response) {
1222
                        var results = Ext.decode(response.responseText);
1223

    
1224
                        if (tblName != 'PHRPA0049') {
1225
                            overView.removeAll();
1226
                            overView.loadData(results.data);
1227
                        } else {
1228
                            var data_ = results.data;
1229
                            var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
1230
                            pnl.store.setRootNode({
1231
                                expanded: true,
1232
                                nodetype: 'async',
1233
                                children: data_
1234
                                //[]
1235
                            });
1236
                        }
1237
                    }
1238
                });
1239
            }
1240
            //overView.removeAll();
1241
            //overView.reload();
1242
            //overView.loadPage(1);
1243
			
1244
    },
1245

    
1246
        
1247

    
1248
        loadChild: function (node, index, item, eOpts) {
1249
            var me = this;
1250
            var _empID = getParam('EmployeeID');
1251
            var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1252
            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1253
            var data_ = null;
1254
            var idx = 0;
1255
            var tree_ = Ext.ComponentQuery.query('treepanel[name=gridPHRPA0049]')[0];
1256
            var v = tree_.getView();
1257

    
1258
            if (node.data.IsSubKPI == '1') {
1259
                return;
1260
            }
1261

    
1262
            tree_.mask('Expanding tree...');
1263

    
1264
            Ext.Ajax.request({
1265
                //method : 'POST',
1266
                async: false,
1267
                url: '/Performance/getSubKPI',
1268
                params: {
1269
                    EmpID: _empID,
1270
                    Seq: seq.getValue(),
1271
                    AppType: appType.getValue(),
1272
                    KPIID: node.data.KPI,
1273
                    KPISeq: node.data.Sequence
1274
                },
1275
                success: function (response) {
1276
                    var results = Ext.decode(response.responseText);
1277
                    data_ = Ext.decode(results.data);
1278
                }
1279
            });
1280

    
1281
            if (data_.length > 0) {
1282
                data_.forEach(function (rec) {
1283
                    if (v.store.data.find('SequenceSubKPI', rec.SequenceSubKPI) == null) {
1284
                        node.appendChild(data_[idx])
1285
                    }
1286
                    idx++;
1287
                })
1288
            }
1289

    
1290
            tree_.unmask();
1291
        },
1292

    
1293
        addNewKPI: function () {
1294
            var me = this;
1295
            var count_lookup = Ext.ComponentQuery.query('[name=AddNewKPI]').length;
1296
            if (count_lookup == 1) {
1297
                Ext.ComponentQuery.query('[name=AddNewKPI]')[0].show();
1298
            } else {
1299
                Ext.create('Ext.window.Window', {
1300
                    title: 'Add KPI',
1301
                    name: 'AddNewKPI',
1302
                    layout: 'fit',
1303
                    items: [{
1304
                            xtype: 'form',
1305
                            name: 'formAddKPI',
1306
                            items: [{
1307
                                    xtype: 'minovaForm',
1308
                                    bodyBorder: false,
1309
                                    cls: 'borderLookup',
1310
                                    border: false,
1311
                                    isLookup: false,
1312
                                    name: "mainformAddKPI",
1313
                                    tableName: 'PDSPMLOOKUPKPI'
1314
                                }
1315
                            ]
1316
                        }
1317
                    ],
1318
                    buttons: [{
1319
                            text: 'Add KPI',
1320
                            name: 'BtnAddKPI',
1321
                            iconCls: 'fa-save',
1322
                            style: 'font-family: FontAwesome',
1323
                            margin: '3 3 10 3',
1324
                            handler: function () {
1325
                                me.addNewKPItoGrid();
1326
                            }
1327
                        }, {
1328
                            text: 'Cancel',
1329
                            name: 'BtnCancelKPI',
1330
                            iconCls: 'fa-reply',
1331
                            style: 'font-family: FontAwesome',
1332
                            margin: '3 3 10 3',
1333
                            handler: function () {
1334
                                me.cancelAddNewKPI();
1335
                            }
1336
                        }
1337
                    ]
1338
                }).show();
1339
            }
1340
        },
1341

    
1342
        cancelAddNewKPI: function () {
1343
            Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1344
        },
1345

    
1346
        addNewKPItoGrid: function () {
1347
            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1348
            var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1349
            var leafCount = 0;
1350
            pnl.getRootNode().cascadeBy(function (node) {
1351
                if (!node.isLeaf())
1352
                    leafCount++;
1353
            });
1354
            var data = '';
1355
            var Sequence = 0;
1356
            if (leafCount == 0) {
1357
                Sequence = 1;
1358
            } else {
1359
                Sequence = 1 + leafCount;
1360
            }
1361

    
1362
            var a = Ext.ComponentQuery.query('[name=mainformAddKPI]')[0];
1363
            var b = a.getValues();
1364
            var C = '';
1365

    
1366
            Ext.Ajax.request({
1367
                method: 'POST',
1368
                async: false,
1369
                url: '/UserControl/GetStore',
1370
                params: {
1371
                    tableName: 'PHROM0002',
1372
                    param: 'ObjectClass[=]KG,RelationshipClass[=]K,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=KPI]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1373
                },
1374
                success: function (response) {
1375
                    var results = Ext.decode(response.responseText);
1376
                    if (results.data != null && results.data.length > 0) {
1377
                        c = results.data[0].ObjectID;
1378
                    }
1379
                }
1380
            });
1381

    
1382
            data = {
1383
                KPIGroup: c,
1384
                EmployeeID: Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1385
                AppraisalType: Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1386
                KPI: Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1387
                Sequence: Sequence,
1388
                ObjectDescription: Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1389
                SubKPI: "-",
1390
                HeaderSequence: seq,
1391
                SequenceSubKPI: "0",
1392
                IsSubKPI: "0",
1393
                leaf: false,
1394
                Target: 1,
1395
                expanded: true
1396
            };
1397

    
1398
            var task = pnl.getRootNode();
1399
            task.appendChild(data);
1400
            Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1401
        },
1402

    
1403
        addNewsubKPI: function (record) {
1404
            var me = this;
1405
            var count_lookup = Ext.ComponentQuery.query('[name=AddNewsubKPI]').length;
1406
            if (count_lookup == 1) {
1407
                Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].show();
1408
            } else {
1409
                Ext.create('Ext.window.Window', {
1410
                    title: 'Add subKPI',
1411
                    name: 'AddNewsubKPI',
1412
                    layout: 'fit',
1413
                    items: [{
1414
                            xtype: 'form',
1415
                            name: 'formAddsubKPI',
1416
                            items: [{
1417
                                    xtype: 'minovaForm',
1418
                                    bodyBorder: false,
1419
                                    cls: 'borderLookup',
1420
                                    border: false,
1421
                                    isLookup: false,
1422
                                    name: "mainformAddsubKPI",
1423
                                    tableName: 'PDSPMLOOKUPKPI'
1424
                                }
1425
                            ]
1426
                        }
1427
                    ],
1428
                    buttons: [{
1429
                            text: 'Add subKPI',
1430
                            name: 'BtnAddsubKPI',
1431
                            iconCls: 'fa-save',
1432
                            style: 'font-family: FontAwesome',
1433
                            margin: '3 3 10 3',
1434
                            handler: function () {
1435
                                me.addNewsubKPItoGrid(record);
1436
                            }
1437
                        }, {
1438
                            text: 'Cancel',
1439
                            name: 'BtnCancelsubKPI',
1440
                            iconCls: 'fa-reply',
1441
                            style: 'font-family: FontAwesome',
1442
                            margin: '3 3 10 3',
1443
                            handler: function () {
1444
                                Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1445
                            }
1446
                        }
1447
                    ]
1448
                }).show();
1449
            }
1450
        },
1451

    
1452
        addNewsubKPItoGrid: function (record) {
1453
            var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1454
            var leafCount = 0;
1455
            var _empID = getParam('EmployeeID');
1456
            var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1457
            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1458
            var i = 0;
1459
            var data_ = null;
1460
            Ext.Ajax.request({
1461
                async: false,
1462
                url: '/Performance/getSubKPI',
1463
                params: {
1464
                    EmpID: _empID,
1465
                    Seq: seq.getValue(),
1466
                    AppType: appType.getValue(),
1467
                    KPIID: record.data.KPI,
1468
                    KPISeq: record.data.Sequence
1469
                },
1470
                success: function (response) {
1471
                    var results = Ext.decode(response.responseText);
1472
                    data_ = Ext.decode(results.data);
1473
                }
1474
            });
1475
            if (data_.length == 0) {
1476
                i = 1;
1477
            } else {
1478
                i += data_.length;
1479
            }
1480

    
1481
            var data = {
1482
                EmployeeID: Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1483
                AppraisalType: Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1484
                KPI: record.data.KPI,
1485
                ObjectDescription: record.data.ObjectDescription,
1486
                Sequence: record.data.Sequence,
1487
                HeaderSequence: seq.getValue(),
1488
                SequenceSubKPI: i,
1489
                IsSubKPI: "1",
1490
                SubKPI: Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1491
                SubKPIDescription: Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1492
                leaf: true
1493
            };
1494

    
1495
            record.appendChild(data);
1496
            Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1497
        },
1498

    
1499
        loadMenu: function () {
1500
            var me = this;
1501
            var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1502
            var record = main_.getView().selection;
1503
            var _a = record.data.leaf;
1504
            var _kpi = record.data.KPI;
1505
            var rowIndex = record.data.index;
1506
            var n = rowIndex * 50;
1507
            var Y = 180 + n;
1508
            var menu_ = []
1509

    
1510
            if (!_a) {
1511
                menu_.push({
1512
                    text: 'Delete KPI',
1513
                    handler: function () {
1514
                        me.deleteSubKPI(record);
1515
                    }
1516
                })
1517
                menu_.push({
1518
                    text: 'Add subKPI',
1519
                    handler: function () {
1520
                        me.addNewsubKPI(record);
1521
                    }
1522
                })
1523
                menu_.push({
1524
                    text: 'Delete All subKPI',
1525
                    handler: function () {}
1526
                })
1527
            } else {
1528
                menu_.push({
1529
                    text: 'Delete subKPI',
1530
                    handler: function () {
1531
                        me.deleteSubKPI(record);
1532
                    }
1533
                })
1534
            }
1535

    
1536
            Ext.create('Ext.menu.Menu', {
1537
                name: 'panelMenu',
1538
                width: 240,
1539
                height: 150,
1540
                margin: '0 0 10 0',
1541
                items: menu_
1542
            }).showAt([1239, Y]);
1543
        },
1544

    
1545
        AddAppraiserQ: function () {},
1546

    
1547
        deleteSubKPI: function (a) {
1548
            /*var main_ = Ext.ComponentQuery.query('[name=PHRPA0049]')[0];
1549
            var record = main_.getView().selection;
1550
            var _empID = getParam('EmployeeID');
1551
            var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1552
            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1553
            var kpiseq = record.data.Sequence;
1554
            var skpiseq = record.data.SequenceSubKPI;
1555
            var params = {
1556
            serviceName : 'Performance.asmx',
1557
            methodName : 'deleteSubKPI',
1558
            parameter : 'empID=' + _empID
1559
            + '&HeaderSeq=' + seq.getValue()
1560
            + '&appType=' + appType.getValue()
1561
            + '&KPISeq=' + kpiseq
1562
            + '&sKPISeq=' + skpiseq
1563
            };
1564
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1565
            var result = Ext.decode(xhr.responseText);
1566
            if (result.success) {
1567
            MinovaMessage('', 'PMS0001', '', 'S');
1568
            record.remove();
1569
            } else {
1570
            MinovaMessage('', '000005', result.message.text, 'E');
1571
            }
1572
            });*/
1573
            a.remove();
1574
        },
1575

    
1576
        calculatePMS: function () {
1577
            var pnl = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1578
            var form_ = pnl.getForm();
1579
            var data = form_.getValues();
1580
            var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1581
            var treestore = treepnl.store;
1582
            var pnlqual = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1583
            var storequal = undefined;
1584
            if (pnlqual != undefined) {
1585
                pnlqual.expandAll();
1586
                storequal = pnlqual.store;
1587
            }
1588
            var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1589
            var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
1590
            var PA0048_dATA = null;
1591
            var PA0051_dATA = null;
1592
            var TREE_dATA = null;
1593
            var Head = null;
1594
            var Child = null;
1595

    
1596
            if (data.AppraisalType != "G") {
1597
                var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1598
                var form_ = form.getForm();
1599
                var data = form_.getValues();
1600
                var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1601
                if (Sum.data.items.length > 0) {
1602
                    var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1603
                    Ext.Array.each(Ext.decode(DataSum), function (rec) {
1604
                        if (rec.Type == "KPI") {
1605
                            data["AdjustedKPI"] = rec.AdjustedScore;
1606
                            data["CalculatedKPI"] = rec.CalculatedScore;
1607
                            data["KPIFinalScore"] = rec.FinalScore;
1608
                            data["KPITotalScore"] = rec.TotalScore;
1609
                        } else {
1610
                            data["AdjustedCompetency"] = rec.AdjustedScore;
1611
                            data["CalculatedCompetency"] = rec.CalculatedScore;
1612
                            data["QualFinalScore"] = rec.FinalScore;
1613
                            data["QualTotalScore"] = rec.TotalScore;
1614
                        }
1615
                    })
1616
                }
1617
                var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1618
                var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1619
                if (dataTotalSum.length > 0) {
1620
                    data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1621
                    data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1622
                    data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1623
                    data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1624
                }
1625
            }
1626

    
1627
            if (PA0048 != undefined)
1628
                PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
1629
            if (storequal != undefined) {
1630
                var _data = Ext.pluck(storequal.data.items, 'data');
1631
                Ext.Array.each(_data, function (rec) {
1632
                    rec.children = null
1633
                })
1634
                PA0051_dATA = Ext.encode(_data);
1635
            }
1636
            if (treepnl != undefined)
1637
                TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
1638

    
1639
            var dataresult = null;
1640
            var data47 = null;
1641

    
1642
            var params = {
1643
                serviceName: 'Performance.asmx',
1644
                methodName: 'CalculatePerformance',
1645
                parameter:
1646
                'header=' + Ext.encode(data)
1647
                 + '&PA0048=' + PA0048_dATA
1648
                 + '&PA0049=' + TREE_dATA
1649
                 + '&PA0051=' + PA0051_dATA
1650
                 + '&Token=' + MinovaUtil.SESSIONS.Token
1651
            };
1652
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1653
                var result = Ext.decode(xhr.responseText);
1654
                dataresult = result.data;
1655
                Head = $.grep(Ext.decode(dataresult), function (r) {
1656
                    return r.Tablename == '0047'
1657
                });
1658
                data47 = Head;
1659
                var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1660
                var form_ = form.getForm();
1661
                form_.setValues(Head[0]);
1662
                var dataPA0048 = $.grep(Ext.decode(dataresult), function (r) {
1663
                    return r.Tablename == '0048'
1664
                });
1665
                var overView = Ext.StoreMgr.lookup('storePHRPA0048');
1666
                if (overView != undefined) {
1667
                    overView.removeAll();
1668
                    overView.loadData(dataPA0048);
1669
                }
1670

    
1671
                var dataPA0049 = $.grep(Ext.decode(dataresult), function (r) {
1672
                    return r.Tablename == '0049'
1673
                });
1674
                var dataKPI = $.grep((dataPA0049), function (r) {
1675
                    return r.SequenceSubKPI == '0'
1676
                });
1677
                var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1678
                if (pnl != undefined) {
1679
                    //pnl.store.removeAll()
1680
                    pnl.store.load()
1681
                    /*pnl.store.setRootNode({
1682
                    expanded : true,
1683
                    nodetype : 'async',
1684
                    children : dataKPI
1685
                    });*/
1686
                    var taskkpi = pnl.getRootNode();
1687
                    taskkpi.appendChild(dataKPI);
1688
                }
1689

    
1690
                var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1691
                    return r.Tablename == '0051'
1692
                });
1693
                var pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1694
                Head = $.grep(dataPA0051, function (r) {
1695
                    return r.SequenceSub == 0
1696
                });
1697
                Child = $.grep(dataPA0051, function (r) {
1698
                    return r.SequenceSub != 0
1699
                });
1700
                Ext.Array.each(Child, function (rec) {
1701
                    rec['leaf'] = true;
1702
                });
1703
                if (pnl2 != undefined) {
1704
                    pnl2.store.load();
1705
                    var task = pnl2.getRootNode();
1706
                    /*task.appendChild(Head);
1707
                    pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1708
                    storequal = pnl2.store;
1709
                    Ext.Array.each(storequal.data.items, function (rec) {
1710
                    var t = rec.data;
1711
                    var QChild = $.grep(Child, function (r) {
1712
                    return r.QualificationID == t.QualificationID
1713
                    });
1714
                    var index = t.index;
1715
                    rec.appendChild(QChild);
1716
                    })*/
1717
                    Ext.Array.each(Head, function (rec) {
1718
                        var QChild = $.grep(Child, function (r) {
1719
                            return r.QualificationID == rec.QualificationID
1720
                        });
1721
                        rec['children'] = QChild;
1722
                        rec['expanded'] = true;
1723
                        task.appendChild(rec);
1724
                    })
1725
                    pnl2.getView().refresh();
1726
                }
1727
                if (result.success) {
1728
                    MinovaMessage('', 'PMS0002', '', 'S');
1729
                } else {
1730
                    MinovaMessage('', '000005', '', 'E');
1731
                }
1732

    
1733
                data = {
1734
                    AdjustedIndex: '',
1735
                    AdjustedScore: data47[0].AdjustedKPI,
1736
                    CalculatedScore: data47[0].CalculatedKPI,
1737
                    FinalScore: data47[0].KPIFinalScore,
1738
                    IndexScore: '',
1739
                    TotalScore: data47[0].KPITotalScore,
1740
                    Type: 'KPI',
1741
                    Weight: '80'
1742
                };
1743

    
1744
                data2 = [];
1745
                data2[0] = data;
1746

    
1747
                data = {
1748
                    AdjustedIndex: '',
1749
                    AdjustedScore: data47[0].AdjustedCompetency,
1750
                    CalculatedScore: data47[0].CalculatedCompetency,
1751
                    FinalScore: data47[0].QualFinalScore,
1752
                    IndexScore: '',
1753
                    TotalScore: data47[0].QualTotalScore,
1754
                    Type: 'Qualification',
1755
                    Weight: '20'
1756
                };
1757

    
1758
                data2[1] = data;
1759

    
1760
                var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
1761
                if (overView != undefined) {
1762
                    overView.removeAll();
1763
                    overView.loadData(data2);
1764
                }
1765

    
1766
                dataTotal = {
1767
                    AdjustedIndex: data47[0].AdjustedIndex,
1768
                    AdjustedScore: data47[0].AdjustedScore,
1769
                    CalculatedScore: data47[0].CalculatedScore,
1770
                    IndexScore: data47[0].CalculatedIndex
1771
                };
1772

    
1773
                dataTotalList = [];
1774
                dataTotalList[0] = dataTotal;
1775

    
1776
                var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
1777
                if (overView != undefined) {
1778
                    overView.removeAll();
1779
                    overView.loadData(dataTotalList);
1780
                }
1781
            });
1782
        },
1783

    
1784
        addNewQualification: function () {
1785
            var me = this;
1786
            var count_lookup = Ext.ComponentQuery.query('[name=AddNewQualification]').length;
1787
            if (count_lookup == 1) {
1788
                Ext.ComponentQuery.query('[name=AddNewQualification]')[0].show();
1789
            } else {
1790
                Ext.create('Ext.window.Window', {
1791
                    title: 'Add Qualification',
1792
                    name: 'AddNewQualification',
1793
                    layout: 'fit',
1794
                    items: [{
1795
                            xtype: 'form',
1796
                            name: 'formAddQualification',
1797
                            items: [{
1798
                                    xtype: 'minovaForm',
1799
                                    bodyBorder: false,
1800
                                    cls: 'borderLookup',
1801
                                    border: false,
1802
                                    isLookup: false,
1803
                                    name: "mainformAddQualification",
1804
                                    tableName: 'PDSPMLOOKUPQUAL'
1805
                                }
1806
                            ]
1807
                        }
1808
                    ],
1809
                    buttons: [{
1810
                            text: 'Add Qualification',
1811
                            name: 'BtnAddKPI',
1812
                            iconCls: 'fa-save',
1813
                            style: 'font-family: FontAwesome',
1814
                            margin: '3 3 10 3',
1815
                            handler: function () {
1816
                                me.addNewQualificationtoGrid();
1817
                            }
1818
                        }, {
1819
                            text: 'Cancel',
1820
                            name: 'BtnCancelQualification',
1821
                            iconCls: 'fa-reply',
1822
                            style: 'font-family: FontAwesome',
1823
                            margin: '3 3 10 3',
1824
                            handler: function () {
1825
                                Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1826
                            }
1827
                        }
1828
                    ]
1829
                }).show();
1830
            }
1831
        },
1832

    
1833
        addNewQualificationtoGrid: function () {
1834
            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1835
            var pnl = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1836
            var str = pnl.store;
1837

    
1838
            if (str.findRecord('QualificationID', Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()) != null) {
1839
                return;
1840
            }
1841

    
1842
            var leafCount = 0;
1843
            pnl.getRootNode().cascadeBy(function (node) {
1844
                if (!node.isLeaf())
1845
                    leafCount++;
1846
            });
1847
            var data = '';
1848
            var Sequence = 0;
1849
            if (leafCount == 0) {
1850
                Sequence = 1;
1851
            } else {
1852
                Sequence = 1 + leafCount;
1853
            }
1854

    
1855
            var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1856
            var formdata_ = form_.getForm();
1857

    
1858
            var data = {
1859
                "EmployeeID": formdata_.findField('EmployeeID').getValue(),
1860
                "HeaderSequence": formdata_.findField('Sequence').getValue(),
1861
                "Sequence": Sequence,
1862
                "AppraisalType": formdata_.findField('AppraisalType').getValue()
1863
            };
1864
            var data2 = null;
1865
            var params = {
1866
                serviceName: 'Performance.asmx',
1867
                methodName: 'SetQualification',
1868
                parameter: 'TableName=' + 'PHRPA0051'
1869
                 + '&Qualification=' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()
1870
                 + '&data=' + Ext.encode(data)
1871
            };
1872
            MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
1873
                var result = Ext.decode(xhr.responseText);
1874
                data2 = result.data;
1875
                if (result.success) {}
1876
                else {
1877
                    MinovaMessage('', '000005', result.message.text, 'E');
1878
                }
1879
            });
1880
            var children = eval("children:" + data2);
1881
            data = {
1882
                EmployeeID: Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1883
                AppraisalType: Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1884
                QualificationID: Ext.ComponentQuery.query('[name=Qualification]')[0].getValue(),
1885
                Sequence: Sequence,
1886
                Description: Ext.ComponentQuery.query('[name=Qualification]')[0].value.split('-')[1].substr(1),
1887
                HeaderSequence: seq,
1888
                SequenceSub: "0",
1889
                Weight: 0,
1890
                leaf: false,
1891
                Target: 1,
1892
                children,
1893
                expanded: true
1894
            };
1895

    
1896
            var task = pnl.getRootNode();
1897
            task.appendChild(data);
1898
            Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1899
        },
1900

    
1901
        loadQualification: function () {
1902
            var pnl = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1903
            var _result = undefined;
1904
            var Head = undefined;
1905
            Ext.Ajax.request({
1906
                async: false,
1907
                //method : 'POST',
1908
                url: '/UserControl/GetStore',
1909
                params: {
1910
                    tableName: 'PHRPA0051',
1911
                    param: 'EmployeeID[=]' + Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue()
1912
                     + ',AppraisalType[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()
1913
                     + ',HeaderSequence[=]' + Ext.ComponentQuery.query('[name=Sequence]')[0].getValue()
1914
                },
1915
                success: function (response) {
1916
                    _result = Ext.decode(response.responseText);
1917
                    if (_result.success) {
1918
                        var data = _result.data;
1919
                        Head = $.grep(data, function (r) {
1920
                            return r.SequenceSub == 0
1921
                        });
1922
                        var Child = $.grep(data, function (r) {
1923
                            return r.SequenceSub != 0
1924
                        });
1925
                        Ext.Array.each(Child, function (rec) {
1926
                            rec['leaf'] = true;
1927
                        })
1928
                        pnl.store.load();
1929
                        var task = pnl.getRootNode();
1930
                        Ext.Array.each(Head, function (rec) {
1931
                            var QChild = $.grep(Child, function (r) {
1932
                                return r.QualificationID == rec.QualificationID
1933
                            });
1934
                            rec['children'] = QChild;
1935
                            rec['expanded'] = true;
1936
                            task.appendChild(rec);
1937
                        })
1938
                    }
1939
                }
1940
            });
1941
        },
1942

    
1943
        deleteQualification: function () {
1944
            var main_ = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1945
            var record = main_.getView().selection;
1946

    
1947
            if (record == null) {
1948
                MinovaMessage('', 'PMSE003', '', 'E');
1949
                return;
1950
            }
1951

    
1952
            var _d = record.data;
1953
            if (_d.SequenceSub != 0) {
1954
                MinovaMessage('', 'PMSE003', '', 'E');
1955
                return;
1956
            }
1957
            record.remove();
1958
        },
1959

    
1960
        deleteKPI: function () {
1961
            var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1962
            var record = main_.getView().selection;
1963

    
1964
            if (record == null) {
1965
                MinovaMessage('', 'PMSE003', '', 'E');
1966
                return;
1967
            }
1968

    
1969
            var _d = record.data;
1970
            if (_d.SequenceSubKPI != 0) {
1971
                MinovaMessage('', 'PMSE003', '', 'E');
1972
                return;
1973
            }
1974
            record.remove();
1975
        },
1976

    
1977
        setDefaultAppbyOM: function () {
1978
            var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1979
            var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1980
            var AppraisalType = Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue();
1981
            var EmployeeID = getParam("EmployeeID");
1982
            var Result = null;
1983
            var params = {
1984
                serviceName: 'Performance.asmx',
1985
                methodName: 'GetDefaultAppraiser',
1986
                parameter:
1987
                'EmployeeID=' + EmployeeID
1988
                 + '&StartDate=' + StartDate
1989
                 + '&EndDate=' + EndDate
1990
                 + '&AppraisalType=' + AppraisalType
1991
            };
1992
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1993
                Result = Ext.decode(xhr.responseText);
1994
                if (Result.success) {
1995
                    var pnl0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1996
                    pnl0048.add(Ext.decode(Result.data));
1997
                } else {}
1998
            })
1999
        },
2000

    
2001
        saveToMDProfile: function () {
2002
            var me = this;
2003
            var pnl = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
2004
            var storequal = pnl.store;
2005
            var PA0051_dATA = null;
2006
            var dataMD8002 = null;
2007
            if (storequal != undefined) {
2008
                pnl.expandAll();
2009
                var _data = Ext.pluck(storequal.data.items, 'data');
2010
                Ext.Array.each(_data, function (rec) {
2011
                    rec.children = null
2012
                })
2013
                PA0051_dATA = Ext.encode(_data);
2014
                dataMD8002 = $.grep(Ext.decode(PA0051_dATA), function (r) {
2015
                    r['StartDate'] = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
2016
                    r['EndDate'] = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
2017
                    r['QualificationLevel'] = r.AppraiserScore
2018
                        return r.SequenceSub == 0
2019
                });
2020
            }
2021
            var Result = null;
2022
            var params = {
2023
                serviceName: 'Performance.asmx',
2024
                methodName: 'SaveToMD',
2025
                parameter:
2026
                'TableName=' + 'PHRPA0045'
2027
                 + '&dataDetail=' + Ext.encode(dataMD8002)
2028
                 + '&Token=' + MinovaUtil.SESSIONS.Token
2029
            };
2030
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
2031
                Result = Ext.decode(xhr.responseText);
2032
                if (Result.success) {
2033
                    MinovaMessage('', 'PY0000', '', 'S');
2034
                } else {
2035
                    MinovaMessage('', '000005', Result.message.text, 'E');
2036
                }
2037
            })
2038
        },
2039

    
2040
        SaveToMDHistory: function () {
2041
            var me = this;
2042
            var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
2043
            var form_ = form.getForm();
2044
            var data = form_.getValues();
2045
            var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
2046
            var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
2047
            Ext.Array.each(Ext.decode(DataSum), function (rec) {
2048
                if (rec.Type == "KPI") {
2049
                    data["AdjustedKPI"] = rec.AdjustedScore;
2050
                    data["CalculatedKPI"] = rec.CalculatedScore;
2051
                    data["KPIFinalScore"] = rec.FinalScore;
2052
                    data["KPITotalScore"] = rec.TotalScore;
2053
                    data["KPITotalWeight"] = rec.Weight;
2054
                } else {
2055
                    data["AdjustedCompetency"] = rec.AdjustedScore;
2056
                    data["CalculatedCompetency"] = rec.CalculatedScore;
2057
                    data["QualFinalScore"] = rec.FinalScore;
2058
                    data["QualTotalScore"] = rec.TotalScore;
2059
                    data["QualTotalWeight"] = rec.Weight;
2060
                }
2061
            })
2062
            var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
2063
            var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
2064
            data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
2065
            data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
2066
            data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
2067
            data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
2068

    
2069
            var Result = null;
2070
            var params = {
2071
                serviceName: 'Performance.asmx',
2072
                methodName: 'SaveToMD',
2073
                parameter:
2074
                'TableName=' + 'PHRPA0029'
2075
                 + '&dataDetail=' + '[' + Ext.encode(data) + ']'
2076
                 + '&Token=' + MinovaUtil.SESSIONS.Token
2077
            };
2078
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
2079
                Result = Ext.decode(xhr.responseText);
2080
                if (Result.success) {
2081
                    MinovaMessage('', 'PY0000', '', 'S');
2082
                } else {
2083
                    MinovaMessage('', '000005', Result.message.text, 'E');
2084
                }
2085
            })
2086
        },
2087
        CheckAppraiserWeight: function () {
2088
            var a = "0";
2089
            var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
2090
            data = Ext.pluck(PA0048.data.items, 'data');
2091
            var kpi = 0;
2092
            var qual = 0;
2093
            data.forEach(function (rec) {
2094
                kpi += Number(rec.KPIWeight);
2095
                qual += Number(rec.QualificationWeight);
2096
            });
2097
            if (kpi != 100 || qual != 100)
2098
                a = "1";
2099
            return a;
2100
        },
2101
		
2102
		
2103
		
2104
		
2105
		TestUy:function(){
2106
setTimeout(function(){ 	var PA00Respon = Ext.StoreMgr.lookup("storeCPMSRESPONSIBLE");
2107
								PA00Respon.getSortOnLoad();
2108
								var grid2 = Ext.ComponentQuery.query('[name=gridCPMSRESPONSIBLE]')[0];
2109
								grid2.getView().refresh();}, 10000);
2110
			
2111
		},
2112
		TestUy2:function(){
2113
setTimeout(function(){ 	var PA00Respon = Ext.StoreMgr.lookup("storeCPMSUMMARYESSKPI");
2114
								PA00Respon.getSortOnLoad();
2115
								var grid2 = Ext.ComponentQuery.query('[name=gridCPMSUMMARYESSKPI]')[0];
2116
								grid2.getView().refresh();}, 10000);
2117
			
2118
		},
2119
		TestUy3:function(){
2120
setTimeout(function(){ 		var PA00Respon = Ext.StoreMgr.lookup("storeCPMSUMTOTALHR");
2121
								PA00Respon.sort([
2122
    { property: 'Sequence',  direction: 'ASC' }
2123
    
2124
]);}, 7000);
2125
			
2126
		}
2127
    });
(5-5/10)