1
|
Ext.define('MinovaES.controller.filo.document', {
|
2
|
extend: 'Ext.app.ViewController',
|
3
|
alias: 'controller.document',
|
4
|
action: '0',
|
5
|
transType: undefined,
|
6
|
docType: undefined,
|
7
|
docNo: "None",
|
8
|
dataExist: "",
|
9
|
docStatus: "",
|
10
|
docStatusExist: "",
|
11
|
PostingDateExist: "",
|
12
|
init: function () {
|
13
|
this.control({
|
14
|
'button[name=CreateDoc]': {
|
15
|
click: this.createDoc
|
16
|
},
|
17
|
'[name=searchResult]': {
|
18
|
afterrender: this.afterrenderLookupGrid,
|
19
|
itemdblclick: this.displayDoc,
|
20
|
itemclick: this.displayResultInfo
|
21
|
},
|
22
|
'button[name=CreateDocRef]': {
|
23
|
click: this.getLookupRefDoc
|
24
|
},
|
25
|
'[name=FiloDocMain]': {
|
26
|
afterrender: this.afterrenderDoc
|
27
|
},
|
28
|
'[name=SaveCreateDoc]': {
|
29
|
//click: this.saveDoc
|
30
|
click: function () {
|
31
|
// this == the button, as we are in the local scope
|
32
|
console.log('SaveCreateDoc!');
|
33
|
this.backCreateDoc();
|
34
|
|
35
|
}
|
36
|
},
|
37
|
'[name=Create1Doc]': {
|
38
|
//click: this.saveDoc
|
39
|
click: function () {
|
40
|
// this == the button, as we are in the local scope
|
41
|
console.log('Create1Doc!');
|
42
|
this.backDoc();
|
43
|
this.loadDoc();
|
44
|
}
|
45
|
},
|
46
|
'button[name=SaveCreateDocRef]': {
|
47
|
click: this.backCreateDoc
|
48
|
},
|
49
|
'button[name=Create1DocRef]': {
|
50
|
click: function () {
|
51
|
this.reloadDoc();
|
52
|
this.createDoc();
|
53
|
this.getLookupRefDoc();
|
54
|
}
|
55
|
},
|
56
|
'[name=SaveDoc]': {
|
57
|
click: this.saveDoc
|
58
|
},
|
59
|
'[name=DeleteDoc]': {
|
60
|
click: this.deleteDoc
|
61
|
},
|
62
|
'[name=CancelDoc]': {
|
63
|
click: this.cancelDoc
|
64
|
},
|
65
|
'[name=EditDoc]': {
|
66
|
click: this.editDoc
|
67
|
},
|
68
|
'#DocNo': {
|
69
|
"ontriggerclick": this.getLookupDoc,
|
70
|
specialkey: this.specialKey
|
71
|
},
|
72
|
'#mainTab': {
|
73
|
tabchange: this.changeTab
|
74
|
},
|
75
|
'[name=panelTab]': {
|
76
|
afterrender: this.afterrenderTab
|
77
|
},
|
78
|
'[name=searchFilter]': {
|
79
|
afterrender: this.doctyperender
|
80
|
},
|
81
|
'[name=PostingDate]': {
|
82
|
change: this.PostingDate
|
83
|
}
|
84
|
});
|
85
|
},
|
86
|
|
87
|
PostingDate: function () {
|
88
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
89
|
var activeTab = tb.activeTab;
|
90
|
var tbl = activeTab.tbl;
|
91
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
92
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
93
|
/*var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
94
|
var formheader = panelHead.getForm();
|
95
|
var FiscalPeriod = formheader.findField("FiscalPeriod").getValue();
|
96
|
var FiscalYear = formheader.findField("FiscalYear").getValue();
|
97
|
var DocStatus = formheader.findField("DocStatus").getValue();
|
98
|
if(DocStatus == '1')
|
99
|
{
|
100
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
101
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
102
|
for (i = 0; i < store.count(); i++) {
|
103
|
store.data.items[i].data.FiscalPeriod = FiscalPeriod;
|
104
|
store.data.items[i].data.FiscalYear = FiscalYear;
|
105
|
}
|
106
|
}*/
|
107
|
},
|
108
|
doctyperender: function () {
|
109
|
var menuID = MinovaUtil.GetMenuID();
|
110
|
var notes = '';
|
111
|
Ext.Ajax.request({
|
112
|
async: false,
|
113
|
method: 'POST',
|
114
|
url: '/UserControl/GetStore',
|
115
|
params: {
|
116
|
tableName: 'SMENU',
|
117
|
param: 'MENUID' + '[=]' + menuID
|
118
|
},
|
119
|
success: function (response) {
|
120
|
var results = Ext.decode(response.responseText);
|
121
|
dt = results.data;
|
122
|
notes = dt[0].Notes;
|
123
|
}
|
124
|
});
|
125
|
console.log(notes);
|
126
|
|
127
|
},
|
128
|
afterrenderLookupGrid: function () {
|
129
|
var store = Ext.data.StoreManager.lookup('storeadvance');
|
130
|
store.sort('ChangeDate', 'DESC');
|
131
|
},
|
132
|
afterrenderDoc: function () {
|
133
|
var me = this;
|
134
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
135
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
136
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
137
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
138
|
var formHead = panelHead.getForm();
|
139
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
140
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
141
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
142
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
143
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
144
|
var btnPost = Ext.ComponentQuery.query('[name=PostDoc]')[0];
|
145
|
|
146
|
|
147
|
//var act = getParam("action");
|
148
|
// var act = me.action;
|
149
|
// if(act == '0'){
|
150
|
// pnlSelect.setHidden(false);
|
151
|
// pnlTransaction.setHidden(true);
|
152
|
// } else {
|
153
|
// pnlSelect.setHidden(true);
|
154
|
// pnlTransaction.setHidden(false);
|
155
|
// if(act == '0'){
|
156
|
// panelHead.setHidden(false);
|
157
|
// panelDisplayHead.setHidden(true);
|
158
|
// btnSave.setDisabled(false);
|
159
|
// btnEdit.setDisabled(true);
|
160
|
// btnDelete.setDisabled(true);
|
161
|
// }
|
162
|
// else if(act == '1'){
|
163
|
// panelHead.setHidden(true);
|
164
|
// panelDisplayHead.setHidden(false);
|
165
|
// btnSave.setDisabled(true);
|
166
|
// btnEdit.setDisabled(false);
|
167
|
// btnDelete.setDisabled(false);
|
168
|
// }
|
169
|
//}
|
170
|
me.transType = panelHead.transType;
|
171
|
me.docType = panelHead.docType;
|
172
|
me.transType = panelDisplayHead.transType;
|
173
|
me.docType = panelDisplayHead.docType;
|
174
|
formHead.findField("DocType").setValue(me.docType);
|
175
|
// if(me.transType == 'FIN'){
|
176
|
// btnPost.setHidden(false);
|
177
|
// }
|
178
|
},
|
179
|
afterrenderTab: function () {
|
180
|
var me = this;
|
181
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
182
|
var activeTab = tb.activeTab;
|
183
|
var keyField = "DocNo";
|
184
|
var keyValue = me.docNo;
|
185
|
var act = me.action;
|
186
|
me.loadTabPanel(activeTab, keyField, keyValue, act);
|
187
|
},
|
188
|
changeTab: function (tabPanel, newCard, oldCard, eOpts) {
|
189
|
var me = this;
|
190
|
var keyField = "DocNo";
|
191
|
var keyValue = me.docNo;
|
192
|
var act = me.action;
|
193
|
me.loadTabPanel(newCard, keyField, keyValue, act);
|
194
|
},
|
195
|
loadTabPanel: function (tabObj, keyField, keyValue, act) {
|
196
|
var tbl = tabObj.tbl;
|
197
|
tabObj.getEl().mask("loading...");
|
198
|
if (tabObj.layoutType == 'L001') {
|
199
|
var dt = undefined;
|
200
|
Ext.Ajax.request({
|
201
|
async: false,
|
202
|
method: 'POST',
|
203
|
url: '/UserControl/GetStore',
|
204
|
params: {
|
205
|
tableName: tbl,
|
206
|
param: keyField + '[=]' + keyValue
|
207
|
},
|
208
|
success: function (response) {
|
209
|
var results = Ext.decode(response.responseText);
|
210
|
dt = results.data;
|
211
|
}
|
212
|
});
|
213
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
214
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
215
|
if (act == '0') {
|
216
|
frmDisplay.setHidden(true);
|
217
|
frmForm.setHidden(false);
|
218
|
} else if (act == '1' || act == '2') {
|
219
|
frmDisplay.reset();
|
220
|
frmForm.reset();
|
221
|
if (dt.length > 0) {
|
222
|
frmDisplay.getForm().setValues(dt[0]);
|
223
|
frmForm.getForm().setValues(dt[0]);
|
224
|
}
|
225
|
frmDisplay.setHidden(false);
|
226
|
frmForm.setHidden(true);
|
227
|
}
|
228
|
}
|
229
|
if (tabObj.layoutType == 'L002' || tabObj.layoutType == 'L003') {
|
230
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
231
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
232
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
233
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
234
|
store.proxy.extraParams = {
|
235
|
tableName: tbl,
|
236
|
param: keyField + '[=]' + keyValue
|
237
|
};
|
238
|
store.removeAll();
|
239
|
store.reload();
|
240
|
store.loadPage(1);
|
241
|
frmDisplay.reset();
|
242
|
frmForm.reset();
|
243
|
frmDisplay.setHidden(true);
|
244
|
frmForm.setHidden(true);
|
245
|
grdPanel.setHidden(false);
|
246
|
}
|
247
|
if (tabObj.layoutType == 'L005') {
|
248
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
249
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
250
|
store.proxy.extraParams = {
|
251
|
tableName: tbl,
|
252
|
param: keyField + '[=]' + keyValue
|
253
|
};
|
254
|
store.removeAll();
|
255
|
store.reload();
|
256
|
store.loadPage(1);
|
257
|
grdPanel.setHidden(false);
|
258
|
}
|
259
|
if (tabObj.layoutType == 'L006' || tabObj.layoutType == 'L007') {
|
260
|
var grdPanel = Ext.ComponentQuery.query('[name=CELLGRID' + tbl + ']')[0];
|
261
|
grdPanel.setHidden(false);
|
262
|
if (act == '0') {
|
263
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
264
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
265
|
if (tabObj.layoutType == 'L007') {
|
266
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(false);
|
267
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(false);
|
268
|
}
|
269
|
} else if (act == '2') {
|
270
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(true);
|
271
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(true);
|
272
|
if (tabObj.layoutType == 'L007') {
|
273
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(true);
|
274
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(true);
|
275
|
}
|
276
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
277
|
store.proxy.url = '/UserControl/GetStore';
|
278
|
store.proxy.extraParams = {
|
279
|
tableName: tbl,
|
280
|
param: keyField + '[=]' + keyValue
|
281
|
};
|
282
|
store.removeAll();
|
283
|
store.reload();
|
284
|
store.loadPage(1);
|
285
|
} else {
|
286
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
287
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
288
|
if (tabObj.layoutType == 'L007') {
|
289
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(false);
|
290
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(false);
|
291
|
}
|
292
|
}
|
293
|
|
294
|
if (tabObj.layoutType == 'L007') {
|
295
|
var sumPanel = Ext.ComponentQuery.query('[name=SUM' + tbl + ']')[0];
|
296
|
var sumForm = sumPanel.getForm();
|
297
|
var itm = sumForm.getFields().items;
|
298
|
Ext.Ajax.request({
|
299
|
async: false,
|
300
|
method: 'POST',
|
301
|
url: '/UserControl/GetStore',
|
302
|
params: {
|
303
|
tableName: tbl,
|
304
|
param: keyField + '[=]' + keyValue
|
305
|
},
|
306
|
success: function (response) {
|
307
|
var results = Ext.decode(response.responseText);
|
308
|
dtgrid = results.data;
|
309
|
}
|
310
|
});
|
311
|
Ext.each(itm, function (i) {
|
312
|
var fld = i.name;
|
313
|
var fldValue = 0;
|
314
|
Ext.each(dtgrid, function (d) {
|
315
|
var fValue = d[fld];
|
316
|
fldValue = fldValue + parseFloat(fValue);
|
317
|
});
|
318
|
fldValue = Ext.util.Format.number(fldValue, '0,000.00');
|
319
|
sumForm.findField(fld).setValue(fldValue);
|
320
|
});
|
321
|
}
|
322
|
}
|
323
|
tabObj.getEl().unmask();
|
324
|
},
|
325
|
buildMultiGrid: function () {
|
326
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
327
|
var GridData = PanelData.query('docgrid');
|
328
|
var GridLength = GridData.length;
|
329
|
var GridBuildStrings = [];
|
330
|
for (var i = 0; i < GridLength; i++) {
|
331
|
var records = [];
|
332
|
var grd = GridData[i].query('grid')[0];
|
333
|
if (grd.hasOwnProperty('CRUDflag')) {
|
334
|
records = grd.CRUDflag.getAllRecords(GridData[i].store)
|
335
|
} else {
|
336
|
var recC = grd.store.getNewRecords();
|
337
|
Ext.each(recC, function (rec) {
|
338
|
rec.data.FlagCrud = "I";
|
339
|
records.push(rec);
|
340
|
});
|
341
|
var recU = grd.store.getUpdatedRecords();
|
342
|
Ext.each(recU, function (rec) {
|
343
|
rec.data.FlagCrud = "U";
|
344
|
records.push(rec);
|
345
|
});
|
346
|
var recD = grd.store.getRemovedRecords();
|
347
|
Ext.each(recD, function (rec) {
|
348
|
rec.data.FlagCrud = "D";
|
349
|
records.push(rec);
|
350
|
});
|
351
|
}
|
352
|
Ext.each(records, function (rec) {
|
353
|
var name = GridData[i].tableName;
|
354
|
var obj = Ext.decode('{' + name + ':' + Ext.encode(rec.data) + '}');
|
355
|
GridBuildStrings.push(obj);
|
356
|
});
|
357
|
}
|
358
|
return GridBuildStrings;
|
359
|
},
|
360
|
buildMultiGridEditCell: function () {
|
361
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
362
|
var GridData = PanelData.query('docgridcelledit');
|
363
|
var GridLength = GridData.length;
|
364
|
var GridBuildStrings = [];
|
365
|
for (var i = 0; i < GridLength; i++) {
|
366
|
var records = [];
|
367
|
var grd = GridData[i].query('grid')[0];
|
368
|
if (grd.hasOwnProperty('CRUDflag')) {
|
369
|
records = grd.CRUDflag.getAllRecords(GridData[i].store)
|
370
|
} else {
|
371
|
var recC = grd.store.getNewRecords();
|
372
|
Ext.each(recC, function (rec) {
|
373
|
rec.data.FlagCrud = "I";
|
374
|
records.push(rec);
|
375
|
});
|
376
|
var recU = grd.store.getUpdatedRecords();
|
377
|
Ext.each(recU, function (rec) {
|
378
|
rec.data.FlagCrud = "U";
|
379
|
records.push(rec);
|
380
|
});
|
381
|
var recD = grd.store.getRemovedRecords();
|
382
|
Ext.each(recD, function (rec) {
|
383
|
rec.data.FlagCrud = "D";
|
384
|
records.push(rec);
|
385
|
});
|
386
|
}
|
387
|
Ext.each(records, function (rec) {
|
388
|
var name = GridData[i].tableName;
|
389
|
var obj = Ext.decode('{' + name + ':' + Ext.encode(rec.data) + '}');
|
390
|
GridBuildStrings.push(obj);
|
391
|
});
|
392
|
}
|
393
|
return GridBuildStrings;
|
394
|
},
|
395
|
buildMultiGridEditCellSum: function () {
|
396
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
397
|
var GridData = PanelData.query('docgridcelleditsum');
|
398
|
var GridLength = GridData.length;
|
399
|
var GridBuildStrings = [];
|
400
|
for (var i = 0; i < GridLength; i++) {
|
401
|
var records = [];
|
402
|
var grd = GridData[i].query('grid')[0];
|
403
|
if (grd.hasOwnProperty('CRUDflag')) {
|
404
|
records = grd.CRUDflag.getAllRecords(GridData[i].store)
|
405
|
} else {
|
406
|
var recC = grd.store.getNewRecords();
|
407
|
Ext.each(recC, function (rec) {
|
408
|
rec.data.FlagCrud = "I";
|
409
|
records.push(rec);
|
410
|
});
|
411
|
var recU = grd.store.getUpdatedRecords();
|
412
|
Ext.each(recU, function (rec) {
|
413
|
rec.data.FlagCrud = "U";
|
414
|
records.push(rec);
|
415
|
});
|
416
|
var recD = grd.store.getRemovedRecords();
|
417
|
Ext.each(recD, function (rec) {
|
418
|
rec.data.FlagCrud = "D";
|
419
|
records.push(rec);
|
420
|
});
|
421
|
}
|
422
|
Ext.each(records, function (rec) {
|
423
|
var name = GridData[i].tableName;
|
424
|
var obj = Ext.decode('{' + name + ':' + Ext.encode(rec.data) + '}');
|
425
|
GridBuildStrings.push(obj);
|
426
|
});
|
427
|
}
|
428
|
return GridBuildStrings;
|
429
|
|
430
|
},
|
431
|
loadTabPanelDocRef: function (dtheader, dtitems) {
|
432
|
var me = this;
|
433
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
434
|
var tabObj = tb.activeTab;
|
435
|
var docno = me.docNo;
|
436
|
var act = me.action;
|
437
|
|
438
|
var tbl = tabObj.tbl;
|
439
|
tabObj.getEl().mask("loading...");
|
440
|
if (tabObj.layoutType == 'L001') {
|
441
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
442
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
443
|
frmDisplay.reset();
|
444
|
frmForm.reset();
|
445
|
if (dtheader.length > 0) {
|
446
|
frmDisplay.getForm().setValues(dtheader[0]);
|
447
|
frmForm.getForm().setValues(dtheader[0]);
|
448
|
}
|
449
|
frmDisplay.setHidden(true);
|
450
|
frmForm.setHidden(false);
|
451
|
}
|
452
|
if (tabObj.layoutType == 'L002' || tabObj.layoutType == 'L003') {
|
453
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
454
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
455
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
456
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
457
|
store.removeAll();
|
458
|
Ext.each(dtitems, function (item) {
|
459
|
store.add(item);
|
460
|
});
|
461
|
frmDisplay.reset();
|
462
|
frmForm.reset();
|
463
|
frmDisplay.setHidden(true);
|
464
|
frmForm.setHidden(true);
|
465
|
grdPanel.setHidden(false);
|
466
|
}
|
467
|
if (tabObj.layoutType == 'L005') {
|
468
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
469
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
470
|
store.removeAll();
|
471
|
Ext.each(dtitems, function (item) {
|
472
|
store.add(item);
|
473
|
});
|
474
|
grdPanel.setHidden(false);
|
475
|
}
|
476
|
if (tabObj.layoutType == 'L006' || tabObj.layoutType == 'L007') {
|
477
|
var grdPanel = Ext.ComponentQuery.query('[name=CELLGRID' + tbl + ']')[0];
|
478
|
grdPanel.setHidden(false);
|
479
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
480
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
481
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
482
|
store.removeAll();
|
483
|
Ext.each(dtitems, function (item) {
|
484
|
store.add(item);
|
485
|
});
|
486
|
if (tabObj.layoutType == 'L007') {
|
487
|
var sumPanel = Ext.ComponentQuery.query('[name=SUM' + tbl + ']')[0];
|
488
|
var sumForm = sumPanel.getForm();
|
489
|
var itm = sumForm.getFields().items;
|
490
|
Ext.each(itm, function (i) {
|
491
|
var fld = i.name;
|
492
|
var fldValue = 0;
|
493
|
Ext.each(dtitems, function (dt) {
|
494
|
Ext.each(dt, function (d) {
|
495
|
var fValue = d[fld];
|
496
|
fldValue = fldValue + parseFloat(fValue);
|
497
|
});
|
498
|
});
|
499
|
fldValue = Ext.util.Format.number(fldValue, '0,000.00');
|
500
|
sumForm.findField(fld).setValue(fldValue);
|
501
|
});
|
502
|
}
|
503
|
}
|
504
|
tabObj.getEl().unmask();
|
505
|
},
|
506
|
createDocRef: function (dtheader, dtitems, intdocref) {
|
507
|
var me = this;
|
508
|
me.action = '0';
|
509
|
me.docNo = 'None'
|
510
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
511
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
512
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
513
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
514
|
var formHead = panelHead.getForm();
|
515
|
formHead.reset();
|
516
|
var formHeadDisplay = panelDisplayHead.getForm();
|
517
|
formHeadDisplay.reset();
|
518
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
519
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
520
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
521
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
522
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
523
|
pnlSelect.setHidden(true);
|
524
|
pnlTransaction.setHidden(false);
|
525
|
panelHead.setHidden(false);
|
526
|
panelDisplayHead.setHidden(true);
|
527
|
btnSaveCreate.setDisabled(false);
|
528
|
btnCreate.setDisabled(false);
|
529
|
btnSave.setDisabled(false);
|
530
|
formHead.findField("DocType").setValue(me.docType);
|
531
|
if (dtheader.length > 0) {
|
532
|
formHead.setValues(dtheader[0]);
|
533
|
formHeadDisplay.setValues(dtheader[0]);
|
534
|
}
|
535
|
var docnoref = "";
|
536
|
Ext.each(intdocref, function (doc) {
|
537
|
docnoref = docnoref + "," + doc;
|
538
|
});
|
539
|
var lg = docnoref.length;
|
540
|
if (lg > 0) {
|
541
|
docnoref = docnoref.substring(1, lg);
|
542
|
}
|
543
|
formHead.findField("IntDocRef").setValue(docnoref);
|
544
|
formHead.findField("RefType").setValue("01");
|
545
|
me.loadTabPanelDocRef(dtheader, dtitems);
|
546
|
},
|
547
|
createDoc: function () {
|
548
|
var me = this;
|
549
|
me.action = '0';
|
550
|
me.docNo = 'None';
|
551
|
me.dataExist= "";
|
552
|
me.docStatus= "";
|
553
|
me.docStatusExist= "";
|
554
|
me.PostingDateExist= "";
|
555
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
556
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
557
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
558
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
559
|
var formHead = panelHead.getForm();
|
560
|
formHead.reset();
|
561
|
var formHeadDisplay = panelDisplayHead.getForm();
|
562
|
formHeadDisplay.reset();
|
563
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
564
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
565
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
566
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
567
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
568
|
pnlSelect.setHidden(true);
|
569
|
pnlTransaction.setHidden(false);
|
570
|
panelHead.setHidden(false);
|
571
|
panelDisplayHead.setHidden(true);
|
572
|
btnSaveCreate.setDisabled(false);
|
573
|
btnCreate.setDisabled(false);
|
574
|
btnSave.setDisabled(false);
|
575
|
formHead.findField("DocType").setValue(me.docType);
|
576
|
me.afterrenderTab();
|
577
|
|
578
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
579
|
var tbl = tb.activeTab.tbl;
|
580
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(true);
|
581
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(true);
|
582
|
|
583
|
},
|
584
|
displayDoc: function () {
|
585
|
var me = this;
|
586
|
//var documentNo = Ext.ComponentQuery.query('triggerfield[name=DocNo]')[0];
|
587
|
//var tbl = documentNo.tableName;
|
588
|
//me.loadDoc(documentNo.getValue(), tbl);
|
589
|
var grid = Ext.ComponentQuery.query('[name=searchResult]')[0];
|
590
|
var selection = grid.getView().getSelectionModel().getSelection()[0];
|
591
|
var documentno = selection.data.DocNo;
|
592
|
LookupFunction = this.LookupFunction;
|
593
|
eval(LookupFunction);
|
594
|
me.loadDoc(documentno, grid.tableName);
|
595
|
},
|
596
|
loadDoc: function (documentno, tbl) {
|
597
|
var me = this;
|
598
|
me.action = '2';
|
599
|
me.docNo = documentno;
|
600
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
601
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
602
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
603
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
604
|
var formHead = panelHead.getForm();
|
605
|
var formHeadDisplay = panelDisplayHead.getForm();
|
606
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
607
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
608
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
609
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
610
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
611
|
var dt = undefined;
|
612
|
Ext.Ajax.request({
|
613
|
async: false,
|
614
|
method: 'POST',
|
615
|
url: '/UserControl/GetStore',
|
616
|
params: {
|
617
|
tableName: tbl,
|
618
|
param: 'DocNo[=]' + me.docNo
|
619
|
},
|
620
|
success: function (response) {
|
621
|
var results = Ext.decode(response.responseText);
|
622
|
dt = results.data;
|
623
|
}
|
624
|
});
|
625
|
formHead.setValues(dt[0]);
|
626
|
formHeadDisplay.setValues(dt[0]);
|
627
|
me.afterrenderTab();
|
628
|
pnlSelect.setHidden(true);
|
629
|
pnlTransaction.setHidden(false);
|
630
|
panelHead.setHidden(false);
|
631
|
panelDisplayHead.setHidden(true);
|
632
|
btnSaveCreate.setDisabled(true);
|
633
|
btnCreate.setDisabled(true);
|
634
|
btnSave.setDisabled(true);
|
635
|
btnEdit.setDisabled(false);
|
636
|
btnDelete.setDisabled(false);
|
637
|
me.dataExist = "Y";
|
638
|
me.docStatusExist = formHead.findField("DocStatus").getValue();
|
639
|
me.PostingDateExist = formHead.findField("PostingDate").getValue();
|
640
|
},
|
641
|
editDoc: function () {
|
642
|
var me = this;
|
643
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
644
|
var formheader = panelHead.getForm();
|
645
|
var status = formheader.findField("DocStatus").getValue();
|
646
|
if (status == "5") {
|
647
|
Ext.Ajax.request({
|
648
|
async: false,
|
649
|
method: 'POST',
|
650
|
url: '/UserControl/GetStore',
|
651
|
params: {
|
652
|
tableName: 'PCMBSDOCSTATUS',
|
653
|
param: 'DocStatus[=]' + status
|
654
|
},
|
655
|
success: function (response) {
|
656
|
var results = Ext.decode(response.responseText);
|
657
|
dt = results.data[0];
|
658
|
}
|
659
|
});
|
660
|
MinovaMessage('000006', 'FILO01', dt.Description, 'W');
|
661
|
/*me.dataExist = "Y";
|
662
|
me.docStatusExist = formheader.findField("DocStatus").getValue();
|
663
|
me.PostingDateExist = formheader.findField("PostingDate").getValue();*/
|
664
|
} else {
|
665
|
me.action = '1';
|
666
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
667
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
668
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
669
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
670
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
671
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
672
|
panelHead.setHidden(false);
|
673
|
panelDisplayHead.setHidden(true);
|
674
|
btnSaveCreate.setDisabled(false);
|
675
|
btnCreate.setDisabled(false);
|
676
|
btnSave.setDisabled(false);
|
677
|
me.afterrenderTab();
|
678
|
/*me.dataExist = "Y";
|
679
|
me.docStatusExist = formheader.findField("DocStatus").getValue();
|
680
|
me.PostingDateExist = formheader.findField("PostingDate").getValue();*/
|
681
|
}
|
682
|
},
|
683
|
saveDoc: function () {
|
684
|
var me = this;
|
685
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
686
|
var tbl = panelHead.tableName;
|
687
|
var formHead = panelHead.getForm();
|
688
|
var docStatus = formHead.findField("DocStatus").getValue();
|
689
|
var DocNo = formHead.findField("DocNo").getValue();
|
690
|
var FiscalYear = formHead.findField("FiscalYear").getValue();
|
691
|
var FiscalPeriod = formHead.findField("FiscalPeriod").getValue();
|
692
|
|
693
|
if (me.transType == 'FIN') {
|
694
|
|
695
|
var pd = formHead.findField("PostingDate").getValue();
|
696
|
var debet = Ext.ComponentQuery.query('displayfield[name=AmountDebet]')[0];
|
697
|
var kredit = Ext.ComponentQuery.query('displayfield[name=AmountCredit]')[0];
|
698
|
|
699
|
if (pd == null || pd == "" || pd == undefined) {
|
700
|
if(docStatus == '9')
|
701
|
{
|
702
|
MinovaMessage("", "FILO05", "", "E");
|
703
|
return;
|
704
|
}
|
705
|
}
|
706
|
if (debet !== undefined && kredit !== undefined) {
|
707
|
if (debet.getValue() !== kredit.getValue()) {
|
708
|
MinovaMessage("", "FILO10", "", "E");
|
709
|
return;
|
710
|
}
|
711
|
}
|
712
|
|
713
|
console.log('FIN!');
|
714
|
|
715
|
if (debet.getValue() == 0 && kredit.getValue() == 0 && docStatus == '9' ) {
|
716
|
if(me.dataExist == 'Y')
|
717
|
{
|
718
|
formHead.findField("DocStatus").setValue("3");
|
719
|
Ext.Ajax.request({
|
720
|
async: false,
|
721
|
method: 'POST',
|
722
|
url: '/UserControl/GetStore',
|
723
|
params: {
|
724
|
tableName: 'PDSFILODELETEDATATABLEPOST',
|
725
|
param: DocNo
|
726
|
},
|
727
|
success: function (response) {
|
728
|
}
|
729
|
});
|
730
|
}
|
731
|
else
|
732
|
{
|
733
|
MinovaMessage("", "FILO11", "", "E");
|
734
|
return;
|
735
|
}
|
736
|
}
|
737
|
|
738
|
if(me.docStatusExist == '9' || me.docStatusExist == '3')
|
739
|
{
|
740
|
if(docStatus == '1' || docStatus == '2')
|
741
|
{
|
742
|
MinovaMessage("", "FILO12", "", "E");
|
743
|
return;
|
744
|
}
|
745
|
if(pd != me.PostingDateExist)
|
746
|
{
|
747
|
MinovaMessage("", "FILO13", "", "E");
|
748
|
return;
|
749
|
}
|
750
|
if(docStatus == '3')//if(me.docStatus == '3')
|
751
|
{
|
752
|
Ext.Ajax.request({
|
753
|
async: false,
|
754
|
method: 'POST',
|
755
|
url: '/UserControl/GetStore',
|
756
|
params: {
|
757
|
tableName: 'PDSFILODELETEDATATABLEPOST',
|
758
|
param: DocNo
|
759
|
},
|
760
|
success: function (response) {
|
761
|
}
|
762
|
});
|
763
|
}
|
764
|
}
|
765
|
|
766
|
if(me.docStatusExist == '1' && docStatus == '1')
|
767
|
{
|
768
|
if(pd != me.PostingDateExist)
|
769
|
{
|
770
|
Ext.Ajax.request({
|
771
|
async: false,
|
772
|
method: 'POST',
|
773
|
url: '/UserControl/GetStore',
|
774
|
params: {
|
775
|
tableName: 'PDSFILOUPDATEPERIODFINANCEITEM',
|
776
|
param: DocNo + ',' + FiscalYear + ',' + FiscalPeriod
|
777
|
},
|
778
|
success: function (response) {
|
779
|
}
|
780
|
});
|
781
|
}
|
782
|
}
|
783
|
|
784
|
if(me.docStatusExist == '1' && docStatus == '9')
|
785
|
{
|
786
|
if(pd != me.PostingDateExist)
|
787
|
{
|
788
|
|
789
|
Ext.Ajax.request({
|
790
|
async: false,
|
791
|
method: 'POST',
|
792
|
url: '/UserControl/GetStore',
|
793
|
params: {
|
794
|
tableName: 'PDSFILOUPDATEPERIODFINANCEITEM',
|
795
|
param: DocNo + ',' + FiscalYear + ',' + FiscalPeriod
|
796
|
},
|
797
|
success: function (response) {
|
798
|
}
|
799
|
});
|
800
|
}
|
801
|
}
|
802
|
}
|
803
|
|
804
|
if (formHead.isValid()) {
|
805
|
panelHead.mask("Loading...");
|
806
|
var dataHeader = Ext.encode(formHead.getValues());
|
807
|
var token = MinovaUtil.SESSIONS.Token;
|
808
|
var objGrid;
|
809
|
var objGridCell;
|
810
|
var objGridCellSum;
|
811
|
try {
|
812
|
objGrid = me.buildMultiGrid();
|
813
|
objGridCell = me.buildMultiGridEditCell();
|
814
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
815
|
for (var i = 0; i < objGridCell.length; i++) {
|
816
|
objGrid.push(objGridCell[i]);
|
817
|
}
|
818
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
819
|
objGrid.push(objGridCellSum[i]);
|
820
|
}
|
821
|
} catch (e) {
|
822
|
Ext.Msg.alert('Build Grid error', e);
|
823
|
return;
|
824
|
}
|
825
|
var dataDetail = Ext.encode(objGrid);
|
826
|
|
827
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
828
|
var GridData = PanelData.query('docgridcelleditsum');
|
829
|
var GridLength = GridData.length;
|
830
|
var glaccount = '';
|
831
|
var glaccount_ = '';
|
832
|
|
833
|
for (var i = 0; i < GridLength; i++) {
|
834
|
glaccount_ = '';
|
835
|
var records = [];
|
836
|
var grd = GridData[i].query('grid')[0];
|
837
|
|
838
|
var recC = grd.store.getNewRecords();
|
839
|
Ext.each(recC, function (rec) {
|
840
|
glaccount = rec.data.GLAccountID.toString();
|
841
|
//glaccount = glaccount + ',' + rec.data.GLAccountID.toString();
|
842
|
});
|
843
|
var recU = grd.store.getUpdatedRecords();
|
844
|
Ext.each(recU, function (rec) {
|
845
|
glaccount = rec.data.GLAccountID.toString();
|
846
|
//glaccount = glaccount + ',' + rec.data.GLAccountID.toString();
|
847
|
});
|
848
|
|
849
|
/*if(glaccount == '')
|
850
|
{
|
851
|
MinovaMessage("", "FILO15", "", "E");
|
852
|
//alert('nwh');
|
853
|
panelHead.unmask();
|
854
|
return;
|
855
|
}*/ ////comment krn tidak bisa rubah status 20210830 by Tri
|
856
|
|
857
|
Ext.Ajax.request({
|
858
|
async : false,
|
859
|
method : 'POST',
|
860
|
url : '/UserControl/GetStore',
|
861
|
params : {
|
862
|
tableName : 'PCMFILOCOAGL',
|
863
|
param : 'GlAccount[equal]' + glaccount
|
864
|
},
|
865
|
success : function (response) {
|
866
|
var results = Ext.decode(response.responseText);
|
867
|
if( results.totalRecords != '0')
|
868
|
{ glaccount_ = results.data[0].GlAccount; }
|
869
|
}
|
870
|
});
|
871
|
|
872
|
|
873
|
if(glaccount_ == '')
|
874
|
{
|
875
|
MinovaMessage("", "FILO14", "", "E");
|
876
|
panelHead.unmask();
|
877
|
return;
|
878
|
};
|
879
|
}
|
880
|
|
881
|
var params = {
|
882
|
serviceName: 'Filo.asmx',
|
883
|
methodName: 'SaveTableDoc',
|
884
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
885
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + me.action + '&token=' + token
|
886
|
};
|
887
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
888
|
console.log('Post!');
|
889
|
var result = Ext.decode(xhr.responseText);
|
890
|
if (result.success) {
|
891
|
var idNo = result.data;
|
892
|
formHead.findField("DocNo").setValue(idNo);
|
893
|
/* add by mae 20200702 */
|
894
|
/* #region update item status */
|
895
|
if (me.transType == "FIN" && me.docType == "IP" && formHead.getValues().DocTypeRef == "AR") {
|
896
|
Ext.Ajax.request({
|
897
|
async: false,
|
898
|
method: 'POST',
|
899
|
url: '/Devt/SaveTable',
|
900
|
params: {
|
901
|
tableName: 'PTRFINANCEITEM',
|
902
|
data: Ext.encode({
|
903
|
DocNo: formHead.getValues().DocIDRef,
|
904
|
ItemStatus: '2'
|
905
|
}),
|
906
|
action: 1
|
907
|
},
|
908
|
waitMsg: 'Saving Data...',
|
909
|
success: function (response) {
|
910
|
var result = Ext.decode(response.responseText);
|
911
|
if (result.success) {
|
912
|
console.log('update item status');
|
913
|
}
|
914
|
},
|
915
|
failure: function (response) {}
|
916
|
});
|
917
|
}
|
918
|
/* #endregion update item status */
|
919
|
MinovaMessage('Not Null', '000006', '', 'S');
|
920
|
panelHead.unmask();
|
921
|
me.loadDoc(idNo, tbl);
|
922
|
} else {
|
923
|
MinovaMessage('', '000005', result.message.text, 'E');
|
924
|
panelHead.unmask();
|
925
|
}
|
926
|
});
|
927
|
}
|
928
|
},
|
929
|
deleteDoc: function () {},
|
930
|
cancelDoc: function () {
|
931
|
var me = this;
|
932
|
me.action = '2';
|
933
|
me.docNo = 'None';
|
934
|
MinovaMessage('Message', '000011', '', 'C', function (respone) {
|
935
|
if (respone == "yes") {
|
936
|
me.afterrenderTab();
|
937
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
938
|
var tes = Ext.ComponentQuery.query('[name=searchResultInfo]')[0];
|
939
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
940
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
941
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
942
|
var formHead = panelHead.getForm();
|
943
|
formHead.reset();
|
944
|
var formHeadDisplay = panelDisplayHead.getForm();
|
945
|
formHeadDisplay.reset();
|
946
|
var btnCreate = Ext.ComponentQuery.query('[name=CreateDoc]')[0];
|
947
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
948
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
949
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
950
|
pnlSelect.setHidden(false);
|
951
|
tes.setHidden(true);
|
952
|
pnlTransaction.setHidden(true);
|
953
|
panelHead.setHidden(false);
|
954
|
panelDisplayHead.setHidden(true);
|
955
|
|
956
|
}
|
957
|
});
|
958
|
},
|
959
|
createNew: function () {
|
960
|
console.log('CreateNew!');
|
961
|
var me = this;
|
962
|
me.action = '0';
|
963
|
me.docNo = 'None'
|
964
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
965
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
966
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
967
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
968
|
var formHead = panelHead.getForm();
|
969
|
formHead.reset();
|
970
|
var formHeadDisplay = panelDisplayHead.getForm();
|
971
|
formHeadDisplay.reset();
|
972
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
973
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
974
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
975
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
976
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
977
|
pnlSelect.setHidden(true);
|
978
|
pnlTransaction.setHidden(false);
|
979
|
panelHead.setHidden(false);
|
980
|
panelDisplayHead.setHidden(true);
|
981
|
btnSaveCreate.setDisabled(false);
|
982
|
btnCreate.setDisabled(false);
|
983
|
btnSave.setDisabled(false);
|
984
|
formHead.findField("DocType").setValue(me.docType);
|
985
|
me.afterrenderTab();
|
986
|
},
|
987
|
reloadDoc: function () {
|
988
|
console.log('reloadDoc');
|
989
|
var me = this;
|
990
|
me.action = '2';
|
991
|
me.docNo = 'None';
|
992
|
//MinovaMessage('Message', '000011', '', 'C', function (respone) {
|
993
|
//if (respone == "yes") {
|
994
|
me.afterrenderTab();
|
995
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
996
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
997
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
998
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
999
|
var formHead = panelHead.getForm();
|
1000
|
formHead.reset();
|
1001
|
var formHeadDisplay = panelDisplayHead.getForm();
|
1002
|
formHeadDisplay.reset();
|
1003
|
var btnCreate = Ext.ComponentQuery.query('[name=CreateDoc]')[0];
|
1004
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
1005
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
1006
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
1007
|
pnlSelect.setHidden(false);
|
1008
|
pnlTransaction.setHidden(true);
|
1009
|
panelHead.setHidden(false);
|
1010
|
panelDisplayHead.setHidden(true);
|
1011
|
//}
|
1012
|
//});
|
1013
|
},
|
1014
|
backDoc: function () {
|
1015
|
var me = this;
|
1016
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1017
|
var tbl = panelHead.tableName;
|
1018
|
var formHead = panelHead.getForm();
|
1019
|
|
1020
|
if (me.transType == 'FIN') {
|
1021
|
var pd = formHead.findField("PostingDate").getValue();
|
1022
|
var debet = Ext.ComponentQuery.query('displayfield[name=AmountDebet]')[0];
|
1023
|
var kredit = Ext.ComponentQuery.query('displayfield[name=AmountCredit]')[0];
|
1024
|
|
1025
|
if (pd == null || pd == "" || pd == undefined) {
|
1026
|
MinovaMessage("", "FILO05", "", "E");
|
1027
|
return;
|
1028
|
}
|
1029
|
if (debet !== undefined && kredit !== undefined) {
|
1030
|
if (debet.getValue() !== kredit.getValue()) {
|
1031
|
MinovaMessage("", "FILO10", "", "E");
|
1032
|
return;
|
1033
|
}
|
1034
|
}
|
1035
|
}
|
1036
|
if (formHead.isValid()) {
|
1037
|
panelHead.mask("Loading...");
|
1038
|
var dataHeader = Ext.encode(formHead.getValues());
|
1039
|
var token = MinovaUtil.SESSIONS.Token;
|
1040
|
var objGrid;
|
1041
|
var objGridCell;
|
1042
|
var objGridCellSum;
|
1043
|
try {
|
1044
|
objGrid = me.buildMultiGrid();
|
1045
|
objGridCell = me.buildMultiGridEditCell();
|
1046
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
1047
|
for (var i = 0; i < objGridCell.length; i++) {
|
1048
|
objGrid.push(objGridCell[i]);
|
1049
|
}
|
1050
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
1051
|
objGrid.push(objGridCellSum[i]);
|
1052
|
}
|
1053
|
} catch (e) {
|
1054
|
Ext.Msg.alert('Build Grid error', e);
|
1055
|
return;
|
1056
|
}
|
1057
|
var dataDetail = Ext.encode(objGrid);
|
1058
|
var params = {
|
1059
|
serviceName: 'Filo.asmx',
|
1060
|
methodName: 'SaveTableDoc',
|
1061
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
1062
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + me.action + '&token=' + token
|
1063
|
};
|
1064
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
1065
|
var result = Ext.decode(xhr.responseText);
|
1066
|
if (result.success) {
|
1067
|
var idNo = result.data;
|
1068
|
formHead.findField("DocNo").setValue(idNo);
|
1069
|
MinovaMessage('Not Null', '000006', '', 'S');
|
1070
|
panelHead.unmask();
|
1071
|
me.loadDoc(idNo, tbl);
|
1072
|
|
1073
|
me.reloadDoc();
|
1074
|
|
1075
|
} else {
|
1076
|
MinovaMessage('', '000005', result.message.text, 'E');
|
1077
|
panelHead.unmask();
|
1078
|
}
|
1079
|
});
|
1080
|
}
|
1081
|
console.log('backDoc');
|
1082
|
|
1083
|
},
|
1084
|
backCreateDoc: function () {
|
1085
|
console.log('backCreateDoc!');
|
1086
|
var me = this;
|
1087
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1088
|
var tbl = panelHead.tableName;
|
1089
|
var formHead = panelHead.getForm();
|
1090
|
|
1091
|
if (me.transType == 'FIN') {
|
1092
|
var pd = formHead.findField("PostingDate").getValue();
|
1093
|
var debet = Ext.ComponentQuery.query('displayfield[name=AmountDebet]')[0];
|
1094
|
var kredit = Ext.ComponentQuery.query('displayfield[name=AmountCredit]')[0];
|
1095
|
|
1096
|
if (pd == null || pd == "" || pd == undefined) {
|
1097
|
MinovaMessage("", "FILO05", "", "E");
|
1098
|
return;
|
1099
|
}
|
1100
|
if (debet !== undefined && kredit !== undefined) {
|
1101
|
if (debet.getValue() !== kredit.getValue()) {
|
1102
|
MinovaMessage("", "FILO10", "", "E");
|
1103
|
return;
|
1104
|
}
|
1105
|
}
|
1106
|
}
|
1107
|
if (formHead.isValid()) {
|
1108
|
panelHead.mask("Loading...");
|
1109
|
var dataHeader = Ext.encode(formHead.getValues());
|
1110
|
var token = MinovaUtil.SESSIONS.Token;
|
1111
|
var objGrid;
|
1112
|
var objGridCell;
|
1113
|
var objGridCellSum;
|
1114
|
try {
|
1115
|
objGrid = me.buildMultiGrid();
|
1116
|
objGridCell = me.buildMultiGridEditCell();
|
1117
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
1118
|
for (var i = 0; i < objGridCell.length; i++) {
|
1119
|
objGrid.push(objGridCell[i]);
|
1120
|
}
|
1121
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
1122
|
objGrid.push(objGridCellSum[i]);
|
1123
|
}
|
1124
|
} catch (e) {
|
1125
|
Ext.Msg.alert('Build Grid error', e);
|
1126
|
return;
|
1127
|
}
|
1128
|
var dataDetail = Ext.encode(objGrid);
|
1129
|
var params = {
|
1130
|
serviceName: 'Filo.asmx',
|
1131
|
methodName: 'SaveTableDoc',
|
1132
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
1133
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + me.action + '&token=' + token
|
1134
|
};
|
1135
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
1136
|
var result = Ext.decode(xhr.responseText);
|
1137
|
if (result.success) {
|
1138
|
var idNo = result.data;
|
1139
|
formHead.findField("DocNo").setValue(idNo);
|
1140
|
/* add by mae 20200702 */
|
1141
|
/* #region update item status */
|
1142
|
if (me.transType == "FIN" && me.docType == "IP" && formHead.getValues().DocTypeRef == "AR") {
|
1143
|
Ext.Ajax.request({
|
1144
|
async: false,
|
1145
|
method: 'POST',
|
1146
|
url: '/Devt/SaveTable',
|
1147
|
params: {
|
1148
|
tableName: 'PTRFINANCEITEM',
|
1149
|
data: Ext.encode({
|
1150
|
DocNo: formHead.getValues().DocIDRef,
|
1151
|
ItemStatus: '2'
|
1152
|
}),
|
1153
|
action: 1
|
1154
|
},
|
1155
|
waitMsg: 'Saving Data...',
|
1156
|
success: function (response) {
|
1157
|
var result = Ext.decode(response.responseText);
|
1158
|
if (result.success) {
|
1159
|
console.log('update item status');
|
1160
|
}
|
1161
|
},
|
1162
|
failure: function (response) {}
|
1163
|
});
|
1164
|
}
|
1165
|
/* #endregion update item status */
|
1166
|
MinovaMessage('Not Null', '000006', '', 'S');
|
1167
|
panelHead.unmask();
|
1168
|
me.loadDoc(idNo, tbl);
|
1169
|
me.reloadDoc();
|
1170
|
me.createDoc();
|
1171
|
me.getLookupRefDoc();
|
1172
|
} else {
|
1173
|
MinovaMessage('', '000005', result.message.text, 'E');
|
1174
|
panelHead.unmask();
|
1175
|
}
|
1176
|
});
|
1177
|
}
|
1178
|
console.log('backDoc');
|
1179
|
|
1180
|
},
|
1181
|
|
1182
|
getLookupDoc: function (obj) {
|
1183
|
var popup = Ext.ComponentQuery.query('[name=LookupDocumentTrans]').length;
|
1184
|
|
1185
|
if (popup == 1) {
|
1186
|
Ext.ComponentQuery.query('[name=LookupDocumentTrans]')[0].targetField = "DocNo";
|
1187
|
Ext.ComponentQuery.query('[name=LookupDocumentTrans]')[0].show();
|
1188
|
} else {
|
1189
|
Ext.create('MinovaUtil.MinovaES.LookupDoc', {
|
1190
|
tableName: obj.tableName,
|
1191
|
targetField: "DocNo",
|
1192
|
fieldValue: "",
|
1193
|
LookupFunction: "",
|
1194
|
filterParam: "DocType[=]" + obj.docType,
|
1195
|
}).show()
|
1196
|
}
|
1197
|
},
|
1198
|
getLookupRefDoc: function () {
|
1199
|
|
1200
|
var me = this;
|
1201
|
var popup = Ext.ComponentQuery.query('[name=LookupDocRef]')[0];
|
1202
|
if (popup === undefined) {
|
1203
|
popup = Ext.create('MinovaUtil.MinovaES.LookupDocRef', {
|
1204
|
targetField: "DocNo",
|
1205
|
fieldValue: "",
|
1206
|
LookupFunction: "",
|
1207
|
filterParam: "DocType[=]" + me.docType,
|
1208
|
});
|
1209
|
}
|
1210
|
popup.show();
|
1211
|
var btnSelect = popup.query('button[name=select]')[0];
|
1212
|
if (btnSelect !== undefined)
|
1213
|
btnSelect.on('click', me.selectDocRef, me);
|
1214
|
},
|
1215
|
selectDocRef: function () {
|
1216
|
var me = this;
|
1217
|
var popup = Ext.ComponentQuery.query('[name=LookupDocRef]')[0];
|
1218
|
var grid = Ext.ComponentQuery.query('[name=gridlookupdocref]')[0];
|
1219
|
if (grid !== undefined) {
|
1220
|
var selection = grid.getView().getSelectionModel();
|
1221
|
var dt = selection.getSelection();
|
1222
|
if (dt.length > 0) {
|
1223
|
var intdocref = [];
|
1224
|
var refheader = [];
|
1225
|
var refitems = [];
|
1226
|
for (var i = 0; i < dt.length; i++) {
|
1227
|
var d = dt[i];
|
1228
|
var trtype = d.data.TransType;
|
1229
|
var dctype = d.data.DocType;
|
1230
|
var trtyperef = d.data.TransTypeRef;
|
1231
|
var dctyperef = d.data.DocTypeRef;
|
1232
|
var dcno = d.data.DocNo;
|
1233
|
var company = d.data.CompanyID;
|
1234
|
var bu = d.data.BusinessUnit;
|
1235
|
var params = {
|
1236
|
serviceName: 'Filo.asmx',
|
1237
|
methodName: 'GetReferenceDoc',
|
1238
|
parameter: 'transType=' + trtype + '&docType=' + dctype +
|
1239
|
'&transTypeRef=' + trtyperef + '&docTypeRef=' + dctyperef + '&docNo=' + dcno
|
1240
|
};
|
1241
|
MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
|
1242
|
var result = Ext.decode(xhr.responseText);
|
1243
|
var dtref = Ext.decode(result.data);
|
1244
|
refheader.push(dtref.Header);
|
1245
|
if (trtype == "FIN" && dctype == "IP" && trtyperef == "FIN" && dctyperef == "AR") {
|
1246
|
var a = dtref.Items[0];
|
1247
|
var b = JSON.parse(JSON.stringify(dtref.Items[0]));
|
1248
|
a.GLAccountID = '';
|
1249
|
a.ItemStatus = '2';
|
1250
|
b.AmountCredit = b.AmountDebet;
|
1251
|
b.AmountCreditCompCurr = b.AmountDebetCompCurr;
|
1252
|
b.AmountDebet = '0';
|
1253
|
b.AmountDebetCompCurr = '0';
|
1254
|
b.ItemStatus = '2';
|
1255
|
var c = [a, b];
|
1256
|
refitems.push(c);
|
1257
|
} else {
|
1258
|
refitems.push(dtref.Items);
|
1259
|
}
|
1260
|
intdocref.push(dcno);
|
1261
|
});
|
1262
|
};
|
1263
|
if (trtype = 'FIN') {
|
1264
|
popup.hide();
|
1265
|
me.createDocRef(refheader, refitems, intdocref);
|
1266
|
} else {
|
1267
|
me.getLookupItemDetailRef(trtype, dctype, trtyperef, dctyperef, refheader, refitems, intdocref);
|
1268
|
}
|
1269
|
}
|
1270
|
}
|
1271
|
},
|
1272
|
getLookupItemDetailRef: function (trtype, dctype, trtyperef, dctyperef, refheader, refitems, intdocref) {
|
1273
|
var me = this;
|
1274
|
var refTable = '';
|
1275
|
Ext.Ajax.request({
|
1276
|
async: false,
|
1277
|
method: 'POST',
|
1278
|
url: '/UserControl/GetStore',
|
1279
|
params: {
|
1280
|
tableName: 'PCMBSTRANSLIST',
|
1281
|
param: 'ItemDetailRef[=]' + '1' + ',TransType[=]' + trtyperef
|
1282
|
},
|
1283
|
success: function (response) {
|
1284
|
var results = Ext.decode(response.responseText);
|
1285
|
data_ = results.data;
|
1286
|
refTable = data_[0].TableName;
|
1287
|
}
|
1288
|
});
|
1289
|
var popupitemref = Ext.ComponentQuery.query('[name=LookupItemDetailRef]')[0];
|
1290
|
if (popupitemref === undefined) {
|
1291
|
popupitemref = Ext.create('MinovaUtil.MinovaES.LookupItemDetailRef', {
|
1292
|
targetField: "DocNo",
|
1293
|
fieldValue: "",
|
1294
|
LookupFunction: "",
|
1295
|
tableName: refTable,
|
1296
|
});
|
1297
|
}
|
1298
|
popupitemref.show();
|
1299
|
var storeItemm = Ext.data.StoreManager.lookup('storeadvanceitem');
|
1300
|
var p = [];
|
1301
|
for (var i = 0; i < intdocref.length; i++) {
|
1302
|
p.push('value == ' + '\'' + intdocref[i] + '\'');
|
1303
|
}
|
1304
|
storeItemm.filter(function (r) {
|
1305
|
var value = r.get('DocNo');
|
1306
|
return (eval(p.join(' || ')));
|
1307
|
});
|
1308
|
|
1309
|
var btnSelect = popupitemref.query('button[name=select]')[0];
|
1310
|
if (btnSelect !== undefined)
|
1311
|
btnSelect.on('click', me.selectItemDetailRef, me);
|
1312
|
},
|
1313
|
selectItemDetailRef: function () {
|
1314
|
var me = this;
|
1315
|
var popup = Ext.ComponentQuery.query('[name=LookupDocRef]')[0];
|
1316
|
var popupitemref = Ext.ComponentQuery.query('[name=LookupItemDetailRef]')[0];
|
1317
|
var grid = Ext.ComponentQuery.query('[name=gridlookupdocref]')[0];
|
1318
|
var griditemref = Ext.ComponentQuery.query('[name=gridlookupitemdetailref]')[0];
|
1319
|
if (grid !== undefined) {
|
1320
|
if (griditemref !== undefined) {
|
1321
|
var selection = grid.getView().getSelectionModel();
|
1322
|
var selectionitemref = griditemref.getView().getSelectionModel();
|
1323
|
var dt = selection.getSelection();
|
1324
|
var dtitemref = selectionitemref.getSelection();
|
1325
|
if (dt.length > 0 && dtitemref.length > 0) {
|
1326
|
var intdocref = [];
|
1327
|
var refheader = [];
|
1328
|
var refitems = [];
|
1329
|
var refitems2 = [];
|
1330
|
var dtref;
|
1331
|
for (var i = 0; i < dt.length; i++) {
|
1332
|
var d = dt[i];
|
1333
|
var trtype = d.data.TransType;
|
1334
|
var dctype = d.data.DocType;
|
1335
|
var trtyperef = d.data.TransTypeRef;
|
1336
|
var dctyperef = d.data.DocTypeRef;
|
1337
|
var dcno = d.data.DocNo;
|
1338
|
var params = {
|
1339
|
serviceName: 'Filo.asmx',
|
1340
|
methodName: 'GetReferenceDoc',
|
1341
|
parameter: 'transType=' + trtype + '&docType=' + dctype +
|
1342
|
'&transTypeRef=' + trtyperef + '&docTypeRef=' + dctyperef + '&docNo=' + dcno
|
1343
|
};
|
1344
|
MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
|
1345
|
var result = Ext.decode(xhr.responseText);
|
1346
|
dtref = Ext.decode(result.data);
|
1347
|
refheader.push(dtref.Header);
|
1348
|
//refitems.push(dtref.Items);
|
1349
|
for (var j = 0; j < dtref.Items.length; j++) {
|
1350
|
refitems.push(dtref.Items[j]);
|
1351
|
}
|
1352
|
intdocref.push(dcno);
|
1353
|
});
|
1354
|
};
|
1355
|
for (var k = 0; k < refitems.length; k++) {
|
1356
|
for (var l = 0; l < dtitemref.length; l++) {
|
1357
|
if (refitems[k].hasOwnProperty('MaterialID') == true && dtitemref[l].data.hasOwnProperty('MaterialID') == true) {
|
1358
|
if (refitems[k].MaterialID == dtitemref[l].data.MaterialID /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
1359
|
refitems2.push(refitems[k]);
|
1360
|
}
|
1361
|
} else if (refitems[k].hasOwnProperty('Material') == true && dtitemref[l].data.hasOwnProperty('MaterialID') == true) {
|
1362
|
if (refitems[k].Material == dtitemref[l].data.MaterialID /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
1363
|
refitems2.push(refitems[k]);
|
1364
|
}
|
1365
|
} else if (refitems[k].hasOwnProperty('MaterialID') == true && dtitemref[l].data.hasOwnProperty('Material') == true) {
|
1366
|
if (refitems[k].MaterialID == dtitemref[l].data.Material /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
1367
|
refitems2.push(refitems[k]);
|
1368
|
}
|
1369
|
} else {
|
1370
|
if (refitems[k].Material == dtitemref[l].data.Material /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
1371
|
refitems2.push(refitems[k]);
|
1372
|
}
|
1373
|
}
|
1374
|
}
|
1375
|
}
|
1376
|
popup.hide();
|
1377
|
popupitemref.hide();
|
1378
|
me.createDocRef(refheader, refitems2, intdocref);
|
1379
|
}
|
1380
|
}
|
1381
|
}
|
1382
|
},
|
1383
|
specialKey: function (f, e) {
|
1384
|
var me = this;
|
1385
|
if (e.getKey() == e.ENTER) {
|
1386
|
getLookupDoc(f);
|
1387
|
}
|
1388
|
},
|
1389
|
displayResultInfo: function () {
|
1390
|
var me = this;
|
1391
|
var gridInfo = Ext.ComponentQuery.query('[name=searchResultInfo]')[0];
|
1392
|
var grid = Ext.ComponentQuery.query('[name=searchResult]')[0];
|
1393
|
var selection = grid.getView().getSelectionModel().getSelection()[0];
|
1394
|
var documentno = selection.data.DocNo;
|
1395
|
//me.action = '2';
|
1396
|
me.docNo = documentno;
|
1397
|
var store = Ext.StoreMgr.lookup("storeadvance2");
|
1398
|
|
1399
|
var menuid = MinovaUtil.GetMenuID();
|
1400
|
var module = undefined;
|
1401
|
var tableItem = undefined;
|
1402
|
Ext.Ajax.request({
|
1403
|
async: false,
|
1404
|
method: 'POST',
|
1405
|
url: '/UserControl/GetStore',
|
1406
|
params: {
|
1407
|
tableName: 'PCMEPMODULETYPE',
|
1408
|
param: 'MenuID[=]' + menuid
|
1409
|
},
|
1410
|
success: function (response) {
|
1411
|
var results = Ext.decode(response.responseText);
|
1412
|
if (results.data.length > 0) {
|
1413
|
module = results.data[0].ModuleItem;
|
1414
|
}
|
1415
|
}
|
1416
|
});
|
1417
|
Ext.Ajax.request({
|
1418
|
async: false,
|
1419
|
method: 'POST',
|
1420
|
url: '/UserControl/GetStore',
|
1421
|
params: {
|
1422
|
tableName: 'PCMBSTRANSLIST',
|
1423
|
param: "TransType[=]" + module + ",Sequence[=]1"
|
1424
|
},
|
1425
|
success: function (response) {
|
1426
|
var results = Ext.decode(response.responseText);
|
1427
|
if (results.data.length > 0) {
|
1428
|
tableItem = results.data[0].TableName;
|
1429
|
}
|
1430
|
}
|
1431
|
});
|
1432
|
store.proxy.url = '/UserControl/GetStore';
|
1433
|
store.proxy.extraParams = {
|
1434
|
tableName: tableItem,
|
1435
|
param: "DocNo" + '[=]' + me.docNo
|
1436
|
};
|
1437
|
store.removeAll();
|
1438
|
store.reload();
|
1439
|
gridInfo.setHidden(false);
|
1440
|
},
|
1441
|
});
|