Project

General

Profile

Bug #913 » wizard.js

dian perdana putra, 02/21/2022 02:59 PM

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

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

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

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

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

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

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

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

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

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

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

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

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

    
188
		if (wizFunc != 'APPI' && wizFunc != 'EMPI' && wizFunc != 'APPT' && wizFunc != 'EMP') {
189
			if (Ext.ComponentQuery.query('[name=ApplicantID]')[0]) {
190
				Return = me.ApplicantIDChange()
191
			} else {
192
				Return = me.empChange();
193
			}
194

    
195
		} else {
196
			Return = true;
197
		}
198

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

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

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

    
251
			},
252
			success: function (response) {
253
				var results = Ext.decode(response.responseText);
254
				data_ = results.data[0];
255
				if (data_ != undefined) {
256
					menuDt = data_;
257
				}
258
			}
259
		});
260
		formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
261

    
262
		if (menuDt) {
263
			typeWizard = menuDt.Variant;
264

    
265
			if (typeWizard == '100') { // for empolyee md
266
				formSelection.findField("ApplicantID").setVisible(false);
267

    
268
			} else {
269
				formSelection.findField("PayrollGroup").setVisible(false);
270
				formSelection.findField("EmployeeID").setVisible(false);
271

    
272
			}
273
		} else {
274
			formSelection.findField("ApplicantID").setVisible(false);
275
		}
276

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

    
293
				},
294
				success: function (response) {
295
					var results = Ext.decode(response.responseText);
296
					data_ = results.data;
297
					if (data_ != undefined) {
298
						//result_ = data_;
299
						//sorting results
300
						// result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
301
						result_ = data_;
302
					}
303
				}
304
			});
305

    
306
		} else {
307
			Ext.Ajax.request({
308
				async: false,
309
				method: 'POST',
310
				url: '/UserControl/GetStore',
311
				params: {
312
					tableName: 'PDSPA0005',
313
					param: 'WizardDescription[equal]' + Ext.ComponentQuery.query('[name=Action]')[0].rawValue
314

    
315
				},
316
				success: function (response) {
317
					var results = Ext.decode(response.responseText);
318
					data_ = results.data;
319
					if (data_ != undefined) {
320
						//result_ = data_;
321
						//sorting results
322
						// result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
323
						result_ = data_;
324
					}
325
				}
326
			});
327

    
328
		}
329

    
330
		storeFlow.getStore().loadData(result_);
331
		storeFlow.unmask();
332

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

    
362
		} else if (WizardFunction == 'APPT') { // app to emp
363
			formSelection.findField("ApplicantID").allowBlank = false;
364
			formSelection.findField("ApplicantID").setValue('');
365
			formSelection.findField("ApplicantID").setReadOnly(false);
366
			//formSelection.findField("MovementType").setHidden(true)
367
			formSelection.findField("CompanyID").setHidden(false);
368
			formSelection.findField("PayrollGroup").setHidden(false);
369

    
370
		} else if (WizardFunction == 'EMP') { // for exsist employee
371
			formSelection.findField("EmployeeID").allowBlank = false;
372
			formSelection.findField("EmployeeID").setReadOnly(false);
373
			formSelection.findField("CompanyID").setHidden(true);
374
			formSelection.findField("PayrollGroup").setHidden(true);
375
			formSelection.findField("CompanyID").allowBlank = true;
376
			formSelection.findField("PayrollGroup").allowBlank = true;
377
		} else if (WizardFunction == 'EMPI') { // new employee
378
			formSelection.findField("EmployeeID").setValue("");
379
			formSelection.findField("EmployeeID").allowBlank = true;
380
			formSelection.findField("EmployeeID").setReadOnly(true);
381

    
382
			formSelection.findField("CompanyID").setHidden(false);
383
			formSelection.findField("PayrollGroup").setHidden(false);
384
		}
385
		this.loadMoveReason();
386
		//this.cekMsg();
387
	},
388
	loadMoveReason: function () {
389
		var ActF = Ext.ComponentQuery.query('[name=Action]')[0]
390
			var Act = ActF.getValue();
391
		localStorage.setItem("Action", ActF.getRawValue());
392

    
393
		if (Act != '') {
394
			var s = Ext.ComponentQuery.query('[name=Action]')[0].getStore();
395
			var actVal = s.findRecord('Wizard', Act).data.MovementType;
396
			var Res = Ext.ComponentQuery.query('[name=Reason]')[0];
397
			if (Res) {
398
				var ResStore = Res.getStore();
399
				ResStore.removeAll();
400

    
401
				Ext.Ajax.request({
402
					async: false,
403
					method: 'POST',
404
					url: '/UserControl/GetStore',
405
					params: {
406
						tableName: 'PCMEPMOVR',
407
						param: 'MovementType[equal]' + actVal
408

    
409
					},
410
					success: function (response) {
411
						var results = Ext.decode(response.responseText);
412
						data_ = results.data;
413
						if (data_ != undefined) {
414
							ResStore.loadData(data_)
415
						}
416
					}
417
				});
418
			}
419

    
420
		}
421

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

    
452

    
453
		var wzFunc = undefined;
454
		selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
455
		if (Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm().isValid()) {
456
			if (payrollStatus == true) {
457

    
458
				Ext.Ajax.request({
459
					async: false,
460
					method: 'POST',
461
					url: '/UserControl/GetStore',
462
					params: {
463
						tableName: 'PHRPAWIZMAIN',
464
						param: 'Wizard[equal]' + selectionValues.Action
465

    
466
					},
467
					success: function (response) {
468
						var results = Ext.decode(response.responseText);
469
						data_ = results.data[0];
470
						if (data_ != undefined) {
471
							localStorage.setItem('wzFunc', JSON.stringify(results.data));
472
							wzFunc = data_.WizardFunction;
473
						}
474
					}
475
				});
476

    
477
				oldID = null;
478
				app_ = null;
479

    
480
				//localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
481
				if (wzFunc == 'APPT') {
482
					/*Ext.Ajax.request({
483
					async: false,
484
					method: 'POST',
485
					url: '/UserControl/GetLastID?class_=E',
486
					success: function (response) {
487
					oldID = response.responseText;
488
					}
489
					});*/
490

    
491
					var PayrollGroup = '';
492
					var LastID = '';
493
					Ext.Ajax.request({
494
						async: false,
495
						method: 'POST',
496
						url: '/UserControl/GetStore',
497
						params: {
498
							tableName: 'PHRPYPGRUP',
499
							param: 'PayrollGroup[equal]' + selectionValues.PayrollGroup
500
						},
501
						success: function (response) {
502
							var results = Ext.decode(response.responseText);
503
							data_ = results.data[0];
504
							if (data_ != undefined) {
505
								PayrollGroup = data_.Notes;
506
								if (data_.LastID == '') {
507
									LastID = '000000';
508
								} else {
509
									LastID = data_.LastID.substring(2, 8);
510
								}
511
							}
512
						}
513
					});
514

    
515
					Ext.Ajax.request({
516
						async: false,
517
						method: 'POST',
518
						url: '/UserControl/GetStore',
519
						params: {
520
							tableName: 'CDSWIZEMPID',
521
							param: 'PayrollGroup[equal]' + PayrollGroup + ',LastID[equal]' + LastID
522
						},
523
						success: function (response) {
524
							var results = Ext.decode(response.responseText);
525
							var dt = results.data;
526
							data_ = dt[0];
527
							oldID = data_.EmployeeID;
528
						}
529
					});
530
					app_ = selectionValues.ApplicantID;
531

    
532
				} else if (wzFunc == 'EMPI') {
533
					/*Ext.Ajax.request({
534
					async: false,
535
					method: 'POST',
536
					url: '/UserControl/GetLastID?class_=E',
537

    
538
					success: function (response) {
539
					oldID = response.responseText;
540
					}
541
					});*/
542

    
543
					var PayrollGroup = '';
544
					var LastID = '';
545
					Ext.Ajax.request({
546
						async: false,
547
						method: 'POST',
548
						url: '/UserControl/GetStore',
549
						params: {
550
							tableName: 'PHRPYPGRUP',
551
							param: 'PayrollGroup[equal]' + selectionValues.PayrollGroup
552
						},
553
						success: function (response) {
554
							var results = Ext.decode(response.responseText);
555
							data_ = results.data[0];
556
							if (data_ != undefined) {
557
								PayrollGroup = data_.Notes;
558
								if (data_.LastID == '') {
559
									LastID = '000000';
560
								} else {
561
									LastID = data_.LastID.substring(2, 8);
562
								}
563
							}
564
						}
565
					});
566

    
567
					Ext.Ajax.request({
568
						async: false,
569
						method: 'POST',
570
						url: '/UserControl/GetStore',
571
						params: {
572
							tableName: 'CDSWIZEMPID',
573
							param: 'PayrollGroup[equal]' + PayrollGroup + ',LastID[equal]' + LastID
574
						},
575
						success: function (response) {
576
							var results = Ext.decode(response.responseText);
577
							var dt = results.data;
578
							data_ = dt[0];
579
							oldID = data_.EmployeeID;
580
						}
581
					});
582

    
583
					Ext.ComponentQuery.query('[name=EmployeeID]')[0].setValue(oldID);
584

    
585
				} else if (wzFunc == 'APPI') {
586
					Ext.Ajax.request({
587
						async: false,
588
						method: 'POST',
589
						url: '/UserControl/GetLastID?class_=A',
590

    
591
						success: function (response) {
592
							oldID = response.responseText;
593

    
594
						}
595
					});
596
					Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID)
597
				} else {
598
					if (selectionValues.ApplicantID) {
599
						oldID = selectionValues.ApplicantID;
600
					} else if (selectionValues.EmployeeID) {
601
						oldID = selectionValues.EmployeeID
602
					}
603
				}
604

    
605
				selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
606
				var wiz = selectionValues.Action;
607
				if (wiz == '') {
608
					wiz = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.Wizard;
609
				}
610
				localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
611
				var nextUrl = MinovaUtil.GetMenuID() + '&wizard=' + wiz + '&id=' + oldID + '&app=' + app_;
612
				var mb = new minovaBlowfish();
613
				e = mb.minovaEncryptUrl(nextUrl);
614
				//if (wizFunc == 'APPI' || wizFunc == 'APPT')
615
				{
616
					var EmployeeID = oldID;
617
				}
618
				window.open('runwizards?' + e, "_self");
619
			}
620
		}
