Project

General

Profile

Bug #1898 » wizard.js

Tri Rizqiaty, 01/04/2023 10:17 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
				var EffectiveMonthYear = selectionValues.EffectiveDate.substr(0, 4);
647
				var EffectiveMonth = selectionValues.EffectiveDate.substr(4, 2);
648
				var EffectiveMonthYear2 = EffectiveMonthYear + EffectiveMonth;
649
				var nextSeq = '';
650
				var act = '1';
651
				var data_ = undefined;
652
				
653
					//localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
654
									if (wzFunc == 'APPT') {
655
					/*Ext.Ajax.request({
656
					async: false,
657
					method: 'POST',
658
					url: '/UserControl/GetLastID?class_=E',
659

    
660
					success: function (response) {
661
					oldID = response.responseText;
662

    
663
					}
664
					});*/
665

    
666
					Ext.Ajax.request({
667
						async : false,
668
						method : 'POST',
669
						url : '/UserControl/GetStore',
670
						params : {
671
							tableName : 'GENERATEID',
672
							param : 'Year[=]' + EffectiveMonthYear
673
						},
674
						success : function (response) {
675
							var results = Ext.decode(response.responseText);
676
							data_ = results.data;
677
							if (data_.length == 0) {
678
								act = '0';
679
								nextSeq = '01';
680
								data_ = [{
681
										Year : EffectiveMonthYear,
682
										Sequence : nextSeq,
683
										Notes : "TEST NOTES"
684
									}
685
								];
686
							} else {
687
								if (isNaN(parseInt(data_[0].Sequence)) == false) {
688
									var s = "0" + (parseInt(data_[0].Sequence) + 1);
689
									nextSeq = s.substr(s.length - 4);
690
								} else {
691
									nextSeq = '01';
692
								}
693
								data_[0].Sequence = nextSeq;
694
							}
695
						}
696
					});
697

    
698
					oldID = EffectiveMonthYear2 + nextSeq;
699
					app_ = selectionValues.ApplicantID;
700

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

    
726
				} else if (wzFunc == 'EMPI') {
727
					/*Ext.Ajax.request({
728
					async: false,
729
					method: 'POST',
730
					url: '/UserControl/GetLastID?class_=E',
731

    
732
					success: function (response) {
733
					oldID = response.responseText;
734

    
735
					}
736
					});*/
737

    
738
					Ext.Ajax.request({
739
						async : false,
740
						method : 'POST',
741
						url : '/UserControl/GetStore',
742
						params : {
743
							tableName : 'GENERATEID',
744
							param : 'Year[=]' + EffectiveMonthYear
745
						},
746
						success : function (response) {
747
							var results = Ext.decode(response.responseText);
748
							data_ = results.data;
749
							if (data_.length == 0) {
750
								act = '0';
751
								nextSeq = '01';
752
								data_ = [{
753
										Year : EffectiveMonthYear,
754
										Sequence : nextSeq,
755
										Notes : "TEST NOTES"
756
									}
757
								];
758
							} else {
759
								if (isNaN(parseInt(data_[0].Sequence)) == false) {
760
									var datseq = data_[0].Sequence;
761
									if (datseq.length =='1'){
762
									var s = "0" + (parseInt(data_[0].Sequence) + 1);
763
									nextSeq = s.substr(s.length - 4);										
764
									}else{
765
									var s = "0" + (parseInt(data_[0].Sequence) + 1); //edit by Tri nwh 20230104
766
									nextSeq = s;										
767
									}
768

    
769

    
770
									
771
								} else {
772
									nextSeq = '01';
773
								}
774
								data_[0].Sequence = nextSeq;
775
							}
776
						}
777
					});
778

    
779
					oldID = EffectiveMonthYear2 + nextSeq;
780
					Ext.ComponentQuery.query('[name=EmployeeID]')[0].setValue(oldID);
781
					Ext.Ajax.request({
782
						method : 'POST',
783
						async : false,
784
						url : '/Devt/SaveTable',
785
						params : {
786
							tableName : 'GENERATEID',
787
							data : Ext.encode(data_[0]),
788
							action : act
789
						},
790
						waitMsg : 'Saving Data...',
791
						success : function (response) {
792
							var result = Ext.decode(response.responseText);
793
							console.log(result);
794
							if (result.success) {
795
								console.log('success');
796
							} else {
797
								console.log('not success');
798
							}
799
						},
800
						failure : function (response) {
801
							var result = Ext.decode(response.responseText);
802
							console.log(result);
803
						}
804
					});
805

    
806
				} else if (wzFunc == 'APPI') {
807
						Ext.Ajax.request({
808
							async : false,
809
							method : 'POST',
810
							url : '/UserControl/GetLastID?class_=A',
811

    
812
							success : function (response) {
813
								oldID = response.responseText;
814

    
815
							}
816
						});
817
						Ext.ComponentQuery.query('[name=ApplicantID]')[0].setValue(oldID)
818
					} else {
819
						if (selectionValues.ApplicantID) {
820
							oldID = selectionValues.ApplicantID;
821
						} else if (selectionValues.EmployeeID) {
822
							oldID = selectionValues.EmployeeID
823
						}
824
					}
825

    
826
					selectionValues = Ext.ComponentQuery.query('[name=selectionForm]')[0].getValues();
827
				var wiz = selectionValues.Action;
828
				if (wiz == '') {
829
					wiz = s.findRecord('WizardDescription', Ext.ComponentQuery.query('[name=Action]')[0].rawValue).data.Wizard;
830
				}
831
				localStorage.setItem('selectionValues', JSON.stringify(selectionValues));
832
				var nextUrl = MinovaUtil.GetMenuID() + '&wizard=' + wiz + '&id=' + oldID + '&app=' + app_;
833
				var mb = new minovaBlowfish();
834
				e = mb.minovaEncryptUrl(nextUrl);
835
				//if (wizFunc == 'APPI' || wizFunc == 'APPT')
836
				{
837
					var EmployeeID = oldID;
838
				}
839
				window.open('runwizards?' + e, "_self");
840
			}
841
		}
842

    
843
	},
844

    
845
	cekMsg : function () {
846
		formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
847
		formValues_ = formSelection.getValues();
848
		if (Ext.ComponentQuery.query('[name=Reason]')[0]) {
849
			Ext.ComponentQuery.query('[name=Reason]')[0].setHidden(true);
850
			formSelection.findField("PayrollGroup").setHidden(true);
851

    
852
		}
853
		var flag = getParam('S');
854
		if (flag == 'S') {
855
			MinovaMessage('', '000006', '', 'S');
856
		}
857
	},
858
	changeProgress : function (idx, idNext, skip) {
859
		//$("#stepStatus" + idx).removeClass("active");
860
		//$("#stepStatus" + idNext).addClass("active");
861
		if (skip) {
862
			//$("#checkStatus" + idx).addClass("fa fa-check");
863
		} else {
864
			$("#checkStatus" + idx).addClass("fa fa-check");
865
		}
866

    
867
	},
868
	cekPayrollStatus : function () {
869

    
870
		formSelection = Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm();
871
		if (formSelection.isValid()) {
872
			// cek payroll status by input payroll group
873
			formValues_ = formSelection.getValues();
874
			var result = undefined;
875
			if (formValues_.PayrollGroup != "") {
876
				Ext.Ajax.request({
877
					async : false,
878
					method : 'POST',
879
					url : '/UserControl/GetStore',
880
					params : {
881
						tableName : 'PHRPYPGCTRL',
882
						param : 'PayrollGroup[equal]' + formValues_.PayrollGroup
883

    
884
					},
885
					success : function (response) {
886
						var results = Ext.decode(response.responseText);
887
						data_ = results.data[0];
888
						if (data_ != undefined) {
889
							result = data_;
890
						}
891
					}
892
				});
893
			}
894
			var cek = true;
895
			if (result) {
896
				if (result.PayrollControlStatus == "V") {
897
					// massage corection
898
					cek = false;
899
				} else if (result.PayrollControlStatus == "S") {
900
					// massage corection
901
					cek = false;
902
				}
903

    
904
			}
905
			if (cek) {
906
				//var storeFlow = Ext.ComponentQuery.query('[name=processflow]')[0];
907
				//storeFlow.mask('Loading...');
908
				//var result_ = undefined;
909
				//Ext.Ajax.request({
910
				//    async: false,
911
				//    method: 'POST',
912
				//    url: '/UserControl/GetStore',
913
				//    params: {
914
				//        tableName: 'PDSPA0005',
915
				//        param: 'Wizard[equal]' + formValues_.Action
916

    
917
				//    },
918
				//    success: function (response) {
919
				//        var results = Ext.decode(response.responseText);
920
				//        data_ = results.data;
921
				//        if (data_ != undefined) {
922
				//            //result_ = data_;
923
				//            //sorting results
924
				//            result_ = data_.sort(MinovaUtil.SortBy("Sequence"))
925
				//        }
926
				//    }
927
				//});
928

    
929
				//storeFlow.getStore().loadData(result_);
930
				//storeFlow.unmask();
931
			}
932
		}
933
		//else {
934
		//    //masih ada field mandtory yang kosong
935
		//}
936
		return cek;
937
	},
