Project

General

Profile

Bug #1308 » controllerperformance.js

Tri Rizqiaty, 07/01/2022 05:18 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
                //viewready: this.viewReadyOverview
20
            },
21
            '[name=savePerformance]': {
22
                click: this.savePerformance,
23
            },
24
            '[name=gotoother]': {
25
                click: this.btnGoToother
26
            },
27
            '[name=deletePerformance]': {
28
                click: this.deletePerformance,
29
            },
30
            '[name=AppraisalType]': {
31
                select: this.createGridDetail,
32
            },
33
            '[name=gridPHRPA0048]': {
34
                itemdblclick: this.addAppraiser,
35
            },
36
            '[name=gridPHRPA0049]': {
37
                afteritemexpand: this.loadChild
38
            },
39
            /*'[name=AddKPI]' : {
40
            click : this.addNewKPI
41
            },*/
42
            '[name=BtnCancelKPI]': {
43
                click: this.cancelAddNewKPI
44
            },
45
            /*'[name=BtnAddKPI]' : {
46
            click : this.addNewKPI
47
            },*/
48
            '[name=Action]': {
49
                "onEditClick": this.loadMenu
50
            },
51
            '[name=PHRPA0048Add]': {
52
                click: this.AddAppraiserQ
53
            },
54
            '[name=PHRPA0049Add]': {
55
                click: this.addNewKPI
56
            },
57
            '[name=PHRPA0051Add]': {
58
                click: this.addNewQualification
59
            },
60
            '[name=PHRPA0051Delete]': {
61
                click: this.deleteQualification
62
            },
63
            '[name=PHRPA0049Delete]': {
64
                click: this.deleteKPI
65
            }
66
        });
67
    },
68

    
69
    getRowIndex_: function () {
70
        return this.rowIndex_;
71
    },
72
    setRowIndex_: function (value) {
73
        var me = this;
74
        me.rowIndex_ = value;
75
        return me;
76
    },
77
    getRec: function () {
78
        return this.rec;
79
    },
80
    setRec: function (value) {
81
        var me = this;
82
        me.rec = value;
83
        return me;
84
    },	
85
	afterRenderOverview : function () {
86
		var overView = Ext.StoreMgr.lookup("PerformanceOverview");
87

    
88
		overView.proxy.extraParams = {
89
			tableName : 'PHRPA0047',
90
			param : 'EmployeeID[=]' + getParam('EmployeeID')
91
		};
92
		overView.removeAll();
93
		overView.reload();
94
		overView.loadPage(1);
95
	},
96
    /*afterRenderOverview: function () { 		//// comment by Tri nwh 20220701
97
        var overView = Ext.StoreMgr.lookup("PerformanceOverview");
98
        var param_ = '';
99
        var menuId = MinovaUtil.GetMenuID();
100
        var AppraisalType = '';
101
        //if (menuId == 'PMS_Goal') param_ = param_ + ",AppraisalType[=]G";
102
        //else if (menuId == 'PMS_Review') param_ = param_ + ",AppraisalType[=]P";
103
        //else if (menuId == 'PMS_Final') param_ = param_ + ",AppraisalType[=]F";
104
        if ((menuId == 'PMS_Goal') || (menuId == 'PMS_Review') || (menuId == 'PMS_Final')) {            
105
            //if ((this.view.regID == undefined) || (this.view.regID == 'null') || (this.view.regID == '0')) {
106
            if (this.view.regID > 0) {
107
                param_ = "RegID[=]" + this.view.regID;
108
                overView.proxy.extraParams = {
109
                    tableName: 'PHRPA0047',
110
                    param: param_
111
                };
112
                overView.removeAll();
113
                overView.load();
114
                initForm = '1';
115
                var MyGrid = Ext.ComponentQuery.query('[name=PA0047]')[0];
116
                MyGrid.getStore().on("load", function (me) {
117
                    if (initForm == 1) {
118
                        var MyRec = me.data.items[0];
119
                        MyGrid.getView().getSelectionModel().select(0);
120
                        MyGrid.fireEvent('itemdblclick', MyGrid, MyRec); //event itemdblclicknya ada di mdgenerator.createGridCard
121

    
122
                        var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
123
                        var combo = form_.getForm().findField('AppraisalType');
124
                        var cancelBtn_ = Ext.ComponentQuery.query('[name=cancelPerformance]')[0];
125
                        var saveBtn_ = Ext.ComponentQuery.query('[name=savePerformance]')[0];
126
                        var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
127
                        combo.setReadOnly(true);
128
                        cancelBtn_.setHidden(true);
129
                        saveBtn_.setHidden(true);
130
                        delBtn_.setHidden(true);
131
                    }
132
                    initForm = '';
133
                });            
134
            }
135
            else {
136
                //this.addPerformance(); //dipindah ke viewReadyOverview agar ga double
137
            }
138
        }
139
        else {
140
            param_= 'EmployeeID[=]' + this.view.empId;
141
            overView.proxy.extraParams = {
142
                tableName: 'PHRPA0047',
143
                param: param_
144
            };
145
            overView.removeAll();
146
            overView.reload();
147
            overView.loadPage(1);
148
        }
149
    },
150
    viewReadyOverview: function () {
151
        var menuId = MinovaUtil.GetMenuID();
152
        if ((menuId == 'PMS_Goal') || (menuId == 'PMS_Review') || (menuId == 'PMS_Final')) {
153
            //if ((this.view.regID == undefined) || (this.view.regID == 'null') || (this.view.regID == '0')) {
154
            if (this.view.regID > 0){
155
                //this.editPerformance();
156
            }
157
            else {
158
                this.addPerformance();
159
            }
160
        }
161
    },*/ 
162
    addPerformance: function () {
163
        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
164
        card_.getLayout().setActiveItem(1);
165
        var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
166
        form_.getForm().reset();
167
        form_.getForm().findField('EmployeeID').setValue(this.view.empId);
168
        var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
169
        delBtn_.setHidden(true);
170
        var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
171
        grid.removeAll();
172

    
173
        var menuId = MinovaUtil.GetMenuID();
174
        if ((menuId == 'PMS_Goal') || (menuId == 'PMS_Review') || (menuId == 'PMS_Final')) {
175
            var combo = form_.getForm().findField('AppraisalType');
176
            var toselect = '';
177
            form_.getForm().findField('StartDate').setValue('20210101');
178
            form_.getForm().findField('EndDate').setValue('20211231');
179
            
180
            if (menuId == 'PMS_Goal') toselect = 'G';
181
            else if (menuId == 'PMS_Review') toselect = 'P';
182
            else if (menuId == 'PMS_Final') toselect = 'F';
183
            combo.setValue(toselect);            
184
            //combo.select(toselect);
185
            var record = combo.getStore().findRecord('name', toselect);
186
            combo.fireEvent('select', combo, [record]);
187

    
188
            //Set Visible & Disable
189
            //combo.setDisabled(true);
190
            combo.setReadOnly(true);
191

    
192
            var cancelBtn_ = Ext.ComponentQuery.query('[name=cancelPerformance]')[0];
193
            var saveBtn_ = Ext.ComponentQuery.query('[name=savePerformance]')[0];
194
            var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
195
            cancelBtn_.setHidden(true);
196
            saveBtn_.setHidden(true);
197
            delBtn_.setHidden(true);
198
            //this.createGridDetail();
199
        }
200
        //form_.setActionSubmit(0);
201
        //this.setHeaderSeqEmpForm(0);
202

    
203
        var me = this;
204
        me._action = "0";
205
    },
206
    editPerformance: function () {        
207
        var me = Ext.ComponentQuery.query('[name=PA0047]')[0];
208
        var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0]; // edit proses
209
        form.setActionSubmit(1);
