Project

General

Profile

Support #1857 » wizard.js

Tri Rizqiaty, 12/09/2022 03:24 PM

 
1
Ext.define('MinovaES.controller.wizard.wizard', {
2
    extend: 'Ext.app.ViewController',
3
    alias: 'controller.wizard',
4
    //typeWizard: undefined,
5
    init: function () {
6
        var typeWizard = null;
7
        var selectionValues = null;
8
        var wzFunc = null;
9
        this.control({
10

    
11
            //'wizard [name=ApplicantID]': {
12
            //    change: this.ApplicantIDChange
13
            //},
14
            'wizard [name=selectionForm]': {
15
                //afterrender: this.afterrenderFunc
16
                afterrender: this.cekMsg
17
            },
18
            'wizard [name=Action]': {
19
                select: this.actionSelect
20
            },
21
            'wizard [name=search]': {
22
                click: this.btnSearch
23
            },
24
            'wizard [name=execute]': {
25
                click: this.execute
26
            },
27
            'wizard [name=processflow]': {
28
                afterrender: this.processflowGrid
29
            },
30

    
31
            'runwizards [name=saveWizard]': {
32
                click: this.saveWizard
33
            },
34
            'runwizards [name=prevWizard]': {
35
                click: this.prevWizard
36
            },
37

    
38
            'runwizards [name=selectionFormDisplay]': {
39
                afterrender: this.selectionFormDisplay
40
            },
41

    
42
            'runwizards [name=skipWizard]': {
43
                click: this.skipMd
44
            },
45

    
46
            'runwizards [name=skipAllWizard]': {
47
                click: this.skipAll
48
            },
49

    
50
            ' [name=mainWizard]': {
51
                afterrender: this.afterrenderMainWizard
52
            },
53
            ' [name=ApplicantID]': {
54
                change: this.ChangeApp
55
            },
56

    
57
        });
58
    },
59
    afterrenderMainWizard: function () {
60
        setTimeout(function () {
61
            if (getParam('wizard').toLowerCase() != 'a001') {
62

    
63
                Ext.ComponentQuery.query('[name=Action]')[0].setRawValue(localStorage.getItem('Action'))
64
                var CompanyID = Ext.ComponentQuery.query('displayfield[name=CompanyID]')[0];
65
                if (CompanyID) {
66
                    var s = CompanyID.store;
67
                    var dt = '';//s.findRecord(CompanyID.valueField, CompanyID.getValue());
68
                    var data_ = undefined;
69
                    Ext.Ajax.request({
70
                        async: false,
71
                        method: 'POST',
72
                        url: '/UserControl/GetStore',
73
                        params: {
74
                            tableName: 'PCMEPCOMPID',
75
                            param: 'StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',CompanyID[=]' + CompanyID.getValue()
76
                        },
77
                        success: function (response) {
78
                            var results = Ext.decode(response.responseText);
79
                            data_ = results.data;
80
                            if (data_.length != 0) {
81
                                CompanyID.setValue(data_[0].CompanyDescription);
82
                            }
83
                        }
84
                    });
85

    
86
                }
87
                var PayrollGroup = Ext.ComponentQuery.query('displayfield[name=PayrollGroup]')[0];
88
                if (PayrollGroup) {
89
                    Ext.Ajax.request({
90
                        async: false,
91
                        method: 'POST',
92
                        url: '/UserControl/GetStore',
93
                        params: {
94
                            tableName: 'PHRPYPGRUP',
95
                            param: 'StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',PayrollGroup[=]' + PayrollGroup.getValue()
96
                        },
97
                        success: function (response) {
98
                            var results = Ext.decode(response.responseText);
99
                            data_ = results.data;
100
                            if (data_.length != 0) {
101
                                PayrollGroup.setValue(data_[0].PayrollGroupDescription);
102
                            }
103
                        }
104
                    });
105
                }
106
            } else {
107
                Ext.ComponentQuery.query('displayfield[name=EmployeeID]')[0].labelEl.update('Employee ID');
108
                Ext.ComponentQuery.query('displayfield[name=CompanyID]')[0].setHidden(true);
109
                Ext.ComponentQuery.query('displayfield[name=PayrollGroup]')[0].setHidden(true);
110
            }
111
        }, 200);
112
        Ext.ComponentQuery.query('[name=Action]')[0].setValue('');
113
        var app = getParam('app');
114
        if (app === "null") {
115
            app = '';
116
        }
117
        if (app != '') {
118
            Ext.ComponentQuery.query('[name=pnlProgress]')[0].setTitle('Applicant Movement');
119
        }
120
        if (getParam('wizard').toLowerCase().substr(0, 1) == 'a') {
121
            if (Ext.ComponentQuery.query('[title=Employee Movement]')[0]) {
122
                Ext.ComponentQuery.query('[title=Employee Movement]')[0].setTitle('Applicant Movement');
123
            }
124

    
125
        }
126
    },
127
    ApplicantIDChange: function () {
128
        var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
129
        var Act = ActF.getValue();
130
        var Return = false;
131
        if (Act != null) {
132
            var btn = Ext.ComponentQuery.query('[name=execute]')[0];
133
            btn.setDisabled(false);
134
            var app = Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue();
135
            if (app != "") {
136
                Ext.Ajax.request({
137
                    async: false,
138
                    method: 'POST',
139
                    url: '/UserControl/GetStore',
140
                    params: {
141
                        tableName: 'phrrc0002',
142
                        param: 'EmployeeID[equal]' + app + ',StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',ApplicantAction[=]8'
143
                    },
144
                    success: function (response) {
145
                        var results = Ext.decode(response.responseText);
146
                        data_ = results.data;
147
                        if (Act == "A900") { // transfer to Employee
148
                            if (data_.length == 0) {
149
                                //app.setValue('');
150
                                MinovaMessage('', 'WZAPPNOFOUND', '', "E");
151
                                btn.setDisabled(true);
152
                            } else {
153
                                if (data_[0].ApplicantStatus != '05' && Act == "A900") {
154
                                    MinovaMessage('', 'RCVALTEMP', '', "E");
155
                                    btn.setDisabled(true);
156
                                }
157
                            }
158
                        } else {
159
                            Return = true;
160
                        }
161

    
162
                    }
163
                });
164
            }
165
        }
166
        return Return
167
    },
168
    execute: function () {
169
        var me = this;
170

    
171
        var Return = undefined;
172
        var s = Ext.ComponentQuery.query('[name=Action]')[0].getStore();
173
        var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
174
        var Act = ActF.getValue();
175
        var wizFunc = '';
176
        if (Act == '') { 
177
            wizFunc = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.WizardFunction;
178
        } else {
179
            wizFunc = s.findRecord('Wizard', Act).data.WizardFunction;
180
        }
181

    
182
        if (wizFunc != 'APPI' && wizFunc != 'EMPI' && wizFunc != 'APPT'&& wizFunc != 'EMP') {
183
            if (Ext.ComponentQuery.query('[name=ApplicantID]')[0]) {
184
                Return = me.ApplicantIDChange();  
185
            } else {
186
                Return = me.empChange();
187
            }
188

    
189
        } else {
190
            Return = true;
191
        }
192

    
193
        if (Return) {
194
            me.btnexecute();
195
        }
196
    },
197
    empChange: function () {
198
        var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
199
        var Act = ActF.getValue();
200
        var Return = false;
201
        if (Act != null) {
202
            var emp = Ext.ComponentQuery.query('[name=EmployeeID]')[0].getValue();
203
            var btn = Ext.ComponentQuery.query('[name=execute]')[0];
204
            btn.setDisabled(false);
205
            if (emp != "") {
206
                Ext.Ajax.request({
207
                    async: false,
208
                    method: 'POST',
209
                    url: '/UserControl/GetStore',
210
                    params: {
211
                        tableName: 'phrpa0002',
212
                        param: 'EmployeeID[equal]' + emp + ',StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',EmployeeStatus[=]01'
213

    
214
                    },
215
                    success: function (response) {
216
                        var results = Ext.decode(response.responseText);
217
                        data_ = results.data;
218
                        if (data_.length > 0) {
219
                            Ext.ComponentQuery.query('[name=CompanyID]')[0].setValue(data_[0].CompanyID);
220
                            Ext.ComponentQuery.query('[name=PayrollGroup]')[0].setValue(data_[0].PayrollGroup);
221
                            Return = true;
222
                        } else {
223
                            if (Act != "E001") { // not hiring
224
                                //btn.setDisabled(true);
225
                                MinovaMessage('', 'WZEMPNOFOUND', '', "E");
226
                            }
227
                        }
228

    
229
                    }
230
                });
231
            }
232
        }
233
        return Return;
234
    },
235
    afterrenderFunc: function () {
236
        var menuDt = undefined;
237
        Ext.Ajax.request({
238
            async: false,
239
            method: 'POST',
240
            url: '/UserControl/GetStore',
241
            params: {
242
                tableName: 'smenu',
243
                param: 'MenuId[equal]' + MinovaUtil.GetMenuID()
244

    
245
            },
246
            success: function (response) {
247
                var results = Ext.decode(response.responseText);
248
                data_ = results.data[0];
249
                if (data_ != undefined) {
250
                    menuDt = data_;
251
                }
252
            }
253
        });
254
        formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
255

    
256
        if (menuDt) {
257
            typeWizard = menuDt.Variant;
258

    
259
            if (typeWizard == '100') { // for empolyee md
260
                formSelection.findField("ApplicantID").setVisible(false);
261

    
262
            } else {
263
                formSelection.findField("PayrollGroup").setVisible(false);
264
                formSelection.findField("EmployeeID").setVisible(false);
265

    
266
            }
267
        } else {
268
            formSelection.findField("ApplicantID").setVisible(false);
269
        }
270

    
271
    },
272
    actionSelect: function (c) {
273
        formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
274
        formValues_ = formSelection.getValues();
275
        var storeFlow = Ext.ComponentQuery.query('[name=processflow]')[0];
276
        storeFlow.mask('Loading...');
277
        var result_ = undefined;
278
        if (MinovaUtil.GetMenuID() != 'RC01') {
279
            Ext.Ajax.request({
280
                async: false,
281
                method: 'POST',
282
                url: '/UserControl/GetStore',
283
                params: {
284
                    tableName: 'PDSPA0005',
285
                    param: 'Wizard[equal]' + formValues_.Action
286

    
287
                },
288
                success: function (response) {
289
                    var results = Ext.decode(response.responseText);
290
                    data_ = results.data;
291
                    if (data_ != undefined) {
292
                        //result_ = data_;
293
                        //sorting results
294
                        // result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
295
                        result_ = data_;
296
                    }
297
                }
298
            });
299

    
300
        } else {
301
            Ext.Ajax.request({
302
                async: false,
303
                method: 'POST',
304
                url: '/UserControl/GetStore',
305
                params: {
306
                    tableName: 'PDSPA0005',
307
                    param: 'WizardDescription[equal]' + Ext.ComponentQuery.query('[name=Action]')[0].rawValue
308

    
309
                },
310
                success: function (response) {
311
                    var results = Ext.decode(response.responseText);
312
                    data_ = results.data;
313
                    if (data_ != undefined) {
314
                        //result_ = data_;
315
                        //sorting results
316
                        // result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
317
                        result_ = data_;
318
                    }
319
                }
320
            });
321

    
322
        }
323

    
324
        storeFlow.getStore().loadData(result_);
325
        storeFlow.unmask();
326

    
327
        var cbStore = c.getStore();
328
        var cbValue = c.getValue();
329
        //find data
330
        var data_ = cbStore.findRecord(c.valueField, cbValue);
331
        //var WizardFunction = data_.data.WizardFunction;
332
        var WizardFunction = result_[0].WizardFunction;
333
        formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
334
        if (WizardFunction == 'APP') { // exsist aplicant
335
            formSelection.findField("ApplicantID").allowBlank = false;
336
            formSelection.findField("ApplicantID").setReadOnly(false);
337
            //formSelection.findField("Reason").setHidden(true);
338
            formSelection.findField("CompanyID").setHidden(true);
339
            formSelection.findField("PayrollGroup").setHidden(true);
340
            //formSelection.findField("Reason").allowBlank = true;
341
            formSelection.findField("CompanyID").allowBlank = true;
342
            formSelection.findField("PayrollGroup").allowBlank = true;
343
            formSelection.findField("PayrollGroup").setHidden(true);
344
        } else if (WizardFunction == 'APPI') { // new aplicant
345
            formSelection.findField("ApplicantID").allowBlank = true;
346
            formSelection.findField("ApplicantID").setReadOnly(true);
347
            //formSelection.findField("Reason").setHidden(true)
348
            formSelection.findField("CompanyID").setHidden(true);
349
            formSelection.findField("PayrollGroup").setHidden(true);
350
            //formSelection.findField("Reason").allowBlank = true;
351
            formSelection.findField("CompanyID").allowBlank = true;
352
            formSelection.findField("PayrollGroup").allowBlank = true;
353
            formSelection.findField("PayrollGroup").setHidden(true);
354
            //formSelection.findField("EmployeeID").setHidden(true)
355

    
356
        } else if (WizardFunction == 'APPT') { // app to emp
357
            formSelection.findField("ApplicantID").allowBlank = false;
358
            formSelection.findField("ApplicantID").setValue('');
359
            formSelection.findField("ApplicantID").setReadOnly(false);
360
            //formSelection.findField("MovementType").setHidden(true)
361
            formSelection.findField("CompanyID").setHidden(false);
362
            formSelection.findField("PayrollGroup").setHidden(false);
363

    
364
        } else if (WizardFunction == 'EMP') { // for exsist employee
365
            formSelection.findField("EmployeeID").allowBlank = false;
366
            formSelection.findField("EmployeeID").setReadOnly(false);
367
            formSelection.findField("CompanyID").setHidden(true);
368
            formSelection.findField("PayrollGroup").setHidden(true);
369
            formSelection.findField("CompanyID").allowBlank = true;
370
            formSelection.findField("PayrollGroup").allowBlank = true;
371
        } else if (WizardFunction == 'EMPI') { // new employee
372
            formSelection.findField("EmployeeID").setValue("");
373
            formSelection.findField("EmployeeID").allowBlank = true;
374
            formSelection.findField("EmployeeID").setReadOnly(true);
375

    
376
            formSelection.findField("CompanyID").setHidden(false);
377
            formSelection.findField("PayrollGroup").setHidden(false);
378
        }
379
        this.loadMoveReason();
380
        //this.cekMsg();
381
    },
382
    loadMoveReason: function () {
383
        var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
384
        var Act = ActF.getValue();
385
        localStorage.setItem("Action", ActF.getRawValue());
386

    
387
        if (Act != '') {
388
            var s = Ext.ComponentQuery.query('[name=Action]')[0].getStore();
389
            var actVal = s.findRecord('Wizard', Act).data.MovementType;
390
            var Res = Ext.ComponentQuery.query('[name=Reason]')[0];
391
            if (Res) {
392
                var ResStore = Res.getStore();
393
                ResStore.removeAll();
394

    
395
                Ext.Ajax.request({
396
                    async: false,
397
                    method: 'POST',
398
                    url: '/UserControl/GetStore',
399
                    params: {
400
                        tableName: 'PCMEPMOVR',
401
                        param: 'MovementType[equal]' + actVal
402

    
403
                    },
404
                    success: function (response) {
405
                        var results = Ext.decode(response.responseText);
406
                        data_ = results.data;
407
                        if (data_ != undefined) {
408
                            ResStore.loadData(data_)
409
                        }
410
                    }
411
                });
412
            }
413

    
414
        }
415

    
416
    },
417
    // btnexecute: function () {
418
        // // get wizard func
419
        // var payrollStatus = true;
420
        // var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
421
        // var Act = ActF.getValue();
422
        // var s = Ext.ComponentQuery.query('[name=Action]')[0].getStore();
423
        // //var wizFunc = s.findRecord('Wizard', Act).data.WizardFunction;
424
        // var wizFunc = '';
425
        // if (Act == '') {
426
            // wizFunc = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.WizardFunction;
427
        // } else {
428
            // wizFunc = s.findRecord('Wizard', Act).data.WizardFunction;
429
        // }
430
        // //if (wizFunc == 'EMPI' || wizFunc == 'APPT') {
431
        // //if (wizFunc != 'EMPI' && wizFunc != 'APPT') {
432
        // //if (wizFunc == 'EMPI' || wizFunc == 'APPI') {
433
        // payrollStatus = this.cekPayrollStatus();
434
        // if (payrollStatus == false && wizFunc != 'EMPI' && wizFunc != 'APPT' && wizFunc != 'APPI') {
435
            // //if (Ext.ComponentQuery.query('[name=PayrollGroup]')[0].getValue() == null) {
436
            // //    MinovaMessage('', '000009', '', "E");
437
            // //} else {
438
            // //    MinovaMessage('', 'PYVAL1', '', "E");
439
            // //}
440
            // MinovaMessage('', 'PYVAL1', '', "E");
441
        // }
442
        // // }
443

    
444

    
445
        // var wzFunc = undefined;
446
        // selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
447
        // if (Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm().isValid()) {
448
            // if (payrollStatus == true) {
449

    
450
                // Ext.Ajax.request({
451
                    // async: false,
452
                    // method: 'POST',
453
                    // url: '/UserControl/GetStore',
454
                    // params: {
455
                        // tableName: 'PHRPAWIZMAIN',
456
                        // param: 'Wizard[equal]' + selectionValues.Action
457

    
458
                    // },
459
                    // success: function (response) {
460
                        // var results = Ext.decode(response.responseText);
461
                        // data_ = results.data[0];
462
                        // if (data_ != undefined) {
463
                            // localStorage.setItem('wzFunc', JSON.stringify(results.data));
464
                            // wzFunc = data_.WizardFunction;
465
                        // }
466
                    // }
467
                // });
468

    
469
                // oldID = null;
470
                // app_ = null;
471

    
472
                // //localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
473
                // if (wzFunc == 'APPT') {
474
                    // Ext.Ajax.request({
475
                        // async: false,
476
                        // method: 'POST',
477
                        // url: '/UserControl/GetLastID?class_=E',
478

    
479
                        // success: function (response) {
480
                            // oldID = response.responseText;Last
481

    
482
                        // }
483
                    // });
484
                    // //Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID);
485
                    // //app_ = Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue();
486
                    // app_ = selectionValues.ApplicantID;
487

    
488
                // } else if (wzFunc == 'EMPI') {
489
                    // /*Ext.Ajax.request({
490
                        // async: false,
491
                        // method: 'POST',
492
                        // url: '/UserControl/GetLastID?class_=E',
493

    
494
                        // success: function (response) {
495
                            // oldID = response.responseText;
496
                        // }
497
                    // });*/
498
                    
499
					// var PayrollGroup = '';
500
					// var HiringYear = '';
501
					// var LastID = '';
502
					// Ext.Ajax.request({
503
						// async: false,
504
						// method: 'POST',
505
						// url: '/UserControl/GetStore',
506
						// params: {
507
							// tableName: 'PHRPYPGRUP',
508
							// param: 'PayrollGroup[equal]' + selectionValues.PayrollGroup
509
						// },
510
						// success: function (response) {
511
							// var results = Ext.decode(response.responseText);
512
							// data_ = results.data[0];
513
							// if (data_ != undefined) {
514
								// PayrollGroup = data_.Notes;
515
							// }
516
						// }
517
					// });
518
					// HiringYear = selectionValues.EffectiveDate.substring(2, 4);
519
					// Ext.Ajax.request({
520
						// async: false,
521
						// method: 'POST',
522
						// url: '/UserControl/GetStore',
523
						// params: {
524
							// tableName: 'PCMEPORMOBJ',
525
							// param: 'ObjectClass[equal]E'
526
						// },
527
						// success: function (response) {
528
							// var results = Ext.decode(response.responseText);
529
							// var dt = results.data;
530
							// data_ = dt[0];
531
							// LastID = data_.LastID.substring(4, 8);
532
						// }
533
					// });
534
					
535
                    // Ext.Ajax.request({
536
                        // async: false,
537
                        // method: 'POST',
538
                        // url: '/UserControl/GetStore',
539
                        // params: {
540
                            // tableName: 'CDSWIZEMPID',
541
                            // param: 'PayrollGroup[equal]' + PayrollGroup + ',HiringYear[equal]' + HiringYear + ',LastID[equal]' + LastID
542
                        // },
543
                        // success: function (response) {
544
                            // var results = Ext.decode(response.responseText);
545
                            // var dt = results.data;
546
                            // data_ = dt[0];
547
                            // oldID = data_.EmployeeID;
548
                        // }
549
                    // });
550

    
551
                    // Ext.ComponentQuery.query('[name=EmployeeID]')[0].setValue(oldID);
552

    
553
                // } else if (wzFunc == 'APPI') {
554
                    // Ext.Ajax.request({
555
                        // async: false,
556
                        // method: 'POST',
557
                        // url: '/UserControl/GetLastID?class_=A',
558

    
559
                        // success: function (response) {
560
                            // oldID = response.responseText;
561

    
562
                        // }
563
                    // });
564
                    // Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID)
565
                // } else {
566
                    // if (selectionValues.ApplicantID) {
567
                        // oldID = selectionValues.ApplicantID;
568
                    // } else if (selectionValues.EmployeeID) {
569
                        // oldID = selectionValues.EmployeeID
570
                    // }
571
                // }
572

    
573
                // selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
574
                // var wiz = selectionValues.Action;
575
                // if (wiz == '') {
576
                    // wiz = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.Wizard;
577
                // }
578
                // localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
579
                // var nextUrl = MinovaUtil.GetMenuID() + '&wizard=' + wiz + '&id=' + oldID + '&app=' + app_;
580
                // var mb = new minovaBlowfish();
581
                // e = mb.minovaEncryptUrl(nextUrl);
582
                // //if (wizFunc == 'APPI' || wizFunc == 'APPT')
583
                // {
584
                    // var EmployeeID = oldID;
585
                // }
586
                // window.open('runwizards?' + e, "_self");
587
            // }
588
        // }
589

    
590
    // },
591
	  btnexecute: function () {
592
        // get wizard func
593
        var payrollStatus = true;
594
        var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
595
        var Act = ActF.getValue();
596
        var s = Ext.ComponentQuery.query('[name=Action]')[0].getStore();
597
        //var wizFunc = s.findRecord('Wizard', Act).data.WizardFunction;
598
        var wizFunc = '';
599
        if (Act == '') {
600
            wizFunc = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.WizardFunction;
601
        } else {
602
            wizFunc = s.findRecord('Wizard', Act).data.WizardFunction;
603
        }
604
        //if (wizFunc == 'EMPI' || wizFunc == 'APPT') {
605
        //if (wizFunc != 'EMPI' && wizFunc != 'APPT') {
606
        //if (wizFunc == 'EMPI' || wizFunc == 'APPI') {
607
        payrollStatus = this.cekPayrollStatus();
608
        //if (payrollStatus == false && wizFunc != 'EMPI' && wizFunc != 'APPT' && wizFunc != 'APPI') {
609
            //if (Ext.ComponentQuery.query('[name=PayrollGroup]')[0].getValue() == null) {
610
            //    MinovaMessage('', '000009', '', "E");
611
            //} else {
612
            //    MinovaMessage('', 'PYVAL1', '', "E");
613
            //}
614
			if (payrollStatus == false ){
615
            MinovaMessage('', 'PYVAL1', '', "E");
616
        }
617
        // }
618

    
619

    
620
        var wzFunc = undefined;
621
        selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
622
        if (Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm().isValid()) {
623
            if (payrollStatus == true) {
624

    
625
                Ext.Ajax.request({
626
                    async: false,
627
                    method: 'POST',
628
                    url: '/UserControl/GetStore',
629
                    params: {
630
                        tableName: 'PHRPAWIZMAIN',
631
                        param: 'Wizard[equal]' + selectionValues.Action
632

    
633
                    },
634
                    success: function (response) {
635
                        var results = Ext.decode(response.responseText);
636
                        data_ = results.data[0];
637
                        if (data_ != undefined) {
638
                            localStorage.setItem('wzFunc', JSON.stringify(results.data));
639
                            wzFunc = data_.WizardFunction;
640
                        }
641
                    }
642
                });
643

    
644
                oldID = null;
645
                app_ = null
646

    
647
                //localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
648
                if (wzFunc == 'APPT') {
649
                    
650
					//// comment by Tri nwh 20220811 start
651
					// Ext.Ajax.request({
652
                        // async: false,
653
                        // method: 'POST',
654
                        // url: '/UserControl/GetLastID?class_=E',
655

    
656
                        // success: function (response) {
657
                            // oldID = response.responseText;
658
							// alert('chani');
659
                        // }
660
                    // });
661
					//// comment by Tri nwh 20220811 end
662
				
663
					//// add by Tri nwh 20220811 start
664
					var hiringdate =  selectionValues.EffectiveDate;
665
					var payrollgroup =  selectionValues.PayrollGroup;
666
					MinovaUtil.ExecuteParamQuery({
667
						ID: "GENEMPID",
668
						HiringDate : hiringdate.toString(),
669
						PayrollGroup : payrollgroup.toString(),
670
						UserName : MinovaUtil.GetUserName()
671
					}, function (s) {
672
						var result = Ext.decode(s.responseText);
673
						var dt = Ext.decode(Ext.decode(result.data));
674
						oldID = dt[0].EmpID.toString();
675
					}, function (f) {});
676
					//// add by Tri nwh 20220811 end
677
					
678
                    //Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID);
679
                    //app_ = Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue();
680
                    app_ = selectionValues.ApplicantID;
681

    
682
                } else if (wzFunc == 'EMPI') {
683
                    
684
					// Ext.Ajax.request({		//// comment by Tri nwh 20220811
685
                        // async: false,
686
                        // method: 'POST',
687
                        // url: '/UserControl/GetLastID?class_=E',
688

    
689
                        // success: function (response) {
690
                            // oldID = response.responseText;
691
                        // }
692
                    // });
693
					
694
					//// add by Tri nwh 20220811 start
695
					var hiringdate =  selectionValues.EffectiveDate;
696
					var payrollgroup =  selectionValues.PayrollGroup;
697
					MinovaUtil.ExecuteParamQuery({
698
						ID: "GENEMPID",
699
						HiringDate : hiringdate.toString(),
700
						PayrollGroup : payrollgroup.toString(),
701
						UserName : MinovaUtil.GetUserName()
702
					}, function (s) {
703
						var result = Ext.decode(s.responseText);
704
						var dt = Ext.decode(Ext.decode(result.data));
705
						oldID = dt[0].EmpID.toString();
706
					}, function (f) {});
707
					//// add by Tri nwh 20220811 end
708
					
709
                    Ext.ComponentQuery.query('[name=EmployeeID]')[0].setValue(oldID)
710
                } else if (wzFunc == 'APPI') {
711
                    Ext.Ajax.request({
712
                        async: false,
713
                        method: 'POST',
714
                        url: '/UserControl/GetLastID?class_=A',
715

    
716
                        success: function (response) {
717
                            oldID = response.responseText;
718

    
719
                        }
720
                    });
721
                    Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID)
722
                } else {
723
                    if (selectionValues.ApplicantID) {
724
                        oldID = selectionValues.ApplicantID;
725
                    } else if (selectionValues.EmployeeID) {
726
                        oldID = selectionValues.EmployeeID;
727
                    }
728
                }
729

    
730
                selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
731
                var wiz = selectionValues.Action;
732
                if (wiz == '') {
733
                    wiz = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.Wizard;
734
                }
735
                localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
736
                var nextUrl = MinovaUtil.GetMenuID() + '&wizard=' + wiz + '&id=' + oldID + '&app=' + app_;
737
                var mb = new minovaBlowfish();
738
                e = mb.minovaEncryptUrl(nextUrl);
739
                //if (wizFunc == 'APPI' || wizFunc == 'APPT')
740
                {
741
                    var EmployeeID = oldID;
742
                }
743
                window.open('runwizards?' + e, "_self");
744
            }
745
        }
746

    
747
    },
748
	
749
	
750

    
751
    cekMsg: function () {
752
        formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
753
        formValues_ = formSelection.getValues();
754
        if (Ext.ComponentQuery.query('[name=Reason]')[0]) {
755
            Ext.ComponentQuery.query('[name=Reason]')[0].setHidden(true);
756
            formSelection.findField("PayrollGroup").setHidden(true);
757

    
758
        }
759
        var flag = getParam('S');
760
        if (flag == 'S') {
761
            MinovaMessage('', '000006', '', 'S');
762
        }
763
    },
764
    changeProgress: function (idx, idNext, skip) {
765
        //$("#stepStatus" + idx).removeClass("active");
766
        //$("#stepStatus" + idNext).addClass("active");
767
        if (skip) {
768
            //$("#checkStatus" + idx).addClass("fa fa-check");
769
        } else {
770
            $("#checkStatus" + idx).addClass("fa fa-check");
771
        }
772

    
773
    },
774
    cekPayrollStatus: function () {
775

    
776
        formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
777
        if (formSelection.isValid()) {
778
            // cek payroll status by input payroll group
779
            formValues_ = formSelection.getValues();
780
            var result = undefined;
781
            if (formValues_.PayrollGroup != "") {
782
                Ext.Ajax.request({
783
                    async: false,
784
                    method: 'POST',
785
                    url: '/UserControl/GetStore',
786
                    params: {
787
                        tableName: 'PHRPYPGCTRL',
788
                        param: 'PayrollGroup[equal]' + formValues_.PayrollGroup
789

    
790
                    },
791
                    success: function (response) {
792
                        var results = Ext.decode(response.responseText);
793
                        data_ = results.data[0];
794
                        if (data_ != undefined) {
795
                            result = data_;
796
                        }
797
                    }
798
                });
799
            }
800
            var cek = true;
801
            if (result) {
802
                if (result.PayrollControlStatus == "V") {
803
                    // massage corection
804
                    cek = false;
805
                } else if (result.PayrollControlStatus == "S") {
806
                    // massage corection
807
                    cek = false;
808
                }
809

    
810
            }
811
            if (cek) {
812
                //var storeFlow = Ext.ComponentQuery.query('[name=processflow]')[0];
813
                //storeFlow.mask('Loading...');
814
                //var result_ = undefined;
815
                //Ext.Ajax.request({
816
                //    async: false,
817
                //    method: 'POST',
818
                //    url: '/UserControl/GetStore',
819
                //    params: {
820
                //        tableName: 'PDSPA0005',
821
                //        param: 'Wizard[equal]' + formValues_.Action
822

    
823
                //    },
824
                //    success: function (response) {
825
                //        var results = Ext.decode(response.responseText);
826
                //        data_ = results.data;
827
                //        if (data_ != undefined) {
828
                //            //result_ = data_;
829
                //            //sorting results
830
                //            result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
831
                //        }
832
                //    }
833
                //});
834

    
835
                //storeFlow.getStore().loadData(result_);
836
                //storeFlow.unmask();
837
            }
838
        }
839
        //else {
840
        //    //masih ada field mandtory yang kosong
841
        //}
842
        return cek;
843
    },
844
    processflowGrid: function (g) {
845
        setTimeout(function () {
846
            var g_ = Ext.ComponentQuery.query('[name=processflow]')[0];
847
            g_.getStore().removeAll();
848
        }, 200);
849

    
850
    },
851
    // fungsi ke form sebelumnya
852
    prevWizard: function () {
853
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
854
        var next_ = prog_.getNextMD() - 1;
855
        var last_ = prog_.getNextMD() - 2;
856
        if (last_ == 0) {
857
            last_ = 1;
858
        }
859
        var currPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
860
        var _last = Ext.ComponentQuery.query('[itemId=MD' + last_ + ']')[0];
861
        currPage.setHidden(true);
862
        _last.setHidden(false);
863

    
864
        // set ulang next and prev page
865
        prog_.setNextMD(next_);
866
        prog_.setPrevMD(last_);
867
        this.setButton(_last);
868

    
869
    },
870
    skipAll: function () {
871
        var me = this;
872
        // if (Formheader.isValid()) {
873
        Ext.Msg.show({
874
            title: "",
875
            msg: MinovaMessageData('WD002', ''),
876
            buttons: Ext.Msg.YESNO,
877
            icon: Ext.Msg.QUESTION,
878
            fn: function (choice) {
879
                console.log(choice);
880
                if (choice === 'yes') {
881
                    // me.saveMD();
882
                    var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
883
                    var page = 'wizards';
884
                    if (prog_.wizardFunction.substring(0, 1) == "A") {
885
                        page = 'rcwizards';
886
                    }
887
                    nextUrl = MinovaUtil.GetMenuID() + '&S=S';
888
                    var mb = new minovaBlowfish();
889
                    e = mb.minovaEncryptUrl(nextUrl);
890
                    window.open(page + '?' + e, "_self");
891

    
892
                }
893

    
894
            }
895
        });
896

    
897
        // }
898

    
899
    },
900
    skipMd: function () {
901
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
902
        var next_ = prog_.getNextMD(); // id form selanjutnya
903
        var me = this;
904
        if (prog_.totalPage < next_) { // md form sudah selesai
905
            // run save data to md
906
            //me.saveToLoacalStorage();
907
            //if (Formheader.isValid()) {
908
            Ext.Msg.show({
909
                title: "",
910
                msg: MinovaMessageData('WD001', ''),
911
                buttons: Ext.Msg.YESNO,
912
                icon: Ext.Msg.QUESTION,
913
                fn: function (choice) {
914
                    console.log(choice);
915
                    if (choice === 'yes') {
916
                        document.getElementById("progressbar").style.width = '100%';
917
                        me.changeProgress(prog_.totalPage, next_, true)
918
                        //me.saveMD();
919
                        var page = 'wizards';
920
                        if (prog_.wizardFunction.substring(0, 1) == "A") {
921
                            page = 'rcwizards';
922
                        }
923
                        nextUrl = MinovaUtil.GetMenuID() + '&S=S';
924
                        var mb = new minovaBlowfish();
925
                        e = mb.minovaEncryptUrl(nextUrl);
926
                        window.open(page + '?' + e, "_self");
927
                    }
928

    
929
                }
930
            });
931

    
932
            // }
933

    
934
        } else {
935
            var lastHide = next_ - 1;
936
            var self_ = Ext.ComponentQuery.query('[itemId=MD' + lastHide + ']')[0]; // formm yang sedang activ
937
            var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
938
            if (nextPage.WizardLayout == 'F') {
939

    
940
                //formName = 'formWizard' + nextPage.tableName;
941
                formName = 'MinovaGridFormEdit' + nextPage.tableName;
942

    
943
                if (Ext.ComponentQuery.query('[name=' + formName + ']')[0].mandatory == '1') {
944
                    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
945
                    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
946
                } else {
947
                    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
948
                    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
949
                }
950

    
951
            } else {
952
                if (Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].mandatory) {
953
                    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
954
                    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
955

    
956
                } else {
957
                    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
958
                    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
959
                }
960
            }
961

    
962
            nextPage.setHidden(false);
963
            self_.setHidden(true);
964
            // set ulang next and prev page
965
            this.changeProgress(next_, next_ + 1, true);
966
            prog_.setNextMD(next_ + 1);
967
            prog_.setPrevMD(next_);
968
            total_ = ((next_ - 1) / prog_.totalPage) * 100;
969
            document.getElementById("progressbar").style.width = total_ + '%';
970
        }
971

    
972
    },