938
	processflowGrid : function (g) {
939
		setTimeout(function () {
940
			var g_ = Ext.ComponentQuery.query('[name=processflow]')[0];
941
			g_.getStore().removeAll();
942
		}, 200);
943

    
944
	},
945
	// fungsi ke form sebelumnya
946
	prevWizard : function () {
947
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
948
		var next_ = prog_.getNextMD() - 1;
949
		var last_ = prog_.getNextMD() - 2;
950
		if (last_ == 0) {
951
			last_ = 1;
952
		}
953
		var currPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
954
		var _last = Ext.ComponentQuery.query('[itemId=MD' + last_ + ']')[0];
955
		currPage.setHidden(true);
956
		_last.setHidden(false);
957

    
958
		// set ulang next and prev page
959
		prog_.setNextMD(next_);
960
		prog_.setPrevMD(last_);
961
		this.setButton(_last);
962

    
963
	},
964
	skipAll : function () {
965
		var me = this;
966
		// if (Formheader.isValid()) {
967
		Ext.Msg.show({
968
			title : "",
969
			msg : MinovaMessageData('WD002', ''),
970
			buttons : Ext.Msg.YESNO,
971
			icon : Ext.Msg.QUESTION,
972
			fn : function (choice) {
973
				console.log(choice);
974
				if (choice === 'yes') {
975
					// me.saveMD();
976
					var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
977
					var page = 'wizards';
978
					if (prog_.wizardFunction.substring(0, 1) == "A") {
979
						page = 'rcwizards';
980
					}
981
					nextUrl = MinovaUtil.GetMenuID() + '&S=S';
982
					var mb = new minovaBlowfish();
983
					e = mb.minovaEncryptUrl(nextUrl);
984
					window.open(page + '?' + e, "_self");
985

    
986
				}
987

    
988
			}
989
		});
990

    
991
		// }
992

    
993
	},
994
	skipMd : function () {
995
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
996
		var next_ = prog_.getNextMD(); // id form selanjutnya
997
		var me = this;
998
		if (prog_.totalPage < next_) { // md form sudah selesai
999
			// run save data to md
1000
			//me.saveToLoacalStorage();
1001
			//if (Formheader.isValid()) {
1002
			Ext.Msg.show({
1003
				title : "",
1004
				msg : MinovaMessageData('WD001', ''),
1005
				buttons : Ext.Msg.YESNO,
1006
				icon : Ext.Msg.QUESTION,
1007
				fn : function (choice) {
1008
					console.log(choice);
1009
					if (choice === 'yes') {
1010
						document.getElementById("progressbar").style.width = '100%';
1011
						me.changeProgress(prog_.totalPage, next_, true)
1012
						//me.saveMD();
1013
						var page = 'wizards';
1014
						if (prog_.wizardFunction.substring(0, 1) == "A") {
1015
							page = 'rcwizards';
1016
						}
1017
						nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1018
						var mb = new minovaBlowfish();
1019
						e = mb.minovaEncryptUrl(nextUrl);
1020
						window.open(page + '?' + e, "_self");
1021
					}
1022

    
1023
				}
1024
			});
1025

    
1026
			// }
1027

    
1028
		} else {
1029
			var lastHide = next_ - 1;
1030
			var self_ = Ext.ComponentQuery.query('[itemId=MD' + lastHide + ']')[0]; // formm yang sedang activ
1031
			var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
1032
			if (nextPage.WizardLayout == 'F') {
1033

    
1034
				//formName = 'formWizard' + nextPage.tableName;
1035
				formName = 'MinovaGridFormEdit' + nextPage.tableName;
1036

    
1037
				if (Ext.ComponentQuery.query('[name=' + formName + ']')[0].mandatory == '1') {
1038
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
1039
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
1040
				} else {
1041
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
1042
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
1043
				}
1044

    
1045
			} else {
1046
				if (Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].mandatory) {
1047
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
1048
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
1049

    
1050
				} else {
1051
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
1052
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
1053
				}
1054
			}
1055

    
1056
			nextPage.setHidden(false);
1057
			self_.setHidden(true);
1058
			// set ulang next and prev page
1059
			this.changeProgress(next_, next_ + 1, true);
1060
			prog_.setNextMD(next_ + 1);
1061
			prog_.setPrevMD(next_);
1062
			total_ = ((next_ - 1) / prog_.totalPage) * 100;
1063
			document.getElementById("progressbar").style.width = total_ + '%';
1064
		}
1065

    
1066
	},
1067
	selectionFormDisplay : function (me) {
1068
		var data_ = JSON.parse(localStorage.getItem('selectionValues'));
1069
		if (data_) {
1070
			if (data_ != null) {
1071
				me.getForm().setValues(data_);
1072
			}
1073
			if (data_.ApplicantID != "") {
1074
				me.getForm().findField('EmployeeID').setValue(data_.ApplicantID);
1075
			}
1076
			me.getForm().findField('EmployeeID').setValue(getParam('id'))
1077
		}
1078

    
1079
		if (getParam('wizard').substr(0, 1) == 'A') {
1080

    
1081
			if (getParam('app') != 'null') {
1082
				me.getForm().findField('ApplicantID').setHidden(true)
1083
				me.getForm().findField('EmployeeID').setFieldLabel('Employee ID');
1084
			} else {
1085
				setTimeout(function () {
1086
					me.getForm().findField('EmployeeID').setFieldLabel('Applicant ID');
1087
				}, 10);
1088
				me.getForm().findField('ApplicantID').setHidden(false);
1089
				me.getForm().findField('EmployeeID').setHidden(true)
1090
			}
1091
		} else {
1092
			me.getForm().findField('EmployeeID').setFieldLabel('Employee ID');
1093
			me.getForm().findField('ApplicantID').setHidden(true);
1094
			me.getForm().findField('EmployeeID').setHidden(false)
1095
		}
1096

    
1097
	},
1098
	// funsi next dan save data
1099
	saveWizardold : function () {
1100
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1101
		var oldTableName = prog_.getTableName(); // nama table form yang sedang aktif
1102
		var oldTableData = prog_.getTableData(); // nama table untuk data set value form yang sedang aktif
1103
		var next_ = prog_.getNextMD(); // id form selanjutnya
1104
		var me = this;
1105
		if (prog_.totalPage < next_) { // md form sudah selesai
1106
			// run save data to md
1107
			//me.saveToLoacalStorage();
1108
			//if (Formheader.isValid()) {
1109
			Ext.Msg.show({
1110
				title : "",
1111
				msg : MinovaMessageData('WD001', ''),
1112
				buttons : Ext.Msg.YESNO,
1113
				icon : Ext.Msg.QUESTION,
1114
				fn : function (choice) {
1115
					console.log(choice);
1116
					if (choice === 'yes') {
1117
						document.getElementById("progressbar").style.width = '100%';
1118
						me.changeProgress(prog_.totalPage, next_, false)
1119
						me.saveMD();
1120

    
1121
					}
1122

    
1123
				}
1124
			});
1125

    
1126
			//}
1127

    
1128
		} else {
1129
			var lastHide = next_ - 1;
1130
			var cekValid = true;
1131
			var self_ = Ext.ComponentQuery.query('[itemId=MD' + lastHide + ']')[0]; // formm yang sedang activ
1132
			var tableName = self_.tableName;
1133
			var formName = undefined;
1134
			var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
1135

    
1136
			if (self_.WizardLayout == 'F') {
1137
				formName = 'MinovaGridFormEdit' + tableName;
1138
				frmSelf = Ext.ComponentQuery.query('[name=' + formName + ']')[0];
1139
				frmSelf.getForm().findField("EmployeeID").setValue(getParam('id'));
1140
				cekValid = frmSelf.getForm().isValid();
1141

    
1142
			} else {
1143

    
1144
				gridPnl = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + tableName + ']')[0].mandatory;
1145
				if (gridPnl == '1') {
1146
					var storeGrid = Ext.StoreMgr.lookup(tableName + "WizardStore");
1147
					var storeCount_ = storeGrid.getCount();
1148
					if (storeCount_ > 0) {
1149
						cekValid = true;
1150
					} else {
1151
						cekValid = false;
1152
					}
1153
				}
1154

    
1155
			}
1156
			// disable button
1157
			if (cekValid) {
1158
				//me.saveToLoacalStorage();
1159
				if (nextPage.mandatory == "1") {
1160
					if (nextPage.nextMD == 1) {
1161
						Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
1162
						//Ext.ComponentQuery.query('[name=saveWizard]')[0].setDisabled(true);
1163
						//Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setText("Finish")
1164
						Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
1165

    
1166
					} else {
1167
						Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
1168
						Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
1169

    
1170
					}
1171

    
1172
				} else {
1173
					Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
1174
					Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
1175
				}
1176
				nextPage.setHidden(false);
1177
				self_.skip_ = false;
1178

    
1179
				if (Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0]) {
1180
					Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0].skip_ = false;
1181
				}
1182
				if (Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0]) {
1183
					Ext.ComponentQuery.query('[name=' + "MinovaGridFormEdit" + self_.tableName + ']')[0].skip_ = false;
1184
				}
1185
				self_.setHidden(true);
1186
				// set ulang next and prev page
1187
				prog_.setNextMD(next_ + 1);
1188
				prog_.setPrevMD(next_);
1189

    
1190
				//change progress bar
1191
				total_ = ((next_ - 1) / prog_.totalPage) * 100;