210
        var selection = me.getView().getSelectionModel().getSelection()[0];
211
        var form_ = form.getForm();
212
        form_.setValues(selection.data);
213

    
214
        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
215
        card_.getLayout().setActiveItem(1);
216
        var delBtn_ = Ext.ComponentQuery.query('[name=deletePerformance]')[0];
217
        delBtn_.setHidden(false);
218

    
219
        this.setGridPerformance('1');
220

    
221
        data = {
222
            AdjustedIndex: '',
223
            AdjustedScore: selection.data.AdjustedKPI,
224
            CalculatedScore: selection.data.CalculatedKPI,
225
            FinalScore: selection.data.KPIFinalScore,
226
            IndexScore: '',
227
            TotalScore: selection.data.KPITotalScore,
228
            Type: 'KPI',
229
            Weight: selection.data.KPITotalWeight
230
        };
231

    
232
        data2 = [];
233
        data2[0] = data;
234

    
235
        data = {
236
            AdjustedIndex: '',
237
            AdjustedScore: selection.data.AdjustedCompetency,
238
            CalculatedScore: selection.data.CalculatedCompetency,
239
            FinalScore: selection.data.QualFinalScore,
240
            IndexScore: '',
241
            TotalScore: selection.data.QualTotalScore,
242
            Type: 'Qualification',
243
            Weight: selection.data.QualificationPercen
244
        };
245

    
246
        data2[1] = data;
247

    
248
        var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
249
        if (overView != undefined) {
250
            overView.removeAll();
251
            overView.loadData(data2);
252
        }
253

    
254
        dataTotal = {
255
            AdjustedIndex: selection.data.AdjustedIndex,
256
            AdjustedScore: selection.data.AdjustedScore,
257
            CalculatedScore: selection.data.CalculatedScore,
258
            IndexScore: selection.data.CalculatedIndex
259
        };
260

    
261
        dataTotalList = [];
262
        dataTotalList[0] = dataTotal;
263

    
264
        var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
265
        if (overView != undefined) {
266
            overView.removeAll();
267
            overView.loadData(dataTotalList);
268
        }
269
		
270
		//// add by Tri nwh 20220701 start
271
		Ext.ComponentQuery.query('[name=PHRPA0048Add]')[0].setHidden(true); 
272
		Ext.ComponentQuery.query('[name=PHRPA0049Add]')[0].setHidden(true); 
273
		Ext.ComponentQuery.query('[name=PHRPA0051Add]')[0].setHidden(true); 
274
		Ext.ComponentQuery.query('[name=PHRPA0048DeleteText]')[0].setHidden(true); 
275
		Ext.ComponentQuery.query('[name=PHRPA0049DeleteText]')[0].setHidden(true); 
276
		Ext.ComponentQuery.query('[name=PHRPA0051DeleteText]')[0].setHidden(true); 
277
		//// add by Tri nwh 20220701 start
278
    },
279
    cancelPerformance: function () {
280
        var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
281
        card_.getLayout().setActiveItem(0);
282
    },
283
    createGridDetail: function (rec) {
284
        var me = this;
285
        var _empID = me.view.empId;
286
        var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
287
        var form = main.getForm();
288
        var SDate = form.findField("StartDate").getValue();
289
        var EDate = form.findField("EndDate").getValue();
290
        if (SDate == '' || SDate == undefined || EDate == '' || EDate == undefined) {
291
            MinovaMessage('', 'PMS0003', '', 'E');
292
            Ext.ComponentQuery.query('[name=AppraisalType]')[0].setValue('');
293
            return;
294
        }
295
        this.setGridPerformance('0');
296

    
297
        var appType = rec.getValue();
298

    
299
        if (appType != 'G') {
300
            var main = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
301
            var form = main.getForm();
302
            var SDate = form.findField("StartDate").getValue();
303
            var EDate = form.findField("EndDate").getValue();
304
            var Data = undefined;
305
            var params = {
306
                serviceName: 'Performance.asmx',
307
                methodName: 'SetDefaultAppraiser',
308
                parameter: 'EmployeeID=' + me.view.empId
309
                    + '&StartDate=' + SDate
310
                    + '&EndDate=' + EDate
311
            };
312
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
313
                var result = Ext.decode(xhr.responseText);
314
                Data = result;
315
                var overView = Ext.StoreMgr.lookup('storePHRPA0048');
316
                if (overView != undefined) {
317
                    overView.removeAll();
318
                    overView.loadData(Ext.decode(Data.data));
319
                }
320
                if (result.success) {
321
                    MinovaMessage('', 'PMS0001', '', 'S');
322
                } else { }
323
            });
324

    
325
            var params = {
326
                serviceName: 'Performance.asmx',
327
                methodName: 'SetDefaultKPI',
328
                parameter: 'EmployeeID=' + _empID
329
                    + '&StartDate=' + SDate
330
                    + '&EndDate=' + EDate
331
            };
332
            MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
333
                var result = Ext.decode(xhr.responseText);
334
                Data = result;
335
                var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
336
                if (pnl != undefined) {
337
                    pnl.store.removeAll()
338
                    pnl.store.load()
339
                    pnl.store.setRootNode({
340
                        expanded: true,
341
                        nodetype: 'async',
342
                        children: Ext.decode(Data.data)
343
                    });
344
                }
345
                if (result.success) { }
346
                else { }
347
            });
348
        } else {
349
            me.setDefaultAppbyOM();
350
        }
351
    },