973
    selectionFormDisplay: function (me) {
974
        var data_ = JSON.parse(localStorage.getItem('selectionValues'));
975
        if (data_) {
976
            if (data_ != null) {
977
                me.getForm().setValues(data_);
978
            }
979
            if (data_.ApplicantID != "") {
980
                me.getForm().findField('EmployeeID').setValue(data_.ApplicantID);
981
            }
982
            me.getForm().findField('EmployeeID').setValue(getParam('id'))
983
        }
984

    
985
        if (getParam('wizard').substr(0, 1) == 'A') {
986
            
987
			 if (getParam('app') != 'null') {
988
				me.getForm().findField('ApplicantID').setHidden(true)
989
				me.getForm().findField('EmployeeID').setFieldLabel('Employee ID');
990
			} else{
991
				setTimeout(function(){ me.getForm().findField('EmployeeID').setFieldLabel('Applicant ID'); }, 10);	
992
				me.getForm().findField('ApplicantID').setHidden(false);	
993
				me.getForm().findField('EmployeeID').setHidden(true)				
994
			}
995
        }
996
       else {
997
            me.getForm().findField('EmployeeID').setFieldLabel('Employee ID');
998
			me.getForm().findField('ApplicantID').setHidden(true);	
999
			me.getForm().findField('EmployeeID').setHidden(false)
1000
        }
1001

    
1002
    },