1192
				document.getElementById("progressbar").style.width = total_ + '%';
1193
				var idx = next_ - 1;
1194
				me.changeProgress(idx, next_, false);
1195
				Ext.ComponentQuery.query('[name=prevWizard]')[0].setDisabled(false);
1196
				var wzFunc = undefined
1197
					//if (Ext.ComponentQuery.query('[name=selectionForm]')[0].getForm().isValid()) {
1198
					Ext.Ajax.request({
1199
						async : false,
1200
						method : 'POST',
1201
						url : '/UserControl/GetStore',
1202
						params : {
1203
							tableName : 'PHRPAWIZMAIN',
1204
							param : 'Wizard[equal]' + getParam('wizard')
1205

    
1206
						},
1207
						success : function (response) {
1208
							var results = Ext.decode(response.responseText);
1209
							data_ = results.data[0];
1210
							if (data_ != undefined) {
1211
								wzFunc = data_.WizardFunction;
1212
							}
1213
						}
1214
					});
1215
				if (wzFunc == 'APPT') {
1216
					if (nextPage.WizardLayout == "F") {
1217
						var datatable = 'PHRRC' + nextPage.tableName.substring(5, 9);
1218
						var nowDate = MinovaUtil.GetNowDate();
1219
						var data_ = JSON.parse(localStorage.getItem(datatable));
1220
						Ext.Ajax.request({
1221
							async : false,
1222
							method : 'POST',
1223
							url : '/UserControl/GetStore',
1224
							params : {
1225
								tableName : datatable,
1226
								param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
1227

    
1228
							},
1229
							success : function (response) {
1230
								var results = Ext.decode(response.responseText);
1231
								dataForm = results.data[0];
1232
								var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0]
1233
									var form_ = _form.getForm();
1234
								form_.setValues(dataForm);
1235
								me.setValueFromParameter(_form);
1236
								var temData = JSON.parse(localStorage.getItem('selectionValues'));
1237

    
1238
								if (datatable == "phrpa0002" || datatable == "PHRPA0002") {
1239
									form_.findField('StartDate').setValue(temData.EffectiveDate);
1240
									form_.findField('CompanyID').setValue(temData.CompanyID);
1241
									form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
1242
									form_.findField('MovementReason').setValue(temData.Reason);
1243
								} else {
1244
									form_.findField('StartDate').setValue(temData.EffectiveDate);
1245
								}
1246
							}
1247
						});
1248
					} else {
1249
						tbl = 'PHRRC' + nextPage.tableName.substring(5, 9)
1250
							var data_ = JSON.parse(localStorage.getItem(tbl));
1251
						var dataForm = undefined;
1252
						var nowDate = MinovaUtil.GetNowDate()
1253

    
1254
							Ext.Ajax.request({
1255
								async : false,
1256
								method : 'POST',
1257
								url : '/UserControl/GetStore',
1258
								params : {
1259
									tableName : tbl,
1260
									param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
1261

    
1262
								},
1263
								success : function (response) {
1264
									var results = Ext.decode(response.responseText);
1265
									dataForm = results.data;
1266
									var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].getStore();
1267
									gridStore.loadData(Ext.decode(dataForm));
1268

    
1269
								}
1270
							});
1271
					}
1272

    
1273
				} else if (wzFunc != 'APPI' && wzFunc != 'EMPI' && wzFunc != 'APPT') {
1274
					var nowDate = MinovaUtil.GetNowDate();
1275
					if (nextPage.WizardLayout == "F") {
1276
						Ext.Ajax.request({
1277
							async : false,
1278
							method : 'POST',
1279
							url : '/UserControl/GetStore',
1280
							params : {
1281
								tableName : nextPage.tableName,
1282
								param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
1283

    
1284
							},
1285
							success : function (response) {
1286
								var results = Ext.decode(response.responseText);
1287
								dataForm = results.data[0];
1288
								var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0];
1289
								var form_ = _form.getForm();
1290
								form_.setValues(dataForm);
1291
								me.setValueFromParameter(_form);
1292
								var temData = JSON.parse(localStorage.getItem('selectionValues'));
1293
								form_.findField('StartDate').setValue(temData.StartDate)
1294
							}
1295
						});
1296
					} else {
1297
						Ext.Ajax.request({
1298
							async : false,
1299
							method : 'POST',
1300
							url : '/UserControl/GetStore',
1301
							params : {
1302
								tableName : nextPage.tableName,
1303
								param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
1304

    
1305
							},
1306
							success : function (response) {
1307
								var results = Ext.decode(response.responseText);
1308
								dataForm = results.data;
1309
								var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0].getStore();
1310
								gridStore.loadData(Ext.decode(dataForm));
1311

    
1312
							}
1313
						});
1314
					}
1315
				} else {
1316
					//
1317
					var frm_ = "MinovaGridFormEdit";
1318
					if (nextPage.WizardLayout == "G") {
1319
						frm_ = "formGridWizard";
1320
					}
1321
					var form_ = Ext.ComponentQuery.query('[name=' + frm_ + nextPage.tableName + ']')[0];
1322
					var emp = form_.getForm().findField("EmployeeID");
1323
					var temData = JSON.parse(localStorage.getItem('selectionValues'));
1324
					form_.getForm().findField('StartDate').setValue(temData.StartDate)
1325
					if (emp) {
1326
						emp.setValue(getParam("id"));
1327

    
1328
					} else {
1329
						Ext.ComponentQuery.query('[name=' + frm_ + nextPage.tableName + ']')[0].getForm().findField("ApplicantID").setValue(getParam("id"))
1330
					}
1331
				}
1332

    
1333
				//} else {
1334
				//    // message jika form tidak valid
1335
				//}
1336

    
1337
			}
1338

    
1339
		}
1340
	},
1341
	// fungsi save data to md
1342
	saveMD : function () {
1343

    
1344
		var pnlProgress = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1345
		var mainWizard = Ext.ComponentQuery.query('[name=mainWizard]')[0];
1346
		mainWizard.mask('Loading...');
1347
		var allTable = pnlProgress.allTable;
1348
		var allData = pnlProgress.allData;
1349
		var wizardFunction = pnlProgress.wizardFunction;
1350
		// md 15 boleh diinput jika statusMD1=true dan statusMD2=true
1351
		var statusMD1 = false;
1352
		var statusMD2 = false;
1353
		var sukses = true;
1354
		var i = 0;
1355
		var data_ = undefined;
1356
		var skip_ = undefined; // only grid or form with skip property is false will be save to md
1357
		Ext.each(allData, function (rec) {
1358
			//console.log(tbl)
1359
			//var data_ = JSON.parse(localStorage.getItem(tbl));
1360
			var tbl_ = rec.TableName
1361
				if (wizardFunction == "APPT") {
1362
					if (tbl_.substring(0, 5) == 'PHRRC') {
1363
						tbl_ = 'PHRPA' + tbl_.substring(5, 9);
1364
					}
1365
				}
1366

    
1367
				i++;
1368
			if (rec.WizardLayout == 'F') { // jika layout form
1369
				var formname = "MinovaGridFormEdit" + tbl_;
1370
				var frm = Ext.ComponentQuery.query('[name=' + formname + ']')[0];
1371
				var validForm_ = Ext.ComponentQuery.query('[name=' + formname + ']')[0].getForm().isValid();
1372
				var formValues_ = frm.getValues();
1373
				// if (formValues_.EmployeeID == "") {
1374
				if (formValues_.EmployeeID == "") {
1375
					formValues_["EmployeeID"] = getParam('id');
1376
				}
1377
				//}
1378

    
1379
				if (wizardFunction == "APPT") {
1380
					formValues_["EmployeeID"] = getParam('id');
1381
				}
1382
				//var end_ = formValues_.EndDate;
1383
				//if (end_ == "") {
1384
				//    skip_ = true;
1385
				//}
1386
				if (validForm_) {
1387
					skip_ = false;
1388
				} else {
1389
					skip_ = true;
1390
				}
1391
				data_ = Ext.encode(formValues_);
1392

    
1393
			} else { // jika layout grid
1394
				var gridName = "MinovaGridFormGrid" + tbl_;
1395
				var grid_ = Ext.ComponentQuery.query('[name=' + gridName + ']')[0];
1396
				var gridStore = grid_.getStore();
1397

    
1398
				if (gridStore.count() > 0) {
1399
					data_ = Ext.encode(Ext.pluck(gridStore.data.items, 'data'));
1400
					skip_ = false;
1401
				} else {
1402
					skip_ = true;
1403
				}
1404

    
1405
			}
1406
			// run save
1407

    
1408
			if (skip_ == false && sukses == true) {
1409
				Ext.Ajax.request({
1410
					async : false,
1411
					method : 'POST',
1412
					url : '/Devt/SaveTable',
1413
					params : {
1414
						tableName : tbl_,
1415
						data : data_,
1416
						action : 0
1417
					},
1418
					waitMsg : 'Saving Data...',
1419
					success : function (response) {
1420
						var result = Ext.decode(response.responseText);
1421
						if (result.success) {
1422
							// MinovaMessage('Not Null', '000006', '', 'S');
1423
							sukses = true;
1424
						} else {
1425
							MinovaMessage('', '000005', result.message.text, 'E');
1426
							sukses = false;
1427
						}
1428
					},
1429
					failure : function (response) {
1430
						var result = Ext.decode(response.responseText);
1431
						MinovaMessage('', '000005', result.message.text, 'E');
1432
						sukses = false;
1433
					}
1434
				});
1435
			}
1436

    
1437
		});
1438

    
1439
		//save md 0015
1440
		if (wizardFunction == 'APPT' || wizardFunction == 'EMPI') {
1441
			ApplicantID = '';
1442
			if (wizardFunction == 'APPT') {
1443
				ApplicantID = getParam('app')
1444
			}
1445
			var date_ = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0002]')[0].getValues().StartDate;
1446
			data = {
1447
				EmployeeID : getParam('id'),
1448
				PaymentUpTo : '',
1449
				RetroDate : date_,
1450
				HiringDate : date_,
1451
				ApplicantID : ApplicantID,
1452
				CorrectStatus : ''
1453
			};
1454
			dataDelete = {
1455
				EmployeeID : getParam('id'),
1456
				PaymentUpTo : '',
1457
				RetroDate : '',
1458
				//HiringDate: date_,
1459
				ApplicantID : ApplicantID,
1460
				CorrectStatus : ''
1461
			};
1462
			data_ = Ext.encode(data);
1463
			dataDelete_ = Ext.encode(dataDelete);
1464

    
1465
			Ext.Ajax.request({
1466
				async : false,
1467
				method : 'POST',
1468
				url : '/Devt/SaveTable',
1469
				params : {
1470
					tableName : 'PHRPA0015',
1471
					data : data_,
1472
					action : 0
1473
				},
1474
				waitMsg : 'Saving Data...',
1475
				success : function (response) {
1476
					var result = Ext.decode(response.responseText);
1477
					if (result.success) {
1478
						MinovaMessage('Not Null', '000006', '', 'S');
1479
						sukses = true;
1480
					} else {
1481
						MinovaMessage('Not Null', '000005', result.message.text, 'E');
1482
						sukses = false;
1483
					}
1484
				},
1485
				failure : function (response) {
1486
					var result = Ext.decode(response.responseText);
1487
					sukses = false;
1488
				}
1489
			});
1490
		}
