Project

General

Profile

Bug #1804 » wizard.js

Tri Rizqiaty, 11/18/2022 10:30 AM

 
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
					}, function (s) {
671
						var result = Ext.decode(s.responseText);
672
						var dt = Ext.decode(Ext.decode(result.data));
673
						oldID = dt[0].EmpID.toString();
674
					}, function (f) {});
675
					//// add by Tri nwh 20220811 end
676
					
677
                    //Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID);
678
                    //app_ = Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue();
679
                    app_ = selectionValues.ApplicantID;
680

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

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

    
714
                        success: function (response) {
715
                            oldID = response.responseText;
716

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

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

    
745
    },
746
	
747
	
748

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

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

    
771
    },
772
    cekPayrollStatus: function () {
773

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

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

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

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

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

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

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

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

    
890
                }
891

    
892
            }
893
        });
894

    
895
        // }
896

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

    
927
                }
928
            });
929

    
930
            // }
931

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

    
938
                //formName = 'formWizard' + nextPage.tableName;
939
                formName = 'MinovaGridFormEdit' + nextPage.tableName;
940

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

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

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

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

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

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

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

    
1024
                    }
1025

    
1026
                }
1027
            });
1028

    
1029
            //}
1030

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

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

    
1045
            } else {
1046

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

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

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

    
1073
                    }
1074

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

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

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

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

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

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

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

    
1173
                            }
1174
                        });
1175
                    }
1176

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

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

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

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

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

    
1237
                //} else {
1238
                //    // message jika form tidak valid
1239
                //}
1240

    
1241
            }
1242

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

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

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

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

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

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

    
1309
            }
1310
            // run save
1311

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

    
1341
        });
1342

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1596
					};
1597

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

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

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

    
1645
								}
1646
							}
1647

    
1648
						}
1649
					});
1650
                                
1651
				}
1652
			}
1653

    
1654
        }
1655

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

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

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

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

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

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

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

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

    
1748
                                                    data1[CreateDate] = CreateDateValue;
1749
                                                    data1[ChangeDate] = ChangeDateValue;
1750
                                                }
1751

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

    
1764
                                                }
1765

    
1766
                                            } else { // jika form error
1767

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

    
1784
                                                        //me.saveDataToMD();
1785

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

    
1797
                                                        }
1798
                                                    }
1799

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

    
1815
                                            }
1816
                                        }
1817

    
1818
                                    }
1819

    
1820
                                }
1821

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

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

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

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

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

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

    
1885
                                            data1[CreateDate] = CreateDateValue;
1886
                                            data1[ChangeDate] = ChangeDateValue;
1887
                                        }
1888

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

    
1901
                                        }
1902

    
1903
                                    } else { // jika form error
1904

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

    
1921
                                                //me.saveDataToMD();
1922

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

    
1934
                                                }
1935
                                            }
1936

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

    
1952
                                    }
1953
                                }
1954

    
1955
                            }
1956

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

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

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

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

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

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

    
2018
                                data1[CreateDate] = CreateDateValue;
2019
                                data1[ChangeDate] = ChangeDateValue;
2020
                            }
2021

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

    
2034
                            }
2035

    
2036
                        } else { // jika form error
2037

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

    
2054
                                    //me.saveDataToMD();
2055

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

    
2067
                                    }
2068
                                }
2069

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

    
2085
                        }
2086
                    }
2087

    
2088
                }
2089

    
2090
            }
2091

    
2092
        }
2093

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

    
2112
		//me.saveDataToMD();
2113

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

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

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

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

    
2175
                            }
2176
                        });
2177

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

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

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

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

    
2319
									};
2320

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

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

    
2439
        }
2440
        prog_.sukses = sukses;
2441
        return (sukses);
2442
    },
2443

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

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

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

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

    
2482
        }
2483
    },
2484

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

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

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

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

    
2533
                }
2534
            });
2535
        }
2536
    },
2537

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

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

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

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

    
2585
                }
2586
            });
2587
        }
2588
    },
2589

    
2590
    setButton: function (nextPage) {
2591

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

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

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

    
2607
            //}
2608

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

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

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

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