621

    
622
	},
623
	cekMsg: function () {
624
		formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
625
		formValues_ = formSelection.getValues();
626
		if (Ext.ComponentQuery.query('[name=Reason]')[0]) {
627
			Ext.ComponentQuery.query('[name=Reason]')[0].setHidden(true);
628
			formSelection.findField("PayrollGroup").setHidden(true);
629

    
630
		}
631
		var flag = getParam('S');
632
		if (flag == 'S') {
633
			MinovaMessage('', '000006', '', 'S');
634
		}
635
	},
636
	changeProgress: function (idx, idNext, skip) {
637
		//$("#stepStatus" + idx).removeClass("active");
638
		//$("#stepStatus" + idNext).addClass("active");
639
		if (skip) {
640
			//$("#checkStatus" + idx).addClass("fa fa-check");
641
		} else {
642
			$("#checkStatus" + idx).addClass("fa fa-check");
643
		}
644

    
645
	},
646
	cekPayrollStatus: function () {
647

    
648
		formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
649
		if (formSelection.isValid()) {
650
			// cek payroll status by input payroll group
651
			formValues_ = formSelection.getValues();
652
			var result = undefined;
653
			if (formValues_.PayrollGroup != "") {
654
				Ext.Ajax.request({
655
					async: false,
656
					method: 'POST',
657
					url: '/UserControl/GetStore',
658
					params: {
659
						tableName: 'PHRPYPGCTRL',
660
						param: 'PayrollGroup[equal]' + formValues_.PayrollGroup
661

    
662
					},
663
					success: function (response) {
664
						var results = Ext.decode(response.responseText);
665
						data_ = results.data[0];
666
						if (data_ != undefined) {
667
							result = data_;
668
						}
669
					}
670
				});
671
			}
672
			var cek = true;
673
			if (result) {
674
				if (result.PayrollControlStatus == "V") {
675
					// massage corection
676
					cek = false;
677
				} else if (result.PayrollControlStatus == "S") {
678
					// massage corection
679
					cek = false;
680
				}
681

    
682
			}
683
			if (cek) {
684
				//var storeFlow = Ext.ComponentQuery.query('[name=processflow]')[0];
685
				//storeFlow.mask('Loading...');
686
				//var result_ = undefined;
687
				//Ext.Ajax.request({
688
				//    async: false,
689
				//    method: 'POST',
690
				//    url: '/UserControl/GetStore',
691
				//    params: {
692
				//        tableName: 'PDSPA0005',
693
				//        param: 'Wizard[equal]' + formValues_.Action
694

    
695
				//    },
696
				//    success: function (response) {
697
				//        var results = Ext.decode(response.responseText);
698
				//        data_ = results.data;
699
				//        if (data_ != undefined) {
700
				//            //result_ = data_;
701
				//            //sorting results
702
				//            result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
703
				//        }
704
				//    }
705
				//});
706

    
707
				//storeFlow.getStore().loadData(result_);
708
				//storeFlow.unmask();
709
			}
710
		}
711
		//else {
712
		//    //masih ada field mandtory yang kosong
713
		//}
714
		return cek;
715
	},
716
	processflowGrid: function (g) {
717
		setTimeout(function () {
718
			var g_ = Ext.ComponentQuery.query('[name=processflow]')[0];
719
			g_.getStore().removeAll();
720
		}, 200);
721

    
722
	},
723
	// fungsi ke form sebelumnya
724
	prevWizard: function () {
725
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
726
		var next_ = prog_.getNextMD() - 1;
727
		var last_ = prog_.getNextMD() - 2;
728
		if (last_ == 0) {
729
			last_ = 1;
730
		}
731
		var currPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
732
		var _last = Ext.ComponentQuery.query('[itemId=MD' + last_ + ']')[0];
733
		currPage.setHidden(true);
734
		_last.setHidden(false);
735

    
736
		// set ulang next and prev page
737
		prog_.setNextMD(next_);
738
		prog_.setPrevMD(last_);
739
		this.setButton(_last);
740

    
741
	},
742
	skipAll: function () {
743
		var me = this;
744
		// if (Formheader.isValid()) {
745
		Ext.Msg.show({
746
			title: "",
747
			msg: MinovaMessageData('WD002', ''),
748
			buttons: Ext.Msg.YESNO,
749
			icon: Ext.Msg.QUESTION,
750
			fn: function (choice) {
751
				console.log(choice);
752
				if (choice === 'yes') {
753
					// me.saveMD();
754
					var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
755
					var page = 'wizards';
756
					if (prog_.wizardFunction.substring(0, 1) == "A") {
757
						page = 'rcwizards';
758
					}
759
					nextUrl = MinovaUtil.GetMenuID() + '&S=S';
760
					var mb = new minovaBlowfish();
761
					e = mb.minovaEncryptUrl(nextUrl);
762
					window.open(page + '?' + e, "_self");
763

    
764
				}
765

    
766
			}
767
		});
768

    
769
		// }
770

    
771
	},
772
	skipMd: function () {
773
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
774
		var next_ = prog_.getNextMD(); // id form selanjutnya
775
		var me = this;
776
		if (prog_.totalPage < next_) { // md form sudah selesai
777
			// run save data to md
778
			//me.saveToLoacalStorage();
779
			//if (Formheader.isValid()) {
780
			Ext.Msg.show({
781
				title: "",
782
				msg: MinovaMessageData('WD001', ''),
783
				buttons: Ext.Msg.YESNO,
784
				icon: Ext.Msg.QUESTION,
785
				fn: function (choice) {
786
					console.log(choice);
787
					if (choice === 'yes') {
788
						document.getElementById("progressbar").style.width = '100%';
789
						me.changeProgress(prog_.totalPage, next_, true)
790
						//me.saveMD();
791
						var page = 'wizards';
792
						if (prog_.wizardFunction.substring(0, 1) == "A") {
793
							page = 'rcwizards';
794
						}
795
						nextUrl = MinovaUtil.GetMenuID() + '&S=S';
796
						var mb = new minovaBlowfish();
797
						e = mb.minovaEncryptUrl(nextUrl);
798
						window.open(page + '?' + e, "_self");
799
					}
800

    
801
				}
802
			});
803

    
804
			// }
805

    
806
		} else {
807
			var lastHide = next_ - 1;
808
			var self_ = Ext.ComponentQuery.query('[itemId=MD' + lastHide + ']')[0]; // formm yang sedang activ
809
			var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
810
			if (nextPage.WizardLayout == 'F') {
811

    
812
				//formName = 'formWizard' + nextPage.tableName;
813
				formName = 'MinovaGridFormEdit' + nextPage.tableName;
814

    
815
				if (Ext.ComponentQuery.query('[name=' + formName + ']')[0].mandatory == '1') {
816
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
817
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
818
				} else {
819
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
820
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
821
				}
822

    
823
			} else {
824
				if (Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].mandatory) {
825
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
826
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
827

    
828
				} else {
829
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
830
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
831
				}
832
			}
833

    
834
			nextPage.setHidden(false);
835
			self_.setHidden(true);
836
			// set ulang next and prev page
837
			this.changeProgress(next_, next_ + 1, true);
838
			prog_.setNextMD(next_ + 1);
839
			prog_.setPrevMD(next_);
840
			total_ = ((next_ - 1) / prog_.totalPage) * 100;
841
			document.getElementById("progressbar").style.width = total_ + '%';
842
		}
843

    
844
	},
845
	selectionFormDisplay: function (me) {
846
		var data_ = JSON.parse(localStorage.getItem('selectionValues'));
847
		if (data_) {
848
			if (data_ != null) {
849
				me.getForm().setValues(data_);
850
			}
851
			if (data_.ApplicantID != "") {
852
				me.getForm().findField('EmployeeID').setValue(data_.ApplicantID);
853
			}
854
			me.getForm().findField('EmployeeID').setValue(getParam('id'))
855
		}
856

    
857
		if (getParam('wizard').substr(0, 1) == 'A') {
858

    
859
			if (getParam('app') != 'null') {
860
				me.getForm().findField('ApplicantID').setHidden(true)
861
				me.getForm().findField('EmployeeID').setFieldLabel('Employee ID');
862
			} else {
863
				setTimeout(function () {
864
					me.getForm().findField('EmployeeID').setFieldLabel('Applicant ID');
865
				}, 10);
866
				me.getForm().findField('ApplicantID').setHidden(false);
867
				me.getForm().findField('EmployeeID').setHidden(true)
868
			}
869
		} else {
870
			me.getForm().findField('EmployeeID').setFieldLabel('Employee ID');
871
			me.getForm().findField('ApplicantID').setHidden(true);
872
			me.getForm().findField('EmployeeID').setHidden(false)
873
		}
874

    
875
	},