1491
		mainWizard.unmask();
1492
		if (sukses == true && allData.length == i) {
1493
			var page = 'wizards';
1494
			if (wizardFunction.substring(0, 1) == "A") {
1495
				page = 'rcwizards';
1496
			}
1497
			nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1498
			var mb = new minovaBlowfish();
1499
			e = mb.minovaEncryptUrl(nextUrl);
1500
			window.open(page + '?' + e, "_self");
1501
			//window.open(nextUrl, "_self");
1502
		}
1503

    
1504
	},
1505
	saveToLoacalStorage : function () {
1506
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1507
		var myID = prog_.getNextMD() - 1;
1508
		var self_ = Ext.ComponentQuery.query('[itemId=MD' + myID + ']')[0];
1509
		var tableName = self_.tableName;
1510
		var WizardLayout = self_.WizardLayout;
1511
		var valuesData = undefined;
1512
		var formName = undefined;
1513
		var mandatory = self_.mandatory
1514

    
1515
			if (WizardLayout == 'F') { // jika tipe layout form
1516
				formName = 'MinovaGridFormEdit' + tableName;
1517
				frm = Ext.ComponentQuery.query('form[name=' + formName + ']')[0].getForm();
1518
				if (frm.isValid()) { // cek semua field mandatory sudah diisi
1519
					valuesData = frm.getValues();
1520
				}
1521

    
1522
			} else { // jika tipe layout grid
1523
				formName = 'MinovaGridFormEdit' + tableName;
1524
				var storeGrid = Ext.StoreMgr.lookup(tableName + "WizardStore");
1525
				valuesData = Ext.encode(Ext.pluck(storeGrid.data.items, 'data'));
1526
			}
1527

    
1528
			//save to local storage
1529
			//localStorage.setItem(tableName, JSON.stringify(valuesData));
1530

    
1531
	},
1532
	setValueFromParameter : function (_form) {
1533
		// set value from wizard parameter
1534
		var wizardID = _form.Wizard;
1535
		var _tablename = _form.tableName;
1536
		var form_ = _form.getForm();
1537
		hasil = undefined;
1538
		Ext.Ajax.request({
1539
			async : false,
1540
			method : 'POST',
1541
			url : '/UserControl/GetStore',
1542
			params : {
1543
				tableName : 'PDSBS0010',
1544
				param : 'Wizard[=]' + wizardID + ',TableName[=]' + _tablename
1545
			},
1546
			success : function (response) {
1547
				var results = Ext.decode(response.responseText);
1548
				hasil = results.data;
1549
			}
1550
		});
1551

    
1552
		if (hasil.length > 0) {
1553
			var value_ = undefined;
1554
			Ext.each(hasil, function (rec) {
1555

    
1556
				if (rec.DefaultValue.substring(0, 2) == 'fn' && rec.FunctionCode != '') {
1557
					value_ = eval(rec.FunctionCode);
1558
				} else {
1559
					value_ = rec.DefaultValue;
1560
				}
1561
				if (form_.findField(rec.FieldName)) {
1562
					form_.findField(rec.FieldName).setValue(value_);
1563
				}
1564
			});
1565
		}
1566
		// set value from wizard parameter
1567
	},
1568
	saveWizard : function () {
1569
		var sukses = false;
1570
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1571
		var _self = prog_.getNextMD() - 1;
1572
		if (_self == 0) {
1573
			_self = 1;
1574
			prog_.setNextMD(2);
1575
		}
1576
		var self_ = Ext.ComponentQuery.query('[itemId=MD' + _self + ']')[0];
1577
		var type_ = self_.WizardLayout;
1578

    
1579
		if (type_ == 'F') { // form layout
1580
			if (self_.getForm().isValid()) {
1581
				this.saveForm(self_);
1582
			} else { // form not valid
1583

    
1584
			}
1585
		} else { // grid layout
1586
			var cekData = false;
1587
			storeCount = 0;
1588
			dataStore = undefined;
1589
			if (Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + self_.tableName + ']')[0]) {
1590
				dataStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + self_.tableName + ']')[0].getStore();
1591
				storeCount = dataStore.count();
1592
			} else {
1593

    
1594
				dataStore = Ext.StoreMgr.lookup("store" + self_.tableName);
1595
				storeCount = dataStore.count();
1596
			}
1597
			if (self_.mandatory == "1") {
1598

    
1599
				if (storeCount > 0) {
1600
					cekData = true;
1601
				} else {
1602
					cekData = false;
1603
					// mesaage
1604
				}
1605
			} else {
1606
				cekData = true;
1607
			}
1608
			//save grid data
1609
			if (storeCount > 0) {
1610
				sukses = true;
1611
				var dtTableSet = null;
1612
				Ext.Ajax.request({
1613
					async : false,
1614
					method : 'POST',
1615
					url : '/UserControl/GetStore',
1616
					params : {
1617
						tableName : 'SDATATABLEFIELD',
1618
						param : 'TableName[equal]' + self_.tableName + ',FormatRef[=]amountencrypt'
1619
						//param : 'TableName[equal]' + self_.tableName
1620
					},
1621
					success : function (response) {
1622
						var results = Ext.decode(response.responseText);
1623
						dtTableSet = results.data;
1624

    
1625
					}
1626
				})
1627
				for (var i = 0; i < storeCount; i++) {
1628
					dataSub = dataStore.data.items[i].data;
1629
					if (dataStore.data.items[i].data.Flag == '0') {
1630
						if (dtTableSet.length > 0) {
1631
							m = 0;
1632
							for (var m = 0; m < dtTableSet.length; m++) {
1633
								var valEnc = '';
1634
								var f = dtTableSet[m].FieldName;
1635
								eval('valEnc=dataSub.' + f)
1636
								if (valEnc != '') {
1637
									Ext.Ajax.request({
1638
										async : false,
1639
										method : 'POST',
1640
										url : '/Devt/DecryptData',
1641
										params : {
1642
											dt : valEnc
1643

    
1644
										},
1645
										success : function (response) {
1646
											var results = Ext.decode(response.responseText);
1647
											value = results.data;
1648
											eval('dataSub.' + f + '=' + value);
1649

    
1650
										}
1651

    
1652
									});
1653
								}
1654
							}
1655
						}
1656
						Ext.Ajax.request({
1657
							async : false,
1658
							method : 'POST',
1659
							url : '/Devt/SaveTable',
1660
							params : {
1661
								tableName : self_.tableName,
1662
								data : Ext.encode(dataSub),
1663
								action : 0
1664
							},
1665
							waitMsg : 'Saving Data...',
1666
							success : function (response) {
1667
								var result = Ext.decode(response.responseText);
1668
								if (result.success) {
1669
									// MinovaMessage('Not Null', '000006', '', 'S');
1670
									sukses = true;
1671
								} else {
1672
									MinovaMessage('', '000005', result.message.text, 'E');
1673
									sukses = false;
1674
								}
1675
							},
1676
							failure : function (response) {
1677
								var result = Ext.decode(response.responseText);
1678
								MinovaMessage('', '000005', result.message.text, 'E');
1679
								sukses = false;
1680
							}
1681
						});
1682
					}
1683

    
1684
				}
1685
				//send mail
1686
				if (sukses) {
1687
					var _param = {
1688
						serviceName : 'ERecruitmentAuthentication.asmx',
1689
						methodName : 'SendMailChangeMD',
1690
						parameter : 'TableName=' + self_.tableName + '&EmployeeID=' + dataStore.data.items[0].data.EmployeeID
1691

    
1692
					};
1693

    
1694
					//var results = null;
1695
					Ext.Ajax.request({
1696
						method : 'post',
1697
						type : 'ajax',
1698
						params : _param,
1699
						url : '/InvokeService/Invoke/',
1700
						loadMask : {
1701
							msg : 'please wait...'
1702
						},
1703
						success : function (response) {}
1704
					});
1705
				}
1706

    
1707
			}