352
    setGridPerformance: function (_a) {
353
        var me = this;
354
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
355
        var grid = Ext.ComponentQuery.query('[name=formPerformanceDetail]')[0];
356
        var _empID = me.view.empId;
357

    
358
        grid.removeAll();
359

    
360
        try {
361
            var hasil = null;
362
            Ext.Ajax.request({
363
                async: false,
364
                method: 'POST',
365
                url: '/Performance/getListTableRef',
366
                params: {
367
                    AppType: appType.getValue(),
368
                    EmpID: _empID
369
                },
370
                success: function (response) {
371
                    var results = Ext.decode(response.responseText);
372
                    hasil = Ext.decode(results.data);
373
                }
374
            });
375

    
376
            if (hasil.length > 0) {
377
                Ext.Array.each(hasil, function (rec) {
378

    
379
                    var _title = undefined;
380
                    Ext.Ajax.request({
381
                        async: false,
382
                        //method : 'POST',
383
                        url: '/UserControl/GetStore',
384
                        params: {
385
                            tableName: 'SDATATABLE',
386
                            param: 'TableName[=]' + rec
387
                        },
388

    
389
                        success: function (response) {
390
                            var results = Ext.decode(response.responseText);
391
                            var dt = results.data[0];
392
                            _title = dt.TableDescription;
393
                        }
394
                    });
395

    
396
                    if (rec != 'PHRPA0049' && rec != 'PHRPA0051') {
397
                        var _GridDetail = {
398
                            xtype: 'fieldset',
399
                            columnWidth: 0.5,
400
                            title: _title,
401
                            collapsible: true,
402
                            defaultType: 'textfield',
403
                            defaults: {
404
                                anchor: '100%'
405
                            },
406
                            height: 400,
407
                            layout: 'anchor',
408
                            bbar: [{
409
                                xtype: 'textfield',
410
                                name: 'TotalScore' + rec,
411
                                label: 'Total Score'
412
                            }
413
                            ],
414
                            items: [{
415
                                xtype: 'minovapmseditablegrid',
416
                                height: 300,
417
                                autoLoad: false,
418
                                autoScroll: true,
419
                                tableName: rec,
420
                                storeName: 'store' + rec,
421
                                name: rec,
422
                                hideButton: false,
423
                                pagesize: 10,
424
                                empID: _empID,
425
                                apprasalType: appType.getValue(),
426
                                listeners: {}
427
                            }
428
                            ]
429
                        };
430
                        grid.add(_GridDetail);
431

    
432
                        if (_a == '1') {
433
                            me.getDataAppraiser(rec);
434
                        }
435
                    } else {
436
                        var _GridDetail = {
437
                            xtype: 'fieldset',
438
                            columnWidth: 0.5,
439
                            title: _title,
440
                            collapsible: true,
441
                            //defaultType : 'textfield',
442
                            //autoScroll : true,
443
                            defaults: {
444
                                anchor: '100%'
445
                            },
446
                            height: 420,
447
                            layout: 'anchor',
448
                            items: [{
449
                                xtype: 'Minovapmstreeeditablegrid',
450
                                tableName: rec,
451
                                height: 280,
452
                                apprasalType: appType.getValue(),
453
                                empID: _empID,
454
                                autoScroll: true,
455
                                hideButton: false,
456
                                multiSelect: false,
457
                                /*xtype : 'panel',
458
                                name : 'Pnl' + rec,
459
                                height : 380,
460
                                width : '100%',
461
                                autoScroll : true,
462
                                /*items : [{
463
                                        xtype : 'Minovapmstreeeditablegrid',
464
                                        tableName : rec,
465
                                        height : 280,
466
                                        apprasalType : appType.getValue(),
467
                                        empID : _empID,
468
                                        autoScroll : true,
469
                                        hideButton : false,
470
                                        multiSelect : false
471
                                    }
472
                                ],*/
473
                                tbar: [{
474
                                    xtype: 'toolbar',
475
                                    items: [{
476
                                        text: 'Add',
477
                                        name: rec + 'Add',
478
                                        iconCls: 'fa-plus-circle',
479
                                        style: 'font-family: FontAwesome'
480
                                    }, {
481
                                        text: 'Delete',
482
                                        name: rec + 'DeleteText',
483
                                        iconCls: 'fa-trash-o',
484
                                        style: 'font-family: FontAwesome',
485
                                        //disabled: true
486
                                        handler: function () {
487
                                            var me = this,
488
                                                store = Ext.StoreMgr.lookup(storeID)
489

    
490
                                            var grid = Ext.getCmp(gridName);
491

    
492
                                            Ext.MessageBox.show({
493
                                                title: 'Remove tab',
494
                                                msg: "This will remove. Do you want to continue?",
495
                                                buttons: Ext.MessageBox.YESNO,
496
                                                fn: function (choice) {
497
                                                    console.log(choice);
498
                                                    if (choice === 'yes') {
499
                                                        var selection = grid.getView().getSelectionModel().getSelection()[0];
500
                                                        if (selection) {
501
                                                            store.remove(selection);
502
                                                        }
503
                                                    }
504
                                                }
505
                                            });
506
                                        }
507
                                    }
508
                                    ]
509
                                }
510
                                ]
511
                            }
512

    
513
                            ]
514
                        };
515
                        grid.add(_GridDetail);
516

    
517
                        if (_a == '1') {
518
                            var pnl = Ext.ComponentQuery.query('[name=grid' + rec + ']')[0];
519
                            var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
520
                            var data_kpi = null;
521
                            var url = null;
522
                            if (rec == 'PHRPA0049') {
523
                                url = '/Performance/getKPI';
524

    
525
                                Ext.Ajax.request({
526
                                    //method : 'POST',
527
                                    async: false,
528
                                    url: url,
529
                                    params: {
530
                                        EmpID: _empID,
531
                                        Seq: seq.getValue(),
532
                                        AppType: appType.getValue()
533
                                    },
534
                                    success: function (response) {
535
                                        var results = Ext.decode(response.responseText);
536
                                        data_kpi = Ext.decode(results.data);
537
                                    }
538
                                });
539

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

    
577
            if (appType.getValue() == 'P' || appType.getValue() == 'F') {
578
                var _title = undefined;
579
                Ext.Ajax.request({
580
                    async: false,
581
                    //method : 'POST',
582
                    url: '/UserControl/GetStore',
583
                    params: {
584
                        tableName: 'SDATATABLE',
585
                        param: 'TableName[=]' + 'PDSPMSUMMARY'
586
                    },
587

    
588
                    success: function (response) {
589
                        var results = Ext.decode(response.responseText);
590
                        var dt = results.data[0];
591
                        _title = dt.TableDescription;
592
                    }
593
                });
594

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

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

    
692
        if (PA0048 != undefined)
693
            PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
694
        if (PA0049 != undefined)
695
            PA0049_dATA = Ext.encode(Ext.pluck(PA0049.data.items, 'data'));
696
        if (PA0049A != undefined)
697
            PA0049A_dATA = Ext.encode(Ext.pluck(PA0049A.data.items, 'data'));
698
        if (storequal != undefined) {
699
            var _data = Ext.pluck(storequal.data.items, 'data');
700
            Ext.Array.each(_data, function (rec) {
701
                rec.children = null
702
            })
703
            PA0051_dATA = Ext.encode(_data);
704
        }
705
        if (treepnl != undefined)
706
            TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
707

    
708
        if (data.AppraisalType != "G") {
709
            var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
710
            var form_ = form.getForm();
711
            var data = form_.getValues();
712
            var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
713
            if (Sum.data.items.length > 0) {
714
                var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
715
                Ext.Array.each(Ext.decode(DataSum), function (rec) {
716
                    if (rec.Type == "KPI") {
717
                        data["AdjustedKPI"] = rec.AdjustedScore;
718
                        data["CalculatedKPI"] = rec.CalculatedScore;
719
                        data["KPIFinalScore"] = rec.FinalScore;
720
                        data["KPITotalScore"] = rec.TotalScore;
721
                    } else {
722
                        data["AdjustedCompetency"] = rec.AdjustedScore;
723
                        data["CalculatedCompetency"] = rec.CalculatedScore;
724
                        data["QualFinalScore"] = rec.FinalScore;
725
                        data["QualTotalScore"] = rec.TotalScore;
726
                    }
727
                })
728
            }
729
            var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
730
            var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
731
            if (dataTotalSum.length > 0) {
732
                data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
733
                data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
734
                data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
735
                data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
736
            }
737
        }
738

    
739
        Ext.Ajax.request({
740
            async: false,
741
            method: 'POST',
742
            url: '/Performance/testController',
743
            params: {
744
                header: Ext.encode(data),
745
                PA0048: PA0048_dATA,
746
                PA0049: TREE_dATA,
747
                PA0049A: PA0049A_dATA,
748
                PA0051: PA0051_dATA,
749
                action: this._action
750
            },
751
            waitMsg: 'Saving Data...',
752
            success: function (response) {
753

    
754
                var result = Ext.decode(response.responseText);
755
                if (result.success) {
756
                    var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
757
                    card_.getLayout().setActiveItem(0);
758
                    MinovaMessage('', '000006', '', 'S');
759
                    if (data.AppraisalType == "F") {
760
                        me.SaveToMDHistory();
761
                        me.saveToMDProfile();
762
                    }
763
                    me.afterRenderOverview();
764
                    form.unmask();
765
                } else {
766
                    form.unmask();
767
                    //MinovaMessage('', result.message.id, result.message.text, "E");
768
                    MinovaMessage('', '000005', result.message.text, "E")
769
                }
770
            },
771
            failure: function (response) {
772
                var result = Ext.decode(response.responseText);
773
                form.unmask();
774
                // MinovaMessage('', result.message.id, result.message.text, "E")
775
                MinovaMessage('', '000005', result.message.text, "E")
776
            }
777
        });
778
    },
779
    btnGoToother: function () {
780
        var menu_ = [];
781
        var Y = 180;
782

    
783
        menu_.push({
784
            text: 'Employee Search',
785
            handler: function () {
786
                Ext.create('Ext.window.Window', {
787
                    title: 'Lookup - Employee',
788
                    height: 530,
789
                    width: 500,
790
                    name: 'lookupMain',
791
                    modal: true,
792
                    items: [{
793
                        xtype: 'minovaform',
794
                        bodyBorder: false,
795
                        MaxHeigth: '100',
796
                        cls: 'borderLookup',
797
                        border: false,
798
                        MaxHeigth: '30',
799
                        scroll: true,
800
                        isLookup: true,
801
                        name: "formLookupFilter",
802
                        tableName: 'PDSEMP0002',
803
                        buttons: [{
804
                            text: 'Search',
805
                            handler: function () {
806
                                var store = Ext.data.StoreManager.lookup('lookupStore');
807
                                var form = Ext.ComponentQuery.query('[name=formLookupFilter]')[0].getForm();
808
                                grid = Ext.ComponentQuery.query('[name=gridLookup]')[0];
809
                                var values_ = form.getValues();
810
                                var fields_ = form.getFields().items;
811
                                var param_ = '';
812
                                for (var i = 0; i < fields_.length; i++) {
813
                                    var val_ = form.getFields().items[i].getValue();
814
                                    var xtype_ = form.getFields().items[i].xtype;
815
                                    var oprator_ = '[like]';
816
                                    if (xtype_ == 'combobox' || xtype_ == 'combo' || xtype_ == 'minovacombo' || xtype_ == 'minovacombobox') {
817
                                        oprator_ = '[Equal]';
818
                                    }
819
                                    if (xtype_ == 'datefield') {
820
                                        if (form.getFields().items[i].name == 'StartDate' || form.getFields().items[i].name == 'ValidForm') {
821
                                            oprator_ = '[LessThanEqual]';
822
                                        } else {
823
                                            oprator_ = '[GreaterThanEqual]';
824
                                        }
825
                                    }
826
                                    if (val_ != 'undefined' && val_ != "" && val_ != null) {
827
                                        param_ = param_ + ',' + form.getFields().items[i].name + oprator_ + val_;
828
                                    }
829
                                }
830
                                store.proxy.extraParams = {
831
                                    tableName: grid.tableName,
832
                                    param: param_,
833
                                    menuId: MinovaUtil.GetMenuID()
834
                                };
835
                                store.removeAll();
836
                                store.reload();
837
                                store.loadPage(1);
838
                            }
839

    
840
                        }
841
                        ],
842
                    }, {
843
                        xtype: 'minovagrid1',
844
                        isLookup: 1,
845
                        minHeight: 280,
846
                        height: 280,
847
                        tableName: 'PDSEMP0002',
848
                        param: '',
849
                        isLookup: true,
850
                        autoLoad: false,
851
                        name: 'gridLookup',
852
                        hidebutton: 0,
853
                        pagesize: 25,
854
                        storename: 'lookupStore',
855
                        listeners: {
856
                            itemdblclick: function (g) {
857
                                var dataSelection = this.getView().getSelectionModel().getSelection()[0].data;
858
                                //console.log(dataSelection)
859
                                var url = MinovaUtil.GetMenuID() + '&EmployeeID=' + dataSelection.EmployeeID + '&FullName=' + dataSelection.FullName + '&Lang=' + localStorage.LangId;
860
                                var mb = new minovaBlowfish();
861
                                e = mb.minovaEncryptUrl(url);
862
                                window.open('masterdataperformancedetail?' + e, "_self");
863

    
864
                            },
865
                            beforeedit: function (grid) {
866
                                return false;
867
                            }
868
                        },
869
                        dockedItems: [{
870
                            xtype: 'pagingtoolbar',
871
                            store: 'lookupStore',
872
                            dock: 'bottom',
873
                            pageSize: 25,
874
                            displayInfo: true
875
                        }
876
                        ]
877

    
878
                    },]
879
                }).show();
880
            }
881
        });
882
        menu_.push({
883
            text: 'Back',
884
            handler: function () {
885
                window.history.back();
886
            }
887
        });
888
        Ext.create('Ext.menu.Menu', {
889
            name: 'panelMenu',
890
            width: 240,
891
            height: 100,
892
            margin: '0 0 10 0',
893

    
894
            items: menu_
895
        }).showAt([1239, Y]);
896
    },
897
    deletePerformance: function () {
898
        var me = this;
899
        var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0];
900
        var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0];
901
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
902
        var Sequence = Ext.ComponentQuery.query('[name=Sequence]')[0];
903
        var _empID = me.view.empId;
904

    
905
        Ext.Ajax.request({
906
            async: false,
907
            method: 'POST',
908
            url: '/Performance/deleteData',
909
            params: {
910
                EmpID: _empID,
911
                Seq: Sequence.getValue(),
912
                AppType: appType.getValue(),
913
                StDate: StartDate.getValue(),
914
                EnDate: EndDate.getValue()
915
            },
916
            waitMsg: 'Deleting Data...',
917
            success: function (response) {
918

    
919
                var result = Ext.decode(response.responseText);
920
                if (result.success) {
921
                    var card_ = Ext.ComponentQuery.query('[name=PerformanceCard]')[0];
922
                    card_.getLayout().setActiveItem(0);
923
                    MinovaMessage('', '000006', '', 'S');
924
                    me.afterRenderOverview();
925
                    //pnl.unmask();
926
                } else {
927
                    //.unmask();
928
                    //MinovaMessage('', result.message.id, result.message.text, "E");
929
                    MinovaMessage('', '000005', result.message.text, "E")
930
                }
931
            },
932
            failure: function (response) {
933
                var result = Ext.decode(response.responseText);
934
                //pnl.unmask();
935
                // MinovaMessage('', result.message.id, result.message.text, "E")
936
                MinovaMessage('', '000005', result.message.text, "E")
937
            }
938
        });
939

    
940
        me.afterRenderOverview();
941
    },
942
    addAppraiser: function () {
943
        var grid = Ext.getCmp('gridPHRPA0048');
944
        var record = grid.getSelectionModel().getSelection()[0];
945
        record.set('EmployeeID', this.view.empId);
946
    },
947
    getDataAppraiser: function (tblName) {
948
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
949
        var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
950
        var overView = Ext.StoreMgr.lookup('store' + tblName);
951
        var param = null;
952
        var data_kpi = null;
953

    
954
        if (tblName == 'PHRPA0049') {
955
            var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
956
            Ext.Ajax.request({
957
                //method : 'POST',
958
                async: false,
959
                url: '/Performance/getKPI',
960
                params: {
961
                    EmpID: _empID,
962
                    Seq: seq.getValue(),
963
                    AppType: appType.getValue()
964
                },
965
                success: function (response) {
966
                    var results = Ext.decode(response.responseText);
967
                    data_kpi = Ext.decode(results.data);
968
                }
969
            });
970
            pnl.store.setRootNode({
971
                expanded: true,
972
                nodetype: 'async',
973
                children: data_kpi
974
                //[]
975
            });
976
        } else {
977
            param = 'EmployeeID[=]' + this.view.empId
978
                + ',HeaderSequence[=]' + seq.getValue()
979
                + ',AppraisalType[=]' + appType.getValue();
980

    
981
            Ext.Ajax.request({
982
                //method : 'POST',
983
                async: false,
984
                url: '/UserControl/GetStore',
985
                params: {
986
                    tableName: tblName,
987
                    param: param
988
                },
989
                success: function (response) {
990
                    var results = Ext.decode(response.responseText);
991

    
992
                    if (tblName != 'PHRPA0049') {
993
                        overView.removeAll();
994
                        overView.loadData(results.data);
995
                    } else {
996
                        var data_ = results.data;
997
                        var pnl = Ext.ComponentQuery.query('[name=' + tblName + ']')[0];
998
                        pnl.store.setRootNode({
999
                            expanded: true,
1000
                            nodetype: 'async',
1001
                            children: data_
1002
                            //[]
1003
                        });
1004
                    }
1005
                }
1006
            });
1007
        }
1008
        //overView.removeAll();
1009
        //overView.reload();
1010
        //overView.loadPage(1);
1011
    },
1012
    loadChild: function (node, index, item, eOpts) {
1013
        var me = this;
1014
        var _empID = me.view.empId;
1015
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1016
        var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1017
        var data_ = null;
1018
        var idx = 0;
1019
        var tree_ = Ext.ComponentQuery.query('treepanel[name=gridPHRPA0049]')[0];
1020
        var v = tree_.getView();
1021

    
1022
        if (node.data.IsSubKPI == '1') {
1023
            return;
1024
        }
1025

    
1026
        tree_.mask('Expanding tree...');
1027

    
1028
        Ext.Ajax.request({
1029
            //method : 'POST',
1030
            async: false,
1031
            url: '/Performance/getSubKPI',
1032
            params: {
1033
                EmpID: _empID,
1034
                Seq: seq.getValue(),
1035
                AppType: appType.getValue(),
1036
                KPIID: node.data.KPI,
1037
                KPISeq: node.data.Sequence
1038
            },
1039
            success: function (response) {
1040
                var results = Ext.decode(response.responseText);
1041
                data_ = Ext.decode(results.data);
1042
            }
1043
        });
1044

    
1045
        if (data_.length > 0) {
1046
            data_.forEach(function (rec) {
1047
                if (v.store.data.find('SequenceSubKPI', rec.SequenceSubKPI) == null) {
1048
                    node.appendChild(data_[idx])
1049
                }
1050
                idx++;
1051
            })
1052
        }
1053

    
1054
        tree_.unmask();
1055
    },
1056
    addNewKPI: function () {
1057
        var me = this;
1058
        var count_lookup = Ext.ComponentQuery.query('[name=AddNewKPI]').length;
1059
        if (count_lookup == 1) {
1060
            Ext.ComponentQuery.query('[name=AddNewKPI]')[0].show();
1061
        } else {
1062
            Ext.create('Ext.window.Window', {
1063
                title: 'Add KPI',
1064
                name: 'AddNewKPI',
1065
                layout: 'fit',
1066
                items: [{
1067
                    xtype: 'form',
1068
                    name: 'formAddKPI',
1069
                    items: [{
1070
                        xtype: 'minovaForm',
1071
                        bodyBorder: false,
1072
                        cls: 'borderLookup',
1073
                        border: false,
1074
                        isLookup: false,
1075
                        name: "mainformAddKPI",
1076
                        tableName: 'PDSPMLOOKUPKPI'
1077
                    }
1078
                    ]
1079
                }
1080
                ],
1081
                buttons: [{
1082
                    text: 'Add KPI',
1083
                    name: 'BtnAddKPI',
1084
                    iconCls: 'fa-save',
1085
                    style: 'font-family: FontAwesome',
1086
                    margin: '3 3 10 3',
1087
                    handler: function () {
1088
                        me.addNewKPItoGrid();
1089
                    }
1090
                }, {
1091
                    text: 'Cancel',
1092
                    name: 'BtnCancelKPI',
1093
                    iconCls: 'fa-reply',
1094
                    style: 'font-family: FontAwesome',
1095
                    margin: '3 3 10 3',
1096
                    handler: function () {
1097
                        me.cancelAddNewKPI();
1098
                    }
1099
                }
1100
                ]
1101
            }).show();
1102
        }
1103
    },
1104
    cancelAddNewKPI: function () {
1105
        Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1106
    },
1107
    addNewKPItoGrid: function () {
1108
        var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1109
        var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1110
        var leafCount = 0;
1111
        pnl.getRootNode().cascadeBy(function (node) {
1112
            if (!node.isLeaf())
1113
                leafCount++;
1114
        });
1115
        var data = '';
1116
        var Sequence = 0;
1117
        if (leafCount == 0) {
1118
            Sequence = 1;
1119
        } else {
1120
            Sequence = 1 + leafCount;
1121
        }
1122

    
1123
        var a = Ext.ComponentQuery.query('[name=mainformAddKPI]')[0];
1124
        var b = a.getValues();
1125
        var c = '';
1126

    
1127
        Ext.Ajax.request({
1128
            method: 'POST',
1129
            async: false,
1130
            url: '/UserControl/GetStore',
1131
            params: {
1132
                tableName: 'PHROM0002',
1133
                param: 'ObjectClass[=]KG,RelationshipClass[=]K,RelationshipObject[=]' + Ext.ComponentQuery.query('[name=KPI]')[0].getValue() + ',StartDate[<=]' + b.StartDate + ',EndDate[>=]' + b.StartDate
1134
            },
1135
            success: function (response) {
1136
                var results = Ext.decode(response.responseText);
1137
                if (results.data != null && results.data.length > 0) {
1138
                    c = results.data[0].ObjectID;
1139
                }
1140
            }
1141
        });
1142

    
1143
        data = {
1144
            KPIGroup: c,
1145
            EmployeeID: Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1146
            AppraisalType: Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1147
            KPI: Ext.ComponentQuery.query('[name=KPI]')[0].getValue(),
1148
            Sequence: Sequence,
1149
            ObjectDescription: Ext.ComponentQuery.query('[name=KPI]')[0].value.split('-')[1].substr(1),
1150
            SubKPI: "-",
1151
            HeaderSequence: seq,
1152
            SequenceSubKPI: "0",
1153
            IsSubKPI: "0",
1154
            leaf: false,
1155
            Target: 1,
1156
            expanded: true
1157
        };
1158

    
1159
        var task = pnl.getRootNode();
1160
        task.appendChild(data);
1161
        Ext.ComponentQuery.query('[name=AddNewKPI]')[0].destroy();
1162
    },
1163
    addNewsubKPI: function (record) {
1164
        var me = this;
1165
        var count_lookup = Ext.ComponentQuery.query('[name=AddNewsubKPI]').length;
1166
        if (count_lookup == 1) {
1167
            Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].show();
1168
        } else {
1169
            Ext.create('Ext.window.Window', {
1170
                title: 'Add subKPI',
1171
                name: 'AddNewsubKPI',
1172
                layout: 'fit',
1173
                items: [{
1174
                    xtype: 'form',
1175
                    name: 'formAddsubKPI',
1176
                    items: [{
1177
                        xtype: 'minovaForm',
1178
                        bodyBorder: false,
1179
                        cls: 'borderLookup',
1180
                        border: false,
1181
                        isLookup: false,
1182
                        name: "mainformAddsubKPI",
1183
                        tableName: 'PDSPMLOOKUPKPI'
1184
                    }
1185
                    ]
1186
                }
1187
                ],
1188
                buttons: [{
1189
                    text: 'Add subKPI',
1190
                    name: 'BtnAddsubKPI',
1191
                    iconCls: 'fa-save',
1192
                    style: 'font-family: FontAwesome',
1193
                    margin: '3 3 10 3',
1194
                    handler: function () {
1195
                        me.addNewsubKPItoGrid(record);
1196
                    }
1197
                }, {
1198
                    text: 'Cancel',
1199
                    name: 'BtnCancelsubKPI',
1200
                    iconCls: 'fa-reply',
1201
                    style: 'font-family: FontAwesome',
1202
                    margin: '3 3 10 3',
1203
                    handler: function () {
1204
                        Ext.ComponentQuery.query('[name=AddNewsubKPI]')[0].destroy();
1205
                    }
1206
                }
1207
                ]
1208
            }).show();
1209
        }
1210
    },
1211
    addNewsubKPItoGrid: function (record) {
1212
        var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1213
        var leafCount = 0;
1214
        var _empID = this.view.empId;
1215
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1216
        var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1217
        var i = 0;
1218
        var data_ = null;
1219
        Ext.Ajax.request({
1220
            async: false,
1221
            url: '/Performance/getSubKPI',
1222
            params: {
1223
                EmpID: _empID,
1224
                Seq: seq.getValue(),
1225
                AppType: appType.getValue(),
1226
                KPIID: record.data.KPI,
1227
                KPISeq: record.data.Sequence
1228
            },
1229
            success: function (response) {
1230
                var results = Ext.decode(response.responseText);
1231
                data_ = Ext.decode(results.data);
1232
            }
1233
        });
1234
        if (data_.length == 0) {
1235
            i = 1;
1236
        } else {
1237
            i += data_.length;
1238
        }
1239

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

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

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

    
1294
        Ext.create('Ext.menu.Menu', {
1295
            name: 'panelMenu',
1296
            width: 240,
1297
            height: 150,
1298
            margin: '0 0 10 0',
1299
            items: menu_
1300
        }).showAt([1239, Y]);
1301
    },
1302
    AddAppraiserQ: function () { },
1303
    deleteSubKPI: function (a) {
1304
        /*var main_ = Ext.ComponentQuery.query('[name=PHRPA0049]')[0];
1305
        var record = main_.getView().selection;
1306
        var _empID = this.view.empId;
1307
        var appType = Ext.ComponentQuery.query('[name=AppraisalType]')[0];
1308
        var seq = Ext.ComponentQuery.query('[name=Sequence]')[0];
1309
        var kpiseq = record.data.Sequence;
1310
        var skpiseq = record.data.SequenceSubKPI;
1311
        var params = {
1312
        serviceName : 'Performance.asmx',
1313
        methodName : 'deleteSubKPI',
1314
        parameter : 'empID=' + _empID
1315
        + '&HeaderSeq=' + seq.getValue()
1316
        + '&appType=' + appType.getValue()
1317
        + '&KPISeq=' + kpiseq
1318
        + '&sKPISeq=' + skpiseq
1319
        };
1320
        MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1321
        var result = Ext.decode(xhr.responseText);
1322
        if (result.success) {
1323
        MinovaMessage('', 'PMS0001', '', 'S');
1324
        record.remove();
1325
        } else {
1326
        MinovaMessage('', '000005', result.message.text, 'E');
1327
        }
1328
        });*/
1329
        a.remove();
1330
    },
1331
    calculatePMS: function () {
1332
        var pnl = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1333
        var form_ = pnl.getForm();
1334
        var data = form_.getValues();
1335
        var treepnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1336
        var treestore = treepnl.store;
1337
        var pnlqual = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1338
        var storequal = undefined;
1339
        if (pnlqual != undefined) {
1340
            pnlqual.expandAll();
1341
            storequal = pnlqual.store;
1342
        }
1343
        var PA0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1344
        var PA0051 = Ext.StoreMgr.lookup("storePHRPA0051");
1345
        var PA0048_dATA = null;
1346
        var PA0051_dATA = null;
1347
        var TREE_dATA = null;
1348
        var Head = null;
1349
        var Child = null;
1350

    
1351
        if (data.AppraisalType != "G") {
1352
            var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1353
            var form_ = form.getForm();
1354
            var data = form_.getValues();
1355
            var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1356
            if (Sum.data.items.length > 0) {
1357
                var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1358
                Ext.Array.each(Ext.decode(DataSum), function (rec) {
1359
                    if (rec.Type == "KPI") {
1360
                        data["AdjustedKPI"] = rec.AdjustedScore;
1361
                        data["CalculatedKPI"] = rec.CalculatedScore;
1362
                        data["KPIFinalScore"] = rec.FinalScore;
1363
                        data["KPITotalScore"] = rec.TotalScore;
1364
                    } else {
1365
                        data["AdjustedCompetency"] = rec.AdjustedScore;
1366
                        data["CalculatedCompetency"] = rec.CalculatedScore;
1367
                        data["QualFinalScore"] = rec.FinalScore;
1368
                        data["QualTotalScore"] = rec.TotalScore;
1369
                    }
1370
                })
1371
            }
1372
            var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1373
            var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1374
            if (dataTotalSum.length > 0) {
1375
                data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1376
                data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1377
                data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1378
                data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1379
            }
1380
        }
1381

    
1382
        if (PA0048 != undefined)
1383
            PA0048_dATA = Ext.encode(Ext.pluck(PA0048.data.items, 'data'));
1384
        if (storequal != undefined) {
1385
            var _data = Ext.pluck(storequal.data.items, 'data');
1386
            Ext.Array.each(_data, function (rec) {
1387
                rec.children = null
1388
            })
1389
            PA0051_dATA = Ext.encode(_data);
1390
        }
1391
        if (treepnl != undefined)
1392
            TREE_dATA = Ext.encode(Ext.pluck(treestore.data.items, 'data'));
1393

    
1394
        var dataresult = null;
1395
        var data47 = null;
1396

    
1397
        var params = {
1398
            serviceName: 'Performance.asmx',
1399
            methodName: 'CalculatePerformance',
1400
            parameter:
1401
                'header=' + Ext.encode(data)
1402
                + '&PA0048=' + PA0048_dATA
1403
                + '&PA0049=' + TREE_dATA
1404
                + '&PA0051=' + PA0051_dATA
1405
                + '&Token=' + MinovaUtil.SESSIONS.Token
1406
        };
1407
        MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1408
            var result = Ext.decode(xhr.responseText);
1409
            dataresult = result.data;
1410
            Head = $.grep(Ext.decode(dataresult), function (r) {
1411
                return r.Tablename == '0047'
1412
            });
1413
            data47 = Head;
1414
            var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1415
            var form_ = form.getForm();
1416
            form_.setValues(Head[0]);
1417
            var dataPA0048 = $.grep(Ext.decode(dataresult), function (r) {
1418
                return r.Tablename == '0048'
1419
            });
1420
            var overView = Ext.StoreMgr.lookup('storePHRPA0048');
1421
            if (overView != undefined) {
1422
                overView.removeAll();
1423
                overView.loadData(dataPA0048);
1424
            }
1425

    
1426
            var dataPA0049 = $.grep(Ext.decode(dataresult), function (r) {
1427
                return r.Tablename == '0049'
1428
            });
1429
            var dataKPI = $.grep((dataPA0049), function (r) {
1430
                return r.SequenceSubKPI == '0'
1431
            });
1432
            var pnl = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1433
            if (pnl != undefined) {
1434
                //pnl.store.removeAll()
1435
                pnl.store.load()
1436
                /*pnl.store.setRootNode({
1437
                expanded : true,
1438
                nodetype : 'async',
1439
                children : dataKPI
1440
                });*/
1441
                var taskkpi = pnl.getRootNode();
1442
                taskkpi.appendChild(dataKPI);
1443
            }
1444

    
1445
            var dataPA0051 = $.grep(Ext.decode(dataresult), function (r) {
1446
                return r.Tablename == '0051'
1447
            });
1448
            var pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1449
            Head = $.grep(dataPA0051, function (r) {
1450
                return r.SequenceSub == 0
1451
            });
1452
            Child = $.grep(dataPA0051, function (r) {
1453
                return r.SequenceSub != 0
1454
            });
1455
            Ext.Array.each(Child, function (rec) {
1456
                rec['leaf'] = true;
1457
            });
1458
            if (pnl2 != undefined) {
1459
                pnl2.store.load();
1460
                var task = pnl2.getRootNode();
1461
                /*task.appendChild(Head);
1462
                pnl2 = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1463
                storequal = pnl2.store;
1464
                Ext.Array.each(storequal.data.items, function (rec) {
1465
                var t = rec.data;
1466
                var QChild = $.grep(Child, function (r) {
1467
                return r.QualificationID == t.QualificationID
1468
                });
1469
                var index = t.index;
1470
                rec.appendChild(QChild);
1471
                })*/
1472
                Ext.Array.each(Head, function (rec) {
1473
                    var QChild = $.grep(Child, function (r) {
1474
                        return r.QualificationID == rec.QualificationID
1475
                    });
1476
                    rec['children'] = QChild;
1477
                    rec['expanded'] = true;
1478
                    task.appendChild(rec);
1479
                })
1480
                pnl2.getView().refresh();
1481
            }
1482
            if (result.success) {
1483
                MinovaMessage('', 'PMS0002', '', 'S');
1484
            } else {
1485
                MinovaMessage('', '000005', '', 'E');
1486
            }
1487

    
1488
            data = {
1489
                AdjustedIndex: '',
1490
                AdjustedScore: data47[0].AdjustedKPI,
1491
                CalculatedScore: data47[0].CalculatedKPI,
1492
                FinalScore: data47[0].KPIFinalScore,
1493
                IndexScore: '',
1494
                TotalScore: data47[0].KPITotalScore,
1495
                Type: 'KPI',
1496
                Weight: '80'
1497
            };
1498

    
1499
            data2 = [];
1500
            data2[0] = data;
1501

    
1502
            data = {
1503
                AdjustedIndex: '',
1504
                AdjustedScore: data47[0].AdjustedCompetency,
1505
                CalculatedScore: data47[0].CalculatedCompetency,
1506
                FinalScore: data47[0].QualFinalScore,
1507
                IndexScore: '',
1508
                TotalScore: data47[0].QualTotalScore,
1509
                Type: 'Qualification',
1510
                Weight: '20'
1511
            };
1512

    
1513
            data2[1] = data;
1514

    
1515
            var overView = Ext.StoreMgr.lookup('storePDSPMSUMMARY');
1516
            if (overView != undefined) {
1517
                overView.removeAll();
1518
                overView.loadData(data2);
1519
            }
1520

    
1521
            dataTotal = {
1522
                AdjustedIndex: data47[0].AdjustedIndex,
1523
                AdjustedScore: data47[0].AdjustedScore,
1524
                CalculatedScore: data47[0].CalculatedScore,
1525
                IndexScore: data47[0].CalculatedIndex
1526
            };
1527

    
1528
            dataTotalList = [];
1529
            dataTotalList[0] = dataTotal;
1530

    
1531
            var overView = Ext.StoreMgr.lookup('storePDSPMSUMTOTAL');
1532
            if (overView != undefined) {
1533
                overView.removeAll();
1534
                overView.loadData(dataTotalList);
1535
            }
1536
        });
1537
    },
1538
    addNewQualification: function () {
1539
        var me = this;
1540
        var count_lookup = Ext.ComponentQuery.query('[name=AddNewQualification]').length;
1541
        if (count_lookup == 1) {
1542
            Ext.ComponentQuery.query('[name=AddNewQualification]')[0].show();
1543
        } else {
1544
            Ext.create('Ext.window.Window', {
1545
                title: 'Add Qualification',
1546
                name: 'AddNewQualification',
1547
                layout: 'fit',
1548
                items: [{
1549
                    xtype: 'form',
1550
                    name: 'formAddQualification',
1551
                    items: [{
1552
                        xtype: 'minovaForm',
1553
                        bodyBorder: false,
1554
                        cls: 'borderLookup',
1555
                        border: false,
1556
                        isLookup: false,
1557
                        name: "mainformAddQualification",
1558
                        tableName: 'PDSPMLOOKUPQUAL'
1559
                    }
1560
                    ]
1561
                }
1562
                ],
1563
                buttons: [{
1564
                    text: 'Add Qualification',
1565
                    name: 'BtnAddKPI',
1566
                    iconCls: 'fa-save',
1567
                    style: 'font-family: FontAwesome',
1568
                    margin: '3 3 10 3',
1569
                    handler: function () {
1570
                        me.addNewQualificationtoGrid();
1571
                    }
1572
                }, {
1573
                    text: 'Cancel',
1574
                    name: 'BtnCancelQualification',
1575
                    iconCls: 'fa-reply',
1576
                    style: 'font-family: FontAwesome',
1577
                    margin: '3 3 10 3',
1578
                    handler: function () {
1579
                        Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1580
                    }
1581
                }
1582
                ]
1583
            }).show();
1584
        }
1585
    },
1586
    addNewQualificationtoGrid: function () {
1587
        var seq = Ext.ComponentQuery.query('[name=Sequence]')[0].getValue();
1588
        var pnl = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1589
        var str = pnl.store;
1590

    
1591
        if (str.findRecord('QualificationID', Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()) != null) {
1592
            return;
1593
        }
1594

    
1595
        var leafCount = 0;
1596
        pnl.getRootNode().cascadeBy(function (node) {
1597
            if (!node.isLeaf())
1598
                leafCount++;
1599
        });
1600
        var data = '';
1601
        var Sequence = 0;
1602
        if (leafCount == 0) {
1603
            Sequence = 1;
1604
        } else {
1605
            Sequence = 1 + leafCount;
1606
        }
1607

    
1608
        var form_ = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1609
        var formdata_ = form_.getForm();
1610

    
1611
        var data = {
1612
            "EmployeeID": formdata_.findField('EmployeeID').getValue(),
1613
            "HeaderSequence": formdata_.findField('Sequence').getValue(),
1614
            "Sequence": Sequence,
1615
            "AppraisalType": formdata_.findField('AppraisalType').getValue()
1616
        };
1617
        var data2 = null;
1618
        var params = {
1619
            serviceName: 'Performance.asmx',
1620
            methodName: 'SetQualification',
1621
            parameter: 'TableName=' + 'PHRPA0051'
1622
                + '&Qualification=' + Ext.ComponentQuery.query('[name=Qualification]')[0].getValue()
1623
                + '&data=' + Ext.encode(data)
1624
        };
1625
        MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
1626
            var result = Ext.decode(xhr.responseText);
1627
            data2 = result.data;
1628
            if (result.success) { }
1629
            else {
1630
                MinovaMessage('', '000005', result.message.text, 'E');
1631
            }
1632
        });
1633
        var children = eval("children:" + data2);
1634
        data = {
1635
            EmployeeID: Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue(),
1636
            AppraisalType: Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue(),
1637
            QualificationID: Ext.ComponentQuery.query('[name=Qualification]')[0].getValue(),
1638
            Sequence: Sequence,
1639
            Description: Ext.ComponentQuery.query('[name=Qualification]')[0].value.split('-')[1].substr(1),
1640
            HeaderSequence: seq,
1641
            SequenceSub: "0",
1642
            Weight: 0,
1643
            leaf: false,
1644
            Target: 1,
1645
            children,
1646
            expanded: true
1647
        };
1648

    
1649
        var task = pnl.getRootNode();
1650
        task.appendChild(data);
1651
        Ext.ComponentQuery.query('[name=AddNewQualification]')[0].destroy();
1652
    },
1653
    loadQualification: function () {
1654
        var pnl = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1655
        var _result = undefined;
1656
        var Head = undefined;
1657
        Ext.Ajax.request({
1658
            async: false,
1659
            //method : 'POST',
1660
            url: '/UserControl/GetStore',
1661
            params: {
1662
                tableName: 'PHRPA0051',
1663
                param: 'EmployeeID[=]' + Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue()
1664
                    + ',AppraisalType[=]' + Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue()
1665
                    + ',HeaderSequence[=]' + Ext.ComponentQuery.query('[name=Sequence]')[0].getValue()
1666
            },
1667
            success: function (response) {
1668
                _result = Ext.decode(response.responseText);
1669
                if (_result.success) {
1670
                    var data = _result.data;
1671
                    Head = $.grep(data, function (r) {
1672
                        return r.SequenceSub == 0
1673
                    });
1674
                    var Child = $.grep(data, function (r) {
1675
                        return r.SequenceSub != 0
1676
                    });
1677
                    Ext.Array.each(Child, function (rec) {
1678
                        rec['leaf'] = true;
1679
                    })
1680
                    pnl.store.load();
1681
                    var task = pnl.getRootNode();
1682
                    Ext.Array.each(Head, function (rec) {
1683
                        var QChild = $.grep(Child, function (r) {
1684
                            return r.QualificationID == rec.QualificationID
1685
                        });
1686
                        rec['children'] = QChild;
1687
                        rec['expanded'] = true;
1688
                        task.appendChild(rec);
1689
                    })
1690
                }
1691
            }
1692
        });
1693
    },
1694
    deleteQualification: function () {
1695
        var main_ = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1696
        var record = main_.getView().selection;
1697

    
1698
        if (record == null) {
1699
            MinovaMessage('', 'PMSE003', '', 'E');
1700
            return;
1701
        }
1702

    
1703
        var _d = record.data;
1704
        if (_d.SequenceSub != 0) {
1705
            MinovaMessage('', 'PMSE003', '', 'E');
1706
            return;
1707
        }
1708
        record.remove();
1709
    },
1710
    deleteKPI: function () {
1711
        var main_ = Ext.ComponentQuery.query('[name=gridPHRPA0049]')[0];
1712
        var record = main_.getView().selection;
1713

    
1714
        if (record == null) {
1715
            MinovaMessage('', 'PMSE003', '', 'E');
1716
            return;
1717
        }
1718

    
1719
        var _d = record.data;
1720
        if (_d.SequenceSubKPI != 0) {
1721
            MinovaMessage('', 'PMSE003', '', 'E');
1722
            return;
1723
        }
1724
        record.remove();
1725
    },
1726
    setDefaultAppbyOM: function () {
1727
        var StartDate = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1728
        var EndDate = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1729
        var AppraisalType = Ext.ComponentQuery.query('[name=AppraisalType]')[0].getValue();
1730
        var EmployeeID = this.view.empId;
1731
        var Result = null;
1732
        var params = {
1733
            serviceName: 'Performance.asmx',
1734
            methodName: 'GetDefaultAppraiser',
1735
            parameter:
1736
                'EmployeeID=' + EmployeeID
1737
                + '&StartDate=' + StartDate
1738
                + '&EndDate=' + EndDate
1739
                + '&AppraisalType=' + AppraisalType
1740
        };
1741
        MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1742
            Result = Ext.decode(xhr.responseText);
1743
            if (Result.success) {
1744
                var pnl0048 = Ext.StoreMgr.lookup("storePHRPA0048");
1745
                pnl0048.add(Ext.decode(Result.data));
1746
            } else { }
1747
        })
