1
|
Ext.define('MinovaES.controller.masterdata.travel.ctrltravel', {
|
2
|
extend: 'Ext.app.ViewController',
|
3
|
alias: 'controller.ctrltravel',
|
4
|
|
5
|
init: function () {
|
6
|
this.control({
|
7
|
'[name=cancelTV]': {
|
8
|
click: this.cancel,
|
9
|
},
|
10
|
'[name=addTV]': {
|
11
|
click: this.addTV,
|
12
|
},
|
13
|
'[name=saveTV]': {
|
14
|
click: this.saveTV,
|
15
|
},
|
16
|
'[name=deleteTV]': {
|
17
|
click: this.btnDeleteTV,
|
18
|
},
|
19
|
'[name=copyTV]': {
|
20
|
click: this.copyTV,
|
21
|
},
|
22
|
'[name=editTV]': {
|
23
|
click: this.editTV,
|
24
|
},
|
25
|
'[name=phrpa0062]': {
|
26
|
itemdblclick: this.overViewDblClick,
|
27
|
afterrender: this.afterRenderOverview
|
28
|
},
|
29
|
'[name=StartDate][nameTable=phrpa0062]': {
|
30
|
change: this.loadCostType,
|
31
|
},
|
32
|
'[name=TravelType][nameTable=phrpa0062]': {
|
33
|
change: this.loadCostType,
|
34
|
},
|
35
|
'[fieldGrid=TransportType]': {
|
36
|
change: this.TransportType,
|
37
|
},
|
38
|
'[id=phrpa0063Amount]': {
|
39
|
blur: this.AmountRoute,
|
40
|
},
|
41
|
'[id=phrpa0063Currency]': {
|
42
|
blur: this.AmountRoute,
|
43
|
},
|
44
|
'[id=phrpa0064Amount]': {
|
45
|
blur: this.AmountAccom,
|
46
|
},
|
47
|
'[id=phrpa0064Currency]': {
|
48
|
blur: this.AmountAccom,
|
49
|
},
|
50
|
'[id=phrpa0065CostType]': {
|
51
|
render: this.loadCostType,
|
52
|
},
|
53
|
'[id=phrpa0065Currency]': {
|
54
|
render: this.loadCurrency,
|
55
|
select: this.setRate,
|
56
|
},
|
57
|
'[id=phrpa0065CostType]': {
|
58
|
select: this.setRate,
|
59
|
select: this.setNumber,
|
60
|
select: this.setCostCenter, //////// ----- add by Tri nwh 20220202
|
61
|
},
|
62
|
'[name=Add]': {
|
63
|
click: this.cekHeader,
|
64
|
},
|
65
|
'[name=phrpa0065DeleteText]': {
|
66
|
click: this.deleteData,
|
67
|
},
|
68
|
'[name=PDSPA0003]': {
|
69
|
afterrender: this.summaries,
|
70
|
},
|
71
|
'[id=phrpa0063StartDate]': {
|
72
|
afterrender: this.setMinMaxDate63,
|
73
|
specialkey: this.specialkey,
|
74
|
change: this.setEndDate63,
|
75
|
},
|
76
|
'[id=phrpa0064StartDate]': {
|
77
|
afterrender: this.setMinMaxDate64,
|
78
|
change: this.setEndDate64,
|
79
|
},
|
80
|
'[id=phrpa0065StartDate]': {
|
81
|
afterrender: this.setMinMaxDate65,
|
82
|
change: this.setEndDate65,
|
83
|
},
|
84
|
'[id=phrpa0063EndDate]': {
|
85
|
afterrender: this.cekEndDate63,
|
86
|
change: this.setStartDate63,
|
87
|
},
|
88
|
'[id=phrpa0064EndDate]': {
|
89
|
afterrender: this.cekEndDate64,
|
90
|
change: this.setStartDate64,
|
91
|
},
|
92
|
'[id=phrpa0065EndDate]': {
|
93
|
afterrender: this.cekEndDate65,
|
94
|
change: this.setStartDate65,
|
95
|
},
|
96
|
'[name=gridtransport]': {
|
97
|
beforeedit: this.beforeedit63,
|
98
|
//edit:this.cekDate
|
99
|
},
|
100
|
'[name=accommodation]': {
|
101
|
beforeedit: this.beforeedit64,
|
102
|
|
103
|
},
|
104
|
'[name=gridphrpa0065]': {
|
105
|
beforeedit: this.beforeedit65,
|
106
|
beforeedit: this.beforeEdit,
|
107
|
edit: this.editRow,
|
108
|
},
|
109
|
'[Text=Yes]': {
|
110
|
click: this.summaries,
|
111
|
},
|
112
|
'[name=CalculateCost]': {
|
113
|
click: this.summaries,
|
114
|
},
|
115
|
});
|
116
|
},
|
117
|
cekHeader: function () {
|
118
|
|
119
|
var form = Ext.ComponentQuery.query('[name=formOverViewTV]')[0].getForm();
|
120
|
if (!form.isValid()) {
|
121
|
MinovaMessage('', 'BSVALFORM', '', 'E')
|
122
|
}
|
123
|
},
|
124
|
AmountRoute: function (a) {
|
125
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
126
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
127
|
var Currency = Ext.ComponentQuery.query('[id=phrpa0063Currency]')[0];
|
128
|
var f = Ext.ComponentQuery.query('[id=phrpa0063Amount]')[0];
|
129
|
var EmployeeID = getParam("EmployeeID");
|
130
|
if (StartDate.getValue() != '' && Currency.getValue() != '' && TravelType.getValue() != '') {
|
131
|
Ext.Ajax.request({
|
132
|
async: false,
|
133
|
method: 'POST',
|
134
|
url: '/UserControl/GetStore',
|
135
|
params: {
|
136
|
tableName: 'PDSTVTOROUTE',
|
137
|
param: EmployeeID + ',' + StartDate.getValue() + ',' + TravelType.getValue() + ',' + Currency.getValue()
|
138
|
},
|
139
|
success: function (response) {
|
140
|
var results = Ext.decode(response.responseText);
|
141
|
var dt = results.data;
|
142
|
if (dt.length > 0) {
|
143
|
data_ = dt[0];
|
144
|
var min = parseFloat(data_.MinAmount);
|
145
|
var max = parseFloat(data_.MaxAmount);
|
146
|
var val = parseFloat(f.getValue());
|
147
|
if (val < min) {
|
148
|
//MinovaMessage('', 'BSMINAMT', '', 'E');
|
149
|
MinovaMessage(' Message ', ' BSMINAMT ', +min + '$' + max, 'C', function (respone) {
|
150
|
if (respone != "yes") {
|
151
|
f.setValue('');
|
152
|
}
|
153
|
})
|
154
|
} else if (val > max) {
|
155
|
//MinovaMessage('', 'BSMAXAMT', '', 'E');
|
156
|
MinovaMessage(' Message ', ' BSMAXAMT ', +min + '$' + max, 'C', function (respone) {
|
157
|
if (respone != "yes") {
|
158
|
f.setValue('');
|
159
|
}
|
160
|
})
|
161
|
}
|
162
|
}
|
163
|
}
|
164
|
});
|
165
|
}
|
166
|
},
|
167
|
AmountAccom: function (a) {
|
168
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
169
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
170
|
var Currency = Ext.ComponentQuery.query('[id=phrpa0064Currency]')[0];
|
171
|
var f = Ext.ComponentQuery.query('[id=phrpa0064Amount]')[0];
|
172
|
var EmployeeID = getParam("EmployeeID");
|
173
|
if (StartDate.getValue() != '' && Currency.getValue() != '' && TravelType.getValue() != '') {
|
174
|
//if (StartDate != '' && Currency != '' && TravelType != '') {
|
175
|
Ext.Ajax.request({
|
176
|
async: false,
|
177
|
method: 'POST',
|
178
|
url: '/UserControl/GetStore',
|
179
|
params: {
|
180
|
tableName: 'PDSTVTOACCOM',
|
181
|
param: EmployeeID + ',' + StartDate.getValue() + ',' + TravelType.getValue() + ',' + Currency.getValue()
|
182
|
},
|
183
|
success: function (response) {
|
184
|
var results = Ext.decode(response.responseText);
|
185
|
var dt = results.data;
|
186
|
if (dt.length > 0) {
|
187
|
data_ = dt[0];
|
188
|
var min = parseFloat(data_.MinAmount);
|
189
|
var max = parseFloat(data_.MaxAmount);
|
190
|
var val = parseFloat(f.getValue());
|
191
|
if (val < min) {
|
192
|
//MinovaMessage('', 'BSMINAMT', '', 'E');
|
193
|
MinovaMessage(' Message ', ' BSMINAMT ', +min + '$' + max, 'C', function (respone) {
|
194
|
if (respone != "yes") {
|
195
|
f.setValue('');
|
196
|
}
|
197
|
})
|
198
|
} else if (val > max) {
|
199
|
//MinovaMessage('', 'BSMAXAMT', '', 'E')
|
200
|
MinovaMessage(' Message ', ' BSMAXAMT ', +min + '$' + max, 'C', function (respone) {
|
201
|
if (respone != "yes") {
|
202
|
f.setValue('');
|
203
|
}
|
204
|
})
|
205
|
}
|
206
|
}
|
207
|
}
|
208
|
});
|
209
|
}
|
210
|
},
|
211
|
loadCostType: function () {
|
212
|
var storeCostType = Ext.data.StoreManager.lookup('store_phrpa0065CostType');
|
213
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
214
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
215
|
var EmployeeID = getParam("EmployeeID");
|
216
|
if (StartDate.getValue() != '' && TravelType.getValue()) {
|
217
|
storeCostType.proxy.extraParams = {
|
218
|
tableName: 'PDSTVCOSTTYPE',
|
219
|
param: EmployeeID + "," + StartDate.getValue() + "," + TravelType.getValue(),
|
220
|
menuId: MinovaUtil.GetMenuID()
|
221
|
};
|
222
|
console.log('nwh');
|
223
|
storeCostType.removeAll();
|
224
|
storeCostType.reload();
|
225
|
}
|
226
|
|
227
|
},
|
228
|
loadCurrency: function () {
|
229
|
//empid,startdate,traveltype
|
230
|
var storeCurrency = Ext.data.StoreManager.lookup('store_phrpa0065Currency');
|
231
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
232
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
233
|
var EmployeeID = getParam("EmployeeID"); console.log('woohyun');
|
234
|
if (StartDate.getValue() != '' && TravelType.getValue() != '') {
|
235
|
|
236
|
storeCurrency.proxy.extraParams = {
|
237
|
tableName: 'PDSTVCOSTCURR',
|
238
|
param: EmployeeID + "," + StartDate.getValue() + "," + TravelType.getValue(),
|
239
|
menuId: MinovaUtil.GetMenuID()
|
240
|
};
|
241
|
storeCurrency.removeAll();
|
242
|
storeCurrency.reload();
|
243
|
}
|
244
|
},
|
245
|
setRate: function (a) {
|
246
|
//empid,startdate,traveltype,cyrrency,costtype
|
247
|
var me = this;
|
248
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
249
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
250
|
var Currency = Ext.ComponentQuery.query('[id=phrpa0065Currency]')[0];
|
251
|
var CostType = Ext.ComponentQuery.query('[id=phrpa0065CostType]')[0];
|
252
|
var EmployeeID = getParam("EmployeeID"); console.log('chani');
|
253
|
if (StartDate.getValue() != '' && Currency.getValue() != '' && TravelType.getValue() != '' && CostType.getValue() != '') {
|
254
|
//if (StartDate != '' && Currency != '' && TravelType != '' && CostType != '') {
|
255
|
Ext.Ajax.request({
|
256
|
async: false,
|
257
|
method: 'POST',
|
258
|
url: '/UserControl/GetStore',
|
259
|
params: {
|
260
|
tableName: 'PDSTVCOSTRATE',
|
261
|
param: EmployeeID + ',' + StartDate.getValue() + ',' + TravelType.getValue() + ',' + Currency.getValue() + "," + CostType.getValue()
|
262
|
},
|
263
|
success: function (response) {
|
264
|
var results = Ext.decode(response.responseText);
|
265
|
var dt = results.data;
|
266
|
if (dt.length > 0) {
|
267
|
data_ = dt[0];
|
268
|
var min = parseFloat(data_.MinAmount);
|
269
|
var max = parseFloat(data_.MaxAmount);
|
270
|
var rate = parseFloat(data_.Rate);
|
271
|
Ext.ComponentQuery.query('[id=phrpa0065Rate]')[0].setValue(rate);
|
272
|
|
273
|
}
|
274
|
}
|
275
|
});
|
276
|
}
|
277
|
me.SetNumber();
|
278
|
},
|
279
|
setNumber: function (a) {
|
280
|
//costtype
|
281
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
282
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
283
|
var EndDate = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0];
|
284
|
var Currency = Ext.ComponentQuery.query('[id=phrpa0065Currency]')[0];
|
285
|
var CostType = Ext.ComponentQuery.query('[id=phrpa0065CostType]')[0]; console.log('seunghyun');
|
286
|
var Duration = parseInt(MinovaUtil.GetDateDiff(EndDate.getValue(), StartDate.getValue())) + 1;
|
287
|
if (StartDate.getValue() != '' && Currency.getValue() != '' && TravelType.getValue() != '' && CostType.getValue() != '') {
|
288
|
Ext.Ajax.request({
|
289
|
async: false,
|
290
|
method: 'POST',
|
291
|
url: '/UserControl/GetStore',
|
292
|
params: {
|
293
|
tableName: 'PDSTVCOSTNUMBER',
|
294
|
param: CostType.getValue()
|
295
|
},
|
296
|
success: function (response) {
|
297
|
var results = Ext.decode(response.responseText);
|
298
|
var dt = results.data;
|
299
|
if (dt.length > 0) {
|
300
|
data_ = dt[0];
|
301
|
var isCountDay = parseInt(data_.IsCountDay);
|
302
|
var countDay = parseInt(data_.CountDay);
|
303
|
if (isCountDay == 0) {
|
304
|
Ext.ComponentQuery.query('[id=phrpa0065Number]')[0].setValue(countDay);
|
305
|
} else {
|
306
|
Ext.ComponentQuery.query('[id=phrpa0065Number]')[0].setValue(Duration - countDay);
|
307
|
}
|
308
|
}
|
309
|
}
|
310
|
});
|
311
|
}
|
312
|
},
|
313
|
setCostCenter: function (a) { //////// ----- add by Tri nwh 20220202
|
314
|
//costtype
|
315
|
var CostCenterHeader = Ext.ComponentQuery.query('[name=CostCenter][nameTable=phrpa0062]')[0];
|
316
|
Ext.ComponentQuery.query('[id=phrpa0065CostCenter]')[0].setValue(CostCenterHeader.getValue());
|
317
|
console.log(CostCenterHeader.getValue()); console.log('jinyoung');
|
318
|
},
|
319
|
TransportType: function () {
|
320
|
var storeTransportClass = Ext.data.StoreManager.lookup('store_phrpa0063TransportClass');
|
321
|
storeTransportClass.proxy.extraParams = {
|
322
|
tableName: 'PHRTVTPCLASS',
|
323
|
//param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + startDate + ',EndDate[>=]' + startDate
|
324
|
param: 'TransportType[=]' + Ext.ComponentQuery.query('[name=TransportType]')[0].getValue(),
|
325
|
menuId: MinovaUtil.GetMenuID()
|
326
|
};
|
327
|
storeTransportClass.removeAll();
|
328
|
storeTransportClass.reload();
|
329
|
Ext.ComponentQuery.query('[name=TransportClass]')[0].setValue('');
|
330
|
|
331
|
var storeTransportProvider = Ext.data.StoreManager.lookup('store_phrpa0063TransportProvider'); ////---- add by Tri nwh 20220421
|
332
|
storeTransportProvider.proxy.extraParams = {
|
333
|
tableName: 'PHRTVTPPROVIDER',
|
334
|
param: 'TransportType[=]' + Ext.ComponentQuery.query('[name=TransportType]')[0].getValue(),
|
335
|
menuId: MinovaUtil.GetMenuID()
|
336
|
};
|
337
|
storeTransportProvider.removeAll();
|
338
|
storeTransportProvider.reload();
|
339
|
Ext.ComponentQuery.query('[name=TransportProvider]')[0].setValue('');
|
340
|
},
|
341
|
TransportProvider: function () {
|
342
|
var startDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
343
|
|
344
|
var store = Ext.data.StoreManager.lookup('store_phrpa0063TransportProvider');
|
345
|
store.proxy.extraParams = {
|
346
|
tableName: 'PDSTVTPPROVID',
|
347
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + startDate + ',EndDate[>=]' + startDate
|
348
|
};
|
349
|
store.removeAll();
|
350
|
store.reload();
|
351
|
|
352
|
},
|
353
|
TransportClass: function () {
|
354
|
var startDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
355
|
|
356
|
var store = Ext.data.StoreManager.lookup('store_phrpa0063TransportClass');
|
357
|
store.proxy.extraParams = {
|
358
|
tableName: 'PDSTVTPCLASS',
|
359
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + startDate + ',EndDate[>=]' + startDate
|
360
|
};
|
361
|
store.removeAll();
|
362
|
store.reload();
|
363
|
|
364
|
},
|
365
|
deleteData: function () {
|
366
|
var me = this;
|
367
|
setTimeout(function () {
|
368
|
me.summaries();
|
369
|
}, 300);
|
370
|
},
|
371
|
accType: function () {
|
372
|
var startDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
373
|
|
374
|
var store = Ext.data.StoreManager.lookup('store_phrpa0064AccommodationType');
|
375
|
store.proxy.extraParams = {
|
376
|
tableName: 'PDSTVACCOMTYP',
|
377
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + startDate + ',EndDate[>=]' + startDate
|
378
|
};
|
379
|
store.removeAll();
|
380
|
store.reload();
|
381
|
|
382
|
},
|
383
|
accClass: function () {
|
384
|
var startDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
385
|
|
386
|
var store = Ext.data.StoreManager.lookup('store_phrpa0064AccommodationClass');
|
387
|
store.proxy.extraParams = {
|
388
|
tableName: 'PDSTVACCOMCLASS',
|
389
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + startDate + ',EndDate[>=]' + startDate
|
390
|
};
|
391
|
store.removeAll();
|
392
|
store.reload();
|
393
|
|
394
|
},
|
395
|
test: function () {
|
396
|
alert('a')
|
397
|
},
|
398
|
addTV: function () {
|
399
|
form = Ext.ComponentQuery.query('[name=formOverViewTV]')[0]; // edit proses
|
400
|
form.reset();
|
401
|
form.getForm().findField('EmployeeID').setValue(getParam('EmployeeID'))
|
402
|
form.setActionSubmit(0);
|
403
|
Ext.StoreMgr.lookup("transport").removeAll();
|
404
|
Ext.StoreMgr.lookup("accommodation").removeAll();
|
405
|
Ext.StoreMgr.lookup("cost").removeAll();
|
406
|
Ext.ComponentQuery.query('[name=PDSPA0003]')[0].getStore().removeAll();
|
407
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
408
|
card_.getLayout().setActiveItem(1);
|
409
|
var FullName = getParam("FullName");
|
410
|
var EmpID = getParam('EmployeeID');
|
411
|
this.setKeyDisabled(false);
|
412
|
Ext.ComponentQuery.query('[name=formOverViewTV]')[0].setTitle('Add - Travel Maintenance' + ' - ' + EmpID + ' - ' + FullName);
|
413
|
var datefield = Ext.ComponentQuery.query('[xtype=datefield]');
|
414
|
for (i = 0; i < datefield.length; i++) {
|
415
|
Ext.ComponentQuery.query('[xtype=datefield]')[i].setMinValue('01/01/1900');
|
416
|
Ext.ComponentQuery.query('[xtype=datefield]')[i].setMaxValue('31/12/10000');
|
417
|
}
|
418
|
|
419
|
},
|
420
|
cekAuth: function () {
|
421
|
actionMenu_ = MinovaUtil.GetActionMenu();
|
422
|
if (actionMenu_ == '0') {
|
423
|
Ext.ComponentQuery.query('[name=actionGrid]')[0].setHidden(true);
|
424
|
Ext.ComponentQuery.query('[name=saveTV]')[0].setHidden(true);
|
425
|
Ext.ComponentQuery.query('[name=deleteTV]')[0].setHidden(true);
|
426
|
}
|
427
|
},
|
428
|
afterRenderOverview: function () {
|
429
|
this.cekAuth();
|
430
|
var overView = Ext.StoreMgr.lookup("tvOverview");
|
431
|
overView.proxy.extraParams = {
|
432
|
tableName: 'phrpa0062',
|
433
|
param: 'EmployeeID[=]' + getParam('EmployeeID')
|
434
|
};
|
435
|
overView.removeAll();
|
436
|
overView.reload();
|
437
|
overView.loadPage(1);
|
438
|
},
|
439
|
copyTV: function () {
|
440
|
form = Ext.ComponentQuery.query('[name=formOverViewTV]')[0]; // edit proses
|
441
|
form.setActionSubmit(0);
|
442
|
this.overViewDblClick();
|
443
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
444
|
card_.getLayout().setActiveItem(1);
|
445
|
var FullName = getParam("FullName");
|
446
|
var EmpID = getParam('EmployeeID');
|
447
|
this.setKeyDisabled(false);
|
448
|
Ext.ComponentQuery.query('[name=formOverViewTV]')[0].setTitle('Copy - Travel Maintenance' + ' - ' + EmpID + ' - ' + FullName);
|
449
|
},
|
450
|
editTV: function () {
|
451
|
form = Ext.ComponentQuery.query('[name=formOverViewTV]')[0]; // edit proses
|
452
|
form.setActionSubmit(0);
|
453
|
this.overViewDblClick();
|
454
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
455
|
card_.getLayout().setActiveItem(1);
|
456
|
var FullName = getParam("FullName");
|
457
|
var EmpID = getParam('EmployeeID');
|
458
|
this.setKeyDisabled(true);
|
459
|
Ext.ComponentQuery.query('[name=formOverViewTV]')[0].setTitle('Edit - Travel Maintenance' + ' - ' + EmpID + ' - ' + FullName);
|
460
|
},
|
461
|
beforeEdit: function (editor, e) {
|
462
|
tvStatus = Ext.ComponentQuery.query('[name=TravelStatus]')[0].getValue();
|
463
|
grid_ = Ext.ComponentQuery.query('[name=gridphrpa0065]')[0];
|
464
|
if (tvStatus == '01') {
|
465
|
grid_.getPlugin('rowEditing').editor.form.findField('Number').enable();
|
466
|
grid_.getPlugin('rowEditing').editor.form.findField('Rate').enable();
|
467
|
grid_.getPlugin('rowEditing').editor.form.findField('AmountSettlement').disable();
|
468
|
grid_.getPlugin('rowEditing').editor.form.findField('AmountApproval').disable();
|
469
|
grid_.getPlugin('rowEditing').editor.form.findField('AmountPlan').disable();
|
470
|
} else if (tvStatus == '02') {
|
471
|
grid_.getPlugin('rowEditing').editor.form.findField('Number').disable();
|
472
|
grid_.getPlugin('rowEditing').editor.form.findField('Rate').disable();
|
473
|
grid_.getPlugin('rowEditing').editor.form.findField('AmountPlan').disable();
|
474
|
grid_.getPlugin('rowEditing').editor.form.findField('AmountSettlement').enable();
|
475
|
grid_.getPlugin('rowEditing').editor.form.findField('AmountApproval').enable();
|
476
|
|
477
|
} else {
|
478
|
MinovaMessage('', 'TVSTS', "", "E");
|
479
|
return false
|
480
|
}
|
481
|
|
482
|
},
|
483
|
cancel: function () {
|
484
|
Ext.Msg.show({
|
485
|
title: "",
|
486
|
msg: MinovaMessageData('000008', 'Over View'),
|
487
|
buttons: Ext.Msg.YESNO,
|
488
|
icon: Ext.Msg.QUESTION,
|
489
|
fn: function (choice) {
|
490
|
console.log(choice);
|
491
|
if (choice === 'yes') {
|
492
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
493
|
card_.getLayout().setActiveItem(0);
|
494
|
var FullName = getParam("FullName");
|
495
|
var EmpID = getParam('EmployeeID');
|
496
|
Ext.ComponentQuery.query('[name=formOverViewTV]')[0].setTitle('Travel Maintenance' + ' - ' + EmpID + ' - ' + FullName);
|
497
|
|
498
|
}
|
499
|
|
500
|
}
|
501
|
});
|
502
|
|
503
|
},
|
504
|
editRow: function (editor, e, eOps) {
|
505
|
|
506
|
var record = e.record;
|
507
|
var Number = parseFloat((record.data.Number).replace(',', '.'));
|
508
|
var Rate = parseFloat((record.data.Rate).replace(',', '.'));
|
509
|
var _amount = 0;
|
510
|
if (Number >= 0 && Rate >= 0) {
|
511
|
_amount = Number * Rate;
|
512
|
}
|
513
|
var valAmount = _amount.toString().replace('.', ',');
|
514
|
record.set("AmountPlan", valAmount);
|
515
|
if (parseInt(record.data.Number) > _amount) {
|
516
|
record.set("AmountApproval", '0');
|
517
|
}
|
518
|
this.cekMaxplan(_amount)
|
519
|
this.summaries();
|
520
|
|
521
|
},
|
522
|
overViewDblClick: function () {
|
523
|
var me = this;
|
524
|
form = Ext.ComponentQuery.query('[name=formOverViewTV]')[0]; // edit proses
|
525
|
form.setActionSubmit(1);
|
526
|
var grid_ = Ext.ComponentQuery.query('[name=phrpa0062]')[0];
|
527
|
var selection = grid_.getView().getSelectionModel().getSelection()[0];
|
528
|
var form_ = form.getForm();
|
529
|
form_.setValues(selection.data);
|
530
|
|
531
|
var HeaderSequence = selection.data.HeaderSequence;
|
532
|
var EmployeeID = selection.data.EmployeeID;
|
533
|
|
534
|
var param = 'EmployeeID[equal]' + EmployeeID + ',HeaderSequence[equal]' + HeaderSequence
|
535
|
|
536
|
var transport = Ext.StoreMgr.lookup("transport");
|
537
|
Ext.Ajax.request({
|
538
|
//method : 'POST',
|
539
|
url: '/UserControl/GetStore',
|
540
|
params: {
|
541
|
tableName: 'phrpa0063',
|
542
|
param: param
|
543
|
},
|
544
|
|
545
|
success: function (response) {
|
546
|
var results = Ext.decode(response.responseText);
|
547
|
transport.loadData(results.data);
|
548
|
|
549
|
}
|
550
|
});
|
551
|
|
552
|
var accommodation = Ext.StoreMgr.lookup("accommodation");
|
553
|
Ext.Ajax.request({
|
554
|
//method : 'POST',
|
555
|
url: '/UserControl/GetStore',
|
556
|
params: {
|
557
|
tableName: 'phrpa0064',
|
558
|
param: param
|
559
|
},
|
560
|
|
561
|
success: function (response) {
|
562
|
var results = Ext.decode(response.responseText);
|
563
|
accommodation.loadData(results.data);
|
564
|
|
565
|
}
|
566
|
});
|
567
|
|
568
|
var cost = Ext.StoreMgr.lookup("cost");
|
569
|
Ext.Ajax.request({
|
570
|
//method : 'POST',
|
571
|
async: false,
|
572
|
url: '/UserControl/GetStore',
|
573
|
params: {
|
574
|
tableName: 'phrpa0065',
|
575
|
param: param
|
576
|
},
|
577
|
|
578
|
success: function (response) {
|
579
|
var results = Ext.decode(response.responseText);
|
580
|
cost.loadData(results.data);
|
581
|
|
582
|
}
|
583
|
});
|
584
|
|
585
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
586
|
card_.getLayout().setActiveItem(1);
|
587
|
var FullName = getParam("FullName");
|
588
|
var EmpID = getParam('EmployeeID');
|
589
|
Ext.ComponentQuery.query('[name=formOverViewTV]')[0].setTitle('Edit - Travel Maintenance' + ' - ' + EmpID + ' - ' + FullName);
|
590
|
|
591
|
me.summaries();
|
592
|
},
|
593
|
summaries: function () {
|
594
|
var storeCost = Ext.StoreMgr.lookup('cost');
|
595
|
var itemCost = storeCost.data.items
|
596
|
var cost = Ext.encode(Ext.pluck(storeCost.data.items, 'data'));
|
597
|
Ext.Ajax.request({
|
598
|
async: false,
|
599
|
method: 'POST',
|
600
|
url: '/Travel/GetCalculatedCostTravel',
|
601
|
params: {
|
602
|
CostData: cost,
|
603
|
},
|
604
|
waitMsg: 'Data...',
|
605
|
success: function (response) {
|
606
|
var result = Ext.decode(response.responseText);
|
607
|
var dataCost = Ext.decode(result.data);
|
608
|
var storeTotal = Ext.ComponentQuery.query('[name=PDSPA0003]')[0].getStore();
|
609
|
storeTotal.removeAll();
|
610
|
storeTotal.loadData(dataCost)
|
611
|
},
|
612
|
failure: function (response) {
|
613
|
var result = Ext.decode(response.responseText);
|
614
|
MinovaMessage('', '000005', result.message.text, "E")
|
615
|
}
|
616
|
});
|
617
|
},
|
618
|
saveTV: function () {
|
619
|
var me = this;
|
620
|
var Formheader = Ext.ComponentQuery.query('[name=formOverViewTV]')[0].getForm();
|
621
|
if (Formheader.isValid()) {
|
622
|
var pnl = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
623
|
pnl.mask('Loading...');
|
624
|
var storeGridRoute = Ext.StoreMgr.lookup("transport");
|
625
|
var storeGridAccomodation = Ext.StoreMgr.lookup("accommodation");
|
626
|
var storeGridCost = Ext.StoreMgr.lookup("cost");
|
627
|
var route = Ext.encode(Ext.pluck(storeGridRoute.data.items, 'data'));
|
628
|
var acomodation = Ext.encode(Ext.pluck(storeGridAccomodation.data.items, 'data'));
|
629
|
var cost = Ext.encode(Ext.pluck(storeGridCost.data.items, 'data'));
|
630
|
|
631
|
Ext.Ajax.request({
|
632
|
async: false,
|
633
|
method: 'POST',
|
634
|
url: '/Devt/SaveTravelMaintenance',
|
635
|
params: {
|
636
|
header: Ext.encode(Formheader.getValues()),
|
637
|
route: route,
|
638
|
accomodation: acomodation,
|
639
|
cost: cost
|
640
|
},
|
641
|
waitMsg: 'Saving Data...',
|
642
|
success: function (response) {
|
643
|
|
644
|
var result = Ext.decode(response.responseText);
|
645
|
if (result.success) {
|
646
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
647
|
card_.getLayout().setActiveItem(0);
|
648
|
MinovaMessage('', '000006', '', 'S');
|
649
|
me.afterRenderOverview();
|
650
|
pnl.unmask();
|
651
|
} else {
|
652
|
pnl.unmask();
|
653
|
MinovaMessage('', '000005', result.message.text, "E")
|
654
|
}
|
655
|
},
|
656
|
failure: function (response) {
|
657
|
var result = Ext.decode(response.responseText);
|
658
|
pnl.unmask();
|
659
|
MinovaMessage('', '000005', result.message.text, "E")
|
660
|
}
|
661
|
});
|
662
|
} else {
|
663
|
var param_ = me.cekMandatoryIsNull();
|
664
|
if (param_ != "") {
|
665
|
MinovaMessage('Not Null', '000009', param_, 'E');
|
666
|
} else {
|
667
|
// ada field yang error
|
668
|
var error_ = me.getErrorFields();
|
669
|
if (error_ != '') {
|
670
|
MinovaMessage('title', '000005', error_, 'E');
|
671
|
}
|
672
|
|
673
|
}
|
674
|
}
|
675
|
|
676
|
},
|
677
|
btnDeleteTV: function () {
|
678
|
var me = this;
|
679
|
MinovaMessage('Message', '000007', '', 'C', function (respone) {
|
680
|
if (respone == "yes") {
|
681
|
me.deleteTV();
|
682
|
}
|
683
|
});
|
684
|
},
|
685
|
deleteTV: function () {
|
686
|
var me = this;
|
687
|
var Formheader = Ext.ComponentQuery.query('[name=formOverViewTV]')[0].getForm();
|
688
|
if (Formheader.isValid()) {
|
689
|
Ext.Msg.show({
|
690
|
title: "",
|
691
|
msg: MinovaMessageData('000007', ''),
|
692
|
buttons: Ext.Msg.YESNO,
|
693
|
icon: Ext.Msg.QUESTION,
|
694
|
fn: function (choice) {
|
695
|
console.log(choice);
|
696
|
if (choice === 'yes') {
|
697
|
var pnl = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
698
|
pnl.mask('Loading...');
|
699
|
Ext.Ajax.request({
|
700
|
async: false,
|
701
|
method: 'POST',
|
702
|
url: '/Devt/DeleteTravelMaintenance',
|
703
|
params: {
|
704
|
header: Ext.encode(Formheader.getValues())
|
705
|
|
706
|
},
|
707
|
waitMsg: 'Saving Data...',
|
708
|
success: function (response) {
|
709
|
|
710
|
var result = Ext.decode(response.responseText);
|
711
|
if (result.success) {
|
712
|
var card_ = Ext.ComponentQuery.query('[name=tvCard]')[0];
|
713
|
card_.getLayout().setActiveItem(0);
|
714
|
MinovaMessage('', 'BSDEL', '', 'S');
|
715
|
me.afterRenderOverview();
|
716
|
pnl.unmask();
|
717
|
} else {
|
718
|
pnl.unmask();
|
719
|
MinovaMessage('', '000005', result.message.text, "E");
|
720
|
}
|
721
|
},
|
722
|
failure: function (response) {
|
723
|
var result = Ext.decode(response.responseText);
|
724
|
MinovaMessage('', '000005', result.message.text, "E");
|
725
|
pnl.unmask();
|
726
|
}
|
727
|
});
|
728
|
}
|
729
|
|
730
|
}
|
731
|
});
|
732
|
|
733
|
}
|
734
|
},
|
735
|
cekMandatoryIsNull: function () {
|
736
|
var fields_ = Ext.ComponentQuery.query('[wasValid=false][allowBlank=false]');
|
737
|
var param_ = '';
|
738
|
if (fields_.length > 0) {
|
739
|
for (var i = 0; i < fields_.length; i++) {
|
740
|
if (i == 0) {
|
741
|
param_ = ':' + fields_[i].fieldLabel
|
742
|
} else {
|
743
|
param_ = param_ + ',' + fields_[i].fieldLabel;
|
744
|
}
|
745
|
|
746
|
}
|
747
|
}
|
748
|
return param_
|
749
|
},
|
750
|
getErrorFields: function () {
|
751
|
var fields_ = Ext.ComponentQuery.query('[wasValid=false]');
|
752
|
var param_ = '';
|
753
|
if (fields_.length > 0) {
|
754
|
for (var i = 0; i < fields_.length; i++) {
|
755
|
if (i == 0) {
|
756
|
param_ = ':' + fields_[i].fieldLabel;
|
757
|
} else {
|
758
|
param_ = param_ + ',' + fields_[i].fieldLabel;
|
759
|
}
|
760
|
|
761
|
}
|
762
|
}
|
763
|
return param_
|
764
|
},
|
765
|
setKeyDisabled: function (param) {
|
766
|
var frmEdit = Ext.ComponentQuery.query('[name=formOverViewTV]')[0].getForm();
|
767
|
var fields_ = frmEdit.getFields().items;
|
768
|
for (var i = 0; i < fields_.length; i++) {
|
769
|
var field_ = frmEdit.getFields().items[i];
|
770
|
iskey_ = field_.IsPrimaryKey;
|
771
|
if (iskey_ == '1') {
|
772
|
field_.setReadOnly(param);
|
773
|
}
|
774
|
}
|
775
|
},
|
776
|
loadrRouteGridParam: function (this_, newValue, oldValue, eOpts) {
|
777
|
var storeTransportType = Ext.data.StoreManager.lookup('store_phrpa0063TransportType');
|
778
|
var tableTransportType = storeTransportType.proxy.extraParams.tableName;
|
779
|
var storeTransportProvider = Ext.data.StoreManager.lookup('store_phrpa0063TransportProvider');
|
780
|
var tableTransportProvider = storeTransportProvider.proxy.extraParams.tableName;
|
781
|
var storeTransportClass = Ext.data.StoreManager.lookup('store_phrpa0063TransportClass');
|
782
|
var tableTransportClass = storeTransportClass.proxy.extraParams.tableName;
|
783
|
|
784
|
//get md travel transport
|
785
|
var data_ = null;
|
786
|
var EmpTVClass = "";
|
787
|
var EmpTVGrade = "";
|
788
|
|
789
|
Ext.Ajax.request({
|
790
|
async: false,
|
791
|
url: '/UserControl/GetStore',
|
792
|
params: {
|
793
|
tableName: 'PDSTVTPTYP',
|
794
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + newValue + ',EndDate[>=]' + newValue
|
795
|
},
|
796
|
|
797
|
success: function (response) {
|
798
|
var results = Ext.decode(response.responseText);
|
799
|
data_ = (results.data);
|
800
|
storeTransportType.loadData(data_)
|
801
|
|
802
|
}
|
803
|
});
|
804
|
|
805
|
Ext.Ajax.request({
|
806
|
async: false,
|
807
|
url: '/UserControl/GetStore',
|
808
|
params: {
|
809
|
tableName: 'PDSTVTPPROVID',
|
810
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + newValue + ',EndDate[>=]' + newValue
|
811
|
},
|
812
|
|
813
|
success: function (response) {
|
814
|
var results = Ext.decode(response.responseText);
|
815
|
data_ = (results.data);
|
816
|
storeTransportProvider.loadData(data_)
|
817
|
|
818
|
}
|
819
|
});
|
820
|
|
821
|
Ext.Ajax.request({
|
822
|
async: false,
|
823
|
url: '/UserControl/GetStore',
|
824
|
params: {
|
825
|
tableName: 'PDSTVTPCLASS',
|
826
|
param: 'EmployeeID[=]' + getParam('EmployeeID') + ',StartDate[<=]' + newValue + ',EndDate[>=]' + newValue
|
827
|
},
|
828
|
|
829
|
success: function (response) {
|
830
|
var results = Ext.decode(response.responseText);
|
831
|
data_ = (results.data);
|
832
|
storeTransportClass.loadData(data_)
|
833
|
|
834
|
}
|
835
|
});
|
836
|
|
837
|
},
|
838
|
cekStartDate: function (f) {
|
839
|
var startDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
840
|
var endDate_ = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
841
|
var endDate = f.getValue();
|
842
|
var dif = MinovaUtil.GetDateDiff(endDate, startDate);
|
843
|
if (dif < 0) {
|
844
|
MinovaMessage('', 'TVDATE', '', 'E');
|
845
|
f.setValue('')
|
846
|
} else {
|
847
|
dif = MinovaUtil.GetDateDiff(endDate_, startDate);
|
848
|
if (dif > 0) {
|
849
|
MinovaMessage('', 'TVDATE', '', 'E');
|
850
|
f.setValue('')
|
851
|
}
|
852
|
}
|
853
|
|
854
|
},
|
855
|
cekEndDate: function (f) {
|
856
|
var startDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
857
|
var endDate_ = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
858
|
var endDate = f.getValue();
|
859
|
var dif = MinovaUtil.GetDateDiff(startDate, endDate);
|
860
|
if (dif > 0) {
|
861
|
MinovaMessage('', 'TVDATE', '', 'E');
|
862
|
f.setValue('')
|
863
|
} else {
|
864
|
dif = MinovaUtil.GetDateDiff(startDate, endDate_);
|
865
|
if (dif < 0) {
|
866
|
MinovaMessage('', 'TVDATE', '', 'E');
|
867
|
f.setValue('')
|
868
|
}
|
869
|
}
|
870
|
|
871
|
},
|
872
|
cekMaxplan: function (val) {
|
873
|
//empid,startdate,traveltype,cyrrency,costtype
|
874
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0];
|
875
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0];
|
876
|
var Currency = Ext.ComponentQuery.query('[id=phrpa0065Currency]')[0];
|
877
|
var CostType = Ext.ComponentQuery.query('[id=phrpa0065CostType]')[0];
|
878
|
var f = Ext.ComponentQuery.query('[id=phrpa0065AmountApproval]')[0];
|
879
|
|
880
|
var EmployeeID = getParam("EmployeeID");
|
881
|
if (StartDate.getValue() != '' && Currency.getValue() != '' && TravelType.getValue() != '' && CostType.getValue != '') {
|
882
|
//if (StartDate != '' && Currency != '' && TravelType != '' && CostType != '') {
|
883
|
Ext.Ajax.request({
|
884
|
async: false,
|
885
|
method: 'POST',
|
886
|
url: '/UserControl/GetStore',
|
887
|
params: {
|
888
|
tableName: 'PDSTVCOSTRATE',
|
889
|
param: EmployeeID + ',' + StartDate.getValue() + ',' + TravelType.getValue() + ',' + Currency.getValue() + "," + CostType.getValue()
|
890
|
},
|
891
|
success: function (response) {
|
892
|
var results = Ext.decode(response.responseText);
|
893
|
var dt = results.data;
|
894
|
if (dt.length > 0) {
|
895
|
data_ = dt[0];
|
896
|
var min = parseFloat(data_.MinAmount);
|
897
|
var max = parseFloat(data_.MaxAmount);
|
898
|
var rate = parseFloat(data_.Rate);
|
899
|
if (val < min) {
|
900
|
//MinovaMessage('', 'BSMINAMT', '', 'E');
|
901
|
MinovaMessage(' Message ', ' BSMINAMT ', +min + '$' + max, 'C', function (respone) {
|
902
|
if (respone != "yes") {
|
903
|
f.setValue('');
|
904
|
}
|
905
|
})
|
906
|
} else if (val > max) {
|
907
|
//MinovaMessage('', 'BSMAXAMT', '', 'E');
|
908
|
MinovaMessage(' Message ', ' BSMAXAMT ', +min + '$' + max, 'C', function (respone) {
|
909
|
if (respone != "yes") {
|
910
|
f.setValue('');
|
911
|
}
|
912
|
})
|
913
|
}
|
914
|
|
915
|
}
|
916
|
}
|
917
|
});
|
918
|
}
|
919
|
},
|
920
|
setMinMaxDate63: function (f) {
|
921
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
922
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
923
|
var dt = Ext.ComponentQuery.query('[id=phrpa0063StartDate]')[0];
|
924
|
if (dt.getValue() == '') {
|
925
|
if (valsd != "") {
|
926
|
dt.setMaxValue(valed.substring(6, 8) + '/' + valed.substring(4, 6) + '/' + valed.substring(0, 4))
|
927
|
}
|
928
|
if (valsd != "") {
|
929
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
930
|
}
|
931
|
}
|
932
|
},
|
933
|
setMinMaxDate64: function (f) {
|
934
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
935
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
936
|
var dt = Ext.ComponentQuery.query('[id=phrpa0064StartDate]')[0];
|
937
|
|
938
|
if (valsd != "") {
|
939
|
dt.setMaxValue(valed.substring(6, 8) + '/' + valed.substring(4, 6) + '/' + valed.substring(0, 4))
|
940
|
}
|
941
|
if (valsd != "") {
|
942
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
943
|
}
|
944
|
},
|
945
|
setMinMaxDate65: function (f) {
|
946
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
947
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
948
|
var dt = Ext.ComponentQuery.query('[id=phrpa0065StartDate]')[0];
|
949
|
|
950
|
if (valsd != "") {
|
951
|
dt.setMaxValue(valed.substring(6, 8) + '/' + valed.substring(4, 6) + '/' + valed.substring(0, 4))
|
952
|
}
|
953
|
if (valsd != "") {
|
954
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
955
|
}
|
956
|
},
|
957
|
cekEndDate63: function (f) {
|
958
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
959
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
960
|
var dt = Ext.ComponentQuery.query('[id=phrpa0063EndDate]')[0];
|
961
|
|
962
|
if (valsd != "") {
|
963
|
dt.setMaxValue(valed.substring(6, 8) + '/' + valed.substring(4, 6) + '/' + valed.substring(0, 4))
|
964
|
}
|
965
|
if (valsd != "") {
|
966
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
967
|
}
|
968
|
},
|
969
|
cekEndDate64: function (f) {
|
970
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
971
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
972
|
var dt = Ext.ComponentQuery.query('[id=phrpa0064EndDate]')[0];
|
973
|
|
974
|
if (valsd != "") {
|
975
|
dt.setMaxValue(valed.substring(6, 8) + '/' + valed.substring(4, 6) + '/' + valed.substring(0, 4))
|
976
|
}
|
977
|
if (valsd != "") {
|
978
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
979
|
}
|
980
|
},
|
981
|
cekEndDate65: function (f) {
|
982
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
983
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
984
|
var dt = Ext.ComponentQuery.query('[id=phrpa0065EndDate]')[0];
|
985
|
|
986
|
if (valsd != "") {
|
987
|
dt.setMaxValue(valed.substring(6, 8) + '/' + valed.substring(4, 6) + '/' + valed.substring(0, 4))
|
988
|
}
|
989
|
if (valsd != "") {
|
990
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
991
|
}
|
992
|
},
|
993
|
|
994
|
setEndDate63: function () {
|
995
|
var valsd = Ext.ComponentQuery.query('[id=phrpa0063StartDate]')[0].getValue();
|
996
|
var dt = Ext.ComponentQuery.query('[id=phrpa0063EndDate]')[0];
|
997
|
|
998
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
999
|
},
|
1000
|
setEndDate64: function () {
|
1001
|
var valsd = Ext.ComponentQuery.query('[id=phrpa0064StartDate]')[0].getValue();
|
1002
|
var dt = Ext.ComponentQuery.query('[id=phrpa0064EndDate]')[0];
|
1003
|
|
1004
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
1005
|
},
|
1006
|
setEndDate65: function () {
|
1007
|
var valsd = Ext.ComponentQuery.query('[id=phrpa0065StartDate]')[0].getValue();
|
1008
|
var dt = Ext.ComponentQuery.query('[id=phrpa0065EndDate]')[0];
|
1009
|
|
1010
|
dt.setMinValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
1011
|
},
|
1012
|
setStartDate63: function () {
|
1013
|
var dt = Ext.ComponentQuery.query('[id=phrpa0063StartDate]')[0];
|
1014
|
var valsd = Ext.ComponentQuery.query('[id=phrpa0063EndDate]')[0].getValue();
|
1015
|
|
1016
|
dt.setMaxValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
1017
|
},
|
1018
|
setStartDate64: function () {
|
1019
|
var dt = Ext.ComponentQuery.query('[id=phrpa0064StartDate]')[0];
|
1020
|
var valsd = Ext.ComponentQuery.query('[id=phrpa0064EndDate]')[0].getValue();
|
1021
|
|
1022
|
dt.setMaxValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
1023
|
},
|
1024
|
setStartDate65: function () {
|
1025
|
var dt = Ext.ComponentQuery.query('[id=phrpa0065StartDate]')[0];
|
1026
|
var valsd = Ext.ComponentQuery.query('[id=phrpa0065EndDate]')[0].getValue();
|
1027
|
|
1028
|
dt.setMaxValue(valsd.substring(6, 8) + '/' + valsd.substring(4, 6) + '/' + valsd.substring(0, 4))
|
1029
|
},
|
1030
|
beforeedit63: function (editor, e, eOpts) {
|
1031
|
var me = this;
|
1032
|
var valsd = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
1033
|
var valed = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
1034
|
if (e.record.data.StartDate == "") {
|
1035
|
Ext.ComponentQuery.query('[id=phrpa0063StartDate]')[0].setValue('');
|
1036
|
Ext.ComponentQuery.query('[id=phrpa0063EndDate]')[0].setValue('');
|
1037
|
} else {
|
1038
|
Ext.ComponentQuery.query('[id=phrpa0063StartDate]')[0].setValue(e.record.data.StartDate);
|
1039
|
Ext.ComponentQuery.query('[id=phrpa0063EndDate]')[0].setValue(e.record.data.EndDate);
|
1040
|
}
|
1041
|
me.setMinMaxDate63();
|
1042
|
me.cekEndDate63();
|
1043
|
},
|
1044
|
beforeedit64: function (editor, e, eOpts) {
|
1045
|
var me = this;
|
1046
|
if (e.record.data.StartDate == "") {
|
1047
|
Ext.ComponentQuery.query('[id=phrpa0064StartDate]')[0].setValue('');
|
1048
|
Ext.ComponentQuery.query('[id=phrpa0064EndDate]')[0].setValue('');
|
1049
|
} else {
|
1050
|
Ext.ComponentQuery.query('[id=phrpa0064StartDate]')[0].setValue(e.record.data.StartDate);
|
1051
|
Ext.ComponentQuery.query('[id=phrpa0064EndDate]')[0].setValue(e.record.data.EndDate);
|
1052
|
}
|
1053
|
me.setMinMaxDate64();
|
1054
|
me.cekEndDate64();
|
1055
|
},
|
1056
|
beforeedit65: function (editor, e, eOpts) {
|
1057
|
var me = this;
|
1058
|
if (e.record.data.StartDate == "") {
|
1059
|
Ext.ComponentQuery.query('[id=phrpa0065StartDate]')[0].setValue('');
|
1060
|
Ext.ComponentQuery.query('[id=phrpa0065EndDate]')[0].setValue('');
|
1061
|
} else {
|
1062
|
Ext.ComponentQuery.query('[id=phrpa0065StartDate]')[0].setValue(e.record.data.StartDate);
|
1063
|
Ext.ComponentQuery.query('[id=phrpa0065EndDate]')[0].setValue(e.record.data.EndDate);
|
1064
|
}
|
1065
|
me.setMinMaxDate65();
|
1066
|
me.cekEndDate65();
|
1067
|
},
|
1068
|
specialkey: function (field, e) {
|
1069
|
var me = this;
|
1070
|
if (e.getKey() == e.ENTER) {
|
1071
|
alert('a')
|
1072
|
}
|
1073
|
},
|
1074
|
deleteCostTV: function () {
|
1075
|
var me = this;
|
1076
|
var store = Ext.StoreMgr.lookup('cost');
|
1077
|
|
1078
|
var grid = Ext.getCmp('gridphrpa0065');
|
1079
|
|
1080
|
Ext.MessageBox.show({
|
1081
|
title: 'Remove tab',
|
1082
|
msg: "This will remove. Do you want to continue?",
|
1083
|
buttons: Ext.MessageBox.YESNO,
|
1084
|
fn: function (choice) {
|
1085
|
console.log(choice);
|
1086
|
if (choice === 'yes') {
|
1087
|
var selection = grid.getView().getSelectionModel().getSelection()[0];
|
1088
|
if (selection) {
|
1089
|
store.remove(selection);
|
1090
|
me.me.summaries();
|
1091
|
}
|
1092
|
}
|
1093
|
//delete panel.pendingClose;
|
1094
|
}
|
1095
|
});
|
1096
|
},
|
1097
|
SetNumber : function (){
|
1098
|
var Number = Ext.ComponentQuery.query('[id=phrpa0065Number]')[0];
|
1099
|
var StartDate = Ext.ComponentQuery.query('[name=StartDate][nameTable=phrpa0062]')[0].getValue();
|
1100
|
var EndDate = Ext.ComponentQuery.query('[name=EndDate][nameTable=phrpa0062]')[0].getValue();
|
1101
|
var TravelType = Ext.ComponentQuery.query('[name=TravelType][nameTable=phrpa0062]')[0].getValue();
|
1102
|
var Code = TravelType.substring(0, 1);
|
1103
|
var Duration = MinovaUtil.GetDateDiff(EndDate, StartDate);
|
1104
|
if (Code === 0) {
|
1105
|
Number.setValue(Duration)
|
1106
|
} else {
|
1107
|
Number.setValue(Duration + 1);
|
1108
|
}
|
1109
|
|
1110
|
|
1111
|
}
|
1112
|
});
|