1708
			if (cekData) {
1709
				prog_.sukses = true;
1710
				this.goNextMD(prog_, self_);
1711
				//change progress bar
1712
				total_ = ((prog_.getNextMD() - 1) / prog_.totalPage) * 100;
1713
				document.getElementById("progressbar").style.width = total_ + '%';
1714
				var idx = prog_.getNextMD() - 1;
1715
				this.changeProgress(idx, prog_.getNextMD(), false);
1716

    
1717
				prog_.setNextMD(prog_.getNextMD() + 1);
1718
				prog_.setPrevMD(prog_.getNextMD() - 1);
1719
			}
1720
			if (sukses == true || total_ == 100) {
1721
				if (_self == self_.nextMD) {
1722
					Ext.Msg.show({
1723
						title : "",
1724
						msg : MinovaMessageData('WD001', ''),
1725
						buttons : Ext.Msg.YESNO,
1726
						icon : Ext.Msg.QUESTION,
1727
						fn : function (choice) {
1728
							console.log(choice);
1729
							if (choice === 'yes') {
1730
								document.getElementById("progressbar").style.width = '100%';
1731
								if (sukses) {
1732
									var page = 'wizards';
1733
									if (prog_.wizardFunction.substring(0, 1) == "A") {
1734
										page = 'rcwizards';
1735
									}
1736
									nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1737
									var mb = new minovaBlowfish();
1738
									e = mb.minovaEncryptUrl(nextUrl);
1739
									window.open(page + '?' + e, "_self");
1740

    
1741
								}
1742
							}
1743

    
1744
						}
1745
					});
1746

    
1747
				}
1748
			}
1749

    
1750
		}
1751

    
1752
	},