1003
    // funsi next dan save data
1004
    saveWizardold: function () {
1005
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1006
        var oldTableName = prog_.getTableName(); // nama table form yang sedang aktif
1007
        var oldTableData = prog_.getTableData(); // nama table untuk data set value form yang sedang aktif
1008
        var next_ = prog_.getNextMD(); // id form selanjutnya
1009
        var me = this;
1010
        if (prog_.totalPage < next_) { // md form sudah selesai
1011
            // run save data to md
1012
            //me.saveToLoacalStorage();
1013
            //if (Formheader.isValid()) {
1014
            Ext.Msg.show({
1015
                title: "",
1016
                msg: MinovaMessageData('WD001', ''),
1017
                buttons: Ext.Msg.YESNO,
1018
                icon: Ext.Msg.QUESTION,
1019
                fn: function (choice) {
1020
                    console.log(choice);
1021
                    if (choice === 'yes') {
1022
                        document.getElementById("progressbar").style.width = '100%';
1023
                        me.changeProgress(prog_.totalPage, next_, false)
1024
                        me.saveMD();
1025

    
1026
                    }
1027

    
1028
                }
1029
            });
1030

    
1031
            //}
1032

    
1033
        } else {
1034
            var lastHide = next_ - 1;
1035
            var cekValid = true;
1036
            var self_ = Ext.ComponentQuery.query('[itemId=MD' + lastHide + ']')[0]; // formm yang sedang activ
1037
            var tableName = self_.tableName;
1038
            var formName = undefined;
1039
            var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
1040

    
1041
            if (self_.WizardLayout == 'F') {
1042
                formName = 'MinovaGridFormEdit' + tableName;
1043
                frmSelf = Ext.ComponentQuery.query('[name=' + formName + ']')[0];
1044
                frmSelf.getForm().findField("EmployeeID").setValue(getParam('id'));
1045
                cekValid = frmSelf.getForm().isValid();
1046

    
1047
            } else {
1048

    
1049
                gridPnl = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + tableName + ']')[0].mandatory;
1050
                if (gridPnl == '1') {
1051
                    var storeGrid = Ext.StoreMgr.lookup(tableName + "WizardStore");
1052
                    var storeCount_ = storeGrid.getCount();
1053
                    if (storeCount_ > 0) {
1054
                        cekValid = true;
1055
                    } else {
1056
                        cekValid = false;
1057
                    }
1058
                }
1059

    
1060
            }
1061
            // disable button
1062
            if (cekValid) {
1063
                //me.saveToLoacalStorage();
1064
                if (nextPage.mandatory == "1") {
1065
                    if (nextPage.nextMD == 1) {
1066
                        Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
1067
                        //Ext.ComponentQuery.query('[name=saveWizard]')[0].setDisabled(true);
1068
                        //Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setText("Finish")
1069
                        Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
1070

    
1071
                    } else {
1072
                        Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
1073
                        Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
1074

    
1075
                    }
1076

    
1077
                } else {
1078
                    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
1079
                    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
1080
                }
1081
                nextPage.setHidden(false);
1082
                self_.skip_ = false;
1083

    
1084
                if (Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0]) {
1085
                    Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0].skip_ = false;
1086
                }