876
	// funsi next dan save data
877
	saveWizardold: function () {
878
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
879
		var oldTableName = prog_.getTableName(); // nama table form yang sedang aktif
880
		var oldTableData = prog_.getTableData(); // nama table untuk data set value form yang sedang aktif
881
		var next_ = prog_.getNextMD(); // id form selanjutnya
882
		var me = this;
883
		if (prog_.totalPage < next_) { // md form sudah selesai
884
			// run save data to md
885
			//me.saveToLoacalStorage();
886
			//if (Formheader.isValid()) {
887
			Ext.Msg.show({
888
				title: "",
889
				msg: MinovaMessageData('WD001', ''),
890
				buttons: Ext.Msg.YESNO,
891
				icon: Ext.Msg.QUESTION,
892
				fn: function (choice) {
893
					console.log(choice);
894
					if (choice === 'yes') {
895
						document.getElementById("progressbar").style.width = '100%';
896
						me.changeProgress(prog_.totalPage, next_, false)
897
						me.saveMD();
898

    
899
					}
900

    
901
				}
902
			});
903

    
904
			//}
905

    
906
		} else {
907
			var lastHide = next_ - 1;
908
			var cekValid = true;
909
			var self_ = Ext.ComponentQuery.query('[itemId=MD' + lastHide + ']')[0]; // formm yang sedang activ
910
			var tableName = self_.tableName;
911
			var formName = undefined;
912
			var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
913

    
914
			if (self_.WizardLayout == 'F') {
915
				formName = 'MinovaGridFormEdit' + tableName;
916
				frmSelf = Ext.ComponentQuery.query('[name=' + formName + ']')[0];
917
				frmSelf.getForm().findField("EmployeeID").setValue(getParam('id'));
918
				cekValid = frmSelf.getForm().isValid();
919

    
920
			} else {
921

    
922
				gridPnl = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + tableName + ']')[0].mandatory;
923
				if (gridPnl == '1') {
924
					var storeGrid = Ext.StoreMgr.lookup(tableName + "WizardStore");
925
					var storeCount_ = storeGrid.getCount();
926
					if (storeCount_ > 0) {
927
						cekValid = true;
928
					} else {
929
						cekValid = false;
930
					}
931
				}
932

    
933
			}
934
			// disable button
935
			if (cekValid) {
936
				//me.saveToLoacalStorage();
937
				if (nextPage.mandatory == "1") {
938
					if (nextPage.nextMD == 1) {
939
						Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
940
						//Ext.ComponentQuery.query('[name=saveWizard]')[0].setDisabled(true);
941
						//Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setText("Finish")
942
						Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
943

    
944
					} else {
945
						Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
946
						Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
947

    
948
					}
949

    
950
				} else {
951
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
952
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
953
				}
954
				nextPage.setHidden(false);
955
				self_.skip_ = false;
956

    
957
				if (Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0]) {
958
					Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0].skip_ = false;
959
				}
960
				if (Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0]) {
961
					Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0].skip_ = false;
962
				}
963
				self_.setHidden(true);
964
				// set ulang next and prev page
965
				prog_.setNextMD(next_ + 1);
966
				prog_.setPrevMD(next_);
967

    
968
				//change progress bar
969
				total_ = ((next_ - 1) / prog_.totalPage) * 100;
970
				document.getElementById("progressbar").style.width = total_ + '%';
971
				var idx = next_ - 1;
972
				me.changeProgress(idx, next_, false);
973
				Ext.ComponentQuery.query('[name=prevWizard]')[0].setDisabled(false);
974
				var wzFunc = undefined
975
					//if (Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm().isValid()) {
976
					Ext.Ajax.request({
977
						async: false,
978
						method: 'POST',
979
						url: '/UserControl/GetStore',
980
						params: {
981
							tableName: 'PHRPAWIZMAIN',
982
							param: 'Wizard[equal]' + getParam('wizard')
983

    
984
						},
985
						success: function (response) {
986
							var results = Ext.decode(response.responseText);
987
							data_ = results.data[0];
988
							if (data_ != undefined) {
989
								wzFunc = data_.WizardFunction;
990
							}
991
						}
992
					});
993
				if (wzFunc == 'APPT') {
994
					if (nextPage.WizardLayout == "F") {
995
						var datatable = 'PHRRC' + nextPage.tableName.substring(5, 9);
996
						var nowDate = MinovaUtil.GetNowDate();
997
						var data_ = JSON.parse(localStorage.getItem(datatable));
998
						Ext.Ajax.request({
999
							async: false,
1000
							method: 'POST',
1001
							url: '/UserControl/GetStore',
1002
							params: {
1003
								tableName: datatable,
1004
								param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
1005

    
1006
							},
1007
							success: function (response) {
1008
								var results = Ext.decode(response.responseText);
1009
								dataForm = results.data[0];
1010
								var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0]
1011
									var form_ = _form.getForm();
1012
								form_.setValues(dataForm);
1013
								me.setValueFromParameter(_form);
1014
								var temData = JSON.parse(localStorage.getItem('selectionValues'));
1015

    
1016
								if (datatable == "phrpa0002" || datatable == "PHRPA0002") {
1017
									form_.findField('StartDate').setValue(temData.EffectiveDate);
1018
									form_.findField('CompanyID').setValue(temData.CompanyID);
1019
									form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
1020
									form_.findField('MovementReason').setValue(temData.Reason);
1021
								} else {
1022
									form_.findField('StartDate').setValue(temData.EffectiveDate);
1023
								}
1024
							}
1025
						});
1026
					} else {
1027
						tbl = 'PHRRC' + nextPage.tableName.substring(5, 9)
1028
							var data_ = JSON.parse(localStorage.getItem(tbl));
1029
						var dataForm = undefined;
1030
						var nowDate = MinovaUtil.GetNowDate()
1031

    
1032
							Ext.Ajax.request({
1033
								async: false,
1034
								method: 'POST',
1035
								url: '/UserControl/GetStore',
1036
								params: {
1037
									tableName: tbl,
1038
									param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
1039

    
1040
								},
1041
								success: function (response) {
1042
									var results = Ext.decode(response.responseText);
1043
									dataForm = results.data;
1044
									var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].getStore();
1045
									gridStore.loadData(Ext.decode(dataForm));
1046

    
1047
								}
1048
							});
1049
					}
1050

    
1051
				} else if (wzFunc != 'APPI' && wzFunc != 'EMPI' && wzFunc != 'APPT') {
1052
					var nowDate = MinovaUtil.GetNowDate();
1053
					if (nextPage.WizardLayout == "F") {
1054
						Ext.Ajax.request({
1055
							async: false,
1056
							method: 'POST',
1057
							url: '/UserControl/GetStore',
1058
							params: {
1059
								tableName: nextPage.tableName,
1060
								param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
1061

    
1062
							},
1063
							success: function (response) {
1064
								var results = Ext.decode(response.responseText);
1065
								dataForm = results.data[0];
1066
								var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0];
1067
								var form_ = _form.getForm();
1068
								form_.setValues(dataForm);
1069
								me.setValueFromParameter(_form);
1070
								var temData = JSON.parse(localStorage.getItem('selectionValues'));
1071
								form_.findField('StartDate').setValue(temData.StartDate)
1072
							}
1073
						});
1074
					} else {
1075
						Ext.Ajax.request({
1076
							async: false,
1077
							method: 'POST',
1078
							url: '/UserControl/GetStore',
1079
							params: {
1080
								tableName: nextPage.tableName,
1081
								param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
1082

    
1083
							},
1084
							success: function (response) {
1085
								var results = Ext.decode(response.responseText);
1086
								dataForm = results.data;
1087
								var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].getStore();
1088
								gridStore.loadData(Ext.decode(dataForm));
1089

    
1090
							}
1091
						});
1092
					}
1093
				} else {
1094
					//
1095
					var frm_ = "MinovaGridFormEdit";
1096
					if (nextPage.WizardLayout == "G") {
1097
						frm_ = "formGridWizard";
1098
					}
1099
					var form_ = Ext.ComponentQuery.query('[name=' + frm_ + nextPage.tableName + ']')[0];
1100
					var emp = form_.getForm().findField("EmployeeID");
1101
					var temData = JSON.parse(localStorage.getItem('selectionValues'));
1102
					form_.getForm().findField('StartDate').setValue(temData.StartDate)
1103
					if (emp) {
1104
						emp.setValue(getParam("id"));
1105

    
1106
					} else {
1107
						Ext.ComponentQuery.query('[name=' + frm_ + nextPage.tableName + ']')[0].getForm().findField("ApplicantID").setValue(getParam("id"))
1108
					}
1109
				}
1110

    
1111
				//} else {
1112
				//    // message jika form tidak valid
1113
				//}
1114

    
1115
			}
1116

    
1117
		}
1118
	},
1119
	// fungsi save data to md