1753
	saveForm : function (self_) {
1754
		var me = this;
1755
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
1756
		var next_ = prog_.getNextMD(); // id form selanjutnya
1757
		var _self = prog_.getNextMD() - 1;
1758
		if (self_ == undefined) {
1759
			self_ = Ext.ComponentQuery.query('[itemId=MD' + _self + ']')[0]; // formm yang sedang activ
1760
		}
1761
		var data1 = undefined;
1762
		var data2 = undefined;
1763
		//cek apakah md PHRPA0001
1764
		var cekKtp = true;
1765
		var _tbl = self_.tableName.toLowerCase();
1766

    
1767
		//cek ktp
1768
		if (_tbl == 'phrpa0001' || _tbl == 'phrrc0001') {
1769
			Ext.Ajax.request({
1770
				async : false,
1771
				method : 'POST',
1772
				url : '/UserControl/GetStore',
1773
				params : {
1774
					tableName : 'PDSPAEMPIDCARD',
1775
					param : 'WizardFunction[equal]' + self_.WizardFunction + ',BirthDate[=]' + Ext.ComponentQuery.query('[name=BirthDate]')[0].getValue() + ',IDCard[=]' + Ext.ComponentQuery.query('[name=IDCard]')[0].getValue()
1776

    
1777
				},
1778
				success : function (response) {
1779
					var results = Ext.decode(response.responseText);
1780
					data_ = results.data;
1781
					if (data_ != undefined && data_.length > 0) {
1782
						var MsgParam = "";
1783
						Ext.each(data_, function (rec) {
1784
							MsgParam = MsgParam + ' Type  :  ' + rec.Type + ' ,  Company  :  ' + rec.Company + ' ,  Status  :  ' + rec.Status + ' ,  Reason  :  ' + rec.Reason
1785
						});
1786
						/* MinovaMessage(' Message ', ' WIZRCIDCARD ', MsgParam, 'C', function (respone) {
1787
						if (respone == "yes") {
1788
						cekKtp = false;
1789
						if (cekKtp) {
1790
						if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1791
						if (_tbl == 'phrpa0001') {
1792
						// past
1793
						if (self_.getForm().isValid()) {
1794
						//change progress bar
1795
						total_ = ((next_ - 1) / prog_.totalPage) * 100;
1796
						document.getElementById("progressbar").style.width = total_ + '%';
1797
						var idx = next_ - 1;
1798
						me.changeProgress(idx, next_, false);
1799
						me.goNextMD(prog_, self_);
1800
						me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1801
						prog_.setNextMD(prog_.getNextMD() + 1);
1802
						prog_.setPrevMD(prog_.getNextMD() - 1);
1803
						} else { // jika form error
1804

    
1805
						}
1806
						} else {
1807
						// save data to md
1808
						if (self_.getForm().isValid()) {
1809
						if (_tbl == 'phrpa0002') {
1810

    
1811
						Ext.Ajax.request({
1812
						async: false,
1813
						method: 'POST',
1814
						url: '/UserControl/GetStore',
1815
						params: {
1816
						tableName: 'PDSPAWIZDEL',
1817
						param: getParam("id")
1818

    
1819
						},
1820
						waitMsg: 'Saving Data...',
1821
						success: function (response) { },
1822
						failure: function (response) { }
1823
						});
1824

    
1825
						formName = 'MinovaGridFormEditPHRPA0001';
1826
						data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1827
						var CreateDate = 'CreateDate';
1828
						var CreateDateValue = "";
1829
						var ChangeDate = 'ChangeDate';
1830
						var ChangeDateValue = "";
1831

    
1832
						data1[CreateDate] = CreateDateValue;
1833
						data1[ChangeDate] = ChangeDateValue;
1834
						data2 = self_.getForm().getValues();
1835
						data2[CreateDate] = CreateDateValue;
1836
						data2[ChangeDate] = ChangeDateValue;
1837
						} else {
1838
						data1 = self_.getForm().getValues();
1839
						var CreateDate = 'CreateDate';
1840
						var CreateDateValue = "";
1841
						var ChangeDate = 'ChangeDate';
1842
						var ChangeDateValue = "";
1843

    
1844
						data1[CreateDate] = CreateDateValue;
1845
						data1[ChangeDate] = ChangeDateValue;
1846
						}
1847

    
1848
						var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1849
						if (sukses) {
1850
						//change progress bar
1851
						total_ = ((next_ - 1) / prog_.totalPage) * 100;
1852
						document.getElementById("progressbar").style.width = total_ + '%';
1853
						var idx = next_ - 1;
1854
						me.changeProgress(idx, next_, false);
1855
						me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1856
						prog_.setNextMD(prog_.getNextMD() + 1);
1857
						prog_.setPrevMD(prog_.getNextMD() - 1);
1858
						me.goNextMD(prog_, self_);
1859

    
1860
						}
1861

    
1862
						} else { // jika form error
1863

    
1864
						}
1865
						}
1866
						} else {
1867
						data1 = self_.getForm().getValues();
1868
						//cek apakah form terakhir
1869
						if (prog_.totalPage < next_) { // md form sudah selesai
1870
						Ext.Msg.show({
1871
						title: "",
1872
						msg: MinovaMessageData('WD001', ''),
1873
						//buttons: Ext.Msg.YESNO,
1874
						icon: Ext.Msg.QUESTION,
1875
						fn: function (choice) {
1876
						console.log(choice);
1877
						if (choice === 'yes') {
1878
						document.getElementById("progressbar").style.width = '100%';
1879

    
1880
						//me.saveDataToMD();
1881

    
1882
						var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1883
						if (sukses) {
1884
						var page = 'wizards';
1885
						if (prog_.wizardFunction.substring(0, 1) == "A") {
1886
						page = 'rcwizards';
1887
						}
1888
						nextUrl = MinovaUtil.GetMenuID() + '&S=S';
1889
						var mb = new minovaBlowfish();
1890
						e = mb.minovaEncryptUrl(nextUrl);
1891
						window.open(page + '?' + e, "_self");
1892

    
1893
						}
1894
						}
1895

    
1896
						}
1897
						});
1898
						} else {
1899
						var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1900
						if (sukses) {
1901
						//change progress bar
1902
						total_ = ((next_ - 1) / prog_.totalPage) * 100;
1903
						document.getElementById("progressbar").style.width = total_ + '%';
1904
						var idx = next_ - 1;
1905
						me.changeProgress(idx, next_, false);
1906
						me.goNextMD(prog_, self_);
1907
						me.setFormValuesAfterNext(self_.WizardFunction, prog_);
1908
						prog_.setNextMD(prog_.getNextMD() + 1);
1909
						prog_.setPrevMD(prog_.getNextMD() - 1);
1910

    
1911
						}
1912
						}
1913

    
1914
						}
1915

    
1916
						}
1917

    
1918
						} else {
1919
						cekKtp = false;
1920
						}
1921
						});
1922
						 */
1923
						MinovaMessageError(' Message ', ' WIZRCIDCARD ', MsgParam)
1924
					} else {
1925
						cekKtp = true;
1926
						if (cekKtp) {
1927
							if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
1928
								if (_tbl == 'phrpa0001') {
1929
									// past
1930
									if (self_.getForm().isValid()) {
1931
										//change progress bar
1932
										total_ = ((next_ - 1) / prog_.totalPage) * 100;
1933
										document.getElementById("progressbar").style.width = total_ + '%';
1934
										var idx = next_ - 1;
1935
										me.changeProgress(idx, next_, false);
1936
										me.goNextMD(prog_, self_);
1937
										me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1938
										prog_.setNextMD(prog_.getNextMD() + 1);
1939
										prog_.setPrevMD(prog_.getNextMD() - 1);
1940
									} else { // jika form error
1941

    
1942
									}
1943
								} else {
1944
									// save data to md
1945
									if (self_.getForm().isValid()) {
1946
										if (_tbl == 'phrpa0002') {
1947

    
1948
											Ext.Ajax.request({
1949
												async : false,
1950
												method : 'POST',
1951
												url : '/UserControl/GetStore',
1952
												params : {
1953
													tableName : 'PDSPAWIZDEL',
1954
													param : getParam("id")
1955

    
1956
												},
1957
												waitMsg : 'Saving Data...',
1958
												success : function (response) {},
1959
												failure : function (response) {}
1960
											});
1961

    
1962
											formName = 'MinovaGridFormEditPHRPA0001';
1963
											data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
1964
											var CreateDate = 'CreateDate';
1965
											var CreateDateValue = "";
1966
											var ChangeDate = 'ChangeDate';
1967
											var ChangeDateValue = "";
1968

    
1969
											data1[CreateDate] = CreateDateValue;
1970
											data1[ChangeDate] = ChangeDateValue;
1971
											data2 = self_.getForm().getValues();
1972
											data2[CreateDate] = CreateDateValue;
1973
											data2[ChangeDate] = ChangeDateValue;
1974
										} else {
1975
											data1 = self_.getForm().getValues();
1976
											var CreateDate = 'CreateDate';
1977
											var CreateDateValue = "";
1978
											var ChangeDate = 'ChangeDate';
1979
											var ChangeDateValue = "";
1980

    
1981
											data1[CreateDate] = CreateDateValue;
1982
											data1[ChangeDate] = ChangeDateValue;
1983
										}
1984

    
1985
										var sukses = me.saveDataToMD(self_.tableName, data1, data2);
1986
										if (sukses) {
1987
											//change progress bar
1988
											total_ = ((next_ - 1) / prog_.totalPage) * 100;
1989
											document.getElementById("progressbar").style.width = total_ + '%';
1990
											var idx = next_ - 1;
1991
											me.changeProgress(idx, next_, false);
1992
											me.setFormValuesAfterNext(self_.wizardFunction, prog_);
1993
											prog_.setNextMD(prog_.getNextMD() + 1);
1994
											prog_.setPrevMD(prog_.getNextMD() - 1);
1995
											me.goNextMD(prog_, self_);
1996

    
1997
										}
1998

    
1999
									} else { // jika form error
2000

    
2001
									}
2002
								}
2003
							} else {
2004
								data1 = self_.getForm().getValues();
2005
								//cek apakah form terakhir
2006
								if (prog_.totalPage < next_) { // md form sudah selesai
2007
									Ext.Msg.show({
2008
										title : "",
2009
										msg : MinovaMessageData('WD001', ''),
2010
										buttons : Ext.Msg.YESNO,
2011
										icon : Ext.Msg.QUESTION,
2012
										fn : function (choice) {
2013
											console.log(choice);
2014
											if (choice === 'yes') {
2015
												document.getElementById("progressbar").style.width = '100%';
2016

    
2017
												//me.saveDataToMD();
2018

    
2019
												var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2020
												if (sukses) {
2021
													var page = 'wizards';
2022
													if (prog_.wizardFunction.substring(0, 1) == "A") {
2023
														page = 'rcwizards';
2024
													}
2025
													nextUrl = MinovaUtil.GetMenuID() + '&S=S';
2026
													var mb = new minovaBlowfish();
2027
													e = mb.minovaEncryptUrl(nextUrl);
2028
													window.open(page + '?' + e, "_self");
2029

    
2030
												}
2031
											}
2032

    
2033
										}
2034
									});
2035
								} else {
2036
									var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2037
									if (sukses) {
2038
										//change progress bar
2039
										total_ = ((next_ - 1) / prog_.totalPage) * 100;
2040
										document.getElementById("progressbar").style.width = total_ + '%';
2041
										var idx = next_ - 1;
2042
										me.changeProgress(idx, next_, false);
2043
										me.goNextMD(prog_, self_);
2044
										me.setFormValuesAfterNext(self_.WizardFunction, prog_);
2045
										prog_.setNextMD(prog_.getNextMD() + 1);
2046
										prog_.setPrevMD(prog_.getNextMD() - 1);
2047

    
2048
									}
2049
								}
2050

    
2051
							}
2052

    
2053
						}
2054
					}
2055
				}
2056
			});
2057
		} else {
2058
			cekKtp = true; ;
2059
			if (cekKtp) {
2060
				if (self_.WizardFunction == "APPT" || self_.WizardFunction == "EMPI") {
2061
					if (_tbl == 'phrpa0001') {
2062
						// past
2063
						if (self_.getForm().isValid()) {
2064
							//change progress bar
2065
							total_ = ((next_ - 1) / prog_.totalPage) * 100;
2066
							document.getElementById("progressbar").style.width = total_ + '%';
2067
							var idx = next_ - 1;
2068
							me.changeProgress(idx, next_, false);
2069
							me.goNextMD(prog_, self_);
2070
							me.setFormValuesAfterNext(self_.wizardFunction, prog_);
2071
							prog_.setNextMD(prog_.getNextMD() + 1);
2072
							prog_.setPrevMD(prog_.getNextMD() - 1);
2073
						} else { // jika form error
2074

    
2075
						}
2076
					} else {
2077
						// save data to md
2078
						if (self_.getForm().isValid()) {
2079
							if (_tbl == 'phrpa0002') {
2080

    
2081
								Ext.Ajax.request({
2082
									async : false,
2083
									method : 'POST',
2084
									url : '/UserControl/GetStore',
2085
									params : {
2086
										tableName : 'PDSPAWIZDEL',
2087
										param : getParam("id")
2088

    
2089
									},
2090
									waitMsg : 'Saving Data...',
2091
									success : function (response) {},
2092
									failure : function (response) {}
2093
								});
2094

    
2095
								formName = 'MinovaGridFormEditPHRPA0001';
2096
								data1 = Ext.ComponentQuery.query('[name=' + formName + ']')[0].getForm().getValues();
2097
								var CreateDate = 'CreateDate';
2098
								var CreateDateValue = "";
2099
								var ChangeDate = 'ChangeDate';
2100
								var ChangeDateValue = "";
2101

    
2102
								data1[CreateDate] = CreateDateValue;
2103
								data1[ChangeDate] = ChangeDateValue;
2104
								data2 = self_.getForm().getValues();
2105
								data2[CreateDate] = CreateDateValue;
2106
								data2[ChangeDate] = ChangeDateValue;
2107
							} else {
2108
								data1 = self_.getForm().getValues();
2109
								var CreateDate = 'CreateDate';
2110
								var CreateDateValue = "";
2111
								var ChangeDate = 'ChangeDate';
2112
								var ChangeDateValue = "";
2113

    
2114
								data1[CreateDate] = CreateDateValue;
2115
								data1[ChangeDate] = ChangeDateValue;
2116
							}
2117

    
2118
							var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2119
							if (sukses) {
2120
								//change progress bar
2121
								total_ = ((next_ - 1) / prog_.totalPage) * 100;
2122
								document.getElementById("progressbar").style.width = total_ + '%';
2123
								var idx = next_ - 1;
2124
								me.changeProgress(idx, next_, false);
2125
								me.setFormValuesAfterNext(self_.wizardFunction, prog_);
2126
								prog_.setNextMD(prog_.getNextMD() + 1);
2127
								prog_.setPrevMD(prog_.getNextMD() - 1);
2128
								me.goNextMD(prog_, self_);
2129

    
2130
							}
2131

    
2132
						} else { // jika form error
2133

    
2134
						}
2135
					}
2136
				} else {
2137
					data1 = self_.getForm().getValues();
2138
					//cek apakah form terakhir
2139
					if (prog_.totalPage < next_) { // md form sudah selesai
2140
						Ext.Msg.show({
2141
							title : "",
2142
							msg : MinovaMessageData('WD001', ''),
2143
							buttons : Ext.Msg.YESNO,
2144
							icon : Ext.Msg.QUESTION,
2145
							fn : function (choice) {
2146
								console.log(choice);
2147
								if (choice === 'yes') {
2148
									document.getElementById("progressbar").style.width = '100%';
2149

    
2150
									//me.saveDataToMD();
2151

    
2152
									var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2153
									if (sukses) {
2154
										var page = 'wizards';
2155
										if (prog_.wizardFunction.substring(0, 1) == "A") {
2156
											page = 'rcwizards';
2157
										}
2158
										nextUrl = MinovaUtil.GetMenuID() + '&S=S';
2159
										var mb = new minovaBlowfish();
2160
										e = mb.minovaEncryptUrl(nextUrl);
2161
										window.open(page + '?' + e, "_self");
2162

    
2163
									}
2164
								}
2165

    
2166
							}
2167
						});
2168
					} else {
2169
						var sukses = me.saveDataToMD(self_.tableName, data1, data2);
2170
						if (sukses) {
2171
							//change progress bar
2172
							total_ = ((next_ - 1) / prog_.totalPage) * 100;
2173
							document.getElementById("progressbar").style.width = total_ + '%';
2174
							var idx = next_ - 1;
2175
							me.changeProgress(idx, next_, false);
2176
							me.goNextMD(prog_, self_);
2177
							me.setFormValuesAfterNext(self_.WizardFunction, prog_);
2178
							prog_.setNextMD(prog_.getNextMD() + 1);
2179
							prog_.setPrevMD(prog_.getNextMD() - 1);
2180

    
2181
						}
2182
					}
2183

    
2184
				}
2185

    
2186
			}
2187

    
2188
		}