1087
                if (Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0]) {
1088
                    Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0].skip_ = false;
1089
                }
1090
                self_.setHidden(true);
1091
                // set ulang next and prev page
1092
                prog_.setNextMD(next_ + 1);
1093
                prog_.setPrevMD(next_);
1094

    
1095
                //change progress bar
1096
                total_ = ((next_ - 1) / prog_.totalPage) * 100;
1097
                document.getElementById("progressbar").style.width = total_ + '%';
1098
                var idx = next_ - 1;
1099
                me.changeProgress(idx, next_, false);
1100
                Ext.ComponentQuery.query('[name=prevWizard]')[0].setDisabled(false);
1101
                var wzFunc = undefined
1102
                //if (Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm().isValid()) {
1103
                Ext.Ajax.request({
1104
                    async: false,
1105
                    method: 'POST',
1106
                    url: '/UserControl/GetStore',
1107
                    params: {
1108
                        tableName: 'PHRPAWIZMAIN',
1109
                        param: 'Wizard[equal]' + getParam('wizard')
1110

    
1111
                    },
1112
                    success: function (response) {
1113
                        var results = Ext.decode(response.responseText);
1114
                        data_ = results.data[0];
1115
                        if (data_ != undefined) {
1116
                            wzFunc = data_.WizardFunction;
1117
                        }
1118
                    }
1119
                });
1120
                if (wzFunc == 'APPT') {
1121
                    if (nextPage.WizardLayout == "F") {
1122
                        var datatable = 'PHRRC' + nextPage.tableName.substring(5, 9);
1123
                        var nowDate = MinovaUtil.GetNowDate();
1124
                        var data_ = JSON.parse(localStorage.getItem(datatable));
1125
                        Ext.Ajax.request({
1126
                            async: false,
1127
                            method: 'POST',
1128
                            url: '/UserControl/GetStore',
1129
                            params: {
1130
                                tableName: datatable,
1131
                                param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
1132

    
1133
                            },
1134
                            success: function (response) {
1135
                                var results = Ext.decode(response.responseText);
1136
                                dataForm = results.data[0];
1137
                                var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0]
1138
                                var form_ = _form.getForm();
1139
                                form_.setValues(dataForm);
1140
                                me.setValueFromParameter(_form);
1141
                                var temData = JSON.parse(localStorage.getItem('selectionValues'));
1142
                                
1143
                                if (datatable == "phrpa0002" || datatable == "PHRPA0002") {
1144
                                    form_.findField('StartDate').setValue(temData.EffectiveDate);
1145
                                    form_.findField('CompanyID').setValue(temData.CompanyID);
1146
                                    form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
1147
                                    form_.findField('MovementReason').setValue(temData.Reason);
1148
                                }
1149
                                else {
1150
                                    form_.findField('StartDate').setValue(temData.EffectiveDate);
1151
                                }
1152
                            }
1153
                        });
1154
                    } else {
1155
                        tbl = 'PHRRC' + nextPage.tableName.substring(5, 9)
1156
                        var data_ = JSON.parse(localStorage.getItem(tbl));
1157
                        var dataForm = undefined;
1158
                        var nowDate = MinovaUtil.GetNowDate()
1159

    
1160
                        Ext.Ajax.request({
1161
                            async: false,
1162
                            method: 'POST',
1163
                            url: '/UserControl/GetStore',
1164
                            params: {
1165
                                tableName: tbl,
1166
                                param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
1167

    
1168
                            },
1169
                            success: function (response) {
1170
                                var results = Ext.decode(response.responseText);
1171
                                dataForm = results.data;
1172
                                var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].getStore();
1173
                                gridStore.loadData(Ext.decode(dataForm));
1174

    
1175
                            }
1176
                        });
1177
                    }
1178

    
1179
                } else if (wzFunc != 'APPI' && wzFunc != 'EMPI' && wzFunc != 'APPT') {
1180
                    var nowDate = MinovaUtil.GetNowDate();
1181
                    if (nextPage.WizardLayout == "F") {
1182
                        Ext.Ajax.request({
1183
                            async: false,
1184
                            method: 'POST',
1185
                            url: '/UserControl/GetStore',
1186
                            params: {
1187
                                tableName: nextPage.tableName,
1188
                                param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
1189

    
1190
                            },
1191
                            success: function (response) {
1192
                                var results = Ext.decode(response.responseText);
1193
                                dataForm = results.data[0];
1194
                                var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0];
1195
                                var form_ = _form.getForm();
1196
                                form_.setValues(dataForm);
1197
                                me.setValueFromParameter(_form);
1198
                                var temData = JSON.parse(localStorage.getItem('selectionValues'));
1199
                                form_.findField('StartDate').setValue(temData.StartDate)
1200
                            }
1201
                        });
1202
                    } else {
1203
                        Ext.Ajax.request({
1204
                            async: false,
1205
                            method: 'POST',
1206
                            url: '/UserControl/GetStore',
1207
                            params: {
1208
                                tableName: nextPage.tableName,
1209
                                param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
1210

    
1211
                            },
1212
                            success: function (response) {
1213
                                var results = Ext.decode(response.responseText);
1214
                                dataForm = results.data;
1215
                                var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].getStore();
1216
                                gridStore.loadData(Ext.decode(dataForm));
1217

    
1218
                            }
1219
                        });
1220
                    }
1221
                } else {
1222
                    //
1223
                    var frm_ = "MinovaGridFormEdit";
1224
                    if (nextPage.WizardLayout == "G") {
1225
                        frm_ = "formGridWizard";
1226
                    }
1227
                    var form_ = Ext.ComponentQuery.query('[name=' + frm_ + nextPage.tableName + ']')[0];
1228
                    var emp = form_.getForm().findField("EmployeeID");
1229
                    var temData = JSON.parse(localStorage.getItem('selectionValues'));
1230
                    form_.getForm().findField('StartDate').setValue(temData.StartDate)
1231
                    if (emp) {
1232
                        emp.setValue(getParam("id"));
1233

    
1234
                    } else {
1235
                        Ext.ComponentQuery.query('[name=' + frm_ + nextPage.tableName + ']')[0].getForm().findField("ApplicantID").setValue(getParam("id"))
1236
                    }
1237
                }
1238

    
1239
                //} else {
1240
                //    // message jika form tidak valid
1241
                //}
1242

    
1243
            }
1244

    
1245
        }
1246
    },
1247
    // fungsi save data to md
1248
    saveMD: function () {
1249

    
1250
        var pnlProgress = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1251
        var mainWizard = Ext.ComponentQuery.query('[name=mainWizard]')[0];
1252
        mainWizard.mask('Loading...');
1253
        var allTable = pnlProgress.allTable;
1254
        var allData = pnlProgress.allData;
1255
        var wizardFunction = pnlProgress.wizardFunction;
1256
        // md 15 boleh diinput jika statusMD1=true dan statusMD2=true
1257
        var statusMD1 = false;
1258
        var statusMD2 = false;
1259
        var sukses = true;
1260
        var i = 0;
1261
        var data_ = undefined;
1262
        var skip_ = undefined; // only grid or form with skip property is false will be save to md
1263
        Ext.each(allData, function (rec) {
1264
            //console.log(tbl)
1265
            //var data_ = JSON.parse(localStorage.getItem(tbl));
1266
            var tbl_ = rec.TableName
1267
            if (wizardFunction == "APPT") {
1268
                if (tbl_.substring(0, 5) == 'PHRRC') {
1269
                    tbl_ = 'PHRPA' + tbl_.substring(5, 9);
1270
                }
1271
            }
1272

    
1273
            i++;
1274
            if (rec.WizardLayout == 'F') { // jika layout form
1275
                var formname = "MinovaGridFormEdit" + tbl_;
1276
                var frm = Ext.ComponentQuery.query('[name=' + formname + ']')[0];
1277
                var validForm_ = Ext.ComponentQuery.query('[name=' + formname + ']')[0].getForm().isValid();
1278
                var formValues_ = frm.getValues();
1279
                // if (formValues_.EmployeeID == "") {
1280
                if (formValues_.EmployeeID == "") {
1281
                    formValues_["EmployeeID"] = getParam('id');
1282
                }
1283
                //}
1284

    
1285
                if (wizardFunction == "APPT") {
1286
                    formValues_["EmployeeID"] = getParam('id');
1287
                }
1288
                //var end_ = formValues_.EndDate;
1289
                //if (end_ == "") {
1290
                //    skip_ = true;
1291
                //}
1292
                if (validForm_) {
1293
                    skip_ = false;
1294
                } else {
1295
                    skip_ = true;
1296
                }
1297
                data_ = Ext.encode(formValues_);
1298

    
1299
            } else { // jika layout grid
1300
                var gridName = "MinovaGridFormGrid" + tbl_;
1301
                var grid_ = Ext.ComponentQuery.query('[name=' + gridName + ']')[0];
1302
                var gridStore = grid_.getStore();
1303

    
1304
                if (gridStore.count() > 0) {
1305
                    data_ = Ext.encode(Ext.pluck(gridStore.data.items, 'data'));
1306
                    skip_ = false;
1307
                } else {
1308
                    skip_ = true;
1309
                }
1310

    
1311
            }
1312
            // run save
1313

    
1314
            if (skip_ == false && sukses == true) {
1315
                Ext.Ajax.request({
1316
                    async: false,
1317
                    method: 'POST',
1318
                    url: '/Devt/SaveTable',
1319
                    params: {
1320
                        tableName: tbl_,
1321
                        data: data_,
1322
                        action: 0
1323
                    },
1324
                    waitMsg: 'Saving Data...',
1325
                    success: function (response) {
1326
                        var result = Ext.decode(response.responseText);
1327
                        if (result.success) {
1328
                            // MinovaMessage('Not Null', '000006', '', 'S');
1329
                            sukses = true;
1330
                        } else {
1331
                            MinovaMessage('', '000005', result.message.text, 'E');
1332
                            sukses = false;
1333
                        }
1334
                    },
1335
                    failure: function (response) {
1336
                        var result = Ext.decode(response.responseText);
1337
                        MinovaMessage('', '000005', result.message.text, 'E');
1338
                        sukses = false;
1339
                    }
1340
                });
1341
            }
1342

    
1343
        });
1344

    
1345
        //save md 0015
1346
        if (wizardFunction == 'APPT' || wizardFunction == 'EMPI') {
1347
            ApplicantID = '';
1348
            if (wizardFunction == 'APPT') {
1349
                ApplicantID = getParam('app')
1350
            }
1351
            var date_ = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0002]')[0].getValues().StartDate;
1352
            data = {
1353
                EmployeeID: getParam('id'),
1354
                PaymentUpTo: '',
1355
                RetroDate: date_,
1356
                HiringDate: date_,
1357
                ApplicantID: ApplicantID,
1358
                CorrectStatus: ''
1359
            };
1360
            dataDelete = {
1361
                EmployeeID: getParam('id'),
1362
                PaymentUpTo: '',
1363
                RetroDate: '',
1364
                //HiringDate: date_,
1365
                ApplicantID: ApplicantID,
1366
                CorrectStatus: ''
1367
            };
1368
            data_ = Ext.encode(data);
1369
            dataDelete_ = Ext.encode(dataDelete);
1370

    
1371
            Ext.Ajax.request({
1372
                async: false,
1373
                method: 'POST',
1374
                url: '/Devt/SaveTable',
1375
                params: {
1376
                    tableName: 'PHRPA0015',
1377
                    data: data_,
1378
                    action: 0
1379
                },
1380
                waitMsg: 'Saving Data...',
1381
                success: function (response) {
1382
                    var result = Ext.decode(response.responseText);
1383
                    if (result.success) {
1384
                        MinovaMessage('Not Null', '000006', '', 'S');
1385
                        sukses = true;
1386
                    } else {
1387
                        MinovaMessage('Not Null', '000005', result.message.text, 'E');
1388
                        sukses = false;
1389
                    }
1390
                },
1391
                failure: function (response) {
1392
                    var result = Ext.decode(response.responseText);
1393
                    sukses = false;
1394
                }
1395
            });
1396
        }