1120
	saveMD: function () {
1121

    
1122
		var pnlProgress = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1123
		var mainWizard = Ext.ComponentQuery.query('[name=mainWizard]')[0];
1124
		mainWizard.mask('Loading...');
1125
		var allTable = pnlProgress.allTable;
1126
		var allData = pnlProgress.allData;
1127
		var wizardFunction = pnlProgress.wizardFunction;
1128
		// md 15 boleh diinput jika statusMD1=true dan statusMD2=true
1129
		var statusMD1 = false;
1130
		var statusMD2 = false;
1131
		var sukses = true;
1132
		var i = 0;
1133
		var data_ = undefined;
1134
		var skip_ = undefined; // only grid or form with skip property is false will be save to md
1135
		Ext.each(allData, function (rec) {
1136
			//console.log(tbl)
1137
			//var data_ = JSON.parse(localStorage.getItem(tbl));
1138
			var tbl_ = rec.TableName
1139
				if (wizardFunction == "APPT") {
1140
					if (tbl_.substring(0, 5) == 'PHRRC') {
1141
						tbl_ = 'PHRPA' + tbl_.substring(5, 9);
1142
					}
1143
				}
1144

    
1145
				i++;
1146
			if (rec.WizardLayout == 'F') { // jika layout form
1147
				var formname = "MinovaGridFormEdit" + tbl_;
1148
				var frm = Ext.ComponentQuery.query('[name=' + formname + ']')[0];
1149
				var validForm_ = Ext.ComponentQuery.query('[name=' + formname + ']')[0].getForm().isValid();
1150
				var formValues_ = frm.getValues();
1151
				// if (formValues_.EmployeeID == "") {
1152
				if (formValues_.EmployeeID == "") {
1153
					formValues_["EmployeeID"] = getParam('id');
1154
				}
1155
				//}
1156

    
1157
				if (wizardFunction == "APPT") {
1158
					formValues_["EmployeeID"] = getParam('id');
1159
				}
1160
				//var end_ = formValues_.EndDate;
1161
				//if (end_ == "") {
1162
				//    skip_ = true;
1163
				//}
1164
				if (validForm_) {
1165
					skip_ = false;
1166
				} else {
1167
					skip_ = true;
1168
				}
1169
				data_ = Ext.encode(formValues_);
1170

    
1171
			} else { // jika layout grid
1172
				var gridName = "MinovaGridFormGrid" + tbl_;
1173
				var grid_ = Ext.ComponentQuery.query('[name=' + gridName + ']')[0];
1174
				var gridStore = grid_.getStore();
1175

    
1176
				if (gridStore.count() > 0) {
1177
					data_ = Ext.encode(Ext.pluck(gridStore.data.items, 'data'));
1178
					skip_ = false;
1179
				} else {
1180
					skip_ = true;
1181
				}
1182

    
1183
			}
1184
			// run save
1185

    
1186
			if (skip_ == false && sukses == true) {
1187
				Ext.Ajax.request({
1188
					async: false,
1189
					method: 'POST',
1190
					url: '/Devt/SaveTable',
1191
					params: {
1192
						tableName: tbl_,
1193
						data: data_,
1194
						action: 0
1195
					},
1196
					waitMsg: 'Saving Data...',
1197
					success: function (response) {
1198
						var result = Ext.decode(response.responseText);
1199
						if (result.success) {
1200
							// MinovaMessage('Not Null', '000006', '', 'S');
1201
							sukses = true;
1202
						} else {
1203
							MinovaMessage('', '000005', result.message.text, 'E');
1204
							sukses = false;
1205
						}
1206
					},
1207
					failure: function (response) {
1208
						var result = Ext.decode(response.responseText);
1209
						MinovaMessage('', '000005', result.message.text, 'E');
1210
						sukses = false;
1211
					}
1212
				});
1213
			}
1214

    
1215
		});
1216

    
1217
		//save md 0015
1218
		if (wizardFunction == 'APPT' || wizardFunction == 'EMPI') {
1219
			ApplicantID = '';
1220
			if (wizardFunction == 'APPT') {
1221
				ApplicantID = getParam('app')
1222
			}
1223
			var date_ = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0002]')[0].getValues().StartDate;
1224
			data = {
1225
				EmployeeID: getParam('id'),
1226
				PaymentUpTo: '',
1227
				RetroDate: date_,
1228
				HiringDate: date_,
1229
				ApplicantID: ApplicantID,
1230
				CorrectStatus: ''
1231
			};
1232
			dataDelete = {
1233
				EmployeeID: getParam('id'),
1234
				PaymentUpTo: '',
1235
				RetroDate: '',
1236
				//HiringDate: date_,
1237
				ApplicantID: ApplicantID,
1238
				CorrectStatus: ''
1239
			};
1240
			data_ = Ext.encode(data);
1241
			dataDelete_ = Ext.encode(dataDelete);
1242

    
1243
			Ext.Ajax.request({
1244
				async: false,
1245
				method: 'POST',
1246
				url: '/Devt/SaveTable',
1247
				params: {
1248
					tableName: 'PHRPA0015',
1249
					data: data_,
1250
					action: 0
1251
				},
1252
				waitMsg: 'Saving Data...',
1253
				success: function (response) {
1254
					var result = Ext.decode(response.responseText);
1255
					if (result.success) {
1256
						MinovaMessage('Not Null', '000006', '', 'S');
1257
						sukses = true;
1258
					} else {
1259
						MinovaMessage('Not Null', '000005', result.message.text, 'E');
1260
						sukses = false;
1261
					}
1262
				},
1263
				failure: function (response) {
1264
					var result = Ext.decode(response.responseText);
1265
					sukses = false;
1266
				}
1267
			});
1268
		}
1269
		mainWizard.unmask();
1270
		if (sukses == true && allData.length == i) {
1271
			var page = 'wizards';
1272
			if (wizardFunction.substring(0, 1) == "A") {
1273
				page = 'rcwizards';
1274
			}
1275
			nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1276
			var mb = new minovaBlowfish();
1277
			e = mb.minovaEncryptUrl(nextUrl);
1278
			window.open(page + '?' + e, "_self");
1279
			//window.open(nextUrl, "_self");
1280
		}
1281

    
1282
	},
1283
	saveToLoacalStorage: function () {
1284
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1285
		var myID = prog_.getNextMD() - 1;
1286
		var self_ = Ext.ComponentQuery.query('[itemId=MD' + myID + ']')[0];
1287
		var tableName = self_.tableName;
1288
		var WizardLayout = self_.WizardLayout;
1289
		var valuesData = undefined;
1290
		var formName = undefined;
1291
		var mandatory = self_.mandatory
1292

    
1293
			if (WizardLayout == 'F') { // jika tipe layout form
1294
				formName = 'MinovaGridFormEdit' + tableName;
1295
				frm = Ext.ComponentQuery.query('form[name=' + formName + ']')[0].getForm();
1296
				if (frm.isValid()) { // cek semua field mandatory sudah diisi
1297
					valuesData = frm.getValues();
1298
				}
1299

    
1300
			} else { // jika tipe layout grid
1301
				formName = 'MinovaGridFormEdit' + tableName;
1302
				var storeGrid = Ext.StoreMgr.lookup(tableName + "WizardStore");
1303
				valuesData = Ext.encode(Ext.pluck(storeGrid.data.items, 'data'));
1304
			}
1305

    
1306
			//save to local storage
1307
			//localStorage.setItem(tableName, JSON.stringify(valuesData));
1308

    
1309
	},
1310
	setValueFromParameter: function (_form) {
1311
		// set value from wizard parameter
1312
		var wizardID = _form.Wizard;
1313
		var _tablename = _form.tableName;
1314
		var form_ = _form.getForm();
1315
		hasil = undefined;
1316
		Ext.Ajax.request({
1317
			async: false,
1318
			method: 'POST',
1319
			url: '/UserControl/GetStore',
1320
			params: {
1321
				tableName: 'PDSBS0010',
1322
				param: 'Wizard[=]' + wizardID + ',TableName[=]' + _tablename
1323
			},
1324
			success: function (response) {
1325
				var results = Ext.decode(response.responseText);
1326
				hasil = results.data;
1327
			}
1328
		});
1329

    
1330
		if (hasil.length > 0) {
1331
			var value_ = undefined;
1332
			Ext.each(hasil, function (rec) {
1333

    
1334
				if (rec.DefaultValue.substring(0, 2) == 'fn' && rec.FunctionCode != '') {
1335
					value_ = eval(rec.FunctionCode);
1336
				} else {
1337
					value_ = rec.DefaultValue;
1338
				}
1339
				if (form_.findField(rec.FieldName)) {
1340
					form_.findField(rec.FieldName).setValue(value_);
1341
				}
1342
			});
1343
		}
1344
		// set value from wizard parameter
1345
	},
1346
	saveWizard: function () {
1347
		var sukses = false;
1348
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1349
		var _self = prog_.getNextMD() - 1;
1350
		if (_self == 0) {
1351
			_self = 1;
1352
			prog_.setNextMD(2);
1353
		}
1354
		var self_ = Ext.ComponentQuery.query('[itemId=MD' + _self + ']')[0];
1355
		var type_ = self_.WizardLayout;
1356

    
1357
		if (type_ == 'F') { // form layout
1358
			if (self_.getForm().isValid()) {
1359
				this.saveForm(self_);
1360
			} else { // form not valid
1361

    
1362
			}
1363
		} else { // grid layout
1364
			var cekData = false;
1365
			storeCount = 0;
1366
			dataStore = undefined;
1367
			if (Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + self_.tableName + ']')[0]) {
1368
				dataStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + self_.tableName + ']')[0].getStore();
1369
				storeCount = dataStore.count();
1370
			} else {
1371

    
1372
				dataStore = Ext.StoreMgr.lookup("store" + self_.tableName);
1373
				storeCount = dataStore.count();
1374
			}
1375
			if (self_.mandatory == "1") {
1376

    
1377
				if (storeCount > 0) {
1378
					cekData = true;
1379
				} else {
1380
					cekData = false;
1381
					// mesaage
1382
				}
1383
			} else {
1384
				cekData = true;
1385
			}