1748
    },
1749

    
1750
    //saveToMDProfile: function () {
1751
    //    var me = this;
1752
    //    var pnl = Ext.ComponentQuery.query('[name=PHRPA0051]')[0];
1753
    //    var storequal = pnl.store;
1754
    //    var PA0051_dATA = null;
1755
    //    var dataMD8002 = null;
1756
    //    if (storequal != undefined) {
1757
    //        pnl.expandAll();
1758
    //        var _data = Ext.pluck(storequal.data.items, 'data');
1759
    //        Ext.Array.each(_data, function (rec) {
1760
    //            rec.children = null
1761
    //        })
1762
    //        PA0051_dATA = Ext.encode(_data);
1763
    //        dataMD8002 = $.grep(Ext.decode(PA0051_dATA), function (r) {
1764
    //            r['StartDate'] = Ext.ComponentQuery.query('[name=StartDate]')[0].getValue();
1765
    //            r['EndDate'] = Ext.ComponentQuery.query('[name=EndDate]')[0].getValue();
1766
    //            r['QualificationLevel'] = r.AppraiserScore
1767
    //            return r.SequenceSub == 0
1768
    //        });
1769
    //    }
1770
    //    var Result = null;
1771
    //    var params = {
1772
    //        serviceName: 'Performance.asmx',