2189

    
2190
	},
2191
	goNextMD : function (prog_, form_) {
2192
		var me = this;
2193
		var table_ = form_.tableName.toLowerCase();
2194
		var next_ = prog_.getNextMD() - 1; // id form selanjutnya
2195
		//var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2196
		/*
2197
		if (prog_.totalPage <= next_) { // md form sudah selesai
2198
		Ext.Msg.show({
2199
		title: "",
2200
		msg: MinovaMessageData('WD001', ''),
2201
		buttons: Ext.Msg.YESNO,
2202
		icon: Ext.Msg.QUESTION,
2203
		fn: function (choice) {
2204
		console.log(choice);
2205
		if (choice === 'yes') {
2206
		document.getElementById("progressbar").style.width = '100%';
2207

    
2208
		//me.saveDataToMD();
2209

    
2210
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2211
		var page = 'wizards';
2212
		if (prog_.wizardFunction.substring(0, 1) == "A") {
2213
		page = 'rcwizards';
2214
		}
2215
		nextUrl = page + '?' + MinovaUtil.GetMenuID() + '&S=S';
2216
		window.open(nextUrl, "_self");
2217
		}
2218

    
2219
		}
2220
		});
2221
		}
2222
		else
2223
		 */
2224
		{
2225
			var next_ = form_.nextMD;
2226
			var _me = next_ - 1;
2227
			var nextPage = Ext.ComponentQuery.query('[itemId=MD' + form_.nextMD + ']')[0];
2228
			var type_ = nextPage.WizardLayout;
2229

    
2230
			if (prog_.sukses == true) {
2231
				if (form_.nextMD != 1) {
2232
					//set value form or grid from md
2233
					hisTable = nextPage.tableName;
2234
					var nowDate = MinovaUtil.GetNowDate();
2235
					if (nextPage.WizardFunction == 'APPT') {
2236
						hisTable = "PHRRC" + hisTable.substring(5, 9);
2237
					}
2238
					if (nextPage.WizardLayout == 'G') {
2239
						var empID = getParam("app");
2240
						if (getParam('wizard').substring(0, 1) == 'E') {
2241
							empID = getParam('id');
2242
						}
2243
						var gridHis = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextPage.tableName + ']')[0];
2244
						dataForm = null;
2245
						Ext.Ajax.request({
2246
							//async: false,
2247
							method : 'POST',
2248
							url : '/UserControl/GetStore',
2249
							params : {
2250
								tableName : hisTable,
2251
								param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + empID
2252

    
2253
							},
2254
							success : function (response) {
2255
								var results = Ext.decode(response.responseText);
2256
								dataForm = results.data;
2257
								if (dataForm.length) {
2258
									Ext.each(dataForm, function (rec) {
2259
										rec["EmployeeID"] = getParam('id');
2260
										rec["Flag"] = '0';
2261
									});
2262
								}
2263
								if (gridHis) {
2264
									var gridStore = gridHis.getStore();
2265
									gridStore.loadData(dataForm);
2266
								} else {
2267
									var gridStore = Ext.StoreMgr.lookup("store" + nextPage.tableName);
2268
									gridStore.loadData(dataForm);
2269
								}
2270

    
2271
							}
2272
						});
2273

    
2274
					} else {
2275
						var form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextPage.tableName + ']')[0];
2276
					}
2277
					form_.setHidden(true);
2278
					nextPage.setHidden(false);
2279
					me.setButton(nextPage);
2280
				} else {
2281
					var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2282
					var page = 'wizards';
2283
					if (prog_.wizardFunction.substring(0, 1) == "A") {
2284
						page = 'rcwizards';
2285
					}
2286
					nextUrl = MinovaUtil.GetMenuID() + '&S=S';
2287
					var mb = new minovaBlowfish();
2288
					e = mb.minovaEncryptUrl(nextUrl);
2289
					window.open(page + '?' + e, "_self");
2290
				}
2291

    
2292
			} else if (table_ == 'phrpa0001' || table_ == 'phrpa0002') {
2293
				form_.setHidden(true);
2294
				nextPage.setHidden(false);
2295
				me.setButton(nextPage);
2296
			}
2297

    
2298
		}
2299
	},
2300
	saveDataToMD : function (tableName, data1, data2) {
2301
		var prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2302
		var sukses = false;
2303
		var TblApp = tableName.toLowerCase().substring(0, 5);
2304
		if (getParam('wizard') == 'A900') {
2305
			var EmployeeID = 'EmployeeID';
2306
			var EmployeeIDValue = getParam('id');
2307
			data1[EmployeeID] = EmployeeIDValue;
2308
			if (data2 != undefined) {
2309
				var EmployeeID = 'EmployeeID';
2310
				var EmployeeIDValue = getParam('id');
2311
				data2[EmployeeID] = EmployeeIDValue;
2312
			}
2313
		}
2314

    
2315
		var CreateDate = 'CreateDate';
2316
		var CreateDateValue = "";
2317
		var ChangeDate = 'ChangeDate';
2318
		var ChangeDateValue = "";
2319
		data1[CreateDate] = CreateDateValue;
2320
		data1[ChangeDate] = ChangeDateValue;
2321
		if (data2 == undefined) {
2322

    
2323
			if (prog_.sukses = true || TblApp == 'phrrc') {
2324
				Ext.Ajax.request({
2325
					async : false,
2326
					method : 'POST',
2327
					url : '/Devt/SaveTable',
2328
					params : {
2329
						tableName : tableName,
2330
						data : Ext.encode(data1),
2331
						action : 0
2332
					},
2333
					waitMsg : 'Saving Data...',
2334
					success : function (response) {
2335
						var result = Ext.decode(response.responseText);
2336
						if (result.success) {
2337
							// MinovaMessage('Not Null', '000006', '', 'S');
2338
							sukses = true;
2339
							//send mail
2340
							var _param = {
2341
								serviceName : 'ERecruitmentAuthentication.asmx',
2342
								methodName : 'SendMailChangeMD',
2343
								parameter : 'TableName=' + tableName + '&EmployeeID=' + data1.EmployeeID
2344

    
2345
							};
2346

    
2347
							//var results = null;
2348
							Ext.Ajax.request({
2349
								method : 'post',
2350
								type : 'ajax',
2351
								params : _param,
2352
								url : '/InvokeService/Invoke/',
2353
								loadMask : {
2354
									msg : 'please wait...'
2355
								},
2356
								success : function (response) {}
2357
							});
2358
						} else {
2359
							MinovaMessage('', '000005', result.message.text, 'E');
2360
							sukses = false;
2361
						}
2362
					},
2363
					failure : function (response) {
2364
						var result = Ext.decode(response.responseText);
2365
						MinovaMessage('', '000005', result.message.text, 'E');
2366
						sukses = false;
2367
					}
2368
				});
2369
			} else {}
2370
		} else {
2371
			data2[CreateDate] = CreateDateValue;
2372
			data2[ChangeDate] = ChangeDateValue;
2373
			Ext.Ajax.request({
2374
				async : false,
2375
				method : 'POST',
2376
				url : '/Devt/SaveTable',
2377
				params : {
2378
					tableName : 'phrpa0001',
2379
					data : Ext.encode(data1),
2380
					action : 0
2381
				},
2382
				waitMsg : 'Saving Data...',
2383
				success : function (response) {
2384
					var result = Ext.decode(response.responseText);
2385
					if (result.success) {
2386
						// MinovaMessage('Not Null', '000006', '', 'S');
2387
						sukses = true;
2388
					} else {
2389
						MinovaMessage('', '000005', result.message.text, 'E');
2390
					}
2391
				},
2392
				failure : function (response) {
2393
					var result = Ext.decode(response.responseText);
2394
					MinovaMessage('', '000005', result.message.text, 'E');
2395
				}
2396
			});
2397
			if (sukses) {
2398
				Ext.Ajax.request({
2399
					async : false,
2400
					method : 'POST',
2401
					url : '/Devt/SaveTable',
2402
					params : {
2403
						tableName : 'PHRPA0002',
2404
						data : Ext.encode(data2),
2405
						action : 0
2406
					},
2407
					waitMsg : 'Saving Data...',
2408
					success : function (response) {
2409
						var result = Ext.decode(response.responseText);
2410
						if (result.success) {
2411
							// MinovaMessage('Not Null', '000006', '', 'S');
2412
							sukses = true;
2413
						} else {
2414
							MinovaMessage('', '000005', result.message.text, 'E');
2415
							sukses = false;
2416
						}
2417
					},
2418
					failure : function (response) {
2419
						var result = Ext.decode(response.responseText);
2420
						MinovaMessage('', '000005', result.message.text, 'E');
2421
					}
2422
				});
2423
			}
2424

    
2425
			//save md 15
2426
			var app = getParam('app');
2427
			if (app === "null") {
2428
				app = '';
2429
			}
2430
			var _date = Ext.ComponentQuery.query('[name=MinovaGridFormEditPHRPA0002]')[0].getValues().StartDate;
2431
			data = {
2432
				EmployeeID : getParam('id'),
2433
				PaymentUpTo : '',
2434
				RetroDate : _date,
2435
				HiringDate : _date,
2436
				ApplicantID : app,
2437
				CorrectStatus : '1'
2438
			};
2439
			Ext.Ajax.request({
2440
				async : false,
2441
				method : 'POST',
2442
				url : '/Devt/SaveTable',
2443
				params : {
2444
					tableName : 'phrpa0015',
2445
					data : Ext.encode(data),
2446
					action : 0
2447
				},
2448
				waitMsg : 'Saving Data...',
2449
				success : function (response) {
2450
					var result = Ext.decode(response.responseText);
2451
					if (result.success) {
2452
						// MinovaMessage('Not Null', '000006', '', 'S');
2453
						sukses = true;
2454
					} else {
2455
						MinovaMessage('', '000005', result.message.text, 'E');
2456
						sukses = false;
2457
					}
2458
				},
2459
				failure : function (response) {
2460
					var result = Ext.decode(response.responseText);
2461
					MinovaMessage('', '000005', result.message.text, 'E');
2462
				}
2463
			});
2464

    
2465
		}
2466
		prog_.sukses = sukses;
2467
		return (sukses);
2468
	},