1397
        mainWizard.unmask();
1398
        if (sukses == true && allData.length == i) {
1399
            var page = 'wizards';
1400
            if (wizardFunction.substring(0, 1) == "A") {
1401
                page = 'rcwizards';
1402
            }
1403
            nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1404
            var mb = new minovaBlowfish();
1405
            e = mb.minovaEncryptUrl(nextUrl);
1406
            window.open(page + '?' + e, "_self");
1407
            //window.open(nextUrl, "_self");
1408
        }
1409

    
1410
    },
1411
    saveToLoacalStorage: function () {
1412
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1413
        var myID = prog_.getNextMD() - 1;
1414
        var self_ = Ext.ComponentQuery.query('[itemId=MD' + myID + ']')[0];
1415
        var tableName = self_.tableName;
1416
        var WizardLayout = self_.WizardLayout;
1417
        var valuesData = undefined;
1418
        var formName = undefined;
1419
        var mandatory = self_.mandatory
1420

    
1421
        if (WizardLayout == 'F') { // jika tipe layout form
1422
            formName = 'MinovaGridFormEdit' + tableName;
1423
            frm = Ext.ComponentQuery.query('form[name=' + formName + ']')[0].getForm();
1424
            if (frm.isValid()) { // cek semua field mandatory sudah diisi
1425
                valuesData = frm.getValues();
1426
            }
1427

    
1428
        } else { // jika tipe layout grid
1429
            formName = 'MinovaGridFormEdit' + tableName;
1430
            var storeGrid = Ext.StoreMgr.lookup(tableName + "WizardStore");
1431
            valuesData = Ext.encode(Ext.pluck(storeGrid.data.items, 'data'));
1432
        }
1433

    
1434
        //save to local storage
1435
        //localStorage.setItem(tableName, JSON.stringify(valuesData));
1436

    
1437
    },
1438
    setValueFromParameter: function (_form) {
1439
        // set value from wizard parameter
1440
        var wizardID = _form.Wizard;
1441
        var _tablename = _form.tableName;
1442
        var form_ = _form.getForm();
1443
        hasil = undefined;
1444
        Ext.Ajax.request({
1445
            async: false,
1446
            method: 'POST',
1447
            url: '/UserControl/GetStore',
1448
            params: {
1449
                tableName: 'PDSBS0010',
1450
                param: 'Wizard[=]' + wizardID + ',TableName[=]' + _tablename
1451
            },
1452
            success: function (response) {
1453
                var results = Ext.decode(response.responseText);
1454
                hasil = results.data;
1455
            }
1456
        });
1457

    
1458
        if (hasil.length > 0) {
1459
            var value_ = undefined;
1460
            Ext.each(hasil, function (rec) {
1461

    
1462
                if (rec.DefaultValue.substring(0, 2) == 'fn' && rec.FunctionCode != '') {
1463
                    value_ = eval(rec.FunctionCode);
1464
                } else {
1465
                    value_ = rec.DefaultValue;
1466
                }
1467
                if (form_.findField(rec.FieldName)) {
1468
                    form_.findField(rec.FieldName).setValue(value_);
1469
                }
1470
            });
1471
        }
1472
        // set value from wizard parameter
1473
    },
1474
    saveWizard: function () {
1475
		var sukses= false;
1476
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1477
        var _self = prog_.getNextMD() - 1;
1478
        if (_self == 0) {
1479
            _self = 1;
1480
            prog_.setNextMD(2);
1481
        }
1482
        var self_ = Ext.ComponentQuery.query('[itemId=MD' + _self + ']')[0];
1483
        var type_ = self_.WizardLayout;
1484

    
1485
        if (type_ == 'F') { // form layout
1486
            if (self_.getForm().isValid()) {
1487
                this.saveForm(self_);
1488
            } else { // form not valid
1489

    
1490
            }
1491
        } else { // grid layout
1492
            var cekData = false;
1493
            storeCount = 0;
1494
            dataStore = undefined;
1495
            if (Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + self_.tableName + ']')[0]) {
1496
                dataStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + self_.tableName + ']')[0].getStore();
1497
                storeCount = dataStore.count();
1498
            } else {
1499

    
1500
                dataStore = Ext.StoreMgr.lookup("store" + self_.tableName);
1501
                storeCount = dataStore.count();
1502
            }
1503
            if (self_.mandatory == "1") {
1504

    
1505
                if (storeCount > 0) {
1506
                    cekData = true;
1507
                } else {
1508
                    cekData = false;
1509
                    // mesaage
1510
                }
1511
            } else {
1512
                cekData = true;
1513
            }
1514
            //save grid data
1515
            if (storeCount > 0) {
1516
				sukses= true;
1517
				var dtTableSet = null;
1518
				Ext.Ajax.request({
1519
					async : false,
1520
					method : 'POST',
1521
					url : '/UserControl/GetStore',
1522
					params : {
1523
						tableName : 'SDATATABLEFIELD',
1524
						param : 'TableName[equal]'+self_.tableName+',FormatRef[=]amountencrypt'
1525
						//param : 'TableName[equal]' + self_.tableName
1526
					},
1527
					success : function (response) {
1528
						var results = Ext.decode(response.responseText);
1529
						dtTableSet = results.data;
1530
						
1531
					}
1532
				})
1533
                for (var i = 0; i < storeCount; i++) {
1534
					dataSub=dataStore.data.items[i].data;
1535
                    if (dataStore.data.items[i].data.Flag == '0') {
1536
						if(dtTableSet.length > 0){
1537
							m=0;
1538
							for (var m = 0; m < dtTableSet.length; m++) {
1539
								var valEnc='';
1540
								var f=dtTableSet[m].FieldName;
1541
								eval('valEnc=dataSub.'+f)
1542
								if(valEnc !=''){
1543
									Ext.Ajax.request({
1544
										async : false,
1545
										method : 'POST',
1546
										url : '/Devt/DecryptData',
1547
										params : {
1548
											dt : valEnc
1549

    
1550
										},
1551
										success : function (response) {
1552
											var results = Ext.decode(response.responseText);
1553
											value = results.data;
1554
											eval('dataSub.'+f+'='+value);
1555
											
1556
										}
1557
			
1558
									});
1559
								}
1560
							}
1561
						}
1562
                        Ext.Ajax.request({
1563
                            async: false,
1564
                            method: 'POST',
1565
                            url: '/Devt/SaveTable',
1566
                            params: {
1567
                                tableName: self_.tableName,
1568
                                data: Ext.encode(dataSub),
1569
                                action: 0
1570
                            },
1571
                            waitMsg: 'Saving Data...',
1572
                            success: function (response) {
1573
                                var result = Ext.decode(response.responseText);
1574
                                if (result.success) {
1575
                                    // MinovaMessage('Not Null', '000006', '', 'S');
1576
                                    sukses = true;
1577
                                } else {
1578
                                    MinovaMessage('', '000005', result.message.text, 'E');
1579
                                    sukses = false;
1580
                                }
1581
                            },
1582
                            failure: function (response) {
1583
                                var result = Ext.decode(response.responseText);
1584
                                MinovaMessage('', '000005', result.message.text, 'E');
1585
                                sukses = false;
1586
                            }
1587
                        });
1588
                    }
1589

    
1590
                }
1591
				//send mail
1592
				if(sukses){
1593
					var _param = {
1594
						serviceName : 'ERecruitmentAuthentication.asmx',
1595
						methodName : 'SendMailChangeMD',
1596
						parameter : 'TableName=' + self_.tableName + '&EmployeeID=' + dataStore.data.items[0].data.EmployeeID
1597

    
1598
					};
1599

    
1600
					//var results = null;
1601
					Ext.Ajax.request({
1602
						method : 'post',
1603
						type : 'ajax',
1604
						params : _param,
1605
						url : '/InvokeService/Invoke/',
1606
						loadMask : {
1607
							msg : 'please wait...'
1608
						},
1609
						success : function (response) {}
1610
					});
1611
				}
1612

    
1613
            }
1614
            if (cekData) {
1615
				prog_.sukses=true;
1616
                this.goNextMD(prog_, self_);
1617
                //change progress bar
1618
                total_ = ((prog_.getNextMD() - 1) / prog_.totalPage) * 100;
1619
                document.getElementById("progressbar").style.width = total_ + '%';
1620
                var idx = prog_.getNextMD() - 1;
1621
                this.changeProgress(idx, prog_.getNextMD(), false);
1622

    
1623
                prog_.setNextMD(prog_.getNextMD() + 1);
1624
                prog_.setPrevMD(prog_.getNextMD() - 1);
1625
            }
1626
			if(sukses== true || total_== 100 ){
1627
				if(_self == self_.nextMD){
1628
					    Ext.Msg.show({
1629
						title: "",
1630
						msg: MinovaMessageData('WD001', ''),
1631
						buttons: Ext.Msg.YESNO,
1632
						icon: Ext.Msg.QUESTION,
1633
						fn: function (choice) {
1634
							console.log(choice);
1635
							if (choice === 'yes') {
1636
								document.getElementById("progressbar").style.width = '100%';
1637
								if (sukses) {
1638
									var page = 'wizards';
1639
									if (prog_.wizardFunction.substring(0, 1) == "A") {
1640
										page = 'rcwizards';
1641
									}
1642
									nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1643
									var mb = new minovaBlowfish();
1644
									e = mb.minovaEncryptUrl(nextUrl);
1645
									window.open(page + '?' + e, "_self");
1646

    
1647
								}
1648
							}
1649

    
1650
						}
1651
					});
1652
                                
1653
				}
1654
			}
1655

    
1656
        }
1657

    
1658
    },