1773
    //        methodName: 'SaveToMD',
1774
    //        parameter:
1775
    //            'TableName=' + 'PHRPA0045'
1776
    //            + '&dataDetail=' + Ext.encode(dataMD8002)
1777
    //            + '&Token=' + MinovaUtil.SESSIONS.Token
1778
    //    };
1779
    //    MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1780
    //        Result = Ext.decode(xhr.responseText);
1781
    //        if (Result.success) {
1782
    //            MinovaMessage('', 'PY0000', '', 'S');
1783
    //        } else {
1784
    //            MinovaMessage('', '000005', Result.message.text, 'E');
1785
    //        }
1786
    //    })
1787
    //},
1788

    
1789
    //SaveToMDHistory: function () {
1790
    //    var me = this;
1791
    //    var form = Ext.ComponentQuery.query('[name=mainformPerformance]')[0];
1792
    //    var form_ = form.getForm();
1793
    //    var data = form_.getValues();
1794
    //    var Sum = Ext.StoreMgr.lookup("storePDSPMSUMMARY");
1795
    //    var DataSum = Ext.encode(Ext.pluck(Sum.data.items, 'data'));
1796
    //    Ext.Array.each(Ext.decode(DataSum), function (rec) {
1797
    //        if (rec.Type == "KPI") {