1386
			//save grid data
1387
			if (storeCount > 0) {
1388
				sukses = true;
1389
				var dtTableSet = null;
1390
				Ext.Ajax.request({
1391
					async: false,
1392
					method: 'POST',
1393
					url: '/UserControl/GetStore',
1394
					params: {
1395
						tableName: 'SDATATABLEFIELD',
1396
						param: 'TableName[equal]' + self_.tableName + ',FormatRef[=]amountencrypt'
1397
						//param : 'TableName[equal]' + self_.tableName
1398
					},
1399
					success: function (response) {
1400
						var results = Ext.decode(response.responseText);
1401
						dtTableSet = results.data;
1402

    
1403
					}
1404
				})
1405
				for (var i = 0; i < storeCount; i++) {
1406
					dataSub = dataStore.data.items[i].data;
1407
					if (dataStore.data.items[i].data.Flag == '0') {
1408
						if (dtTableSet.length > 0) {
1409
							m = 0;
1410
							for (var m = 0; m < dtTableSet.length; m++) {
1411
								var valEnc = '';
1412
								var f = dtTableSet[m].FieldName;
1413
								eval('valEnc=dataSub.' + f)
1414
								if (valEnc != '') {
1415
									Ext.Ajax.request({
1416
										async: false,
1417
										method: 'POST',
1418
										url: '/Devt/DecryptData',
1419
										params: {
1420
											dt: valEnc
1421

    
1422
										},
1423
										success: function (response) {
1424
											var results = Ext.decode(response.responseText);
1425
											value = results.data;
1426
											eval('dataSub.' + f + '=' + value);
1427

    
1428
										}
1429

    
1430
									});
1431
								}
1432
							}
1433
						}
1434
						Ext.Ajax.request({
1435
							async: false,
1436
							method: 'POST',
1437
							url: '/Devt/SaveTable',
1438
							params: {
1439
								tableName: self_.tableName,
1440
								data: Ext.encode(dataSub),
1441
								action: 0
1442
							},
1443
							waitMsg: 'Saving Data...',
1444
							success: function (response) {
1445
								var result = Ext.decode(response.responseText);
1446
								if (result.success) {
1447
									// MinovaMessage('Not Null', '000006', '', 'S');
1448
									sukses = true;
1449
								} else {
1450
									MinovaMessage('', '000005', result.message.text, 'E');
1451
									sukses = false;
1452
								}
1453
							},
1454
							failure: function (response) {
1455
								var result = Ext.decode(response.responseText);
1456
								MinovaMessage('', '000005', result.message.text, 'E');
1457
								sukses = false;
1458
							}
1459
						});
1460
					}
1461

    
1462
				}
1463
				//send mail
1464
				if (sukses) {
1465
					var _param = {
1466
						serviceName: 'ERecruitmentAuthentication.asmx',
1467
						methodName: 'SendMailChangeMD',
1468
						parameter: 'TableName=' + self_.tableName + '&EmployeeID=' + dataStore.data.items[0].data.EmployeeID
1469

    
1470
					};
1471

    
1472
					//var results = null;
1473
					Ext.Ajax.request({
1474
						method: 'post',
1475
						type: 'ajax',
1476
						params: _param,
1477
						url: '/InvokeService/Invoke/',
1478
						loadMask: {
1479
							msg: 'please wait...'
1480
						},
1481
						success: function (response) {}
1482
					});
1483
				}
1484

    
1485
			}
1486
			if (cekData) {
1487
				prog_.sukses = true;
1488
				this.goNextMD(prog_, self_);
1489
				//change progress bar
1490
				total_ = ((prog_.getNextMD() - 1) / prog_.totalPage) * 100;
1491
				document.getElementById("progressbar").style.width = total_ + '%';
1492
				var idx = prog_.getNextMD() - 1;
1493
				this.changeProgress(idx, prog_.getNextMD(), false);
1494

    
1495
				prog_.setNextMD(prog_.getNextMD() + 1);
1496
				prog_.setPrevMD(prog_.getNextMD() - 1);
1497
			}
1498
			if (sukses == true || total_ == 100) {
1499
				if (_self == self_.nextMD) {
1500
					Ext.Msg.show({
1501
						title: "",
1502
						msg: MinovaMessageData('WD001', ''),
1503
						buttons: Ext.Msg.YESNO,
1504
						icon: Ext.Msg.QUESTION,
1505
						fn: function (choice) {
1506
							console.log(choice);
1507
							if (choice === 'yes') {
1508
								document.getElementById("progressbar").style.width = '100%';
1509
								if (sukses) {
1510
									var page = 'wizards';
1511
									if (prog_.wizardFunction.substring(0, 1) == "A") {
1512
										page = 'rcwizards';
1513
									}
1514
									nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1515
									var mb = new minovaBlowfish();
1516
									e = mb.minovaEncryptUrl(nextUrl);
1517
									window.open(page + '?' + e, "_self");
1518

    
1519
								}
1520
							}
1521

    
1522
						}
1523
					});
1524

    
1525
				}
1526
			}
1527

    
1528
		}
1529

    
1530
	},