2469

    
2470
	setFormValuesAfterNext : function (WizardFunction, prog_) {
2471
		var nowDate = MinovaUtil.GetNowDate();
2472
		//var data_ = JSON.parse(localStorage.getItem(datatable));
2473
		var me = this;
2474
		var next_ = prog_.getNextMD()
2475

    
2476
			if (Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0]) {
2477
				var nextPage = Ext.ComponentQuery.query('[itemId=MD' + next_ + ']')[0];
2478
				var type_ = nextPage.WizardLayout;
2479
				var tabl_ = nextPage.tableName;
2480
				switch (nextPage.WizardFunction) {
2481
				case "APP":
2482
					var tabl_ = nextPage.tableName;
2483
					me.getLastValue(tabl_, type_);
2484
					break
2485
				case "APPI":
2486

    
2487
					break
2488
				case "APPT":
2489
					var tabl_ = prog_.allTable[next_ - 1];
2490
					tbl_ = "PHRRC" + tabl_.substring(5, 9);
2491
					paData = "PHRPA" + tabl_.substring(5, 9);
2492
					me.getLastValueAPPT(tbl_, type_, paData);
2493
					break
2494
				case "EMP":
2495
					var tabl_ = nextPage.tableName;
2496
					me.getLastValue(tabl_, type_);
2497
					break
2498
				case "EMPI":
2499

    
2500
					break
2501
				default:
2502
					break
2503
				}
2504
				if (type_ == "F") {
2505
					me.setValueFromParameter(nextPage);
2506
				}
2507

    
2508
			}
2509
	},
2510

    
2511
	getLastValueAPPT : function (nextTable, type_, paData) {
2512
		var nowDate = MinovaUtil.GetNowDate();
2513
		if (type_ == "F") {
2514
			Ext.Ajax.request({
2515
				async : false,
2516
				method : 'POST',
2517
				url : '/UserControl/GetStore',
2518
				params : {
2519
					tableName : nextTable,
2520
					//param: 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("app")
2521
					param : 'EmployeeID[=]' + getParam("app")
2522

    
2523
				},
2524
				success : function (response) {
2525
					var results = Ext.decode(response.responseText);
2526
					dataForm = results.data[0];
2527
					var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + paData + ']')[0]
2528
						var form_ = _form.getForm();
2529
					form_.setValues(dataForm);
2530
					var temData = JSON.parse(localStorage.getItem('selectionValues'));
2531

    
2532
					if (nextTable.toLowerCase == "phrpa0002") {
2533
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2534
						form_.findField('CompanyID').setValue(temData.CompanyID);
2535
						form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
2536
						form_.findField('MovementReason').setValue(temData.Reason);
2537
					} else {
2538
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2539
					}
2540
				}
2541
			});
2542
		} else {
2543
			Ext.Ajax.request({
2544
				async : false,
2545
				method : 'POST',
2546
				url : '/UserControl/GetStore',
2547
				params : {
2548
					tableName : nextTable,
2549
					param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2550

    
2551
				},
2552
				success : function (response) {
2553
					var results = Ext.decode(response.responseText);
2554
					var data_ = results.data;
2555
					var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + paData + ']')[0].getStore();
2556
					gridStore.loadData(data_);
2557

    
2558
				}
2559
			});
2560
		}
2561
	},
2562

    
2563
	getLastValue : function (nextTable, type_) {
2564
		var nowDate = MinovaUtil.GetNowDate();
2565
		if (type_ == "F") {
2566
			Ext.Ajax.request({
2567
				async : false,
2568
				method : 'POST',
2569
				url : '/UserControl/GetStore',
2570
				params : {
2571
					tableName : nextTable,
2572
					param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2573

    
2574
				},
2575
				success : function (response) {
2576
					var results = Ext.decode(response.responseText);
2577
					dataForm = results.data[0];
2578
					var _form = Ext.ComponentQuery.query('[name=MinovaGridFormEdit' + nextTable + ']')[0]
2579
						var form_ = _form.getForm();
2580
					form_.setValues(dataForm);
2581
					var temData = JSON.parse(localStorage.getItem('selectionValues'));
2582

    
2583
					if (nextTable.toLowerCase == "phrpa0002") {
2584
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2585
						form_.findField('CompanyID').setValue(temData.CompanyID);
2586
						form_.findField('PayrollGroup').setValue(temData.PayrollGroup);
2587
						form_.findField('MovementReason').setValue(temData.Reason);
2588
					} else {
2589
						form_.findField('StartDate').setValue(temData.EffectiveDate);
2590
					}
2591
				}
2592
			});
2593
		} else {
2594
			Ext.Ajax.request({
2595
				async : false,
2596
				method : 'POST',
2597
				url : '/UserControl/GetStore',
2598
				params : {
2599
					tableName : nextTable,
2600
					param : 'StartDate[<=]' + nowDate + ',EndDate[>=]' + nowDate + ',EmployeeID[=]' + getParam("id")
2601

    
2602
				},
2603
				success : function (response) {
2604
					var results = Ext.decode(response.responseText);
2605
					var data_ = results.data;
2606
					var gridStore = Ext.ComponentQuery.query('[name=MinovaGridFormGrid' + nextTable + ']')[0].getStore();
2607
					gridStore.loadData(data_);
2608

    
2609
				}
2610
			});
2611
		}
2612
	},
2613

    
2614
	setButton : function (nextPage) {
2615

    
2616
		prog_ = Ext.ComponentQuery.query('[name=pnlProgress]')[0];
2617
		id_ = parseInt(nextPage.itemId.substring(2, 3));
2618
		Ext.ComponentQuery.query('[name=prevWizard]')[0].setDisabled(false);
2619
		Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
2620
		Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
2621

    
2622
		if (nextPage.mandatory == "1") {
2623
			//if (nextPage.nextMD == 1) {
2624
			//    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2625
			//    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2626

    
2627
			//} else {
2628
			//    Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2629
			//    Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2630

    
2631
			//}
2632

    
2633
			Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2634
			Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2635

    
2636
		} else {
2637
			Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(false);
2638
			Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(false);
2639
		}
2640

    
2641
		if (id_ == prog_.totalPage) {
2642
			Ext.ComponentQuery.query('[name=skipWizard]')[0].setDisabled(true);
2643
			Ext.ComponentQuery.query('[name=skipAllWizard]')[0].setDisabled(true);
2644
		}
2645
	},
2646
	ChangeApp : function () {
2647
		Ext.Ajax.request({
2648
			async : false,
2649
			method : 'POST',
2650
			url : '/UserControl/GetStore',
2651
			params : {
2652
				tableName : "PHRRC0002",
2653
				param : 'StartDate[<=]' + MinovaUtil.GetNowDate() + ',EndDate[>=]' + MinovaUtil.GetNowDate() + ',EmployeeID[=]' + Ext.ComponentQuery.query('[name=ApplicantID]')[0].getValue()
2654

    
2655
			},
2656
			success : function (response) {
2657
				var results = Ext.decode(response.responseText);
2658
				var data = results.data;
2659
				if (data != null && data.length > 0) {
2660
					var data_ = results.data[0];
2661
					Ext.ComponentQuery.query('[name=CompanyID]')[0].setValue(data_.CompanyID);
2662
				}
2663
			}
2664
		});
2665
	},
2666
});
(5-5/5)