1659
    saveForm: function (self_) {
1660
        var me = this;
1661
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1662
        var next_ = prog_.getNextMD(); // id form selanjutnya
1663
        var _self = prog_.getNextMD() - 1;
1664
        if (self_ == undefined) {
1665
            self_ = Ext.ComponentQuery.query('[itemId=MD' + _self + ']')[0]; // formm yang sedang activ
1666
        }
1667
        var data1 = undefined;
1668
        var data2 = undefined;
1669
        //cek apakah md PHRPA0001
1670
        var cekKtp = true;
1671
        var _tbl = self_.tableName.toLowerCase();
1672

    
1673
        //cek ktp
1674
        if (_tbl == 'phrpa0001' || _tbl == 'phrrc0001') {
1675
            Ext.Ajax.request({
1676
                async: false,
1677
                method: 'POST',
1678
                url: '/UserControl/GetStore',
1679
                params: {
1680
                    tableName: 'PDSPAEMPIDCARD',
1681
                    param: 'WizardFunction[equal]' + self_.WizardFunction + ',BirthDate[=]' + Ext.ComponentQuery.query('[name=BirthDate]')[0].getValue() + ',IDCard[=]' + Ext.ComponentQuery.query('[name=IDCard]')[0].getValue()
1682

    
1683
                },
1684
                success: function (response) {
1685
                    var results = Ext.decode(response.responseText);
1686
                    data_ = results.data;
1687
                    if (data_ != undefined && data_.length > 0) {
1688
                        var MsgParam = "";
1689
                        Ext.each(data_, function (rec) {
1690
                            MsgParam = MsgParam + ' Type  :  ' + rec.Type + ' ,  Company  :  ' + rec.Company + ' ,  Status  :  ' + rec.Status + ' ,  Reason  :  ' + rec.Reason
1691
                        });
1692
                        /* MinovaMessage(' Message ', ' WIZRCIDCARD ', MsgParam, 'C', function (respone) {
1693
                            if (respone == "yes") {
1694
                                cekKtp = false;
1695
                                if (cekKtp) {
1696
                                    if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1697
                                        if (_tbl == 'phrpa0001') {
1698
                                            // past
1699
                                            if (self_.getForm().isValid()) {
1700
                                                //change progress bar
1701
                                                total_ = ((next_ - 1) / prog_.totalPage) * 100;
1702
                                                document.getElementById("progressbar").style.width = total_ + '%';
1703
                                                var idx = next_ - 1;
1704
                                                me.changeProgress(idx, next_, false);
1705
                                                me.goNextMD(prog_, self_);
1706
                                                me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1707
                                                prog_.setNextMD(prog_.getNextMD() + 1);
1708
                                                prog_.setPrevMD(prog_.getNextMD() - 1);
1709
                                            } else { // jika form error
1710

    
1711
                                            }
1712
                                        } else {
1713
                                            // save data to md
1714
                                            if (self_.getForm().isValid()) {
1715
                                                if (_tbl == 'phrpa0002') {
1716

    
1717
                                                    Ext.Ajax.request({
1718
                                                        async: false,
1719
                                                        method: 'POST',
1720
                                                        url: '/UserControl/GetStore',
1721
                                                        params: {
1722
                                                            tableName: 'PDSPAWIZDEL',
1723
                                                            param: getParam("id")
1724

    
1725
                                                        },
1726
                                                        waitMsg: 'Saving Data...',
1727
                                                        success: function (response) { },
1728
                                                        failure: function (response) { }
1729
                                                    });
1730

    
1731
                                                    formName = 'MinovaGridFormEditPHRPA0001';
1732
                                                    data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1733
                                                    var CreateDate = 'CreateDate';
1734
                                                    var CreateDateValue = "";
1735
                                                    var ChangeDate = 'ChangeDate';
1736
                                                    var ChangeDateValue = "";
1737

    
1738
                                                    data1[CreateDate] = CreateDateValue;
1739
                                                    data1[ChangeDate] = ChangeDateValue;
1740
                                                    data2 = self_.getForm().getValues();
1741
                                                    data2[CreateDate] = CreateDateValue;
1742
                                                    data2[ChangeDate] = ChangeDateValue;
1743
                                                } else {
1744
                                                    data1 = self_.getForm().getValues();
1745
                                                    var CreateDate = 'CreateDate';
1746
                                                    var CreateDateValue = "";
1747
                                                    var ChangeDate = 'ChangeDate';
1748
                                                    var ChangeDateValue = "";
1749

    
1750
                                                    data1[CreateDate] = CreateDateValue;
1751
                                                    data1[ChangeDate] = ChangeDateValue;
1752
                                                }
1753

    
1754
                                                var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1755
                                                if (sukses) {
1756
                                                    //change progress bar
1757
                                                    total_ = ((next_ - 1) / prog_.totalPage) * 100;
1758
                                                    document.getElementById("progressbar").style.width = total_ + '%';
1759
                                                    var idx = next_ - 1;
1760
                                                    me.changeProgress(idx, next_, false);
1761
                                                    me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1762
                                                    prog_.setNextMD(prog_.getNextMD() + 1);
1763
                                                    prog_.setPrevMD(prog_.getNextMD() - 1);
1764
                                                    me.goNextMD(prog_, self_);
1765

    
1766
                                                }
1767

    
1768
                                            } else { // jika form error
1769

    
1770
                                            }
1771
                                        }
1772
                                    } else {
1773
                                        data1 = self_.getForm().getValues();
1774
                                        //cek apakah form terakhir
1775
                                        if (prog_.totalPage < next_) { // md form sudah selesai
1776
                                            Ext.Msg.show({
1777
                                                title: "",
1778
                                                msg: MinovaMessageData('WD001', ''),
1779
                                                //buttons: Ext.Msg.YESNO,
1780
                                                icon: Ext.Msg.QUESTION,
1781
                                                fn: function (choice) {
1782
                                                    console.log(choice);
1783
                                                    if (choice === 'yes') {
1784
                                                        document.getElementById("progressbar").style.width = '100%';
1785

    
1786
                                                        //me.saveDataToMD();
1787

    
1788
                                                        var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1789
                                                        if (sukses) {
1790
                                                            var page = 'wizards';
1791
                                                            if (prog_.wizardFunction.substring(0, 1) == "A") {
1792
                                                                page = 'rcwizards';
1793
                                                            }
1794
                                                            nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1795
                                                            var mb = new minovaBlowfish();
1796
                                                            e = mb.minovaEncryptUrl(nextUrl);
1797
                                                            window.open(page + '?' + e, "_self");
1798

    
1799
                                                        }
1800
                                                    }
1801

    
1802
                                                }
1803
                                            });
1804
                                        } else {
1805
                                            var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1806
                                            if (sukses) {
1807
                                                //change progress bar
1808
                                                total_ = ((next_ - 1) / prog_.totalPage) * 100;
1809
                                                document.getElementById("progressbar").style.width = total_ + '%';
1810
                                                var idx = next_ - 1;
1811
                                                me.changeProgress(idx, next_, false);
1812
                                                me.goNextMD(prog_, self_);
1813
                                                me.setFormValuesAfterNext(self_.WizardFunction, prog_);
1814
                                                prog_.setNextMD(prog_.getNextMD() + 1);
1815
                                                prog_.setPrevMD(prog_.getNextMD() - 1);
1816

    
1817
                                            }
1818
                                        }
1819

    
1820
                                    }
1821

    
1822
                                }
1823

    
1824
                            } else {
1825
                                cekKtp = false;
1826
                            }
1827
                        });
1828
                    */
1829
                        MinovaMessageError(' Message ', ' WIZRCIDCARD ', MsgParam)
1830
                    } else {
1831
                        cekKtp = true;
1832
                        if (cekKtp) {
1833
                            if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1834
                                if (_tbl == 'phrpa0001') {
1835
                                    // past
1836
                                    if (self_.getForm().isValid()) {
1837
                                        //change progress bar
1838
                                        total_ = ((next_ - 1) / prog_.totalPage) * 100;
1839
                                        document.getElementById("progressbar").style.width = total_ + '%';
1840
                                        var idx = next_ - 1;
1841
                                        me.changeProgress(idx, next_, false);
1842
                                        me.goNextMD(prog_, self_);
1843
                                        me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1844
                                        prog_.setNextMD(prog_.getNextMD() + 1);
1845
                                        prog_.setPrevMD(prog_.getNextMD() - 1);
1846
                                    } else { // jika form error
1847

    
1848
                                    }
1849
                                } else {
1850
                                    // save data to md
1851
                                    if (self_.getForm().isValid()) {
1852
                                        if (_tbl == 'phrpa0002') {
1853

    
1854
                                            Ext.Ajax.request({
1855
                                                async: false,
1856
                                                method: 'POST',
1857
                                                url: '/UserControl/GetStore',
1858
                                                params: {
1859
                                                    tableName: 'PDSPAWIZDEL',
1860
                                                    param: getParam("id")
1861

    
1862
                                                },
1863
                                                waitMsg: 'Saving Data...',
1864
                                                success: function (response) { },
1865
                                                failure: function (response) { }
1866
                                            });
1867

    
1868
                                            formName = 'MinovaGridFormEditPHRPA0001';
1869
                                            data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1870
                                            var CreateDate = 'CreateDate';
1871
                                            var CreateDateValue = "";
1872
                                            var ChangeDate = 'ChangeDate';
1873
                                            var ChangeDateValue = "";
1874

    
1875
                                            data1[CreateDate] = CreateDateValue;
1876
                                            data1[ChangeDate] = ChangeDateValue;
1877
                                            data2 = self_.getForm().getValues();
1878
                                            data2[CreateDate] = CreateDateValue;
1879
                                            data2[ChangeDate] = ChangeDateValue;
1880
                                        } else {
1881
                                            data1 = self_.getForm().getValues();
1882
                                            var CreateDate = 'CreateDate';
1883
                                            var CreateDateValue = "";
1884
                                            var ChangeDate = 'ChangeDate';
1885
                                            var ChangeDateValue = "";
1886

    
1887
                                            data1[CreateDate] = CreateDateValue;
1888
                                            data1[ChangeDate] = ChangeDateValue;
1889
                                        }
1890

    
1891
                                        var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1892
                                        if (sukses) {
1893
                                            //change progress bar
1894
                                            total_ = ((next_ - 1) / prog_.totalPage) * 100;
1895
                                            document.getElementById("progressbar").style.width = total_ + '%';
1896
                                            var idx = next_ - 1;
1897
                                            me.changeProgress(idx, next_, false);
1898
                                            me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1899
                                            prog_.setNextMD(prog_.getNextMD() + 1);
1900
                                            prog_.setPrevMD(prog_.getNextMD() - 1);
1901
                                            me.goNextMD(prog_, self_);
1902

    
1903
                                        }
1904

    
1905
                                    } else { // jika form error
1906

    
1907
                                    }
1908
                                }
1909
                            } else {
1910
                                data1 = self_.getForm().getValues();
1911
                                //cek apakah form terakhir
1912
                                if (prog_.totalPage < next_) { // md form sudah selesai
1913
                                    Ext.Msg.show({
1914
                                        title: "",
1915
                                        msg: MinovaMessageData('WD001', ''),
1916
                                        buttons: Ext.Msg.YESNO,
1917
                                        icon: Ext.Msg.QUESTION,
1918
                                        fn: function (choice) {
1919
                                            console.log(choice);
1920
                                            if (choice === 'yes') {
1921
                                                document.getElementById("progressbar").style.width = '100%';
1922

    
1923
                                                //me.saveDataToMD();
1924

    
1925
                                                var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1926
                                                if (sukses) {
1927
                                                    var page = 'wizards';
1928
                                                    if (prog_.wizardFunction.substring(0, 1) == "A") {
1929
                                                        page = 'rcwizards';
1930
                                                    }
1931
                                                    nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1932
                                                    var mb = new minovaBlowfish();
1933
                                                    e = mb.minovaEncryptUrl(nextUrl);
1934
                                                    window.open(page + '?' + e, "_self");
1935

    
1936
                                                }
1937
                                            }
1938

    
1939
                                        }
1940
                                    });
1941
                                } else {
1942
                                    var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1943
                                    if (sukses) {
1944
                                        //change progress bar
1945
                                        total_ = ((next_ - 1) / prog_.totalPage) * 100;
1946
                                        document.getElementById("progressbar").style.width = total_ + '%';
1947
                                        var idx = next_ - 1;
1948
                                        me.changeProgress(idx, next_, false);
1949
                                        me.goNextMD(prog_, self_);
1950
                                        me.setFormValuesAfterNext(self_.WizardFunction, prog_);
1951
                                        prog_.setNextMD(prog_.getNextMD() + 1);
1952
                                        prog_.setPrevMD(prog_.getNextMD() - 1);
1953

    
1954
                                    }
1955
                                }
1956

    
1957
                            }
1958

    
1959
                        }
1960
                    }
1961
                }
1962
            });
1963
        } else {
1964
            cekKtp = true;;
1965
            if (cekKtp) {
1966
                if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1967
                    if (_tbl == 'phrpa0001') {
1968
                        // past
1969
                        if (self_.getForm().isValid()) {
1970
                            //change progress bar
1971
                            total_ = ((next_ - 1) / prog_.totalPage) * 100;
1972
                            document.getElementById("progressbar").style.width = total_ + '%';
1973
                            var idx = next_ - 1;
1974
                            me.changeProgress(idx, next_, false);
1975
                            me.goNextMD(prog_, self_);
1976
                            me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1977
                            prog_.setNextMD(prog_.getNextMD() + 1);
1978
                            prog_.setPrevMD(prog_.getNextMD() - 1);
1979
                        } else { // jika form error
1980

    
1981
                        }
1982
                    } else {
1983
                        // save data to md
1984
                        if (self_.getForm().isValid()) {
1985
                            if (_tbl == 'phrpa0002') {
1986

    
1987
                                Ext.Ajax.request({
1988
                                    async: false,
1989
                                    method: 'POST',
1990
                                    url: '/UserControl/GetStore',
1991
                                    params: {
1992
                                        tableName: 'PDSPAWIZDEL',
1993
                                        param: getParam("id")
1994

    
1995
                                    },
1996
                                    waitMsg: 'Saving Data...',
1997
                                    success: function (response) { },
1998
                                    failure: function (response) { }
1999
                                });
2000

    
2001
                                formName = 'MinovaGridFormEditPHRPA0001';
2002
                                data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
2003
                                var CreateDate = 'CreateDate';
2004
                                var CreateDateValue = "";
2005
                                var ChangeDate = 'ChangeDate';
2006
                                var ChangeDateValue = "";
2007

    
2008
                                data1[CreateDate] = CreateDateValue;
2009
                                data1[ChangeDate] = ChangeDateValue;
2010
                                data2 = self_.getForm().getValues();
2011
                                data2[CreateDate] = CreateDateValue;
2012
                                data2[ChangeDate] = ChangeDateValue;
2013
                            } else {
2014
                                data1 = self_.getForm().getValues();
2015
                                var CreateDate = 'CreateDate';
2016
                                var CreateDateValue = "";
2017
                                var ChangeDate = 'ChangeDate';
2018
                                var ChangeDateValue = "";
2019

    
2020
                                data1[CreateDate] = CreateDateValue;
2021
                                data1[ChangeDate] = ChangeDateValue;
2022
                            }
2023

    
2024
                            var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2025
                            if (sukses) {
2026
                                //change progress bar
2027
                                total_ = ((next_ - 1) / prog_.totalPage) * 100;
2028
                                document.getElementById("progressbar").style.width = total_ + '%';
2029
                                var idx = next_ - 1;
2030
                                me.changeProgress(idx, next_, false);
2031
                                me.setFormValuesAfterNext(self_.wizardFunction, prog_);
2032
                                prog_.setNextMD(prog_.getNextMD() + 1);
2033
                                prog_.setPrevMD(prog_.getNextMD() - 1);
2034
                                me.goNextMD(prog_, self_);
2035

    
2036
                            }
2037

    
2038
                        } else { // jika form error
2039

    
2040
                        }
2041
                    }
2042
                } else {
2043
                    data1 = self_.getForm().getValues();
2044
                    //cek apakah form terakhir
2045
                    if (prog_.totalPage < next_) { // md form sudah selesai
2046
                        Ext.Msg.show({
2047
                            title: "",
2048
                            msg: MinovaMessageData('WD001', ''),
2049
                            buttons: Ext.Msg.YESNO,
2050
                            icon: Ext.Msg.QUESTION,
2051
                            fn: function (choice) {
2052
                                console.log(choice);
2053
                                if (choice === 'yes') {
2054
                                    document.getElementById("progressbar").style.width = '100%';
2055

    
2056
                                    //me.saveDataToMD();
2057

    
2058
                                    var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2059
                                    if (sukses) {
2060
                                        var page = 'wizards';
2061
                                        if (prog_.wizardFunction.substring(0, 1) == "A") {
2062
                                            page = 'rcwizards';
2063
                                        }
2064
                                        nextUrl = MinovaUtil.GetMenuID() + '&S=S';
2065
                                        var mb = new minovaBlowfish();
2066
                                        e = mb.minovaEncryptUrl(nextUrl);
2067
                                        window.open(page + '?' + e, "_self");
2068

    
2069
                                    }
2070
                                }
2071

    
2072
                            }
2073
                        });
2074
                    } else {
2075
                        var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2076
                        if (sukses) {
2077
                            //change progress bar
2078
                            total_ = ((next_ - 1) / prog_.totalPage) * 100;
2079
                            document.getElementById("progressbar").style.width = total_ + '%';
2080
                            var idx = next_ - 1;
2081
                            me.changeProgress(idx, next_, false);
2082
                            me.goNextMD(prog_, self_);
2083
                            me.setFormValuesAfterNext(self_.WizardFunction, prog_);
2084
                            prog_.setNextMD(prog_.getNextMD() + 1);
2085
                            prog_.setPrevMD(prog_.getNextMD() - 1);
2086

    
2087
                        }
2088
                    }
2089

    
2090
                }
2091

    
2092
            }
