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