1531
	saveForm: function (self_) {
1532
		var me = this;
1533
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1534
		var next_ = prog_.getNextMD(); // id form selanjutnya
1535
		var _self = prog_.getNextMD() - 1;
1536
		if (self_ == undefined) {
1537
			self_ = Ext.ComponentQuery.query('[itemId=MD' + _self + ']')[0]; // formm yang sedang activ
1538
		}
1539
		var data1 = undefined;
1540
		var data2 = undefined;
1541
		//cek apakah md PHRPA0001
1542
		var cekKtp = true;
1543
		var _tbl = self_.tableName.toLowerCase();
1544

    
1545
		//cek ktp
1546
		if (_tbl == 'phrpa0001' || _tbl == 'phrrc0001') {
1547
			Ext.Ajax.request({
1548
				async: false,
1549
				method: 'POST',
1550
				url: '/UserControl/GetStore',
1551
				params: {
1552
					tableName: 'PDSPAEMPIDCARD',
1553
					param: 'WizardFunction[equal]' + self_.WizardFunction + ',BirthDate[=]' + Ext.ComponentQuery.query('[name=BirthDate]')[0].getValue() + ',FullName[=]' + Ext.ComponentQuery.query('[name=FullName]')[0].getValue()
1554

    
1555
				},
1556
				success: function (response) {
1557
					var results = Ext.decode(response.responseText);
1558
					data_ = results.data;
1559
					if (data_ != undefined && data_.length > 0) {
1560
						var MsgParam = "";
1561
						Ext.each(data_, function (rec) {
1562
							MsgParam = MsgParam + ' Type  :  ' + rec.Type + ' ,  Company  :  ' + rec.Company + ' ,  Status  :  ' + rec.Status + ' ,  Reason  :  ' + rec.Reason
1563
						});
1564
						Ext.Msg.show({
1565
							title: "",
1566
							msg: MinovaMessageData('WIZRCIDCARD', ''),
1567
							buttons: Ext.Msg.YESNO,
1568
							icon: Ext.Msg.QUESTION,
1569
							fn: function (choice) {
1570
								console.log(choice);
1571
								if (choice === 'yes') {
1572

    
1573
									cekKtp = true;
1574
									if (cekKtp) {
1575
										if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1576
											if (_tbl == 'phrpa0001') {
1577
												// past
1578
												if (self_.getForm().isValid()) {
1579
													//change progress bar
1580
													total_ = ((next_ - 1) / prog_.totalPage) * 100;
1581
													document.getElementById("progressbar").style.width = total_ + '%';
1582
													var idx = next_ - 1;
1583
													me.changeProgress(idx, next_, false);
1584
													me.goNextMD(prog_, self_);
1585
													me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1586
													prog_.setNextMD(prog_.getNextMD() + 1);
1587
													prog_.setPrevMD(prog_.getNextMD() - 1);
1588
												} else { // jika form error
1589

    
1590
												}
1591
											} else {
1592
												// save data to md
1593
												if (self_.getForm().isValid()) {
1594
													if (_tbl == 'phrpa0002') {
1595

    
1596
														Ext.Ajax.request({
1597
															async: false,
1598
															method: 'POST',
1599
															url: '/UserControl/GetStore',
1600
															params: {
1601
																tableName: 'PDSPAWIZDEL',
1602
																param: getParam("id")
1603

    
1604
															},
1605
															waitMsg: 'Saving Data...',
1606
															success: function (response) {},
1607
															failure: function (response) {}
1608
														});
1609

    
1610
														formName = 'MinovaGridFormEditPHRPA0001';
1611
														data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1612
														var CreateDate = 'CreateDate';
1613
														var CreateDateValue = "";
1614
														var ChangeDate = 'ChangeDate';
1615
														var ChangeDateValue = "";
1616

    
1617
														data1[CreateDate] = CreateDateValue;
1618
														data1[ChangeDate] = ChangeDateValue;
1619
														data2 = self_.getForm().getValues();
1620
														data2[CreateDate] = CreateDateValue;
1621
														data2[ChangeDate] = ChangeDateValue;
1622
													} else {
1623
														data1 = self_.getForm().getValues();
1624
														var CreateDate = 'CreateDate';
1625
														var CreateDateValue = "";
1626
														var ChangeDate = 'ChangeDate';
1627
														var ChangeDateValue = "";
1628

    
1629
														data1[CreateDate] = CreateDateValue;
1630
														data1[ChangeDate] = ChangeDateValue;
1631
													}
1632

    
1633
													var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1634
													if (sukses) {
1635
														//change progress bar
1636
														total_ = ((next_ - 1) / prog_.totalPage) * 100;
1637
														document.getElementById("progressbar").style.width = total_ + '%';
1638
														var idx = next_ - 1;
1639
														me.changeProgress(idx, next_, false);
1640
														me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1641
														prog_.setNextMD(prog_.getNextMD() + 1);
1642
														prog_.setPrevMD(prog_.getNextMD() - 1);
1643
														me.goNextMD(prog_, self_);
1644

    
1645
													}
1646

    
1647
												} else { // jika form error
1648

    
1649
												}
1650
											}
1651
										} else {
1652
											data1 = self_.getForm().getValues();
1653
											//cek apakah form terakhir
1654
											if (prog_.totalPage < next_) { // md form sudah selesai
1655
												Ext.Msg.show({
1656
													title: "",
1657
													msg: MinovaMessageData('WD001', ''),
1658
													buttons: Ext.Msg.YESNO,
1659
													icon: Ext.Msg.QUESTION,
1660
													fn: function (choice) {
1661
														console.log(choice);
1662
														if (choice === 'yes') {
1663
															document.getElementById("progressbar").style.width = '100%';
1664

    
1665
															//me.saveDataToMD();
1666

    
1667
															var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1668
															if (sukses) {
1669
																var page = 'wizards';
1670
																if (prog_.wizardFunction.substring(0, 1) == "A") {
1671
																	page = 'rcwizards';
1672
																}
1673
																nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1674
																var mb = new minovaBlowfish();
1675
																e = mb.minovaEncryptUrl(nextUrl);
1676
																window.open(page + '?' + e, "_self");
1677

    
1678
															}
1679
														}
1680

    
1681
													}
1682
												});
1683
											} else {
1684
												var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1685
												if (sukses) {
1686
													//change progress bar
1687
													total_ = ((next_ - 1) / prog_.totalPage) * 100;
1688
													document.getElementById("progressbar").style.width = total_ + '%';
1689
													var idx = next_ - 1;
1690
													me.changeProgress(idx, next_, false);
1691
													me.goNextMD(prog_, self_);
1692
													me.setFormValuesAfterNext(self_.WizardFunction, prog_);
1693
													prog_.setNextMD(prog_.getNextMD() + 1);
1694
													prog_.setPrevMD(prog_.getNextMD() - 1);
1695

    
1696
												}
1697
											}
1698

    
1699
										}
1700

    
1701
									}
1702

    
1703
								}
1704

    
1705
							}
1706
						});
1707

    
1708
						/*MinovaMessageError(' Message ', ' WIZRCIDCARD ', MsgParam)*/
1709
					} else {
1710
						cekKtp = true;
1711
						if (cekKtp) {
1712
							if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1713
								if (_tbl == 'phrpa0001') {
1714
									// past
1715
									if (self_.getForm().isValid()) {
1716
										//change progress bar
1717
										total_ = ((next_ - 1) / prog_.totalPage) * 100;
1718
										document.getElementById("progressbar").style.width = total_ + '%';
1719
										var idx = next_ - 1;
1720
										me.changeProgress(idx, next_, false);
1721
										me.goNextMD(prog_, self_);
1722
										me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1723
										prog_.setNextMD(prog_.getNextMD() + 1);
1724
										prog_.setPrevMD(prog_.getNextMD() - 1);
1725
									} else { // jika form error
1726

    
1727
									}
1728
								} else {
1729
									// save data to md
1730
									if (self_.getForm().isValid()) {
1731
										if (_tbl == 'phrpa0002') {
1732

    
1733
											Ext.Ajax.request({
1734
												async: false,
1735
												method: 'POST',
1736
												url: '/UserControl/GetStore',
1737
												params: {
1738
													tableName: 'PDSPAWIZDEL',
1739
													param: getParam("id")
1740

    
1741
												},
1742
												waitMsg: 'Saving Data...',
1743
												success: function (response) {},
1744
												failure: function (response) {}
1745
											});
1746

    
1747
											formName = 'MinovaGridFormEditPHRPA0001';
1748
											data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1749
											var CreateDate = 'CreateDate';
1750
											var CreateDateValue = "";
1751
											var ChangeDate = 'ChangeDate';
1752
											var ChangeDateValue = "";
1753

    
1754
											data1[CreateDate] = CreateDateValue;
1755
											data1[ChangeDate] = ChangeDateValue;
1756
											data2 = self_.getForm().getValues();
1757
											data2[CreateDate] = CreateDateValue;
1758
											data2[ChangeDate] = ChangeDateValue;
1759
										} else {
1760
											data1 = self_.getForm().getValues();
1761
											var CreateDate = 'CreateDate';
1762
											var CreateDateValue = "";
1763
											var ChangeDate = 'ChangeDate';
1764
											var ChangeDateValue = "";
1765

    
1766
											data1[CreateDate] = CreateDateValue;
1767
											data1[ChangeDate] = ChangeDateValue;
1768
										}
1769

    
1770
										var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1771
										if (sukses) {
1772
											//change progress bar
1773
											total_ = ((next_ - 1) / prog_.totalPage) * 100;
1774
											document.getElementById("progressbar").style.width = total_ + '%';
1775
											var idx = next_ - 1;
1776
											me.changeProgress(idx, next_, false);
1777
											me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1778
											prog_.setNextMD(prog_.getNextMD() + 1);
1779
											prog_.setPrevMD(prog_.getNextMD() - 1);
1780
											me.goNextMD(prog_, self_);
1781

    
1782
										}
1783

    
1784
									} else { // jika form error
1785

    
1786
									}
1787
								}
1788
							} else {
1789
								data1 = self_.getForm().getValues();
1790
								//cek apakah form terakhir
1791
								if (prog_.totalPage < next_) { // md form sudah selesai
1792
									Ext.Msg.show({
1793
										title: "",
1794
										msg: MinovaMessageData('WD001', ''),
1795
										buttons: Ext.Msg.YESNO,
1796
										icon: Ext.Msg.QUESTION,
1797
										fn: function (choice) {
1798
											console.log(choice);
1799
											if (choice === 'yes') {
1800
												document.getElementById("progressbar").style.width = '100%';
1801

    
1802
												//me.saveDataToMD();
1803

    
1804
												var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1805
												if (sukses) {
1806
													var page = 'wizards';
1807
													if (prog_.wizardFunction.substring(0, 1) == "A") {
1808
														page = 'rcwizards';
1809
													}
1810
													nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1811
													var mb = new minovaBlowfish();
1812
													e = mb.minovaEncryptUrl(nextUrl);
1813
													window.open(page + '?' + e, "_self");
1814

    
1815
												}
1816
											}
1817

    
1818
										}
1819
									});
1820
								} else {
1821
									var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1822
									if (sukses) {
1823
										//change progress bar
1824
										total_ = ((next_ - 1) / prog_.totalPage) * 100;
1825
										document.getElementById("progressbar").style.width = total_ + '%';
1826
										var idx = next_ - 1;
1827
										me.changeProgress(idx, next_, false);
1828
										me.goNextMD(prog_, self_);
1829
										me.setFormValuesAfterNext(self_.WizardFunction, prog_);
1830
										prog_.setNextMD(prog_.getNextMD() + 1);
1831
										prog_.setPrevMD(prog_.getNextMD() - 1);
1832

    
1833
									}
1834
								}
1835

    
1836
							}
1837

    
1838
						}
1839
					}
1840
				}
1841
			});