2093

    
2094
        }
2095

    
2096
    },
2097
    goNextMD: function (prog_, form_) {
2098
        var me = this;
2099
        var table_ = form_.tableName.toLowerCase();
2100
        var next_ = prog_.getNextMD() - 1; // id form selanjutnya
2101
        //var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2102
        /*
2103
		if (prog_.totalPage <= next_) { // md form sudah selesai
2104
		Ext.Msg.show({
2105
		title: "",
2106
		msg: MinovaMessageData('WD001', ''),
2107
		buttons: Ext.Msg.YESNO,
2108
		icon: Ext.Msg.QUESTION,
2109
		fn: function (choice) {
2110
		console.log(choice);
2111
		if (choice === 'yes') {
2112
		document.getElementById("progressbar").style.width = '100%';
2113

    
2114
		//me.saveDataToMD();
2115

    
2116
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2117
		var page = 'wizards';
2118
		if (prog_.wizardFunction.substring(0, 1) == "A") {
2119
		page = 'rcwizards';
2120
		}
2121
		nextUrl = page + '?' + MinovaUtil.GetMenuID() + '&S=S';
2122
		window.open(nextUrl, "_self");
2123
		}
2124

    
2125
		}
2126
		});
2127
		}
2128
		else
2129
		 */
2130
        {
2131
            var next_ = form_.nextMD;
2132
            var _me = next_ - 1;
2133
            var nextPage = Ext.ComponentQuery.query('[itemId=MD' + form_.nextMD + ']')[0];
2134
            var type_ = nextPage.WizardLayout;
2135

    
2136
            if (prog_.sukses == true) {
2137
                if (form_.nextMD != 1) {
2138
                    //set value form or grid from md
2139
                    hisTable = nextPage.tableName;
2140
                    var nowDate = MinovaUtil.GetNowDate();
2141
                    if (nextPage.WizardFunction == 'APPT') {
2142
                        hisTable = "PHRRC" + hisTable.substring(5, 9);
2143
                    }
2144
                    if (nextPage.WizardLayout == 'G') {
2145
						var empID=getParam("app");
2146
						if(getParam('wizard').substring(0,1)== 'E'){
2147
						empID=getParam('id');
2148
						}
2149
                        var gridHis = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0];
2150
                        dataForm = null;
2151
                        Ext.Ajax.request({
2152
                            //async: false,
2153
                            method: 'POST',
2154
                            url: '/UserControl/GetStore',
2155
                            params: {
2156
                                tableName: hisTable,
2157
                                param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + empID
2158

    
2159
                            },
2160
                            success: function (response) {
2161
                                var results = Ext.decode(response.responseText);
2162
                                dataForm = results.data;
2163
                                if (dataForm.length) {
2164
                                    Ext.each(dataForm, function (rec) {
2165
                                        rec["EmployeeID"] = getParam('id');
2166
                                        rec["Flag"] = '0';
2167
                                    });
2168
                                }
2169
                                if (gridHis) {
2170
                                    var gridStore = gridHis.getStore();
2171
                                    gridStore.loadData(dataForm);
2172
                                } else {
2173
                                    var gridStore = Ext.StoreMgr.lookup("store" + nextPage.tableName);
2174
                                    gridStore.loadData(dataForm);
2175
                                }
2176

    
2177
                            }
2178
                        });
2179

    
2180
                    } else {
2181
                        var form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0];
2182
                    }
2183
                    form_.setHidden(true);
2184
                    nextPage.setHidden(false);
2185
                    me.setButton(nextPage);
2186
                } else {
2187
                    var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2188
                    var page = 'wizards';
2189
                    if (prog_.wizardFunction.substring(0, 1) == "A") {
2190
                        page = 'rcwizards';
2191
                    }
2192
                    nextUrl = MinovaUtil.GetMenuID() + '&S=S';
2193
                    var mb = new minovaBlowfish();
2194
                    e = mb.minovaEncryptUrl(nextUrl);
2195
                    window.open(page + '?' + e, "_self");
2196
                }
2197

    
2198
            } else if (table_ == 'phrpa0001' || table_ == 'phrpa0002') {
2199
                form_.setHidden(true);
2200
                nextPage.setHidden(false);
2201
                me.setButton(nextPage);
2202
            }
2203

    
2204
        }
2205
    },
2206
    saveDataToMD: function (tableName, data1, data2) {
2207
        var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2208
        var sukses = false;
2209
        var TblApp = tableName.toLowerCase().substring(0, 5);
2210
		if(getParam('wizard')=='A900'){
2211
			var EmployeeID = 'EmployeeID';
2212
			var EmployeeIDValue = getParam('id');
2213
			data1[EmployeeID] = EmployeeIDValue;
2214
			if(data2 != undefined){
2215
				var EmployeeID = 'EmployeeID';
2216
				var EmployeeIDValue = getParam('id');
2217
				data2[EmployeeID] = EmployeeIDValue;
2218
			}
2219
		}
2220
		
2221
		var CreateDate = 'CreateDate';
2222
		var CreateDateValue = "";
2223
		var ChangeDate = 'ChangeDate';
2224
		var ChangeDateValue = "";
2225
		data1[CreateDate] = CreateDateValue;
2226
		data1[ChangeDate] = ChangeDateValue;
2227
        if (data2 == undefined) {
2228
		
2229
            if (prog_.sukses = true || TblApp == 'phrrc') {
2230
				
2231
				if(tableName == 'PHRPA0012')
2232
				{
2233
					var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
2234
					var Act = ActF.getValue();
2235
					if(Act == 'E001' ||  Act == 'A009');
2236
					{
2237
						var CommunicationType = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0012]')[0].getValues().CommunicationType;
2238
						//alert(CommunicationType);
2239
						var EmployeeID = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0012]')[0].getValues().EmployeeID;
2240
						//alert(EmployeeID);
2241
						var CommunicationDesc = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0012]')[0].getValues().CommunicationDescription;
2242
						//alert(CommunicationDesc);
2243
						var hasil = undefined;	
2244
						var issuccess = undefined;
2245
						Ext.Ajax.request({
2246
							async: false,
2247
							method: 'POST',
2248
							url: '/UserControl/GetStore',
2249
							params: {
2250
								tableName: 'SGENERATEUSERWIZ',
2251
								param: EmployeeID + ',' + CommunicationType 
2252
							},
2253
							success: function (response) {
2254
								var results = Ext.decode(response.responseText);
2255
								hasil = results.data;
2256
								//issuccess = 'y';
2257
								var UserData = Ext.encode(results.data);
2258
								
2259
								Ext.Ajax.request({
2260
								async: false,
2261
								method: 'POST',
2262
								url: '/UserControl/GenerateMassUser',
2263
								params: {
2264
									UserData: UserData
2265
								},
2266
								success: function (response) {						
2267
									var data_ = Ext.decode(response.responseText);
2268
									issuccess = 'y';
2269
								}
2270
								});								
2271
							},
2272
							failure: function (response) {
2273
								var result = Ext.decode(response.responseText);
2274
								MinovaMessage('', '000005', result.message.text, "E");
2275
							}
2276
						});
2277
						
2278
						if(issuccess == 'y')
2279
						{
2280
							Ext.Ajax.request({
2281
								async: false,
2282
								method: 'POST',
2283
								url: '/UserControl/GetStore',
2284
								params: {
2285
									tableName: 'SGENERATEUSERWIZEMAIL',
2286
									param: EmployeeID + ',' + CommunicationType + ',' + CommunicationDesc
2287
								},
2288
								success: function (response) {
2289
									var results = Ext.decode(response.responseText);					
2290
								},
2291
								failure: function (response) {
2292
									var result = Ext.decode(response.responseText);
2293
									MinovaMessage('', '000005', result.message.text, "E");
2294
								}
2295
							});
2296
						}
2297
					}
2298
				}