1798
    //            data["AdjustedKPI"] = rec.AdjustedScore;
1799
    //            data["CalculatedKPI"] = rec.CalculatedScore;
1800
    //            data["KPIFinalScore"] = rec.FinalScore;
1801
    //            data["KPITotalScore"] = rec.TotalScore;
1802
    //            data["KPITotalWeight"] = rec.Weight;
1803
    //        } else {
1804
    //            data["AdjustedCompetency"] = rec.AdjustedScore;
1805
    //            data["CalculatedCompetency"] = rec.CalculatedScore;
1806
    //            data["QualFinalScore"] = rec.FinalScore;
1807
    //            data["QualTotalScore"] = rec.TotalScore;
1808
    //            data["QualTotalWeight"] = rec.Weight;
1809
    //        }
1810
    //    })
1811
    //    var TotalSum = Ext.StoreMgr.lookup("storePDSPMSUMTOTAL");
1812
    //    var dataTotalSum = Ext.pluck(TotalSum.data.items, 'data');
1813
    //    data["AdjustedIndex"] = dataTotalSum[0].AdjustedIndex;
1814
    //    data["AdjustedScore"] = dataTotalSum[0].AdjustedScore;
1815
    //    data["CalculatedScore"] = dataTotalSum[0].CalculatedScore;
1816
    //    data["CalculatedIndex"] = dataTotalSum[0].IndexScore;
1817

    
1818
    //    var Result = null;
1819
    //    var params = {
1820
    //        serviceName: 'Performance.asmx',
1821
    //        methodName: 'SaveToMD',
1822
    //        parameter:
1823
    //            'TableName=' + 'PHRPA0029'
1824
    //            + '&dataDetail=' + '[' + Ext.encode(data) + ']'
1825
    //            + '&Token=' + MinovaUtil.SESSIONS.Token
1826
    //    };
1827
    //    MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
1828
    //        Result = Ext.decode(xhr.responseText);
1829
    //        if (Result.success) {
1830
    //            MinovaMessage('', 'PY0000', '', 'S');
1831
    //        } else {
1832
    //            MinovaMessage('', '000005', Result.message.text, 'E');
1833
    //        }
1834
    //    })
1835
    //}
1836
});
(2-2/3)