1842
		} else {
1843
			cekKtp = true; ;
1844
			if (cekKtp) {
1845
				if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1846
					if (_tbl == 'phrpa0001') {
1847
						// past
1848
						if (self_.getForm().isValid()) {
1849
							//change progress bar
1850
							total_ = ((next_ - 1) / prog_.totalPage) * 100;
1851
							document.getElementById("progressbar").style.width = total_ + '%';
1852
							var idx = next_ - 1;
1853
							me.changeProgress(idx, next_, false);
1854
							me.goNextMD(prog_, self_);
1855
							me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1856
							prog_.setNextMD(prog_.getNextMD() + 1);
1857
							prog_.setPrevMD(prog_.getNextMD() - 1);
1858
						} else { // jika form error
1859

    
1860
						}
1861
					} else {
1862
						// save data to md
1863
						if (self_.getForm().isValid()) {
1864
							if (_tbl == 'phrpa0002') {
1865

    
1866
								Ext.Ajax.request({
1867
									async: false,
1868
									method: 'POST',
1869
									url: '/UserControl/GetStore',
1870
									params: {
1871
										tableName: 'PDSPAWIZDEL',
1872
										param: getParam("id")
1873

    
1874
									},
1875
									waitMsg: 'Saving Data...',
1876
									success: function (response) {},
1877
									failure: function (response) {}
1878
								});
1879

    
1880
								formName = 'MinovaGridFormEditPHRPA0001';
1881
								data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1882
								var CreateDate = 'CreateDate';
1883
								var CreateDateValue = "";
1884
								var ChangeDate = 'ChangeDate';
1885
								var ChangeDateValue = "";
1886

    
1887
								data1[CreateDate] = CreateDateValue;
1888
								data1[ChangeDate] = ChangeDateValue;
1889
								data2 = self_.getForm().getValues();
1890
								data2[CreateDate] = CreateDateValue;
1891
								data2[ChangeDate] = ChangeDateValue;
1892
							} else {
1893
								data1 = self_.getForm().getValues();
1894
								var CreateDate = 'CreateDate';
1895
								var CreateDateValue = "";
1896
								var ChangeDate = 'ChangeDate';
1897
								var ChangeDateValue = "";
1898

    
1899
								data1[CreateDate] = CreateDateValue;
1900
								data1[ChangeDate] = ChangeDateValue;
1901
							}
1902

    
1903
							var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1904
							if (sukses) {
1905
								//change progress bar
1906
								total_ = ((next_ - 1) / prog_.totalPage) * 100;
1907
								document.getElementById("progressbar").style.width = total_ + '%';
1908
								var idx = next_ - 1;
1909
								me.changeProgress(idx, next_, false);
1910
								me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1911
								prog_.setNextMD(prog_.getNextMD() + 1);
1912
								prog_.setPrevMD(prog_.getNextMD() - 1);
1913
								me.goNextMD(prog_, self_);
1914

    
1915
							}
1916

    
1917
						} else { // jika form error
1918

    
1919
						}
1920
					}
1921
				} else {
1922
					data1 = self_.getForm().getValues();
1923
					//cek apakah form terakhir
1924
					if (prog_.totalPage < next_) { // md form sudah selesai
1925
						Ext.Msg.show({
1926
							title: "",
1927
							msg: MinovaMessageData('WD001', ''),
1928
							buttons: Ext.Msg.YESNO,
1929
							icon: Ext.Msg.QUESTION,
1930
							fn: function (choice) {
1931
								console.log(choice);
1932
								if (choice === 'yes') {
1933
									document.getElementById("progressbar").style.width = '100%';
1934

    
1935
									//me.saveDataToMD();
1936

    
1937
									var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1938
									if (sukses) {
1939
										var page = 'wizards';
1940
										if (prog_.wizardFunction.substring(0, 1) == "A") {
1941
											page = 'rcwizards';
1942
										}
1943
										nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1944
										var mb = new minovaBlowfish();
1945
										e = mb.minovaEncryptUrl(nextUrl);
1946
										window.open(page + '?' + e, "_self");
1947

    
1948
									}
1949
								}
1950

    
1951
							}
1952
						});
1953
					} else {
1954
						var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1955
						if (sukses) {
1956
							//change progress bar
1957
							total_ = ((next_ - 1) / prog_.totalPage) * 100;
1958
							document.getElementById("progressbar").style.width = total_ + '%';
1959
							var idx = next_ - 1;
1960
							me.changeProgress(idx, next_, false);
1961
							me.goNextMD(prog_, self_);
1962
							me.setFormValuesAfterNext(self_.WizardFunction, prog_);
1963
							prog_.setNextMD(prog_.getNextMD() + 1);
1964
							prog_.setPrevMD(prog_.getNextMD() - 1);
1965

    
1966
						}
1967
					}
1968

    
1969
				}
1970

    
1971
			}
1972

    
1973
		}
1974

    
1975
	},
1976
	goNextMD: function (prog_, form_) {
1977
		var me = this;
1978
		var table_ = form_.tableName.toLowerCase();
1979
		var next_ = prog_.getNextMD() - 1; // id form selanjutnya
1980
		//var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1981
		/*
1982
		if (prog_.totalPage <= next_) { // md form sudah selesai
1983
		Ext.Msg.show({
1984
		title: "",
1985
		msg: MinovaMessageData('WD001', ''),
1986
		buttons: Ext.Msg.YESNO,
1987
		icon: Ext.Msg.QUESTION,
1988
		fn: function (choice) {
1989
		console.log(choice);
1990
		if (choice === 'yes') {
1991
		document.getElementById("progressbar").style.width = '100%';
1992

    
1993
		//me.saveDataToMD();
1994

    
1995
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1996
		var page = 'wizards';
1997
		if (prog_.wizardFunction.substring(0, 1) == "A") {
1998
		page = 'rcwizards';
1999
		}
2000
		nextUrl = page + '?' + MinovaUtil.GetMenuID() + '&S=S';
2001
		window.open(nextUrl, "_self");
2002
		}
2003

    
2004
		}
2005
		});
2006
		}
2007
		else
2008
		 */
2009
		{
2010
			var next_ = form_.nextMD;
2011
			var _me = next_ - 1;
2012
			var nextPage = Ext.ComponentQuery.query('[itemId=MD' + form_.nextMD + ']')[0];
2013
			var type_ = nextPage.WizardLayout;
2014

    
2015
			if (prog_.sukses == true) {
2016
				if (form_.nextMD != 1) {
2017
					//set value form or grid from md
2018
					hisTable = nextPage.tableName;
2019
					var nowDate = MinovaUtil.GetNowDate();
2020
					if (nextPage.WizardFunction == 'APPT') {
2021
						hisTable = "PHRRC" + hisTable.substring(5, 9);
2022
					}
2023
					if (nextPage.WizardLayout == 'G') {
2024
						var empID = getParam("app");
2025
						if (getParam('wizard').substring(0, 1) == 'E') {
2026
							empID = getParam('id');
2027
						}
2028
						var gridHis = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0];
2029
						dataForm = null;
2030
						Ext.Ajax.request({
2031
							//async: false,
2032
							method: 'POST',
2033
							url: '/UserControl/GetStore',
2034
							params: {
2035
								tableName: hisTable,
2036
								param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + empID
2037

    
2038
							},
2039
							success: function (response) {
2040
								var results = Ext.decode(response.responseText);
2041
								dataForm = results.data;
2042
								if (dataForm.length) {
2043
									Ext.each(dataForm, function (rec) {
2044
										rec["EmployeeID"] = getParam('id');
2045
										rec["Flag"] = '0';
2046
									});
2047
								}
2048
								if (gridHis) {
2049
									var gridStore = gridHis.getStore();
2050
									gridStore.loadData(dataForm);
2051
								} else {
2052
									var gridStore = Ext.StoreMgr.lookup("store" + nextPage.tableName);
2053
									gridStore.loadData(dataForm);
2054
								}
2055

    
2056
							}
2057
						});
2058

    
2059
					} else {
2060
						var form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0];
2061
					}
2062
					form_.setHidden(true);
2063
					nextPage.setHidden(false);
2064
					me.setButton(nextPage);
2065
				} else {
2066
					var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2067
					var page = 'wizards';
2068
					if (prog_.wizardFunction.substring(0, 1) == "A") {
2069
						page = 'rcwizards';
2070
					}
2071
					nextUrl = MinovaUtil.GetMenuID() + '&S=S';
2072
					var mb = new minovaBlowfish();
2073
					e = mb.minovaEncryptUrl(nextUrl);
2074
					window.open(page + '?' + e, "_self");
2075
				}
2076

    
2077
			} else if (table_ == 'phrpa0001' || table_ == 'phrpa0002') {
2078
				form_.setHidden(true);
2079
				nextPage.setHidden(false);
2080
				me.setButton(nextPage);
2081
			}
2082

    
2083
		}
2084
	},