2299

    
2300
                Ext.Ajax.request({
2301
                    async: false,
2302
                    method: 'POST',
2303
                    url: '/Devt/SaveTable',
2304
                    params: {
2305
                        tableName: tableName,
2306
                        data: Ext.encode(data1),
2307
                        action: 0
2308
                    },
2309
                    waitMsg: 'Saving Data...',
2310
                    success: function (response) {
2311
                        var result = Ext.decode(response.responseText);
2312
                        if (result.success) {
2313
                            // MinovaMessage('Not Null', '000006', '', 'S');
2314
                            sukses = true;
2315
							//send mail
2316
							var _param = {
2317
										serviceName : 'ERecruitmentAuthentication.asmx',
2318
										methodName : 'SendMailChangeMD',
2319
										parameter : 'TableName=' + tableName + '&EmployeeID=' + data1.EmployeeID
2320

    
2321
									};
2322

    
2323
									//var results = null;
2324
									Ext.Ajax.request({
2325
										method : 'post',
2326
										type : 'ajax',
2327
										params : _param,
2328
										url : '/InvokeService/Invoke/',
2329
										loadMask : {
2330
											msg : 'please wait...'
2331
										},
2332
										success : function (response) {}
2333
									});
2334
                        } else {
2335
                            MinovaMessage('', '000005', result.message.text, 'E');
2336
                            sukses = false;
2337
                        }
2338
                    },
2339
                    failure: function (response) {
2340
                        var result = Ext.decode(response.responseText);
2341
                        MinovaMessage('', '000005', result.message.text, 'E');
2342
                        sukses = false;
2343
                    }
2344
                });
2345
            } else { }
2346
        } else {
2347
			data2[CreateDate] = CreateDateValue;
2348
			data2[ChangeDate] = ChangeDateValue;
2349
            Ext.Ajax.request({
2350
                async: false,
2351
                method: 'POST',
2352
                url: '/Devt/SaveTable',
2353
                params: {
2354
                    tableName: 'phrpa0001',
2355
                    data: Ext.encode(data1),
2356
                    action: 0
2357
                },
2358
                waitMsg: 'Saving Data...',
2359
                success: function (response) {
2360
                    var result = Ext.decode(response.responseText);
2361
                    if (result.success) {
2362
                        // MinovaMessage('Not Null', '000006', '', 'S');
2363
                        sukses = true;
2364
                    } else {
2365
                        MinovaMessage('', '000005', result.message.text, 'E');
2366
                    }
2367
                },
2368
                failure: function (response) {
2369
                    var result = Ext.decode(response.responseText);
2370
                    MinovaMessage('', '000005', result.message.text, 'E');
2371
                }
2372
            });
2373
            if (sukses) {
2374
                Ext.Ajax.request({
2375
                    async: false,
2376
                    method: 'POST',
2377
                    url: '/Devt/SaveTable',
2378
                    params: {
2379
                        tableName: 'PHRPA0002',
2380
                        data: Ext.encode(data2),
2381
                        action: 0
2382
                    },
2383
                    waitMsg: 'Saving Data...',
2384
                    success: function (response) {
2385
                        var result = Ext.decode(response.responseText);
2386
                        if (result.success) {
2387
                            // MinovaMessage('Not Null', '000006', '', 'S');
2388
                            sukses = true;
2389
                        } else {
2390
                            MinovaMessage('', '000005', result.message.text, 'E');
2391
                            sukses = false;
2392
                        }
2393
                    },
2394
                    failure: function (response) {
2395
                        var result = Ext.decode(response.responseText);
2396
                        MinovaMessage('', '000005', result.message.text, 'E');
2397
                    }
2398
                });
2399
            }
2400

    
2401
            //save md 15
2402
            var app = getParam('app');
2403
            if (app === "null") {
2404
                app = '';
2405
            }
2406
            var _date = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0002]')[0].getValues().StartDate;
2407
            data = {
2408
                EmployeeID: getParam('id'),
2409
                PaymentUpTo: '',
2410
                RetroDate: _date,
2411
                HiringDate: _date,
2412
                ApplicantID: app,
2413
                CorrectStatus: '1'
2414
            };
2415
            Ext.Ajax.request({
2416
                async: false,
2417
                method: 'POST',
2418
                url: '/Devt/SaveTable',
2419
                params: {
2420
                    tableName: 'phrpa0015',
2421
                    data: Ext.encode(data),
2422
                    action: 0
2423
                },
2424
                waitMsg: 'Saving Data...',
2425
                success: function (response) {
2426
                    var result = Ext.decode(response.responseText);
2427
                    if (result.success) {
2428
                        // MinovaMessage('Not Null', '000006', '', 'S');
2429
                        sukses = true;
2430
                    } else {
2431
                        MinovaMessage('', '000005', result.message.text, 'E');
2432
                        sukses = false;
2433
                    }
2434
                },
2435
                failure: function (response) {
2436
                    var result = Ext.decode(response.responseText);
2437
                    MinovaMessage('', '000005', result.message.text, 'E');
2438
                }
2439
            });
2440

    
2441
        }
2442
        prog_.sukses = sukses;
2443
        return (sukses);
2444
    },
2445

    
2446
    setFormValuesAfterNext: function (WizardFunction, prog_) {
2447
        var nowDate = MinovaUtil.GetNowDate();
2448
        //var data_ = JSON.parse(localStorage.getItem(datatable));
2449
        var me = this;
2450
        var next_ = prog_.getNextMD()
2451

    
2452
        if (Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0]) {
2453
            var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
2454
            var type_ = nextPage.WizardLayout;
2455
            var tabl_ = nextPage.tableName;
2456
            switch (nextPage.WizardFunction) {
2457
                case "APP":
2458
                    var tabl_ = nextPage.tableName;
2459
                    me.getLastValue(tabl_, type_);
2460
                    break
2461
                case "APPI":
2462

    
2463
                    break
2464
                case "APPT":
2465
                    var tabl_ = prog_.allTable[next_-1];
2466
                    tbl_ = "PHRRC" + tabl_.substring(5, 9);
2467
					paData= "PHRPA" + tabl_.substring(5, 9);
2468
                    me.getLastValueAPPT(tbl_, type_,paData);
2469
                    break
2470
                case "EMP":
2471
                    var tabl_ = nextPage.tableName;
2472
                    me.getLastValue(tabl_, type_);
2473
                    break
2474
                case "EMPI":
2475

    
2476
                    break
2477
                default:
2478
                    break
2479
            }
2480
            if (type_ == "F") {
2481
                me.setValueFromParameter(nextPage);
2482
            }
2483

    
2484
        }
2485
    },
2486

    
2487
	getLastValueAPPT: function (nextTable, type_,paData) {
2488
        var nowDate = MinovaUtil.GetNowDate();
2489
        if (type_ == "F") {
2490
            Ext.Ajax.request({
2491
                async: false,
2492
                method: 'POST',
2493
                url: '/UserControl/GetStore',
2494
                params: {
2495
                    tableName: nextTable,
2496
                    //param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
2497
					param: 'EmployeeID[=]' + getParam("app")
2498

    
2499
                },
2500
                success: function (response) {
2501
                    var results = Ext.decode(response.responseText);
2502
                    dataForm = results.data[0];
2503
                    var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + paData + ']')[0]
2504
                    var form_ = _form.getForm();
2505
                    form_.setValues(dataForm);
2506
                    var temData = JSON.parse(localStorage.getItem('selectionValues'));
2507

    
2508
                    if (nextTable.toLowerCase == "phrpa0002") {
2509
                        form_.findField('StartDate').setValue(temData.EffectiveDate);
2510
                        form_.findField('CompanyID').setValue(temData.CompanyID);
2511
                        form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
2512
                        form_.findField('MovementReason').setValue(temData.Reason);
2513
                    }
2514
                    else {
2515
                        form_.findField('StartDate').setValue(temData.EffectiveDate);
2516
                    }
2517
                }
2518
            });
2519
        } else {
2520
            Ext.Ajax.request({
2521
                async: false,
2522
                method: 'POST',
2523
                url: '/UserControl/GetStore',
2524
                params: {
2525
                    tableName: nextTable,
2526
                    param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2527

    
2528
                },
2529
                success: function (response) {
2530
                    var results = Ext.decode(response.responseText);
2531
                    var data_ = results.data;
2532
                    var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + paData + ']')[0].getStore();
2533
                    gridStore.loadData(data_);
2534

    
2535
                }
2536
            });
2537
        }
2538
    },
2539

    
2540
    getLastValue: function (nextTable, type_) {
2541
        var nowDate = MinovaUtil.GetNowDate();
2542
        if (type_ == "F") {
2543
            Ext.Ajax.request({
2544
                async: false,
2545
                method: 'POST',
2546
                url: '/UserControl/GetStore',
2547
                params: {
2548
                    tableName: nextTable,
2549
                    param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2550

    
2551
                },
2552
                success: function (response) {
2553
                    var results = Ext.decode(response.responseText);
2554
                    dataForm = results.data[0];
2555
                    var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextTable + ']')[0]
2556
                    var form_ = _form.getForm();
2557
                    form_.setValues(dataForm);
2558
                    var temData = JSON.parse(localStorage.getItem('selectionValues'));
2559

    
2560
                    if (nextTable.toLowerCase == "phrpa0002") {
2561
                        form_.findField('StartDate').setValue(temData.EffectiveDate);
2562
                        form_.findField('CompanyID').setValue(temData.CompanyID);
2563
                        form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
2564
                        form_.findField('MovementReason').setValue(temData.Reason);
2565
                    }
2566
                    else {
2567
                        form_.findField('StartDate').setValue(temData.EffectiveDate);
2568
                    }
2569
                }
2570
            });
2571
        } else {
2572
            Ext.Ajax.request({
2573
                async: false,
2574
                method: 'POST',
2575
                url: '/UserControl/GetStore',
2576
                params: {
2577
                    tableName: nextTable,
2578
                    param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2579

    
2580
                },
2581
                success: function (response) {
2582
                    var results = Ext.decode(response.responseText);
2583
                    var data_ = results.data;
2584
                    var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextTable + ']')[0].getStore();
2585
                    gridStore.loadData(data_);
2586

    
2587
                }
2588
            });
2589
        }
2590
    },
2591

    
2592
    setButton: function (nextPage) {
2593

    
2594
        prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2595
        id_ = parseInt(nextPage.itemId.substring(2, 3));
2596
        Ext.ComponentQuery.query('[name=prevWizard]')[0].setDisabled(false);
2597
        Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
2598
        Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
2599

    
2600
        if (nextPage.mandatory == "1") {
2601
            //if (nextPage.nextMD == 1) {
2602
            //    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2603
            //    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2604

    
2605
            //} else {
2606
            //    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2607
            //    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2608

    
2609
            //}
2610

    
2611
            Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2612
            Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2613

    
2614
        } else {
2615
            Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
2616
            Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
2617
        }
2618

    
2619
        if (id_ == prog_.totalPage) {
2620
            Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2621
            Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2622
        }
2623
    },
2624
    ChangeApp: function () {
2625
        Ext.Ajax.request({
2626
            async: false,
2627
            method: 'POST',
2628
            url: '/UserControl/GetStore',
2629
            params: {
2630
                tableName: "PHRRC0002",
2631
                param: 'StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',EmployeeID[=]' + Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue()
2632

    
2633
            },
2634
            success: function (response) {
2635
                var results = Ext.decode(response.responseText);
2636
                var data = results.data;
2637
                if (data != null && data.length > 0) {
2638
                    var data_ = results.data[0];
2639
                    Ext.ComponentQuery.query('[name=CompanyID]')[0].setValue(data_.CompanyID);
2640
                }
2641
            }
2642
        });
2643
    },
2644
});
(2-2/4)