2085
	saveDataToMD: function (tableName, data1, data2) {
2086
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2087
		var sukses = false;
2088
		var TblApp = tableName.toLowerCase().substring(0, 5);
2089
		if (getParam('wizard') == 'A900') {
2090
			var EmployeeID = 'EmployeeID';
2091
			var EmployeeIDValue = getParam('id');
2092
			data1[EmployeeID] = EmployeeIDValue;
2093
			if (data2 != undefined) {
2094
				var EmployeeID = 'EmployeeID';
2095
				var EmployeeIDValue = getParam('id');
2096
				data2[EmployeeID] = EmployeeIDValue;
2097
			}
2098
		}
2099

    
2100
		var CreateDate = 'CreateDate';
2101
		var CreateDateValue = "";
2102
		var ChangeDate = 'ChangeDate';
2103
		var ChangeDateValue = "";
2104
		data1[CreateDate] = CreateDateValue;
2105
		data1[ChangeDate] = ChangeDateValue;
2106
		if (data2 == undefined) {
2107

    
2108
			if (prog_.sukses = true || TblApp == 'phrrc') {
2109
				Ext.Ajax.request({
2110
					async: false,
2111
					method: 'POST',
2112
					url: '/Devt/SaveTable',
2113
					params: {
2114
						tableName: tableName,
2115
						data: Ext.encode(data1),
2116
						action: 0
2117
					},
2118
					waitMsg: 'Saving Data...',
2119
					success: function (response) {
2120
						var result = Ext.decode(response.responseText);
2121
						if (result.success) {
2122
							// MinovaMessage('Not Null', '000006', '', 'S');
2123
							sukses = true;
2124
							//send mail
2125
							var _param = {
2126
								serviceName: 'ERecruitmentAuthentication.asmx',
2127
								methodName: 'SendMailChangeMD',
2128
								parameter: 'TableName=' + tableName + '&EmployeeID=' + data1.EmployeeID
2129

    
2130
							};
2131

    
2132
							//var results = null;
2133
							Ext.Ajax.request({
2134
								method: 'post',
2135
								type: 'ajax',
2136
								params: _param,
2137
								url: '/InvokeService/Invoke/',
2138
								loadMask: {
2139
									msg: 'please wait...'
2140
								},
2141
								success: function (response) {}
2142
							});
2143
						} else {
2144
							MinovaMessage('', '000005', result.message.text, 'E');
2145
							sukses = false;
2146
						}
2147
					},
2148
					failure: function (response) {
2149
						var result = Ext.decode(response.responseText);
2150
						MinovaMessage('', '000005', result.message.text, 'E');
2151
						sukses = false;
2152
					}
2153
				});
2154
			} else {}
2155
		} else {
2156
			data2[CreateDate] = CreateDateValue;
2157
			data2[ChangeDate] = ChangeDateValue;
2158
			Ext.Ajax.request({
2159
				async: false,
2160
				method: 'POST',
2161
				url: '/Devt/SaveTable',
2162
				params: {
2163
					tableName: 'phrpa0001',
2164
					data: Ext.encode(data1),
2165
					action: 0
2166
				},
2167
				waitMsg: 'Saving Data...',
2168
				success: function (response) {
2169
					var result = Ext.decode(response.responseText);
2170
					if (result.success) {
2171
						// MinovaMessage('Not Null', '000006', '', 'S');
2172
						sukses = true;
2173
					} else {
2174
						MinovaMessage('', '000005', result.message.text, 'E');
2175
					}
2176
				},
2177
				failure: function (response) {
2178
					var result = Ext.decode(response.responseText);
2179
					MinovaMessage('', '000005', result.message.text, 'E');
2180
				}
2181
			});
2182
			if (sukses) {
2183
				Ext.Ajax.request({
2184
					async: false,
2185
					method: 'POST',
2186
					url: '/Devt/SaveTable',
2187
					params: {
2188
						tableName: 'PHRPA0002',
2189
						data: Ext.encode(data2),
2190
						action: 0
2191
					},
2192
					waitMsg: 'Saving Data...',
2193
					success: function (response) {
2194
						var result = Ext.decode(response.responseText);
2195
						if (result.success) {
2196
							// MinovaMessage('Not Null', '000006', '', 'S');
2197
							sukses = true;
2198
						} else {
2199
							MinovaMessage('', '000005', result.message.text, 'E');
2200
							sukses = false;
2201
						}
2202
					},
2203
					failure: function (response) {
2204
						var result = Ext.decode(response.responseText);
2205
						MinovaMessage('', '000005', result.message.text, 'E');
2206
					}
2207
				});
2208
			}
2209

    
2210
			//save md 15
2211
			var app = getParam('app');
2212
			if (app === "null") {
2213
				app = '';
2214
			}
2215
			var _date = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0002]')[0].getValues().StartDate;
2216
			data = {
2217
				EmployeeID: getParam('id'),
2218
				PaymentUpTo: '',
2219
				RetroDate: _date,
2220
				HiringDate: _date,
2221
				ApplicantID: app,
2222
				CorrectStatus: '1'
2223
			};
2224
			Ext.Ajax.request({
2225
				async: false,
2226
				method: 'POST',
2227
				url: '/Devt/SaveTable',
2228
				params: {
2229
					tableName: 'phrpa0015',
2230
					data: Ext.encode(data),
2231
					action: 0
2232
				},
2233
				waitMsg: 'Saving Data...',
2234
				success: function (response) {
2235
					var result = Ext.decode(response.responseText);
2236
					if (result.success) {
2237
						// MinovaMessage('Not Null', '000006', '', 'S');
2238
						sukses = true;
2239
					} else {
2240
						MinovaMessage('', '000005', result.message.text, 'E');
2241
						sukses = false;
2242
					}
2243
				},
2244
				failure: function (response) {
2245
					var result = Ext.decode(response.responseText);
2246
					MinovaMessage('', '000005', result.message.text, 'E');
2247
				}
2248
			});
2249

    
2250
		}
2251
		prog_.sukses = sukses;
2252
		return (sukses);
2253
	},
2254

    
2255
	setFormValuesAfterNext: function (WizardFunction, prog_) {
2256
		var nowDate = MinovaUtil.GetNowDate();
2257
		//var data_ = JSON.parse(localStorage.getItem(datatable));
2258
		var me = this;
2259
		var next_ = prog_.getNextMD()
2260

    
2261
			if (Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0]) {
2262
				var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
2263
				var type_ = nextPage.WizardLayout;
2264
				var tabl_ = nextPage.tableName;
2265
				switch (nextPage.WizardFunction) {
2266
				case "APP":
2267
					var tabl_ = nextPage.tableName;
2268
					me.getLastValue(tabl_, type_);
2269
					break
2270
				case "APPI":
2271

    
2272
					break
2273
				case "APPT":
2274
					var tabl_ = prog_.allTable[next_ - 1];
2275
					tbl_ = "PHRRC" + tabl_.substring(5, 9);
2276
					paData = "PHRPA" + tabl_.substring(5, 9);
2277
					me.getLastValueAPPT(tbl_, type_, paData);
2278
					break
2279
				case "EMP":
2280
					var tabl_ = nextPage.tableName;
2281
					me.getLastValue(tabl_, type_);
2282
					break
2283
				case "EMPI":
2284

    
2285
					break
2286
				default:
2287
					break
2288
				}
2289
				if (type_ == "F") {
2290
					me.setValueFromParameter(nextPage);
2291
				}
2292

    
2293
			}
2294
	},
2295

    
2296
	getLastValueAPPT: function (nextTable, type_, paData) {
2297
		var nowDate = MinovaUtil.GetNowDate();
2298
		if (type_ == "F") {
2299
			Ext.Ajax.request({
2300
				async: false,
2301
				method: 'POST',
2302
				url: '/UserControl/GetStore',
2303
				params: {
2304
					tableName: nextTable,
2305
					//param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
2306
					param: 'EmployeeID[=]' + getParam("app")
2307

    
2308
				},
2309
				success: function (response) {
2310
					var results = Ext.decode(response.responseText);
2311
					dataForm = results.data[0];
2312
					var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + paData + ']')[0]
2313
						var form_ = _form.getForm();
2314
					form_.setValues(dataForm);
2315
					var temData = JSON.parse(localStorage.getItem('selectionValues'));
2316

    
2317
					if (nextTable.toLowerCase == "phrpa0002") {
2318
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2319
						form_.findField('CompanyID').setValue(temData.CompanyID);
2320
						form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
2321
						form_.findField('MovementReason').setValue(temData.Reason);
2322
					} else {
2323
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2324
					}
2325
				}
2326
			});
2327
		} else {
2328
			Ext.Ajax.request({
2329
				async: false,
2330
				method: 'POST',
2331
				url: '/UserControl/GetStore',
2332
				params: {
2333
					tableName: nextTable,
2334
					param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2335

    
2336
				},
2337
				success: function (response) {
2338
					var results = Ext.decode(response.responseText);
2339
					var data_ = results.data;
2340
					var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + paData + ']')[0].getStore();
2341
					gridStore.loadData(data_);
2342

    
2343
				}
2344
			});
2345
		}
2346
	},
2347

    
2348
	getLastValue: function (nextTable, type_) {
2349
		var nowDate = MinovaUtil.GetNowDate();
2350
		if (type_ == "F") {
2351
			Ext.Ajax.request({
2352
				async: false,
2353
				method: 'POST',
2354
				url: '/UserControl/GetStore',
2355
				params: {
2356
					tableName: nextTable,
2357
					param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2358

    
2359
				},
2360
				success: function (response) {
2361
					var results = Ext.decode(response.responseText);
2362
					dataForm = results.data[0];
2363
					var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextTable + ']')[0]
2364
						var form_ = _form.getForm();
2365
					form_.setValues(dataForm);
2366
					var temData = JSON.parse(localStorage.getItem('selectionValues'));
2367

    
2368
					if (nextTable.toLowerCase == "phrpa0002") {
2369
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2370
						form_.findField('CompanyID').setValue(temData.CompanyID);
2371
						form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
2372
						form_.findField('MovementReason').setValue(temData.Reason);
2373
					} else {
2374
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2375
					}
2376
				}
2377
			});
2378
		} else {
2379
			Ext.Ajax.request({
2380
				async: false,
2381
				method: 'POST',
2382
				url: '/UserControl/GetStore',
2383
				params: {
2384
					tableName: nextTable,
2385
					param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2386

    
2387
				},
2388
				success: function (response) {
2389
					var results = Ext.decode(response.responseText);
2390
					var data_ = results.data;
2391
					var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextTable + ']')[0].getStore();
2392
					gridStore.loadData(data_);
2393

    
2394
				}
2395
			});
2396
		}
2397
	},
2398

    
2399
	setButton: function (nextPage) {
2400

    
2401
		prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2402
		id_ = parseInt(nextPage.itemId.substring(2, 3));
2403
		Ext.ComponentQuery.query('[name=prevWizard]')[0].setDisabled(false);
2404
		Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
2405
		Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
2406

    
2407
		if (nextPage.mandatory == "1") {
2408
			//if (nextPage.nextMD == 1) {
2409
			//    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2410
			//    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2411

    
2412
			//} else {
2413
			//    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2414
			//    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2415

    
2416
			//}
2417

    
2418
			Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2419
			Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2420

    
2421
		} else {
2422
			Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
2423
			Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
2424
		}
2425

    
2426
		if (id_ == prog_.totalPage) {
2427
			Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2428
			Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2429
		}
2430
	},
2431
	ChangeApp: function () {
2432
		Ext.Ajax.request({
2433
			async: false,
2434
			method: 'POST',
2435
			url: '/UserControl/GetStore',
2436
			params: {
2437
				tableName: "PHRRC0002",
2438
				param: 'StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',EmployeeID[=]' + Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue()
2439

    
2440
			},
2441
			success: function (response) {
2442
				var results = Ext.decode(response.responseText);
2443
				var data = results.data;
2444
				if (data != null && data.length > 0) {
2445
					var data_ = results.data[0];
2446
					Ext.ComponentQuery.query('[name=CompanyID]')[0].setValue(data_.CompanyID);
2447
				}
2448
			}
2449
		});
2450
	},
2451
});
    (1-1/1)