1
|
Ext.define('MinovaES.controller.logistic.documentlogistic', {
|
2
|
extend: 'Ext.app.ViewController',
|
3
|
alias: 'controller.documentlogistic',
|
4
|
action: '0',
|
5
|
transType: undefined,
|
6
|
docType: undefined,
|
7
|
docNo: "None",
|
8
|
dataExist: "",
|
9
|
docStatus: "",
|
10
|
docStatusExist: "",
|
11
|
PostingDateExist: "",
|
12
|
IsCompanyIDChange: "0",
|
13
|
stockAdjustmentDocNo: "",
|
14
|
tblApprove:"",
|
15
|
init: function () {
|
16
|
this.control({
|
17
|
'button[name=CreateDoc]': {
|
18
|
click: this.createDoc
|
19
|
},
|
20
|
'[name=searchResult]': {
|
21
|
afterrender: this.afterrenderLookupGrid,
|
22
|
itemdblclick: this.displayDoc,
|
23
|
//itemclick: this.displayResultInfo // comment Tri nwh
|
24
|
},
|
25
|
'button[name=CreateDocRef]': {
|
26
|
click: this.getLookupRefDoc
|
27
|
},
|
28
|
'button[name=CopyDocRef]': {
|
29
|
click: this.getcopyDocRef
|
30
|
},
|
31
|
'[name=FiloDocMain]': {
|
32
|
afterrender: this.afterrenderDoc,
|
33
|
},
|
34
|
'[name=SaveCreateDoc]': {
|
35
|
//click: this.saveDoc
|
36
|
click: function () {
|
37
|
// this == the button, as we are in the local scope
|
38
|
console.log('SaveCreateDoc!');
|
39
|
this.backCreateDoc();
|
40
|
|
41
|
}
|
42
|
},
|
43
|
'[name=Create1Doc]': {
|
44
|
//click: this.saveDoc
|
45
|
click: function () {
|
46
|
// this == the button, as we are in the local scope
|
47
|
console.log('Create1Doc!');
|
48
|
this.backDoc();
|
49
|
this.loadDoc();
|
50
|
}
|
51
|
},
|
52
|
'[name=DisplayDoc]': {
|
53
|
|
54
|
//click: this.saveDoc
|
55
|
click: function () {
|
56
|
// this == the button, as we are in the local scope
|
57
|
console.log('DisplayDoc!');
|
58
|
//this.backDoc();
|
59
|
this.loadDoc();
|
60
|
}
|
61
|
},
|
62
|
'button[name=SaveCreateDocRef]': {
|
63
|
click: this.backCreateDoc
|
64
|
},
|
65
|
'button[name=Create1DocRef]': {
|
66
|
click: function () {
|
67
|
this.reloadDoc();
|
68
|
this.createDoc();
|
69
|
this.getLookupRefDoc();
|
70
|
}
|
71
|
},
|
72
|
'[name=SaveDoc]': {
|
73
|
click: this.saveDoc
|
74
|
},
|
75
|
'[name=SaveCopyDoc]': {
|
76
|
click: this.SaveCopyDoc
|
77
|
},
|
78
|
'[name=DeleteDoc]': {
|
79
|
click: this.deleteDoc
|
80
|
},
|
81
|
'[name=CancelDoc]': {
|
82
|
click: this.cancelDoc
|
83
|
},
|
84
|
'[name=EditDoc]': {
|
85
|
click: this.editDoc
|
86
|
},
|
87
|
'#DocNo': {
|
88
|
"ontriggerclick": this.getLookupDoc,
|
89
|
specialkey: this.specialKey
|
90
|
},
|
91
|
'#mainTab': {
|
92
|
tabchange: this.changeTab
|
93
|
},
|
94
|
'[name=panelTab]': {
|
95
|
afterrender: this.afterrenderTab
|
96
|
},
|
97
|
'[name=searchFilter]': {
|
98
|
afterrender: this.doctyperender
|
99
|
},
|
100
|
'[name=PostingDate]': {
|
101
|
change: this.PostingDate
|
102
|
},
|
103
|
'[name=CompanyID]': {
|
104
|
change: this.CompanyID
|
105
|
}/*,
|
106
|
'[name=DocStatus]': {
|
107
|
change: this.DocStatus
|
108
|
}*/
|
109
|
});
|
110
|
},
|
111
|
stockAdjustment: function () {
|
112
|
var me = this; // Ensure 'me' is assigned to 'this'
|
113
|
var queryString = window.location.search;
|
114
|
var cf = new minovaBlowfish();
|
115
|
var urlEncrypt = cf.minovaDecryptUrl(queryString);
|
116
|
|
117
|
// Split the string by '&' to separate the parameters
|
118
|
var params = urlEncrypt.split('&');
|
119
|
|
120
|
// Initialize variables to store the decoded data and the array
|
121
|
var dataArray;
|
122
|
var decodedData;
|
123
|
|
124
|
// Initialize variable to store the 'from' parameter value
|
125
|
var fromValue;
|
126
|
|
127
|
// Initialize variable to store the 'from' parameter value
|
128
|
var docNo;
|
129
|
var tableName;
|
130
|
|
131
|
// Try-catch block to handle potential errors
|
132
|
try {
|
133
|
// Loop through the parameters to find the 'data' and 'from' parameters
|
134
|
params.forEach(function (param) {
|
135
|
// Split each parameter by '=' to separate the name and value
|
136
|
var parts = param.split('=');
|
137
|
|
138
|
// Check if the parameter is the 'data' parameter
|
139
|
if (parts[0] === 'data') {
|
140
|
// Decode the URL-encoded string
|
141
|
decodedData = decodeURIComponent(parts[1]);
|
142
|
|
143
|
// Parse the JSON string to get the array
|
144
|
dataArray = JSON.parse(decodedData);
|
145
|
}
|
146
|
|
147
|
// Check if the parameter is the 'from' parameter
|
148
|
if (parts[0] === 'from') {
|
149
|
// Get the value of the 'from' parameter
|
150
|
fromValue = parts[1];
|
151
|
}
|
152
|
|
153
|
if (parts[0] === 'docno'){
|
154
|
docNo = parts[1];
|
155
|
}
|
156
|
|
157
|
if (parts[0] === 'tablename'){
|
158
|
tableName = parts[1];
|
159
|
}
|
160
|
|
161
|
});
|
162
|
console.log(dataArray);
|
163
|
|
164
|
// Get the first object from the dataArray
|
165
|
var firstItem = dataArray ? dataArray[0] : undefined;
|
166
|
|
167
|
// Get the value of the "Warehouse" property from the first object
|
168
|
var firstWarehouse = firstItem ? firstItem.Warehouse : undefined;
|
169
|
|
170
|
// Check if fromValue is 'STOCKADJUSTMENT'
|
171
|
if (fromValue === 'STOCKADJUSTMENT') {
|
172
|
// Set To Action Create
|
173
|
// Get a reference to the button with the name "CreateDoc"
|
174
|
var createButton = Ext.ComponentQuery.query('button[name=CreateDoc]')[0];
|
175
|
|
176
|
// Check if the button exists
|
177
|
if (createButton) {
|
178
|
// Fire the click event on the button
|
179
|
createButton.fireEvent('click', createButton);
|
180
|
}
|
181
|
}
|
182
|
// Load Display Doc dari Menu Stock Adjusment > Stock Adjustment List Grid Double Click
|
183
|
else if (fromValue === 'STOCKADJUSTMENTLIST'){
|
184
|
//
|
185
|
me.loadDocList(docNo, tableName);
|
186
|
}
|
187
|
|
188
|
} catch (error) {
|
189
|
//console.error('Error in stock adjustment processing:', error);
|
190
|
}
|
191
|
},
|
192
|
|
193
|
|
194
|
|
195
|
getcopyDocRef: function () {
|
196
|
var me = this;
|
197
|
var grid = Ext.ComponentQuery.query('[name=searchResult]')[0];
|
198
|
var selection = grid.getView().getSelectionModel().getSelection()[0];
|
199
|
try {
|
200
|
var documentno = selection.data.DocNo;
|
201
|
}
|
202
|
catch (err) {
|
203
|
}
|
204
|
LookupFunction = this.LookupFunction;
|
205
|
eval(LookupFunction);
|
206
|
if ( documentno === undefined ) {
|
207
|
MinovaMessage('Message', '00003', '', 'E', function (respone){
|
208
|
});
|
209
|
}
|
210
|
else {
|
211
|
me.copyDoc(documentno, grid.tableName);
|
212
|
me.action = '0';
|
213
|
}
|
214
|
},
|
215
|
|
216
|
PostingDate: function () {
|
217
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
218
|
var activeTab = tb.activeTab;
|
219
|
var tbl = activeTab.tbl;
|
220
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
221
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
222
|
/*var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
223
|
var formheader = panelHead.getForm();
|
224
|
var FiscalPeriod = formheader.findField("FiscalPeriod").getValue();
|
225
|
var FiscalYear = formheader.findField("FiscalYear").getValue();
|
226
|
var DocStatus = formheader.findField("DocStatus").getValue();
|
227
|
if(DocStatus == '1')
|
228
|
{
|
229
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
230
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
231
|
for (i = 0; i < store.count(); i++) {
|
232
|
store.data.items[i].data.FiscalPeriod = FiscalPeriod;
|
233
|
store.data.items[i].data.FiscalYear = FiscalYear;
|
234
|
}
|
235
|
}*/
|
236
|
},
|
237
|
|
238
|
CompanyID: function () {
|
239
|
//IsCompanyIDChange = '1';
|
240
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
241
|
var formheader = panelHead.getForm();
|
242
|
//var readonly = formheader.findField("DocStatus").setReadOnly(false);
|
243
|
//var status = formheader.findField("DocStatus").clearValue();
|
244
|
},
|
245
|
|
246
|
/*DocStatus: function () {
|
247
|
alert('nwh');
|
248
|
console.log(IsCompanyIDChange);
|
249
|
if(IsCompanyIDChange == '0')
|
250
|
{
|
251
|
alert('Please choose CompanyID first?');
|
252
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
253
|
var formheader = panelHead.getForm();
|
254
|
var status = formheader.findField("DocStatus").setReadOnly(true);
|
255
|
}
|
256
|
},*/
|
257
|
|
258
|
doctyperender: function () {
|
259
|
var menuID = MinovaUtil.GetMenuID();
|
260
|
var notes = '';
|
261
|
Ext.Ajax.request({
|
262
|
async: false,
|
263
|
method: 'POST',
|
264
|
url: '/UserControl/GetStore',
|
265
|
params: {
|
266
|
tableName: 'SMENU',
|
267
|
param: 'MENUID' + '[=]' + menuID
|
268
|
},
|
269
|
success: function (response) {
|
270
|
var results = Ext.decode(response.responseText);
|
271
|
dt = results.data;
|
272
|
notes = dt[0].Notes;
|
273
|
}
|
274
|
});
|
275
|
console.log(notes);
|
276
|
|
277
|
},
|
278
|
afterrenderLookupGrid: function () { console.log('afterrender lookup');
|
279
|
setTimeout(function () {
|
280
|
var store = Ext.data.StoreManager.lookup('storeadvance');
|
281
|
store.removeAll();
|
282
|
store.reload();
|
283
|
store.sort("ChangeDate", "DESC");
|
284
|
//store.loadPage(1);
|
285
|
}, 3000);
|
286
|
},
|
287
|
afterrenderDoc: function () { console.log('afterrender doc');
|
288
|
var me = this;
|
289
|
me.stockAdjustment();
|
290
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
291
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
292
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
293
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
294
|
var formHead = panelHead.getForm();
|
295
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
296
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
297
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
298
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
299
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
300
|
var btnPost = Ext.ComponentQuery.query('[name=PostDoc]')[0];
|
301
|
var btnCreateRef = Ext.ComponentQuery.query('[name=CreateDocRef]')[0];
|
302
|
|
303
|
|
304
|
//var act = getParam("action");
|
305
|
// var act = me.action;
|
306
|
// if(act == '0'){
|
307
|
// pnlSelect.setHidden(false);
|
308
|
// pnlTransaction.setHidden(true);
|
309
|
// } else {
|
310
|
// pnlSelect.setHidden(true);
|
311
|
// pnlTransaction.setHidden(false);
|
312
|
// if(act == '0'){
|
313
|
// panelHead.setHidden(false);
|
314
|
// panelDisplayHead.setHidden(true);
|
315
|
// btnSave.setDisabled(false);
|
316
|
// btnEdit.setDisabled(true);
|
317
|
// btnDelete.setDisabled(true);
|
318
|
// }
|
319
|
// else if(act == '1'){
|
320
|
// panelHead.setHidden(true);
|
321
|
// panelDisplayHead.setHidden(false);
|
322
|
// btnSave.setDisabled(true);
|
323
|
// btnEdit.setDisabled(false);
|
324
|
// btnDelete.setDisabled(false);
|
325
|
// }
|
326
|
//}
|
327
|
me.transType = panelHead.transType;
|
328
|
me.docType = panelHead.docType;
|
329
|
me.transType = panelDisplayHead.transType;
|
330
|
me.docType = panelDisplayHead.docType;
|
331
|
formHead.findField("DocType").setValue(me.docType);
|
332
|
if(me.transType == 'SLS' && me.docType == 'SINQ'){
|
333
|
btnCreateRef.setHidden(true);
|
334
|
};
|
335
|
if(me.transType == 'PUR' && me.docType == 'PB'){
|
336
|
btnCreateRef.setHidden(true);
|
337
|
};
|
338
|
},
|
339
|
afterrenderTab: function () { console.log('afterrender tab');
|
340
|
var me = this;
|
341
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
342
|
var activeTab = tb.activeTab;
|
343
|
var keyField = "DocNo";
|
344
|
var keyValue = me.docNo;
|
345
|
var act = me.action;
|
346
|
me.loadTabPanel(activeTab, keyField, keyValue, act);
|
347
|
},
|
348
|
changeTab: function (tabPanel, newCard, oldCard, eOpts) {
|
349
|
var me = this;
|
350
|
var keyField = "DocNo";
|
351
|
var keyValue = me.docNo;
|
352
|
var act = me.action;
|
353
|
me.loadTabPanel(newCard, keyField, keyValue, act);
|
354
|
},
|
355
|
loadTabPanel: function (tabObj, keyField, keyValue, act) { console.log('load tab');
|
356
|
var me = this;
|
357
|
var tbl = tabObj.tbl;
|
358
|
tabObj.getEl().mask("loading...");
|
359
|
console.log(tbl);
|
360
|
|
361
|
//region load tab doc ref
|
362
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
363
|
var formHead = panelHead.getForm();
|
364
|
var trtype = panelHead.transType;
|
365
|
var dctype = panelHead.docType;
|
366
|
var trtyperef = formHead.findField("TransTypeRef").getValue();
|
367
|
var dctyperef = formHead.findField("DocTypeRef").getValue();
|
368
|
var docidref = formHead.findField("DocIDRef").getValue();
|
369
|
//console.log(trtype); console.log(dctype); console.log(trtyperef); console.log(dctyperef); console.log(docidref);
|
370
|
var stritem = Ext.StoreMgr.lookup('store' + tbl);
|
371
|
var stritemcount = stritem.count();
|
372
|
if(docidref != "" && stritemcount == 0)
|
373
|
{
|
374
|
console.log('get tab doc ref');
|
375
|
var intdocref = [];
|
376
|
var refheader = [];
|
377
|
var refitems = [];
|
378
|
var params = {
|
379
|
serviceName: 'Logistic.asmx',
|
380
|
methodName: 'GetReferenceDocNew',
|
381
|
parameter: 'transType=' + trtype + '&docType=' + dctype +
|
382
|
'&transTypeRef=' + trtyperef + '&docTypeRef=' + dctyperef + '&docNo=' + docidref + '&tableItem=' + tbl
|
383
|
};
|
384
|
MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) { console.log('sukses get docrefnew');
|
385
|
var result = Ext.decode(xhr.responseText);
|
386
|
var dtref = Ext.decode(result.data);
|
387
|
refheader.push(dtref.Header);
|
388
|
refitems.push(dtref.Items);
|
389
|
//intdocref.push(dcno);
|
390
|
});
|
391
|
me.loadTabPanelDocRef(refheader, refitems);
|
392
|
}
|
393
|
//end region load tab doc ref
|
394
|
|
395
|
if (tabObj.layoutType == 'L001') {
|
396
|
var dt = undefined;
|
397
|
Ext.Ajax.request({
|
398
|
async: false,
|
399
|
method: 'POST',
|
400
|
url: '/UserControl/GetStore',
|
401
|
params: {
|
402
|
tableName: tbl,
|
403
|
param: keyField + '[=]' + keyValue
|
404
|
},
|
405
|
success: function (response) {
|
406
|
var results = Ext.decode(response.responseText);
|
407
|
dt = results.data;
|
408
|
}
|
409
|
});
|
410
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
411
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
412
|
if (act == '0') {
|
413
|
frmDisplay.setHidden(true);
|
414
|
frmForm.setHidden(false);
|
415
|
} else if (act == '1' || act == '2') {
|
416
|
frmDisplay.reset();
|
417
|
frmForm.reset();
|
418
|
if (dt.length > 0) {
|
419
|
frmDisplay.getForm().setValues(dt[0]);
|
420
|
frmForm.getForm().setValues(dt[0]);
|
421
|
}
|
422
|
frmDisplay.setHidden(false);
|
423
|
frmForm.setHidden(true);
|
424
|
}
|
425
|
}
|
426
|
if (tabObj.layoutType == 'L002' || tabObj.layoutType == 'L003') {
|
427
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
428
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
429
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
430
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
431
|
store.proxy.extraParams = {
|
432
|
tableName: tbl,
|
433
|
param: keyField + '[=]' + keyValue
|
434
|
};
|
435
|
store.removeAll();
|
436
|
store.reload();
|
437
|
store.loadPage(1);
|
438
|
frmDisplay.reset();
|
439
|
frmForm.reset();
|
440
|
frmDisplay.setHidden(true);
|
441
|
frmForm.setHidden(true);
|
442
|
grdPanel.setHidden(false);
|
443
|
}
|
444
|
if (tabObj.layoutType == 'L005') {
|
445
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
446
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
447
|
store.proxy.extraParams = {
|
448
|
tableName: tbl,
|
449
|
param: keyField + '[=]' + keyValue
|
450
|
};
|
451
|
store.removeAll();
|
452
|
store.reload();
|
453
|
store.loadPage(1);
|
454
|
grdPanel.setHidden(false);
|
455
|
}
|
456
|
if (tabObj.layoutType == 'L006' || tabObj.layoutType == 'L007') {
|
457
|
|
458
|
// Cek Apakah Page dari Stock Adjustment
|
459
|
var queryString = window.location.search;
|
460
|
var cf = new minovaBlowfish();
|
461
|
var urlEncrypt = cf.minovaDecryptUrl(queryString);
|
462
|
|
463
|
// Split the string by '&' to separate the parameters
|
464
|
var params = urlEncrypt.split('&');
|
465
|
|
466
|
// Initialize variables to store the decoded data and the array
|
467
|
var dataArray;
|
468
|
var decodedData;
|
469
|
// Cek Apabila Page dari Stock Adjustment, maka Grid akan diisi dari table tampungan
|
470
|
var fromPage = '';
|
471
|
try {
|
472
|
// Loop through the parameters to find the 'data' and 'from' parameters
|
473
|
params.forEach(function (param) {
|
474
|
// Split each parameter by '=' to separate the name and value
|
475
|
var parts = param.split('=');
|
476
|
|
477
|
// Check if the parameter is the 'data' parameter
|
478
|
if (parts[0] === 'data') {
|
479
|
// Decode the URL-encoded string
|
480
|
decodedData = decodeURIComponent(parts[1]);
|
481
|
|
482
|
// Parse the JSON string to get the array
|
483
|
dataArray = JSON.parse(decodedData);
|
484
|
}
|
485
|
|
486
|
// Check if the parameter is the 'from' parameter
|
487
|
if (parts[0] === 'from') {
|
488
|
// Get the value of the 'from' parameter
|
489
|
fromValue = parts[1];
|
490
|
}
|
491
|
});
|
492
|
console.log(dataArray);
|
493
|
|
494
|
// Get the first object from the dataArray
|
495
|
var firstItem = dataArray ? dataArray[0] : undefined;
|
496
|
|
497
|
// Get the value of the "Warehouse" property from the first object
|
498
|
var firstWarehouse = firstItem ? firstItem.Warehouse : undefined;
|
499
|
|
500
|
// Check if fromValue is 'STOCKADJUSTMENT'
|
501
|
if (fromValue === 'STOCKADJUSTMENT') {
|
502
|
fromPage = fromValue;
|
503
|
// Set Value Act Untuk Load Grid
|
504
|
act = '2';
|
505
|
}
|
506
|
} catch (error) {
|
507
|
}
|
508
|
|
509
|
var grdPanel = Ext.ComponentQuery.query('[name=CELLGRID' + tbl + ']')[0];
|
510
|
grdPanel.setHidden(false);
|
511
|
if (act == '0') {
|
512
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
513
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
514
|
if (tabObj.layoutType == 'L007') {
|
515
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(false);
|
516
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(false);
|
517
|
}
|
518
|
|
519
|
if ( tbl == 'PTRSALESFORMSAMPLE')
|
520
|
{
|
521
|
//region auto load tab sales sample
|
522
|
var getPnl = Ext.ComponentQuery.query('[name=panelTabPTRSALESITEMS]')[0];
|
523
|
var getTbl = getPnl.query('[name=gridCELLGRIDPTRSALESITEMS]')[0];
|
524
|
var recC = getTbl.store.getNewRecords();
|
525
|
console.log(recC);
|
526
|
var obj = [];
|
527
|
var matid = '';
|
528
|
var qty = '';
|
529
|
for (var i = 0; i < recC.length; i++) {
|
530
|
var temp = [];
|
531
|
temp.push(recC[i]);
|
532
|
Ext.each(temp, function (rec) {
|
533
|
matid = matid + ',' + rec.data.Material; console.log(matid);
|
534
|
qty = qty + ',' + rec.data.QtySample; console.log(qty);
|
535
|
});
|
536
|
}
|
537
|
|
538
|
store = Ext.StoreMgr.lookup('storePTRSALESFORMSAMPLE');
|
539
|
var afterCheck = store.getNewRecords();
|
540
|
if (afterCheck.length != '0') {
|
541
|
store.remove(afterCheck);
|
542
|
}
|
543
|
idx = store.getCount();
|
544
|
|
545
|
if (recC.length > 0) {
|
546
|
var dt = '';
|
547
|
MinovaUtil.ExecuteParamQuery({
|
548
|
ID: "PDSTRSALESFORMSAMPLE",
|
549
|
MaterialID: matid,
|
550
|
Qty: qty
|
551
|
}, function (s) {
|
552
|
var result = Ext.decode(s.responseText); console.log('get data dr param query');
|
553
|
dt = Ext.decode(Ext.decode(result.data));
|
554
|
console.log(dt);
|
555
|
});
|
556
|
|
557
|
store.insert(idx, dt);
|
558
|
}
|
559
|
store.reload();
|
560
|
}
|
561
|
} else if (act == '2') {
|
562
|
if (fromPage == 'STOCKADJUSTMENT'){
|
563
|
|
564
|
// Clear Data Item
|
565
|
MinovaUtil.ExecuteParamQuery({
|
566
|
ID: 'STOCKADJUSTMENTCLEARITEM',
|
567
|
}, function(s) {
|
568
|
try {
|
569
|
var result = Ext.decode(s.responseText);
|
570
|
var dt = Ext.decode(Ext.decode(result.data));
|
571
|
if (dt != null && dt.length != 0) {
|
572
|
var storeAdjustmentClear = Ext.create('Ext.data.Store', {
|
573
|
data: dt,
|
574
|
});
|
575
|
}
|
576
|
} catch (e) {
|
577
|
console.error('Error clearing stock adjustment items:', e);
|
578
|
}
|
579
|
}, function(e) {
|
580
|
console.error('Error executing STOCKADJUSTMENTCLEARITEM query:', e);
|
581
|
});
|
582
|
|
583
|
// Insert Data Array To Item Master Data
|
584
|
// Loop through each item in the dataArray array
|
585
|
dataArray.forEach(function(item) {
|
586
|
// Execute MinovaUtil.ExecuteParamQuery
|
587
|
MinovaUtil.ExecuteParamQuery({
|
588
|
ID: 'STOCKADJUSTMENTINSERTITEM',
|
589
|
Warehouse: item.Warehouse,
|
590
|
StockStatus: item.StockStatus,
|
591
|
MaterialID: item.MaterialID,
|
592
|
QtyAdjust: item.QtyAdjust,
|
593
|
Qty: item.Qty,
|
594
|
QtyReal: item.QtyReal,
|
595
|
ItemFlow: item.QtyAdjust > 0 ? 'RCPT' : (item.QtyAdjust < 0 ? 'ISSU' : ''),
|
596
|
UserID: 'shofwan'
|
597
|
}, function(s) {
|
598
|
try {
|
599
|
var result = Ext.decode(s.responseText);
|
600
|
var dt = Ext.decode(Ext.decode(result.data));
|
601
|
if (dt != null && dt.length != 0) {
|
602
|
var storeAdjustment = Ext.create('Ext.data.Store', {
|
603
|
data: dt,
|
604
|
});
|
605
|
|
606
|
// Save Doc No Stock Adjustment in a temporary table
|
607
|
me.stockAdjustmentDocNo = dt[0].DocNo;
|
608
|
}
|
609
|
} catch (e) {
|
610
|
console.error('Error inserting stock adjustment item:', e);
|
611
|
}
|
612
|
}, function(e) {
|
613
|
console.error('Error executing STOCKADJUSTMENTINSERTITEM query:', e);
|
614
|
});
|
615
|
});
|
616
|
|
617
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(true);
|
618
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(true);
|
619
|
if (tabObj.layoutType == 'L007') {
|
620
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(true);
|
621
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(true);
|
622
|
}
|
623
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
624
|
store.proxy.url = '/UserControl/GetStore';
|
625
|
store.proxy.extraParams = {
|
626
|
tableName: 'PTRMATERIALITEM_SA',
|
627
|
param: keyField + '[=]' + me.stockAdjustmentDocNo
|
628
|
};
|
629
|
store.removeAll();
|
630
|
store.reload();
|
631
|
store.loadPage(1);
|
632
|
}
|
633
|
else{
|
634
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(true);
|
635
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(true);
|
636
|
if (tabObj.layoutType == 'L007') {
|
637
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(true);
|
638
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(true);
|
639
|
}
|
640
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
641
|
store.proxy.url = '/UserControl/GetStore';
|
642
|
store.proxy.extraParams = {
|
643
|
tableName: tbl,
|
644
|
param: keyField + '[=]' + keyValue
|
645
|
};
|
646
|
store.removeAll();
|
647
|
store.reload();
|
648
|
store.loadPage(1);
|
649
|
}
|
650
|
} else {
|
651
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
652
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
653
|
if (tabObj.layoutType == 'L007') {
|
654
|
var btnupload = Ext.ComponentQuery.query('[name=upload' + tbl + ']')[0].setDisabled(false);
|
655
|
var btndownload = Ext.ComponentQuery.query('[name=download' + tbl + ']')[0].setDisabled(false);
|
656
|
}
|
657
|
}
|
658
|
|
659
|
if (tabObj.layoutType == 'L007') {
|
660
|
|
661
|
// Cek Apabila Page dari Stock Adjustment
|
662
|
|
663
|
// Apabila Page dari stock adjustment maka auto load tadi table tampungan PTRMATERIALITEM_STOCKADJUSTMERT
|
664
|
if (fromPage == 'STOCKADJUSTMENT'){
|
665
|
var sumPanel = Ext.ComponentQuery.query('[name=SUM' + tbl + ']')[0];
|
666
|
var sumForm = sumPanel.getForm();
|
667
|
var itm = sumForm.getFields().items;
|
668
|
Ext.Ajax.request({
|
669
|
async: false,
|
670
|
method: 'POST',
|
671
|
url: '/UserControl/GetStore',
|
672
|
params: {
|
673
|
tableName: 'PTRMATERIALITEM_SA',
|
674
|
param: keyField + '[=]' + me.stockAdjustmentDocNo
|
675
|
},
|
676
|
success: function (response) {
|
677
|
var results = Ext.decode(response.responseText);
|
678
|
dtgrid = results.data;
|
679
|
}
|
680
|
});
|
681
|
Ext.each(itm, function (i) {
|
682
|
var fld = i.name;
|
683
|
var fldValue = 0;
|
684
|
Ext.each(dtgrid, function (d) {
|
685
|
var fValue = d[fld];
|
686
|
fldValue = fldValue + parseFloat(fValue);
|
687
|
});
|
688
|
fldValue = Ext.util.Format.number(fldValue, '0,000.00');
|
689
|
sumForm.findField(fld).setValue(fldValue);
|
690
|
});
|
691
|
var total_item = dtgrid.length;
|
692
|
Ext.ComponentQuery.query('displayfield[name=totalitem]')[0].setValue(total_item);
|
693
|
}
|
694
|
|
695
|
//Kondisi Selain Stock Adjusment
|
696
|
else {
|
697
|
var sumPanel = Ext.ComponentQuery.query('[name=SUM' + tbl + ']')[0];
|
698
|
var sumForm = sumPanel.getForm();
|
699
|
var itm = sumForm.getFields().items;
|
700
|
Ext.Ajax.request({
|
701
|
async: false,
|
702
|
method: 'POST',
|
703
|
url: '/UserControl/GetStore',
|
704
|
params: {
|
705
|
tableName: tbl,
|
706
|
param: keyField + '[=]' + keyValue
|
707
|
},
|
708
|
success: function (response) {
|
709
|
var results = Ext.decode(response.responseText);
|
710
|
dtgrid = results.data;
|
711
|
}
|
712
|
});
|
713
|
Ext.each(itm, function (i) {
|
714
|
var fld = i.name;
|
715
|
var fldValue = 0;
|
716
|
Ext.each(dtgrid, function (d) {
|
717
|
var fValue = d[fld];
|
718
|
fldValue = fldValue + parseFloat(fValue);
|
719
|
});
|
720
|
fldValue = Ext.util.Format.number(fldValue, '0,000.00');
|
721
|
sumForm.findField(fld).setValue(fldValue);
|
722
|
});
|
723
|
var total_item = dtgrid.length;
|
724
|
Ext.ComponentQuery.query('displayfield[name=totalitem]')[0].setValue(total_item);
|
725
|
}
|
726
|
}
|
727
|
}
|
728
|
tabObj.getEl().unmask();
|
729
|
if(tbl == 'PTRALLOCATION') //add by Tri nwh 20240426
|
730
|
{ console.log('r'); console.log(act);
|
731
|
var storea = Ext.StoreMgr.lookup("storePTRALLOCATION");
|
732
|
var grid = Ext.getCmp('gridCELLGRIDPTRALLOCATION');
|
733
|
var selectiona = grid.getView().getSelectionModel().getSelection()[0];
|
734
|
console.log(storea.data.length);
|
735
|
|
736
|
grid.on('beforeedit', function(e, editor) {
|
737
|
console.log(e); console.log(editor); console.log(editor.rowIdx);
|
738
|
var st = storea.getAt(editor.rowIdx).get('IsAllocated');
|
739
|
if(st == 1)
|
740
|
{
|
741
|
return false;
|
742
|
}
|
743
|
}, grid);
|
744
|
}
|
745
|
if (tbl == 'PTRSALESDOCAPPROVER'){
|
746
|
var gridPanel = Ext.getCmp('gridCELLGRIDPTRSALESDOCAPPROVER');
|
747
|
if (gridPanel) {
|
748
|
gridPanel.on('beforeedit', function(editor, context) {
|
749
|
// Check if the editing is happening in the ApprovedFlag column
|
750
|
if (context.field === 'ApprovedFlag') {
|
751
|
// Get the EmployeeID from the session
|
752
|
var currentEmployeeID = MinovaUtil.SESSIONS.EmployeeID;
|
753
|
|
754
|
// Get the ApproverID for the current row
|
755
|
var approverID = context.record.get('ApproverID');
|
756
|
|
757
|
// Get the editor for the ApprovedFlag column
|
758
|
var combo = context.column.getEditor();
|
759
|
|
760
|
// Compare ApproverID with EmployeeID
|
761
|
if (approverID === currentEmployeeID) {
|
762
|
// Allow editing if they match
|
763
|
if (combo) {
|
764
|
combo.setEditable(true); // Make it editable
|
765
|
combo.setReadOnly(false); // Ensure it's not read-only
|
766
|
}
|
767
|
} else {
|
768
|
// Disable the editor if they do not match
|
769
|
if (combo) {
|
770
|
MinovaMessageInfo("Information", "APPROVEVALIDATION", "", "");
|
771
|
combo.setEditable(false); // Make it non-editable
|
772
|
combo.setReadOnly(true); // Set it to read-only
|
773
|
}
|
774
|
return false; // Prevent editing
|
775
|
}
|
776
|
}
|
777
|
});
|
778
|
} else {
|
779
|
console.warn('Grid panel not found.');
|
780
|
}
|
781
|
}
|
782
|
},
|
783
|
buildMultiGrid: function () {
|
784
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
785
|
var GridData = PanelData.query('docgrid');
|
786
|
var GridLength = GridData.length;
|
787
|
var GridBuildStrings = [];
|
788
|
for (var i = 0; i < GridLength; i++) {
|
789
|
var records = [];
|
790
|
var grd = GridData[i].query('grid')[0];
|
791
|
if (grd.hasOwnProperty('CRUDflag')) {
|
792
|
records = grd.CRUDflag.getAllRecords(GridData[i].store)
|
793
|
} else {
|
794
|
var recC = grd.store.getNewRecords();
|
795
|
Ext.each(recC, function (rec) {
|
796
|
rec.data.FlagCrud = "I";
|
797
|
records.push(rec);
|
798
|
});
|
799
|
var recU = grd.store.getUpdatedRecords();
|
800
|
Ext.each(recU, function (rec) {
|
801
|
rec.data.FlagCrud = "U";
|
802
|
records.push(rec);
|
803
|
});
|
804
|
var recD = grd.store.getRemovedRecords();
|
805
|
Ext.each(recD, function (rec) {
|
806
|
rec.data.FlagCrud = "D";
|
807
|
records.push(rec);
|
808
|
});
|
809
|
}
|
810
|
Ext.each(records, function (rec) {
|
811
|
var name = GridData[i].tableName;
|
812
|
var obj = Ext.decode('{' + name + ':' + Ext.encode(rec.data) + '}');
|
813
|
GridBuildStrings.push(obj);
|
814
|
});
|
815
|
}
|
816
|
return GridBuildStrings;
|
817
|
},
|
818
|
buildMultiGridEditCell: function () {
|
819
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
820
|
var GridData = PanelData.query('docgridcelledit');
|
821
|
var GridLength = GridData.length;
|
822
|
var GridBuildStrings = [];
|
823
|
for (var i = 0; i < GridLength; i++) {
|
824
|
var records = [];
|
825
|
var grd = GridData[i].query('grid')[0];
|
826
|
if (grd.hasOwnProperty('CRUDflag')) {
|
827
|
records = grd.CRUDflag.getAllRecords(GridData[i].store)
|
828
|
} else {
|
829
|
var recC = grd.store.getNewRecords();
|
830
|
Ext.each(recC, function (rec) {
|
831
|
rec.data.FlagCrud = "I";
|
832
|
records.push(rec);
|
833
|
});
|
834
|
var recU = grd.store.getUpdatedRecords();
|
835
|
Ext.each(recU, function (rec) {
|
836
|
rec.data.FlagCrud = "U";
|
837
|
records.push(rec);
|
838
|
});
|
839
|
var recD = grd.store.getRemovedRecords();
|
840
|
Ext.each(recD, function (rec) {
|
841
|
rec.data.FlagCrud = "D";
|
842
|
records.push(rec);
|
843
|
});
|
844
|
}
|
845
|
Ext.each(records, function (rec) {
|
846
|
var name = GridData[i].tableName;
|
847
|
var obj = Ext.decode('{' + name + ':' + Ext.encode(rec.data) + '}');
|
848
|
GridBuildStrings.push(obj);
|
849
|
});
|
850
|
}
|
851
|
return GridBuildStrings;
|
852
|
},
|
853
|
buildMultiGridEditCellSum: function () {
|
854
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
855
|
var GridData = PanelData.query('docgridcelleditsum');
|
856
|
var GridLength = GridData.length;
|
857
|
var GridBuildStrings = [];
|
858
|
for (var i = 0; i < GridLength; i++) {
|
859
|
var records = [];
|
860
|
var grd = GridData[i].query('grid')[0];
|
861
|
if (grd.hasOwnProperty('CRUDflag')) {
|
862
|
records = grd.CRUDflag.getAllRecords(GridData[i].store)
|
863
|
} else {
|
864
|
var recC = grd.store.getNewRecords();
|
865
|
Ext.each(recC, function (rec) {
|
866
|
rec.data.FlagCrud = "I";
|
867
|
records.push(rec);
|
868
|
});
|
869
|
var recU = grd.store.getUpdatedRecords();
|
870
|
Ext.each(recU, function (rec) {
|
871
|
rec.data.FlagCrud = "U";
|
872
|
records.push(rec);
|
873
|
});
|
874
|
var recD = grd.store.getRemovedRecords();
|
875
|
Ext.each(recD, function (rec) {
|
876
|
rec.data.FlagCrud = "D";
|
877
|
records.push(rec);
|
878
|
});
|
879
|
}
|
880
|
Ext.each(records, function (rec) {
|
881
|
var name = GridData[i].tableName;
|
882
|
var obj = Ext.decode('{' + name + ':' + Ext.encode(rec.data) + '}');
|
883
|
GridBuildStrings.push(obj);
|
884
|
});
|
885
|
}
|
886
|
return GridBuildStrings;
|
887
|
|
888
|
},
|
889
|
loadTabPanelDocRef: function (dtheader, dtitems) { console.log('load tab ref');
|
890
|
var me = this;
|
891
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
892
|
var tabObj = tb.activeTab;
|
893
|
var docno = me.docNo;
|
894
|
var act = me.action;
|
895
|
|
896
|
var tbl = tabObj.tbl;
|
897
|
tabObj.getEl().mask("loading...");
|
898
|
if (tabObj.layoutType == 'L001') {
|
899
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
900
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
901
|
frmDisplay.reset();
|
902
|
frmForm.reset();
|
903
|
if (dtheader.length > 0) {
|
904
|
frmDisplay.getForm().setValues(dtheader[0]);
|
905
|
frmForm.getForm().setValues(dtheader[0]);
|
906
|
}
|
907
|
frmDisplay.setHidden(true);
|
908
|
frmForm.setHidden(false);
|
909
|
}
|
910
|
if (tabObj.layoutType == 'L002' || tabObj.layoutType == 'L003') {
|
911
|
var frmDisplay = Ext.ComponentQuery.query('[name=DISPLAY' + tbl + ']')[0];
|
912
|
var frmForm = Ext.ComponentQuery.query('[name=FORM' + tbl + ']')[0];
|
913
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
914
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
915
|
store.removeAll();
|
916
|
Ext.each(dtitems, function (item) {
|
917
|
store.add(item);
|
918
|
});
|
919
|
frmDisplay.reset();
|
920
|
frmForm.reset();
|
921
|
frmDisplay.setHidden(true);
|
922
|
frmForm.setHidden(true);
|
923
|
grdPanel.setHidden(false);
|
924
|
}
|
925
|
if (tabObj.layoutType == 'L005') {
|
926
|
var grdPanel = Ext.ComponentQuery.query('[name=GRID' + tbl + ']')[0];
|
927
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
928
|
store.removeAll();
|
929
|
Ext.each(dtitems, function (item) {
|
930
|
store.add(item);
|
931
|
});
|
932
|
grdPanel.setHidden(false);
|
933
|
}
|
934
|
if (tabObj.layoutType == 'L006' || tabObj.layoutType == 'L007') {
|
935
|
var grdPanel = Ext.ComponentQuery.query('[name=CELLGRID' + tbl + ']')[0];
|
936
|
grdPanel.setHidden(false);
|
937
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
938
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
939
|
var store = Ext.StoreMgr.lookup("store" + tbl);
|
940
|
store.removeAll();
|
941
|
Ext.each(dtitems, function (item) {
|
942
|
store.add(item);
|
943
|
});
|
944
|
if (tabObj.layoutType == 'L007') {
|
945
|
var sumPanel = Ext.ComponentQuery.query('[name=SUM' + tbl + ']')[0];
|
946
|
var sumForm = sumPanel.getForm();
|
947
|
var itm = sumForm.getFields().items;
|
948
|
Ext.each(itm, function (i) {
|
949
|
var fld = i.name;
|
950
|
var fldValue = 0;
|
951
|
Ext.each(dtitems, function (dt) {
|
952
|
Ext.each(dt, function (d) {
|
953
|
var fValue = d[fld];
|
954
|
fldValue = fldValue + parseFloat(fValue);
|
955
|
});
|
956
|
});
|
957
|
fldValue = Ext.util.Format.number(fldValue, '0,000.00');
|
958
|
sumForm.findField(fld).setValue(fldValue);
|
959
|
});
|
960
|
}
|
961
|
}
|
962
|
tabObj.getEl().unmask();
|
963
|
},
|
964
|
createDocRef: function (dtheader, dtitems, intdocref) {
|
965
|
var me = this;
|
966
|
me.action = '0';
|
967
|
me.docNo = 'None'
|
968
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
969
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
970
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
971
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
972
|
var formHead = panelHead.getForm();
|
973
|
formHead.reset();
|
974
|
var formHeadDisplay = panelDisplayHead.getForm();
|
975
|
formHeadDisplay.reset();
|
976
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
977
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
978
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
979
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
980
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
981
|
pnlSelect.setHidden(true);
|
982
|
pnlTransaction.setHidden(false);
|
983
|
panelHead.setHidden(false);
|
984
|
panelDisplayHead.setHidden(true);
|
985
|
btnSaveCreate.setDisabled(false);
|
986
|
btnCreate.setDisabled(false);
|
987
|
btnSave.setDisabled(false);
|
988
|
formHead.findField("DocType").setValue(me.docType);
|
989
|
if (dtheader.length > 0) {
|
990
|
formHead.setValues(dtheader[0]);
|
991
|
formHeadDisplay.setValues(dtheader[0]);
|
992
|
}
|
993
|
var docnoref = "";
|
994
|
Ext.each(intdocref, function (doc) {
|
995
|
docnoref = docnoref + "," + doc;
|
996
|
});
|
997
|
var lg = docnoref.length;
|
998
|
if (lg > 0) {
|
999
|
docnoref = docnoref.substring(1, lg);
|
1000
|
}
|
1001
|
formHead.findField("IntDocRef").setValue(docnoref);
|
1002
|
formHead.findField("RefType").setValue("01");
|
1003
|
me.loadTabPanelDocRef(dtheader, dtitems);
|
1004
|
},
|
1005
|
createDoc: function () {
|
1006
|
|
1007
|
var me = this
|
1008
|
// shofwan 20240508
|
1009
|
// Auto Loac Create Doc saat stock adjustment
|
1010
|
|
1011
|
var queryString = window.location.search;
|
1012
|
var cf = new minovaBlowfish();
|
1013
|
var urlEncrypt = cf.minovaDecryptUrl(queryString);
|
1014
|
|
1015
|
// Split the string by '&' to separate the parameters
|
1016
|
var params = urlEncrypt.split('&');
|
1017
|
|
1018
|
// Initialize variables to store the decoded data and the array
|
1019
|
var dataArray;
|
1020
|
var decodedData;
|
1021
|
|
1022
|
// Initialize variable to store the 'from' parameter value
|
1023
|
var fromValue;
|
1024
|
|
1025
|
try {
|
1026
|
// Loop through the parameters to find the 'data' and 'from' parameters
|
1027
|
params.forEach(function (param) {
|
1028
|
// Split each parameter by '=' to separate the name and value
|
1029
|
var parts = param.split('=');
|
1030
|
|
1031
|
// Check if the parameter is the 'data' parameter
|
1032
|
if (parts[0] === 'data') {
|
1033
|
// Decode the URL-encoded string
|
1034
|
decodedData = decodeURIComponent(parts[1]);
|
1035
|
|
1036
|
// Parse the JSON string to get the array
|
1037
|
dataArray = JSON.parse(decodedData);
|
1038
|
}
|
1039
|
|
1040
|
// Check if the parameter is the 'from' parameter
|
1041
|
if (parts[0] === 'from') {
|
1042
|
// Get the value of the 'from' parameter
|
1043
|
fromValue = parts[1];
|
1044
|
}
|
1045
|
});
|
1046
|
console.log(dataArray);
|
1047
|
|
1048
|
// Get the first object from the dataArray
|
1049
|
var firstItem = dataArray ? dataArray[0] : undefined;
|
1050
|
|
1051
|
// Get the value of the "Warehouse" property from the first object
|
1052
|
var firstWarehouse = firstItem ? firstItem.Warehouse : undefined;
|
1053
|
|
1054
|
// Get the first object from the dataArray
|
1055
|
var firstItem = dataArray ? dataArray[0] : undefined;
|
1056
|
|
1057
|
// Get the value of the "Warehouse" property from the first object
|
1058
|
var firstWarehouse = firstItem ? firstItem.Warehouse : undefined;
|
1059
|
}
|
1060
|
catch (error) {
|
1061
|
}
|
1062
|
|
1063
|
|
1064
|
me.action = '0';
|
1065
|
me.docNo = 'None';
|
1066
|
me.dataExist= "";
|
1067
|
me.docStatus= "";
|
1068
|
me.docStatusExist= "";
|
1069
|
me.PostingDateExist= "";
|
1070
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
1071
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
1072
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1073
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
1074
|
var formHead = panelHead.getForm();
|
1075
|
var docdate = formHead.findField("DocDate").getValue(); console.log(docdate); console.log(me.docType); //IntID by Tri nwh
|
1076
|
formHead.reset();
|
1077
|
var formHeadDisplay = panelDisplayHead.getForm();
|
1078
|
formHeadDisplay.reset();
|
1079
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
1080
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
1081
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
1082
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
1083
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
1084
|
pnlSelect.setHidden(true);
|
1085
|
pnlTransaction.setHidden(false);
|
1086
|
panelHead.setHidden(false);
|
1087
|
panelDisplayHead.setHidden(true);
|
1088
|
formHead.findField("DocType").setValue(me.docType); //// pindahin by Tri nwh
|
1089
|
|
1090
|
if(MinovaUtil.GetMenuID() == 'PURCHDEMANDFORGOODS')
|
1091
|
{
|
1092
|
formHead.findField("DocStatus").setValue('2');
|
1093
|
}
|
1094
|
// shofwan 20240508 Auto Load warehouse untuk stock adjustment
|
1095
|
try{
|
1096
|
formHead.findField("Warehouse").setValue(firstWarehouse); //// Shofwan
|
1097
|
}
|
1098
|
catch (error){
|
1099
|
|
1100
|
};
|
1101
|
|
1102
|
btnSaveCreate.setDisabled(false);
|
1103
|
btnCreate.setDisabled(false);
|
1104
|
btnSave.setDisabled(false);
|
1105
|
btnEdit.setDisabled(true); // nwh tri
|
1106
|
/*formHead.findField("DocType").setValue(me.docType);
|
1107
|
console.log(formHead.findField("DocType").getValue());*/ //// dipindahin keatas by Tri nwh
|
1108
|
me.afterrenderTab();
|
1109
|
|
1110
|
var tb = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
1111
|
var tbl = tb.activeTab.tbl; console.log(me.transType);
|
1112
|
if(me.transType == 'FIN')
|
1113
|
{
|
1114
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(true);
|
1115
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(true);
|
1116
|
}
|
1117
|
else
|
1118
|
{
|
1119
|
var btnadd = Ext.ComponentQuery.query('[name=add' + tbl + ']')[0].setDisabled(false);
|
1120
|
var btndelete = Ext.ComponentQuery.query('[name=delete' + tbl + ']')[0].setDisabled(false);
|
1121
|
}
|
1122
|
|
1123
|
/*MinovaUtil.ExecuteParamQuery({ //// IntID by Tri nwh
|
1124
|
ID: "CKJLLOGINTID",
|
1125
|
DocType: me.docType,
|
1126
|
DocDate: docdate
|
1127
|
}, function (s) {
|
1128
|
var result = Ext.decode(s.responseText);
|
1129
|
var dt = Ext.decode(Ext.decode(result.data));
|
1130
|
formHead.findField("InternalID").setValue(dt[0].IntID);
|
1131
|
}, function (f) {});
|
1132
|
|
1133
|
MinovaUtil.ExecuteParamQuery({ //// ExtID by Tri nwh
|
1134
|
ID: "CKJLLOGEXTID",
|
1135
|
DocType: me.docType,
|
1136
|
DocDate: docdate
|
1137
|
}, function (s) {
|
1138
|
var result = Ext.decode(s.responseText);
|
1139
|
var dt = Ext.decode(Ext.decode(result.data));
|
1140
|
formHead.findField("ExternalID").setValue(dt[0].ExtID);
|
1141
|
}, function (f) {});*/
|
1142
|
},
|
1143
|
displayDoc: function () {
|
1144
|
var me = this;
|
1145
|
//var documentNo = Ext.ComponentQuery.query('triggerfield[name=DocNo]')[0];
|
1146
|
//var tbl = documentNo.tableName;
|
1147
|
//me.loadDoc(documentNo.getValue(), tbl);
|
1148
|
var grid = Ext.ComponentQuery.query('[name=searchResult]')[0];
|
1149
|
var selection = grid.getView().getSelectionModel().getSelection()[0];
|
1150
|
var documentno = selection.data.DocNo;
|
1151
|
LookupFunction = this.LookupFunction;
|
1152
|
eval(LookupFunction);
|
1153
|
me.loadDoc(documentno, grid.tableName);
|
1154
|
},
|
1155
|
loadDoc: function (documentno, tbl) {
|
1156
|
var me = this;
|
1157
|
me.action = '2';
|
1158
|
me.docNo = documentno;
|
1159
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
1160
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
1161
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1162
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
1163
|
var formHead = panelHead.getForm();
|
1164
|
var formHeadDisplay = panelDisplayHead.getForm();
|
1165
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
1166
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
1167
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
1168
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
1169
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
1170
|
var dt = undefined;
|
1171
|
Ext.Ajax.request({
|
1172
|
async: false,
|
1173
|
method: 'POST',
|
1174
|
url: '/UserControl/GetStore',
|
1175
|
params: {
|
1176
|
tableName: tbl,
|
1177
|
param: 'DocNo[=]' + me.docNo
|
1178
|
},
|
1179
|
success: function (response) {
|
1180
|
var results = Ext.decode(response.responseText);
|
1181
|
dt = results.data;
|
1182
|
}
|
1183
|
});
|
1184
|
console.log(dt);
|
1185
|
formHead.setValues(dt[0]);
|
1186
|
formHeadDisplay.setValues(dt[0]);
|
1187
|
me.afterrenderTab();
|
1188
|
pnlSelect.setHidden(true);
|
1189
|
pnlTransaction.setHidden(false);
|
1190
|
panelHead.setHidden(false);
|
1191
|
panelDisplayHead.setHidden(true);
|
1192
|
btnSaveCreate.setDisabled(true);
|
1193
|
btnCreate.setDisabled(true);
|
1194
|
if(MinovaUtil.GetActionMenu() == "0")
|
1195
|
{
|
1196
|
btnSave.setHidden(true);
|
1197
|
btnEdit.setHidden(true);
|
1198
|
}
|
1199
|
else
|
1200
|
{
|
1201
|
btnSave.setDisabled(true);
|
1202
|
btnEdit.setDisabled(false);
|
1203
|
}
|
1204
|
btnDelete.setDisabled(false);
|
1205
|
me.dataExist = "Y";
|
1206
|
me.docStatusExist = formHead.findField("DocStatus").getValue();
|
1207
|
|
1208
|
//Ext.ComponentQuery.query('displayfield[name=totalitem]')[0].setValue('2');
|
1209
|
//me.PostingDateExist = formHead.findField("PostingDate").getValue();
|
1210
|
},
|
1211
|
loadDocList: function (documentno, tbl) {
|
1212
|
var me = this;
|
1213
|
me.action = '2';
|
1214
|
me.docNo = documentno;
|
1215
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
1216
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
1217
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1218
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
1219
|
var formHead = panelHead.getForm();
|
1220
|
var formHeadDisplay = panelDisplayHead.getForm();
|
1221
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
1222
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
1223
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
1224
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
1225
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
1226
|
var dt = undefined;
|
1227
|
Ext.Ajax.request({
|
1228
|
async: false,
|
1229
|
method: 'POST',
|
1230
|
url: '/UserControl/GetStore',
|
1231
|
params: {
|
1232
|
tableName: tbl,
|
1233
|
param: 'DocNo[=]' + me.docNo
|
1234
|
},
|
1235
|
success: function (response) {
|
1236
|
var results = Ext.decode(response.responseText);
|
1237
|
dt = results.data;
|
1238
|
}
|
1239
|
});
|
1240
|
console.log(dt);
|
1241
|
formHead.setValues(dt[0]);
|
1242
|
formHeadDisplay.setValues(dt[0]);
|
1243
|
me.afterrenderTab();
|
1244
|
pnlSelect.setHidden(true);
|
1245
|
pnlTransaction.setHidden(false);
|
1246
|
panelHead.setHidden(false);
|
1247
|
panelDisplayHead.setHidden(true);
|
1248
|
btnSaveCreate.setDisabled(true);
|
1249
|
btnCreate.setDisabled(true);
|
1250
|
btnSave.setHidden(true);
|
1251
|
btnEdit.setHidden(true);
|
1252
|
btnEdit.setDisabled(false);
|
1253
|
btnSave.setDisabled(true);
|
1254
|
btnDelete.setDisabled(false);
|
1255
|
me.dataExist = "Y";
|
1256
|
me.docStatusExist = formHead.findField("DocStatus").getValue();
|
1257
|
|
1258
|
//Ext.ComponentQuery.query('displayfield[name=totalitem]')[0].setValue('2');
|
1259
|
//me.PostingDateExist = formHead.findField("PostingDate").getValue();
|
1260
|
},
|
1261
|
copyDoc: function (documentno, tbl) {
|
1262
|
var me = this;
|
1263
|
me.action = '2';
|
1264
|
me.docNo = documentno;
|
1265
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
1266
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
1267
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1268
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
1269
|
var formHead = panelHead.getForm();
|
1270
|
var formHeadDisplay = panelDisplayHead.getForm();
|
1271
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
1272
|
var btnSaveCreateDocRef = Ext.ComponentQuery.query('[name=SaveCreateDocRef]')[0];
|
1273
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
1274
|
var btnCreateDocRef = Ext.ComponentQuery.query('[name=Create1DocRef]')[0];
|
1275
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
1276
|
var btnSaveCopy = Ext.ComponentQuery.query('[name=SaveCopyDoc]')[0];
|
1277
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
1278
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
1279
|
var dt = undefined;
|
1280
|
Ext.Ajax.request({
|
1281
|
async: false,
|
1282
|
method: 'POST',
|
1283
|
url: '/UserControl/GetStore',
|
1284
|
params: {
|
1285
|
tableName: tbl,
|
1286
|
param: 'DocNo[=]' + me.docNo
|
1287
|
},
|
1288
|
success: function (response) {
|
1289
|
var results = Ext.decode(response.responseText);
|
1290
|
results.data[0].DocNo='';
|
1291
|
results.data[0].ProcessID='';
|
1292
|
dt = results.data;
|
1293
|
}
|
1294
|
});
|
1295
|
console.log(dt);
|
1296
|
formHead.setValues(dt[0]);
|
1297
|
formHeadDisplay.setValues(dt[0]);
|
1298
|
me.afterrenderTab();
|
1299
|
pnlSelect.setHidden(true);
|
1300
|
pnlTransaction.setHidden(false);
|
1301
|
panelHead.setHidden(false);
|
1302
|
panelDisplayHead.setHidden(true);
|
1303
|
btnSaveCreate.setDisabled(true);
|
1304
|
btnCreate.setDisabled(true);
|
1305
|
btnSaveCreateDocRef.setDisabled(true);
|
1306
|
btnCreateDocRef.setDisabled(true);
|
1307
|
btnSave.setDisabled(true);
|
1308
|
btnSaveCopy.setHidden(false);
|
1309
|
btnEdit.setDisabled(false);
|
1310
|
btnDelete.setDisabled(false);
|
1311
|
me.dataExist = "Y";
|
1312
|
me.docStatusExist = formHead.findField("DocStatus").getValue();
|
1313
|
},
|
1314
|
editDoc: function () {
|
1315
|
var me = this;
|
1316
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1317
|
var formheader = panelHead.getForm();
|
1318
|
var status = formheader.findField("DocStatus").getValue();
|
1319
|
|
1320
|
if (status == "5") {
|
1321
|
Ext.Ajax.request({
|
1322
|
async: false,
|
1323
|
method: 'POST',
|
1324
|
url: '/UserControl/GetStore',
|
1325
|
params: {
|
1326
|
tableName: 'PCMBSDOCSTATUS',
|
1327
|
param: 'DocStatus[=]' + status
|
1328
|
},
|
1329
|
success: function (response) {
|
1330
|
var results = Ext.decode(response.responseText);
|
1331
|
dt = results.data[0];
|
1332
|
}
|
1333
|
});
|
1334
|
MinovaMessage('000006', 'FILO01', dt.Description, 'W');
|
1335
|
/*me.dataExist = "Y";
|
1336
|
me.docStatusExist = formheader.findField("DocStatus").getValue();
|
1337
|
me.PostingDateExist = formheader.findField("PostingDate").getValue();*/
|
1338
|
} else {
|
1339
|
me.action = '1';
|
1340
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
1341
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
1342
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
1343
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
1344
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
1345
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
1346
|
panelHead.setHidden(false);
|
1347
|
panelDisplayHead.setHidden(true);
|
1348
|
btnSaveCreate.setDisabled(false);
|
1349
|
btnCreate.setDisabled(false);
|
1350
|
btnSave.setDisabled(false);
|
1351
|
me.afterrenderTab();
|
1352
|
/*me.dataExist = "Y";
|
1353
|
me.docStatusExist = formheader.findField("DocStatus").getValue();
|
1354
|
me.PostingDateExist = formheader.findField("PostingDate").getValue();*/
|
1355
|
}
|
1356
|
},
|
1357
|
saveDoc: function () {
|
1358
|
var me = this;
|
1359
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
1360
|
var tbl = panelHead.tableName;
|
1361
|
var formHead = panelHead.getForm();
|
1362
|
var docStatus = formHead.findField("DocStatus").getValue();
|
1363
|
var DocNo = formHead.findField("DocNo").getValue();
|
1364
|
|
1365
|
|
1366
|
|
1367
|
if (me.transType == 'FIN') {
|
1368
|
var FiscalYear = formHead.findField("FiscalYear").getValue();
|
1369
|
var FiscalPeriod = formHead.findField("FiscalPeriod").getValue();
|
1370
|
var pd = formHead.findField("PostingDate").getValue();
|
1371
|
var debet = Ext.ComponentQuery.query('displayfield[name=AmountDebet]')[0];
|
1372
|
var kredit = Ext.ComponentQuery.query('displayfield[name=AmountCredit]')[0];
|
1373
|
|
1374
|
if (pd == null || pd == "" || pd == undefined) {
|
1375
|
if(docStatus == '9')
|
1376
|
{
|
1377
|
MinovaMessage("", "FILO05", "", "E");
|
1378
|
return;
|
1379
|
}
|
1380
|
}
|
1381
|
if (debet !== undefined && kredit !== undefined) {
|
1382
|
if (debet.getValue() !== kredit.getValue()) {
|
1383
|
MinovaMessage("", "FILO10", "", "E");
|
1384
|
return;
|
1385
|
}
|
1386
|
}
|
1387
|
|
1388
|
console.log('FIN!');
|
1389
|
|
1390
|
if (debet.getValue() == 0 && kredit.getValue() == 0 && docStatus == '9' ) {
|
1391
|
if(me.dataExist == 'Y')
|
1392
|
{
|
1393
|
formHead.findField("DocStatus").setValue("3");
|
1394
|
Ext.Ajax.request({
|
1395
|
async: false,
|
1396
|
method: 'POST',
|
1397
|
url: '/UserControl/GetStore',
|
1398
|
params: {
|
1399
|
tableName: 'PDSFILODELETEDATATABLEPOST',
|
1400
|
param: DocNo
|
1401
|
},
|
1402
|
success: function (response) {
|
1403
|
}
|
1404
|
});
|
1405
|
}
|
1406
|
else
|
1407
|
{
|
1408
|
MinovaMessage("", "FILO11", "", "E");
|
1409
|
return;
|
1410
|
}
|
1411
|
}
|
1412
|
|
1413
|
if(me.docStatusExist == '9' || me.docStatusExist == '3')
|
1414
|
{
|
1415
|
if(docStatus == '1' || docStatus == '2')
|
1416
|
{
|
1417
|
MinovaMessage("", "FILO12", "", "E");
|
1418
|
return;
|
1419
|
}
|
1420
|
if(pd != me.PostingDateExist)
|
1421
|
{
|
1422
|
MinovaMessage("", "FILO13", "", "E");
|
1423
|
return;
|
1424
|
}
|
1425
|
if(docStatus == '3')//if(me.docStatus == '3')
|
1426
|
{
|
1427
|
Ext.Ajax.request({
|
1428
|
async: false,
|
1429
|
method: 'POST',
|
1430
|
url: '/UserControl/GetStore',
|
1431
|
params: {
|
1432
|
tableName: 'PDSFILODELETEDATATABLEPOST',
|
1433
|
param: DocNo
|
1434
|
},
|
1435
|
success: function (response) {
|
1436
|
}
|
1437
|
});
|
1438
|
}
|
1439
|
}
|
1440
|
|
1441
|
if(me.docStatusExist == '1' && docStatus == '1')
|
1442
|
{
|
1443
|
if(pd != me.PostingDateExist)
|
1444
|
{
|
1445
|
Ext.Ajax.request({
|
1446
|
async: false,
|
1447
|
method: 'POST',
|
1448
|
url: '/UserControl/GetStore',
|
1449
|
params: {
|
1450
|
tableName: 'PDSFILOUPDATEPERIODFINANCEITEM',
|
1451
|
param: DocNo + ',' + FiscalYear + ',' + FiscalPeriod
|
1452
|
},
|
1453
|
success: function (response) {
|
1454
|
}
|
1455
|
});
|
1456
|
}
|
1457
|
}
|
1458
|
|
1459
|
if(me.docStatusExist == '1' && docStatus == '9')
|
1460
|
{
|
1461
|
if(pd != me.PostingDateExist)
|
1462
|
{
|
1463
|
|
1464
|
Ext.Ajax.request({
|
1465
|
async: false,
|
1466
|
method: 'POST',
|
1467
|
url: '/UserControl/GetStore',
|
1468
|
params: {
|
1469
|
tableName: 'PDSFILOUPDATEPERIODFINANCEITEM',
|
1470
|
param: DocNo + ',' + FiscalYear + ',' + FiscalPeriod
|
1471
|
},
|
1472
|
success: function (response) {
|
1473
|
}
|
1474
|
});
|
1475
|
}
|
1476
|
}
|
1477
|
}
|
1478
|
|
1479
|
if (formHead.isValid()) {
|
1480
|
panelHead.mask("Loading...");
|
1481
|
var dataHeader = Ext.encode(formHead.getValues());
|
1482
|
var token = MinovaUtil.SESSIONS.Token;
|
1483
|
var objGrid;
|
1484
|
var objGridCell;
|
1485
|
var objGridCellSum;
|
1486
|
try {
|
1487
|
objGrid = me.buildMultiGrid();
|
1488
|
objGridCell = me.buildMultiGridEditCell();
|
1489
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
1490
|
for (var i = 0; i < objGridCell.length; i++) {
|
1491
|
objGrid.push(objGridCell[i]);
|
1492
|
}
|
1493
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
1494
|
objGrid.push(objGridCellSum[i]);
|
1495
|
}
|
1496
|
} catch (e) {
|
1497
|
Ext.Msg.alert('Build Grid error', e);
|
1498
|
return;
|
1499
|
}
|
1500
|
console.log(objGrid);
|
1501
|
|
1502
|
// Shofwan 20240524 Untuk Push Data Detail
|
1503
|
var queryString = window.location.search;
|
1504
|
var cf = new minovaBlowfish();
|
1505
|
var urlEncrypt = cf.minovaDecryptUrl(queryString);
|
1506
|
|
1507
|
// Split the string by '&' to separate the parameters
|
1508
|
var params = urlEncrypt.split('&');
|
1509
|
|
1510
|
// Initialize variables to store the decoded data and the array
|
1511
|
var dataArray;
|
1512
|
var decodedData;
|
1513
|
var dataDetail;
|
1514
|
// Initialize variable to store the 'from' parameter value
|
1515
|
var fromValue;
|
1516
|
|
1517
|
// Try-catch block to handle potential errors
|
1518
|
try {
|
1519
|
// Loop through the parameters to find the 'data' and 'from' parameters
|
1520
|
params.forEach(function (param) {
|
1521
|
// Split each parameter by '=' to separate the name and value
|
1522
|
var parts = param.split('=');
|
1523
|
|
1524
|
// Check if the parameter is the 'data' parameter
|
1525
|
if (parts[0] === 'data') {
|
1526
|
// Decode the URL-encoded string
|
1527
|
decodedData = decodeURIComponent(parts[1]);
|
1528
|
|
1529
|
// Parse the JSON string to get the array
|
1530
|
dataArray = JSON.parse(decodedData);
|
1531
|
}
|
1532
|
|
1533
|
// Check if the parameter is the 'from' parameter
|
1534
|
if (parts[0] === 'from') {
|
1535
|
// Get the value of the 'from' parameter
|
1536
|
fromValue = parts[1];
|
1537
|
}
|
1538
|
});
|
1539
|
|
1540
|
// Check if fromValue is 'STOCKADJUSTMENT'
|
1541
|
if (fromValue === 'STOCKADJUSTMENT') {
|
1542
|
var storeItems = Ext.StoreManager.lookup('storePTRMATERIALITEM').data.items;
|
1543
|
var objGrid_ = [];
|
1544
|
storeItems.forEach(function(item) {
|
1545
|
var data = item.data; // Extract the data from the item
|
1546
|
|
1547
|
// Create an object to hold the transformed data
|
1548
|
var transformedData = {
|
1549
|
PTRMATERIALITEM: {
|
1550
|
PriceAmount: "0.00",
|
1551
|
Discount: 0,
|
1552
|
FlagCrud: "I"
|
1553
|
}
|
1554
|
};
|
1555
|
|
1556
|
// Get Specify Data
|
1557
|
var fieldsToInclude = [
|
1558
|
"DocNo",
|
1559
|
"DocItemID",
|
1560
|
"ItemType",
|
1561
|
"MaterialID",
|
1562
|
"StockStatus",
|
1563
|
"Quantity",
|
1564
|
"ItemFlow",
|
1565
|
"UnitMeasurement",
|
1566
|
"QtyReal",
|
1567
|
"QtyAdjust",
|
1568
|
"Notes",
|
1569
|
"id",
|
1570
|
"MaterialType",
|
1571
|
"NetPrice",
|
1572
|
"PriceAmount",
|
1573
|
"Discount",
|
1574
|
"FlagCrud"
|
1575
|
];
|
1576
|
|
1577
|
// Copy all properties from data to PTRMATERIALITEM
|
1578
|
fieldsToInclude.forEach(function(key) {
|
1579
|
if (data.hasOwnProperty(key)) {
|
1580
|
transformedData.PTRMATERIALITEM[key] = data[key];
|
1581
|
}
|
1582
|
});
|
1583
|
// Add the transformed data to the objGrid_ array
|
1584
|
objGrid_.push(transformedData);
|
1585
|
dataDetail = Ext.encode(objGrid_);
|
1586
|
});
|
1587
|
}
|
1588
|
else
|
1589
|
{
|
1590
|
dataDetail = Ext.encode(objGrid);
|
1591
|
}
|
1592
|
} catch (error) {
|
1593
|
|
1594
|
}
|
1595
|
|
1596
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
1597
|
var GridData = PanelData.query('docgridcelleditsum');
|
1598
|
var GridLength = GridData.length;
|
1599
|
var glaccount = '';
|
1600
|
var glaccount_ = '';
|
1601
|
|
1602
|
if (me.transType == 'FIN') { //// add by Tri nwh 20211201
|
1603
|
for (var i = 0; i < GridLength; i++) {
|
1604
|
glaccount_ = '';
|
1605
|
var records = [];
|
1606
|
var grd = GridData[i].query('grid')[0];
|
1607
|
|
1608
|
var recC = grd.store.getNewRecords();
|
1609
|
Ext.each(recC, function (rec) {
|
1610
|
glaccount = rec.data.GLAccountID.toString();
|
1611
|
//glaccount = glaccount + ',' + rec.data.GLAccountID.toString();
|
1612
|
});
|
1613
|
var recU = grd.store.getUpdatedRecords();
|
1614
|
Ext.each(recU, function (rec) {
|
1615
|
glaccount = rec.data.GLAccountID.toString();
|
1616
|
//glaccount = glaccount + ',' + rec.data.GLAccountID.toString();
|
1617
|
});
|
1618
|
|
1619
|
/*if(glaccount == '')
|
1620
|
{
|
1621
|
MinovaMessage("", "FILO15", "", "E");
|
1622
|
//alert('nwh');
|
1623
|
panelHead.unmask();
|
1624
|
return;
|
1625
|
}*/ ////comment krn tidak bisa rubah status 20210830 by Tri
|
1626
|
|
1627
|
Ext.Ajax.request({
|
1628
|
async : false,
|
1629
|
method : 'POST',
|
1630
|
url : '/UserControl/GetStore',
|
1631
|
params : {
|
1632
|
tableName : 'PCMFILOCOAGL',
|
1633
|
param : 'GlAccount[equal]' + glaccount
|
1634
|
},
|
1635
|
success : function (response) {
|
1636
|
var results = Ext.decode(response.responseText);
|
1637
|
if( results.totalRecords != '0')
|
1638
|
{ glaccount_ = results.data[0].GlAccount; }
|
1639
|
}
|
1640
|
});
|
1641
|
|
1642
|
|
1643
|
if(glaccount_ == '')
|
1644
|
{
|
1645
|
MinovaMessage("", "FILO14", "", "E");
|
1646
|
panelHead.unmask();
|
1647
|
return;
|
1648
|
};
|
1649
|
}
|
1650
|
}
|
1651
|
|
1652
|
var params = {
|
1653
|
serviceName: 'Logistic.asmx',
|
1654
|
methodName: 'SaveTableDoc',
|
1655
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
1656
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + me.action + '&token=' + token
|
1657
|
};
|
1658
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
1659
|
console.log('Post!');
|
1660
|
var result = Ext.decode(xhr.responseText);
|
1661
|
if (result.success) {
|
1662
|
var idNo = result.data;
|
1663
|
formHead.findField("DocNo").setValue(idNo);
|
1664
|
if (me.docType == "SORD") //// add by tri nwh 20241107
|
1665
|
{
|
1666
|
MinovaUtil.ExecuteParamQuery({
|
1667
|
ID: "PDSFILOSALESHEADERAPPROVE",
|
1668
|
DocNo: idNo,
|
1669
|
UserName: MinovaUtil.GetUserName()
|
1670
|
}, function (s) {}, function (f) {});
|
1671
|
}
|
1672
|
/* add by mae 20200702 */
|
1673
|
/* #region update item status */
|
1674
|
else if (me.transType == "FIN" && me.docType == "IP" && formHead.getValues().DocTypeRef == "AR") {
|
1675
|
Ext.Ajax.request({
|
1676
|
async: false,
|
1677
|
method: 'POST',
|
1678
|
url: '/Devt/SaveTable',
|
1679
|
params: {
|
1680
|
tableName: 'PTRFINANCEITEM',
|
1681
|
data: Ext.encode({
|
1682
|
DocNo: formHead.getValues().DocIDRef,
|
1683
|
ItemStatus: '2'
|
1684
|
}),
|
1685
|
action: 1
|
1686
|
},
|
1687
|
waitMsg: 'Saving Data...',
|
1688
|
success: function (response) {
|
1689
|
var result = Ext.decode(response.responseText);
|
1690
|
if (result.success) {
|
1691
|
console.log('update item status');
|
1692
|
}
|
1693
|
},
|
1694
|
failure: function (response) {}
|
1695
|
});
|
1696
|
}
|
1697
|
/* #endregion update item status */
|
1698
|
MinovaMessage('Not Null', '000006', '', 'S');
|
1699
|
panelHead.unmask();
|
1700
|
me.loadDoc(idNo, tbl);
|
1701
|
} else {
|
1702
|
MinovaMessage('', '000005', result.message.text, 'E');
|
1703
|
panelHead.unmask();
|
1704
|
}
|
1705
|
});
|
1706
|
}
|
1707
|
|
1708
|
// ENGINE UNTUK KIRIM EMAIL
|
1709
|
var storeApprover = Ext.data.StoreManager.lookup('storePTRSALESDOCAPPROVER');
|
1710
|
|
1711
|
if (storeApprover.data.items && storeApprover.data.items.length > 0) {
|
1712
|
|
1713
|
var DocStatus = formHead.findField("DocStatus").getValue();
|
1714
|
|
1715
|
if ( DocStatus == '10' ){
|
1716
|
// Engine Kirim Email apabila status Dokumen Sudah Submit
|
1717
|
|
1718
|
// Loop through each item in storeApprover.data.items
|
1719
|
Ext.each(storeApprover.data.items, function(item) {
|
1720
|
|
1721
|
var statussend = '';
|
1722
|
var employeeid = item.data.ApproverID; // Get the ApproverID for each item
|
1723
|
var employeeNameCreator = ""; // Replace with actual employee name
|
1724
|
var docno = formHead.findField("DocNo").getValue(); // Example Sales Order number
|
1725
|
var docdate = formHead.findField("DocDate").getValue(); // Example Document Date
|
1726
|
// Extract year, month, and day from the docdate string
|
1727
|
var year = docdate.substring(0, 4);
|
1728
|
var month = docdate.substring(4, 6);
|
1729
|
var day = docdate.substring(6, 8);
|
1730
|
|
1731
|
// Create the formatted date in 'YYYY/MM/DD' format
|
1732
|
var formattedDate = year + '/' + month + '/' + day;
|
1733
|
var description = formHead.findField("Description").getValue(); // Example Document Date
|
1734
|
var customerID = formHead.findField("CustomerID").getValue(); // Example Customer Date
|
1735
|
var customerName = ""; // Replace with actual customer name
|
1736
|
var approverName = ""; // Replace with actual approver name
|
1737
|
var approverPosition = ""; // Replace with actual approver position
|
1738
|
var linkemail = window.location.href;
|
1739
|
|
1740
|
|
1741
|
// Get Customer Name from PMDCUS0001 table
|
1742
|
Ext.Ajax.request({
|
1743
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1744
|
method: 'POST',
|
1745
|
url: '/UserControl/GetStore',
|
1746
|
params: {
|
1747
|
tableName: 'PMDCUS0001',
|
1748
|
param: 'CustomerID[=]' + customerID
|
1749
|
},
|
1750
|
success: function(response) {
|
1751
|
var results = Ext.decode(response.responseText);
|
1752
|
var data_ = results.data;
|
1753
|
if (data_ && data_.length > 0) {
|
1754
|
customerName = data_[0].Description; // Get Customer Name
|
1755
|
} else {
|
1756
|
MinovaMessage('', "000004", "No customer found for CustomerID: " + customerID, "E");
|
1757
|
}
|
1758
|
},
|
1759
|
failure: function() {
|
1760
|
MinovaMessage('', "000004", "Failed to fetch customer details for CustomerID: " + customerID, "E");
|
1761
|
}
|
1762
|
});
|
1763
|
|
1764
|
// Get Approver's FullName from PHRPA0001
|
1765
|
Ext.Ajax.request({
|
1766
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1767
|
method: 'POST',
|
1768
|
url: '/UserControl/GetStore',
|
1769
|
params: {
|
1770
|
tableName: 'PHRPA0001',
|
1771
|
param: 'EmployeeID[=]' + employeeid + ',enddate[=]' + '99991231'
|
1772
|
},
|
1773
|
success: function(response) {
|
1774
|
var results = Ext.decode(response.responseText);
|
1775
|
var data_ = results.data;
|
1776
|
if (data_ && data_.length > 0) {
|
1777
|
approver = data_[0].FullName; // Get FullName of the approver
|
1778
|
} else {
|
1779
|
MinovaMessage('', "000004", "No approver found for EmployeeID: " + employeeid, "E");
|
1780
|
}
|
1781
|
},
|
1782
|
failure: function() {
|
1783
|
MinovaMessage('', "000004", "Failed to fetch approver name for EmployeeID: " + employeeid, "E");
|
1784
|
}
|
1785
|
});
|
1786
|
|
1787
|
// Get Position from PHRPA0002
|
1788
|
Ext.Ajax.request({
|
1789
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1790
|
method: 'POST',
|
1791
|
url: '/UserControl/GetStore',
|
1792
|
params: {
|
1793
|
tableName: 'PHRPA0002',
|
1794
|
param: 'EmployeeID[=]' + employeeid + ',enddate[=]' + '99991231'
|
1795
|
},
|
1796
|
success: function(response) {
|
1797
|
var results = Ext.decode(response.responseText);
|
1798
|
var data_ = results.data;
|
1799
|
if (data_ && data_.length > 0) {
|
1800
|
position = data_[0].Position; // Get Position from the data
|
1801
|
} else {
|
1802
|
MinovaMessage('', "000004", "No position found for EmployeeID: " + employeeid, "E");
|
1803
|
}
|
1804
|
},
|
1805
|
failure: function() {
|
1806
|
MinovaMessage('', "000004", "Failed to fetch position for EmployeeID: " + employeeid, "E");
|
1807
|
}
|
1808
|
});
|
1809
|
|
1810
|
// Get Position Description from PHROM0001 using the position obtained
|
1811
|
Ext.Ajax.request({
|
1812
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1813
|
method: 'POST',
|
1814
|
url: '/UserControl/GetStore',
|
1815
|
params: {
|
1816
|
tableName: 'PHROM0001',
|
1817
|
param: 'ObjectID[=]' + position + ',enddate[=]' + '99991231' + ',ObjectClass[=]' + 'P'
|
1818
|
},
|
1819
|
success: function(response) {
|
1820
|
var results = Ext.decode(response.responseText);
|
1821
|
var data_ = results.data;
|
1822
|
if (data_ && data_.length > 0) {
|
1823
|
positiondesc = data_[0].ObjectDescription; // Get Position Description
|
1824
|
} else {
|
1825
|
MinovaMessage('', "000004", "No position description found for position: " + position, "E");
|
1826
|
}
|
1827
|
},
|
1828
|
failure: function() {
|
1829
|
MinovaMessage('', "000004", "Failed to fetch position description for position: " + position, "E");
|
1830
|
}
|
1831
|
});
|
1832
|
|
1833
|
var mymailattachment = '';
|
1834
|
var userNameCreator = formHead.findField("CreateBy").getValue();
|
1835
|
var employeeIDCreator = '';
|
1836
|
var creatorFullName = '';
|
1837
|
|
1838
|
// Get EmployeeID of Creator
|
1839
|
Ext.Ajax.request({
|
1840
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1841
|
method: 'POST',
|
1842
|
url: '/UserControl/GetStore',
|
1843
|
params: {
|
1844
|
tableName: 'SUSERGENERALDATA',
|
1845
|
param: 'UserName[=]' + userNameCreator
|
1846
|
},
|
1847
|
success: function(response) {
|
1848
|
var results = Ext.decode(response.responseText);
|
1849
|
var data_ = results.data;
|
1850
|
if (data_ && data_.length > 0) {
|
1851
|
employeeIDCreator = data_[0].EmployeeID; // Get Position Description
|
1852
|
} else {
|
1853
|
MinovaMessage('', "000004", "No position description found for position: " + position, "E");
|
1854
|
}
|
1855
|
},
|
1856
|
failure: function() {
|
1857
|
MinovaMessage('', "000004", "Failed to fetch position description for position: " + position, "E");
|
1858
|
}
|
1859
|
});
|
1860
|
|
1861
|
// Get Creator ID FullName
|
1862
|
Ext.Ajax.request({
|
1863
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1864
|
method: 'POST',
|
1865
|
url: '/UserControl/GetStore',
|
1866
|
params: {
|
1867
|
tableName: 'PHRPA0001',
|
1868
|
param: 'EmployeeID[=]' + employeeIDCreator + ',enddate[=]' + '99991231'
|
1869
|
},
|
1870
|
success: function(response) {
|
1871
|
var results = Ext.decode(response.responseText);
|
1872
|
var data_ = results.data;
|
1873
|
if (data_ && data_.length > 0) {
|
1874
|
creatorFullName = data_[0].FullName; // Get FullName of the approver
|
1875
|
} else {
|
1876
|
MinovaMessage('', "000004", "No approver found for EmployeeID: " + employeeIDCreator, "E");
|
1877
|
}
|
1878
|
},
|
1879
|
failure: function() {
|
1880
|
MinovaMessage('', "000004", "Failed to fetch approver name for EmployeeID: " + employeeIDCreator, "E");
|
1881
|
}
|
1882
|
});
|
1883
|
|
1884
|
var approvedFlag = item.data.ApprovedFlag;
|
1885
|
if ( approvedFlag == '1' ){
|
1886
|
|
1887
|
// Now that we have approver, position, positiondesc, and customer name, construct the email body
|
1888
|
var mailbodyhtml = `
|
1889
|
<p>Dear ${approverName},</p>
|
1890
|
<p>Position: ${positiondesc}</p> <!-- Position Description inserted here -->
|
1891
|
<p>Saya mengirimkan email ini untuk meminta persetujuan Anda atas dokumen Sales Order dengan nomor ${docno}. Dokumen ini memerlukan persetujuan Anda untuk melanjutkan proses lebih lanjut.</p>
|
1892
|
<p><strong>Detail Dokumen:</strong></p>
|
1893
|
<ul>
|
1894
|
<li>Nomor Sales Order: ${docno}</li>
|
1895
|
<li>Document Date: ${formattedDate}</li>
|
1896
|
<li>Customer: ${customerName}</li>
|
1897
|
<li>Description: ${description}</li>
|
1898
|
</ul>
|
1899
|
<p>Anda dapat meninjau dokumen tersebut melalui tautan berikut: <a href="${linkemail}">${linkemail}</a></p>
|
1900
|
<p>Mohon tinjauan dan persetujuan Anda atas dokumen ini. Apabila terdapat informasi tambahan atau klarifikasi yang diperlukan, silakan hubungi saya.</p>
|
1901
|
<p>Terima kasih atas perhatian dan kerjasamanya.</p>
|
1902
|
<p>Best regards,<br>${creatorFullName}</p>
|
1903
|
`;
|
1904
|
|
1905
|
var mysubjecttxt = 'Permintaan Persetujuan: Sales Order No '+docno;
|
1906
|
var mymailattachment = '';
|
1907
|
|
1908
|
// Get email address using AJAX request with updated param format
|
1909
|
Ext.Ajax.request({
|
1910
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1911
|
method: 'POST',
|
1912
|
url: '/UserControl/GetStore',
|
1913
|
params: {
|
1914
|
tableName: 'PHRPA0012',
|
1915
|
param: 'CommunicationType[=]' + '0004' + ',EmployeeID[=]' + employeeid + ',enddate[=]' + '99991231'
|
1916
|
},
|
1917
|
success: function(response) {
|
1918
|
var results = Ext.decode(response.responseText);
|
1919
|
var data_ = results.data;
|
1920
|
if (data_ && data_.length > 0) {
|
1921
|
var email = data_[0].CommunicationDescription;
|
1922
|
var parameter = email + '§' + mysubjecttxt + '§' + btoa(mailbodyhtml) + '§' + mymailattachment;
|
1923
|
|
1924
|
// Send email if email and body are available
|
1925
|
if (email != "" && mailbodyhtml != "") {
|
1926
|
Ext.Ajax.request({
|
1927
|
async: false,
|
1928
|
method: 'POST',
|
1929
|
url: '/UserControl/GetStore',
|
1930
|
params: {
|
1931
|
tableName: 'PdsSendMassMail',
|
1932
|
param: parameter
|
1933
|
},
|
1934
|
success: function(response) {
|
1935
|
var results = Ext.decode(response.responseText);
|
1936
|
var data_ = results.data;
|
1937
|
if (data_ != null && data_.length > 0) {
|
1938
|
statussend = 'sukses';
|
1939
|
}
|
1940
|
}
|
1941
|
});
|
1942
|
if (statussend == "sukses") {
|
1943
|
MinovaMessage('', "000006", "Send Mail Success", "S");
|
1944
|
} else {
|
1945
|
MinovaMessage('', "000004", "Send Mail Failure", "E");
|
1946
|
}
|
1947
|
} else {
|
1948
|
MinovaMessage('', "000004", "Mail addr or Mail Message cannot be empty", "E");
|
1949
|
}
|
1950
|
} else {
|
1951
|
MinovaMessage('', "000004", "No email found for EmployeeID: " + employeeid, "E");
|
1952
|
}
|
1953
|
},
|
1954
|
failure: function() {
|
1955
|
MinovaMessage('', "000004", "Failed to fetch email for EmployeeID: " + employeeid, "E");
|
1956
|
}
|
1957
|
});
|
1958
|
}
|
1959
|
else if ( approvedFlag == '2' ){
|
1960
|
// ENGINE SEND MAIL Approve -shofwan 20241010
|
1961
|
|
1962
|
// Loop through each item in storeApprover.data.items
|
1963
|
Ext.each(storeApprover.data.items, function(item) {
|
1964
|
|
1965
|
// Now that we have approver, position, positiondesc, and customer name, construct the email body
|
1966
|
var mailbodyhtml = `
|
1967
|
<p>Dear ${creatorFullName},</p>
|
1968
|
<p>Melalui email ini, saya ingin menginformasikan bahwa dokumen Sales Order dengan nomor <strong>${docno}</strong> telah disetujui oleh <strong>${approverName}</strong>.</p>
|
1969
|
<p><strong>Detail Dokumen:</strong></p>
|
1970
|
<ul>
|
1971
|
<li>Nomor Sales Order: ${docno}</li>
|
1972
|
<li>Document Date: ${formattedDate}</li>
|
1973
|
<li>Customer: ${customerName}</li>
|
1974
|
<li>Description: ${description}</li>
|
1975
|
</ul>
|
1976
|
<p>Silakan melanjutkan langkah berikutnya yang diperlukan. Jika ada pertanyaan atau informasi tambahan, jangan ragu untuk menghubungi saya.</p>
|
1977
|
<p>Terima kasih atas kerjasamanya.</p>
|
1978
|
<p>Best regards,<br>${approver}<br>${positiondesc}</p>
|
1979
|
`;
|
1980
|
|
1981
|
var mysubjecttxt = 'Informasi Persetujuan ? Sales Order No. '+docno;
|
1982
|
|
1983
|
|
1984
|
// Get email address using AJAX request with updated param format
|
1985
|
Ext.Ajax.request({
|
1986
|
async: false, // Synchronize the request (blocking, not recommended in a real app)
|
1987
|
method: 'POST',
|
1988
|
url: '/UserControl/GetStore',
|
1989
|
params: {
|
1990
|
tableName: 'PHRPA0012',
|
1991
|
param: 'CommunicationType[=]' + '0004' + ',EmployeeID[=]' + employeeIDCreator + ',enddate[=]' + '99991231'
|
1992
|
},
|
1993
|
success: function(response) {
|
1994
|
var results = Ext.decode(response.responseText);
|
1995
|
var data_ = results.data;
|
1996
|
if (data_ && data_.length > 0) {
|
1997
|
var email = data_[0].CommunicationDescription;
|
1998
|
var parameter = email + '§' + mysubjecttxt + '§' + btoa(mailbodyhtml) + '§' + mymailattachment;
|
1999
|
|
2000
|
// Send email if email and body are available
|
2001
|
if (email != "" && mailbodyhtml != "") {
|
2002
|
Ext.Ajax.request({
|
2003
|
async: false,
|
2004
|
method: 'POST',
|
2005
|
url: '/UserControl/GetStore',
|
2006
|
params: {
|
2007
|
tableName: 'PdsSendMassMail',
|
2008
|
param: parameter
|
2009
|
},
|
2010
|
success: function(response) {
|
2011
|
var results = Ext.decode(response.responseText);
|
2012
|
var data_ = results.data;
|
2013
|
if (data_ != null && data_.length > 0) {
|
2014
|
statussend = 'sukses';
|
2015
|
}
|
2016
|
}
|
2017
|
});
|
2018
|
if (statussend == "sukses") {
|
2019
|
MinovaMessage('', "000006", "Send Mail Success", "S");
|
2020
|
} else {
|
2021
|
MinovaMessage('', "000004", "Send Mail Failure", "E");
|
2022
|
}
|
2023
|
} else {
|
2024
|
MinovaMessage('', "000004", "Mail addr or Mail Message cannot be empty", "E");
|
2025
|
}
|
2026
|
} else {
|
2027
|
MinovaMessage('', "000004", "No email found for EmployeeID: " + employeeid, "E");
|
2028
|
}
|
2029
|
},
|
2030
|
failure: function() {
|
2031
|
MinovaMessage('', "000004", "Failed to fetch email for EmployeeID: " + employeeid, "E");
|
2032
|
}
|
2033
|
});
|
2034
|
});
|
2035
|
}
|
2036
|
});
|
2037
|
|
2038
|
}
|
2039
|
}
|
2040
|
|
2041
|
|
2042
|
|
2043
|
|
2044
|
|
2045
|
},
|
2046
|
SaveCopyDoc: function () {
|
2047
|
var me = this
|
2048
|
if (me.transType == 'PUR') {
|
2049
|
var myStringArray_item = Ext.StoreManager.lookup('storePTRPURCHITEM').data.items;
|
2050
|
var myStringArray_Cost = Ext.StoreManager.lookup('storePTRPURCHOTHRCOST').data.items;
|
2051
|
var myStringArray_Payterm = Ext.StoreManager.lookup('storePTRPURCHPAYTERM').data.items;
|
2052
|
var myStringArray_Notes = Ext.StoreManager.lookup('storeCTRPURCHNOTES').data.items;
|
2053
|
|
2054
|
var arrayLength_item = myStringArray_item.length;
|
2055
|
for (var i = 0; i < arrayLength_item; i++) {
|
2056
|
myStringArray_item[i].data.DocNo='';
|
2057
|
myStringArray_item[i].phantom=true;
|
2058
|
}
|
2059
|
|
2060
|
var arrayLength_Cost = myStringArray_Cost.length;
|
2061
|
for (var i = 0; i < arrayLength_Cost; i++) {
|
2062
|
myStringArray_Cost[i].data.DocNo='';
|
2063
|
myStringArray_Cost[i].phantom=true;
|
2064
|
}
|
2065
|
|
2066
|
var arrayLength_Payterm = myStringArray_Payterm.length;
|
2067
|
for (var i = 0; i < arrayLength_Payterm; i++) {
|
2068
|
myStringArray_Payterm[i].data.DocNo='';
|
2069
|
myStringArray_Payterm[i].phantom=true;
|
2070
|
}
|
2071
|
|
2072
|
var arrayLength_Notes = myStringArray_Notes.length;
|
2073
|
for (var i = 0; i < arrayLength_Notes; i++) {
|
2074
|
myStringArray_Notes[i].data.DocNo='';
|
2075
|
myStringArray_Notes[i].phantom=true;
|
2076
|
}
|
2077
|
|
2078
|
}
|
2079
|
else if (me.transType == 'SLS') {
|
2080
|
var myStringArray_Item = Ext.StoreManager.lookup('storePTRSALESITEMS').data.items;
|
2081
|
var myStringArray_Allocation = Ext.StoreManager.lookup('storePTRALLOCATION').data.items;
|
2082
|
var myStringArray_Payterm = Ext.StoreManager.lookup('storePTRSALESPAYTERM').data.items;
|
2083
|
var myStringArray_OtherCost = Ext.StoreManager.lookup('storePTRSALESOTHRCOST').data.items;
|
2084
|
|
2085
|
var arrayLength_item = myStringArray_Item.length;
|
2086
|
for (var i = 0; i < arrayLength_item; i++) {
|
2087
|
myStringArray_Item[i].data.DocNo='';
|
2088
|
myStringArray_Item[i].phantom=true;
|
2089
|
}
|
2090
|
|
2091
|
var arrayLength_Allocation = myStringArray_Allocation.length;
|
2092
|
for (var i = 0; i < arrayLength_Allocation; i++) {
|
2093
|
myStringArray_Allocation[i].data.DocNo='';
|
2094
|
myStringArray_Allocation[i].phantom=true;
|
2095
|
}
|
2096
|
|
2097
|
var arrayLength_Payterm = myStringArray_Payterm.length;
|
2098
|
for (var i = 0; i < arrayLength_Payterm; i++) {
|
2099
|
myStringArray_Payterm[i].data.DocNo='';
|
2100
|
myStringArray_Payterm[i].phantom=true;
|
2101
|
}
|
2102
|
|
2103
|
var arrayLength_OtherCost = myStringArray_OtherCost.length;
|
2104
|
for (var i = 0; i < arrayLength_OtherCost; i++) {
|
2105
|
myStringArray_OtherCost[i].data.DocNo='';
|
2106
|
myStringArray_OtherCost[i].phantom=true;
|
2107
|
}
|
2108
|
}
|
2109
|
else if (me.transType == 'MTR') {
|
2110
|
var myStringArray_Material = Ext.StoreManager.lookup('storePTRMATERIALITEM').data.items;
|
2111
|
|
2112
|
var arrayLength_Material = myStringArray_Material.length;
|
2113
|
for (var i = 0; i < arrayLength_Material; i++) {
|
2114
|
myStringArray_Material[i].data.DocNo='';
|
2115
|
myStringArray_Material[i].phantom=true;
|
2116
|
}
|
2117
|
}
|
2118
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
2119
|
var tbl = panelHead.tableName;
|
2120
|
var formHead = panelHead.getForm();
|
2121
|
var docStatus = formHead.findField("DocStatus").getValue();
|
2122
|
var DocNo = formHead.findField("DocNo").getValue();
|
2123
|
|
2124
|
if (formHead.isValid()) {
|
2125
|
panelHead.mask("Loading...");
|
2126
|
var dataHeader = Ext.encode(formHead.getValues());
|
2127
|
var token = MinovaUtil.SESSIONS.Token;
|
2128
|
var objGrid;
|
2129
|
var objGridCell;
|
2130
|
var objGridCellSum;
|
2131
|
try {
|
2132
|
objGrid = me.buildMultiGrid();
|
2133
|
objGridCell = me.buildMultiGridEditCell();
|
2134
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
2135
|
console.log(objGrid); console.log(objGridCell); console.log(objGridCellSum);
|
2136
|
for (var i = 0; i < objGridCell.length; i++) {
|
2137
|
objGrid.push(objGridCell[i]);
|
2138
|
}
|
2139
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
2140
|
objGrid.push(objGridCellSum[i]);
|
2141
|
}
|
2142
|
} catch (e) {
|
2143
|
Ext.Msg.alert('Build Grid error', e);
|
2144
|
return;
|
2145
|
}
|
2146
|
var dataDetail = Ext.encode(objGrid);
|
2147
|
|
2148
|
var PanelData = Ext.ComponentQuery.query('[name=panelTab]')[0];
|
2149
|
var GridData = PanelData.query('docgridcelleditsum');
|
2150
|
var GridLength = GridData.length;
|
2151
|
var glaccount = '';
|
2152
|
var glaccount_ = '';
|
2153
|
|
2154
|
var params = {
|
2155
|
serviceName: 'Logistic.asmx',
|
2156
|
methodName: 'SaveTableDoc',
|
2157
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
2158
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + '0' + '&token=' + token
|
2159
|
};
|
2160
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
2161
|
console.log('Post!');
|
2162
|
var result = Ext.decode(xhr.responseText);
|
2163
|
if (result.success) {
|
2164
|
var idNo = result.data;
|
2165
|
formHead.findField("DocNo").setValue(idNo);
|
2166
|
/* add by mae 20200702 */
|
2167
|
/* #region update item status */
|
2168
|
if (me.transType == "FIN" && me.docType == "IP" && formHead.getValues().DocTypeRef == "AR") {
|
2169
|
Ext.Ajax.request({
|
2170
|
async: false,
|
2171
|
method: 'POST',
|
2172
|
url: '/Devt/SaveTable',
|
2173
|
params: {
|
2174
|
tableName: 'PTRFINANCEITEM',
|
2175
|
data: Ext.encode({
|
2176
|
DocNo: formHead.getValues().DocIDRef,
|
2177
|
ItemStatus: '2'
|
2178
|
}),
|
2179
|
action: 1
|
2180
|
},
|
2181
|
waitMsg: 'Saving Data...',
|
2182
|
success: function (response) {
|
2183
|
var result = Ext.decode(response.responseText);
|
2184
|
if (result.success) {
|
2185
|
console.log('update item status');
|
2186
|
}
|
2187
|
},
|
2188
|
failure: function (response) {}
|
2189
|
});
|
2190
|
}
|
2191
|
/* #endregion update item status */
|
2192
|
MinovaMessage('Not Null', '000006', '', 'S');
|
2193
|
panelHead.unmask();
|
2194
|
me.loadDoc(idNo, tbl);
|
2195
|
} else {
|
2196
|
MinovaMessage('', '000005', result.message.text, 'E');
|
2197
|
panelHead.unmask();
|
2198
|
}
|
2199
|
});
|
2200
|
}
|
2201
|
},
|
2202
|
deleteDoc: function () {},
|
2203
|
cancelDoc: function () {
|
2204
|
var me = this;
|
2205
|
me.action = '2';
|
2206
|
me.docNo = 'None';
|
2207
|
MinovaMessage('Message', '000011', '', 'C', function (respone) {
|
2208
|
if (respone == "yes") {
|
2209
|
me.afterrenderTab();
|
2210
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
2211
|
var tes = Ext.ComponentQuery.query('[name=searchResultInfo]')[0];
|
2212
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
2213
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
2214
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
2215
|
var formHead = panelHead.getForm();
|
2216
|
formHead.reset();
|
2217
|
var formHeadDisplay = panelDisplayHead.getForm();
|
2218
|
formHeadDisplay.reset();
|
2219
|
var btnCreate = Ext.ComponentQuery.query('[name=CreateDoc]')[0];
|
2220
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
2221
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
2222
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
2223
|
pnlSelect.setHidden(false);
|
2224
|
tes.setHidden(true);
|
2225
|
pnlTransaction.setHidden(true);
|
2226
|
panelHead.setHidden(false);
|
2227
|
panelDisplayHead.setHidden(true);
|
2228
|
|
2229
|
}
|
2230
|
});
|
2231
|
},
|
2232
|
createNew: function () {
|
2233
|
console.log('CreateNew!');
|
2234
|
var me = this;
|
2235
|
me.action = '0';
|
2236
|
me.docNo = 'None'
|
2237
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
2238
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
2239
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
2240
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
2241
|
var formHead = panelHead.getForm();
|
2242
|
formHead.reset();
|
2243
|
var formHeadDisplay = panelDisplayHead.getForm();
|
2244
|
formHeadDisplay.reset();
|
2245
|
var btnSaveCreate = Ext.ComponentQuery.query('[name=SaveCreateDoc]')[0];
|
2246
|
var btnCreate = Ext.ComponentQuery.query('[name=Create1Doc]')[0];
|
2247
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
2248
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
2249
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
2250
|
pnlSelect.setHidden(true);
|
2251
|
pnlTransaction.setHidden(false);
|
2252
|
panelHead.setHidden(false);
|
2253
|
panelDisplayHead.setHidden(true);
|
2254
|
btnSaveCreate.setDisabled(false);
|
2255
|
btnCreate.setDisabled(false);
|
2256
|
btnSave.setDisabled(false);
|
2257
|
formHead.findField("DocType").setValue(me.docType);
|
2258
|
me.afterrenderTab();
|
2259
|
},
|
2260
|
reloadDoc: function () {
|
2261
|
console.log('reloadDoc');
|
2262
|
var me = this;
|
2263
|
me.action = '2';
|
2264
|
me.docNo = 'None';
|
2265
|
//MinovaMessage('Message', '000011', '', 'C', function (respone) {
|
2266
|
//if (respone == "yes") {
|
2267
|
me.afterrenderTab();
|
2268
|
var pnlSelect = Ext.ComponentQuery.query('[name=DocSelectionJoil]')[0];
|
2269
|
var pnlTransaction = Ext.ComponentQuery.query('[name=DocTransaction]')[0];
|
2270
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
2271
|
var panelDisplayHead = Ext.ComponentQuery.query('[name=DisplayMainHeaderDocument]')[0];
|
2272
|
var formHead = panelHead.getForm();
|
2273
|
formHead.reset();
|
2274
|
var formHeadDisplay = panelDisplayHead.getForm();
|
2275
|
formHeadDisplay.reset();
|
2276
|
var btnCreate = Ext.ComponentQuery.query('[name=CreateDoc]')[0];
|
2277
|
var btnSave = Ext.ComponentQuery.query('[name=SaveDoc]')[0];
|
2278
|
var btnEdit = Ext.ComponentQuery.query('[name=EditDoc]')[0];
|
2279
|
var btnDelete = Ext.ComponentQuery.query('[name=DeleteDoc]')[0];
|
2280
|
pnlSelect.setHidden(false);
|
2281
|
pnlTransaction.setHidden(true);
|
2282
|
panelHead.setHidden(false);
|
2283
|
panelDisplayHead.setHidden(true);
|
2284
|
//}
|
2285
|
//});
|
2286
|
},
|
2287
|
backDoc: function () {
|
2288
|
var me = this;
|
2289
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
2290
|
var tbl = panelHead.tableName;
|
2291
|
var formHead = panelHead.getForm();
|
2292
|
|
2293
|
if (me.transType == 'FIN') {
|
2294
|
var pd = formHead.findField("PostingDate").getValue();
|
2295
|
var debet = Ext.ComponentQuery.query('displayfield[name=AmountDebet]')[0];
|
2296
|
var kredit = Ext.ComponentQuery.query('displayfield[name=AmountCredit]')[0];
|
2297
|
|
2298
|
if (pd == null || pd == "" || pd == undefined) {
|
2299
|
MinovaMessage("", "FILO05", "", "E");
|
2300
|
return;
|
2301
|
}
|
2302
|
if (debet !== undefined && kredit !== undefined) {
|
2303
|
if (debet.getValue() !== kredit.getValue()) {
|
2304
|
MinovaMessage("", "FILO10", "", "E");
|
2305
|
return;
|
2306
|
}
|
2307
|
}
|
2308
|
}
|
2309
|
if (formHead.isValid()) {
|
2310
|
panelHead.mask("Loading...");
|
2311
|
var dataHeader = Ext.encode(formHead.getValues());
|
2312
|
var token = MinovaUtil.SESSIONS.Token;
|
2313
|
var objGrid;
|
2314
|
var objGridCell;
|
2315
|
var objGridCellSum;
|
2316
|
try {
|
2317
|
objGrid = me.buildMultiGrid();
|
2318
|
objGridCell = me.buildMultiGridEditCell();
|
2319
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
2320
|
for (var i = 0; i < objGridCell.length; i++) {
|
2321
|
objGrid.push(objGridCell[i]);
|
2322
|
}
|
2323
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
2324
|
objGrid.push(objGridCellSum[i]);
|
2325
|
}
|
2326
|
} catch (e) {
|
2327
|
Ext.Msg.alert('Build Grid error', e);
|
2328
|
return;
|
2329
|
}
|
2330
|
var dataDetail = Ext.encode(objGrid);
|
2331
|
var params = {
|
2332
|
serviceName: 'Filo.asmx',
|
2333
|
methodName: 'SaveTableDoc',
|
2334
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
2335
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + me.action + '&token=' + token
|
2336
|
};
|
2337
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
2338
|
var result = Ext.decode(xhr.responseText);
|
2339
|
if (result.success) {
|
2340
|
var idNo = result.data;
|
2341
|
formHead.findField("DocNo").setValue(idNo);
|
2342
|
MinovaMessage('Not Null', '000006', '', 'S');
|
2343
|
panelHead.unmask();
|
2344
|
me.loadDoc(idNo, tbl);
|
2345
|
|
2346
|
me.reloadDoc();
|
2347
|
|
2348
|
} else {
|
2349
|
MinovaMessage('', '000005', result.message.text, 'E');
|
2350
|
panelHead.unmask();
|
2351
|
}
|
2352
|
});
|
2353
|
}
|
2354
|
console.log('backDoc');
|
2355
|
|
2356
|
},
|
2357
|
backCreateDoc: function () {
|
2358
|
console.log('backCreateDoc!');
|
2359
|
var me = this;
|
2360
|
var panelHead = Ext.ComponentQuery.query('[name=MainHeaderDocument]')[0];
|
2361
|
var tbl = panelHead.tableName;
|
2362
|
var formHead = panelHead.getForm();
|
2363
|
|
2364
|
if (me.transType == 'FIN') {
|
2365
|
var pd = formHead.findField("PostingDate").getValue();
|
2366
|
var debet = Ext.ComponentQuery.query('displayfield[name=AmountDebet]')[0];
|
2367
|
var kredit = Ext.ComponentQuery.query('displayfield[name=AmountCredit]')[0];
|
2368
|
|
2369
|
if (pd == null || pd == "" || pd == undefined) {
|
2370
|
MinovaMessage("", "FILO05", "", "E");
|
2371
|
return;
|
2372
|
}
|
2373
|
if (debet !== undefined && kredit !== undefined) {
|
2374
|
if (debet.getValue() !== kredit.getValue()) {
|
2375
|
MinovaMessage("", "FILO10", "", "E");
|
2376
|
return;
|
2377
|
}
|
2378
|
}
|
2379
|
}
|
2380
|
if (formHead.isValid()) {
|
2381
|
panelHead.mask("Loading...");
|
2382
|
var dataHeader = Ext.encode(formHead.getValues());
|
2383
|
var token = MinovaUtil.SESSIONS.Token;
|
2384
|
var objGrid;
|
2385
|
var objGridCell;
|
2386
|
var objGridCellSum;
|
2387
|
try {
|
2388
|
objGrid = me.buildMultiGrid();
|
2389
|
objGridCell = me.buildMultiGridEditCell();
|
2390
|
objGridCellSum = me.buildMultiGridEditCellSum();
|
2391
|
for (var i = 0; i < objGridCell.length; i++) {
|
2392
|
objGrid.push(objGridCell[i]);
|
2393
|
}
|
2394
|
for (var i = 0; i < objGridCellSum.length; i++) {
|
2395
|
objGrid.push(objGridCellSum[i]);
|
2396
|
}
|
2397
|
} catch (e) {
|
2398
|
Ext.Msg.alert('Build Grid error', e);
|
2399
|
return;
|
2400
|
}
|
2401
|
var dataDetail = Ext.encode(objGrid);
|
2402
|
var params = {
|
2403
|
serviceName: 'Filo.asmx',
|
2404
|
methodName: 'SaveTableDoc',
|
2405
|
parameter: 'transType=' + me.transType + '&docType=' + me.docType +
|
2406
|
'&header=' + dataHeader + '&detail=' + dataDetail + '&action=' + me.action + '&token=' + token
|
2407
|
};
|
2408
|
MinovaAjaxPost('/InvokeService/Invoke/', params, function (xhr) {
|
2409
|
var result = Ext.decode(xhr.responseText);
|
2410
|
if (result.success) {
|
2411
|
var idNo = result.data;
|
2412
|
formHead.findField("DocNo").setValue(idNo);
|
2413
|
/* add by mae 20200702 */
|
2414
|
/* #region update item status */
|
2415
|
if (me.transType == "FIN" && me.docType == "IP" && formHead.getValues().DocTypeRef == "AR") {
|
2416
|
Ext.Ajax.request({
|
2417
|
async: false,
|
2418
|
method: 'POST',
|
2419
|
url: '/Devt/SaveTable',
|
2420
|
params: {
|
2421
|
tableName: 'PTRFINANCEITEM',
|
2422
|
data: Ext.encode({
|
2423
|
DocNo: formHead.getValues().DocIDRef,
|
2424
|
ItemStatus: '2'
|
2425
|
}),
|
2426
|
action: 1
|
2427
|
},
|
2428
|
waitMsg: 'Saving Data...',
|
2429
|
success: function (response) {
|
2430
|
var result = Ext.decode(response.responseText);
|
2431
|
if (result.success) {
|
2432
|
console.log('update item status');
|
2433
|
}
|
2434
|
},
|
2435
|
failure: function (response) {}
|
2436
|
});
|
2437
|
}
|
2438
|
/* #endregion update item status */
|
2439
|
MinovaMessage('Not Null', '000006', '', 'S');
|
2440
|
panelHead.unmask();
|
2441
|
me.loadDoc(idNo, tbl);
|
2442
|
me.reloadDoc();
|
2443
|
me.createDoc();
|
2444
|
me.getLookupRefDoc();
|
2445
|
} else {
|
2446
|
MinovaMessage('', '000005', result.message.text, 'E');
|
2447
|
panelHead.unmask();
|
2448
|
}
|
2449
|
});
|
2450
|
}
|
2451
|
console.log('backDoc');
|
2452
|
|
2453
|
},
|
2454
|
|
2455
|
getLookupDoc: function (obj) {
|
2456
|
var popup = Ext.ComponentQuery.query('[name=LookupDocumentTrans]').length;
|
2457
|
|
2458
|
if (popup == 1) {
|
2459
|
Ext.ComponentQuery.query('[name=LookupDocumentTrans]')[0].targetField = "DocNo";
|
2460
|
Ext.ComponentQuery.query('[name=LookupDocumentTrans]')[0].show();
|
2461
|
} else {
|
2462
|
Ext.create('MinovaUtil.MinovaES.LookupDoc', {
|
2463
|
tableName: obj.tableName,
|
2464
|
targetField: "DocNo",
|
2465
|
fieldValue: "",
|
2466
|
LookupFunction: "",
|
2467
|
filterParam: "DocType[=]" + obj.docType,
|
2468
|
}).show()
|
2469
|
}
|
2470
|
},
|
2471
|
getLookupRefDoc: function () {
|
2472
|
|
2473
|
var me = this;
|
2474
|
var popup = Ext.ComponentQuery.query('[name=LookupDocRef]')[0];
|
2475
|
if (popup === undefined) {
|
2476
|
popup = Ext.create('MinovaUtil.MinovaES.LookupDocRef', {
|
2477
|
targetField: "DocNo",
|
2478
|
fieldValue: "",
|
2479
|
LookupFunction: "",
|
2480
|
filterParam: "DocType[=]" + me.docType,
|
2481
|
});
|
2482
|
}
|
2483
|
popup.show();
|
2484
|
var btnSelect = popup.query('button[name=select]')[0];
|
2485
|
if (btnSelect !== undefined)
|
2486
|
btnSelect.on('click', me.selectDocRef, me);
|
2487
|
},
|
2488
|
selectDocRef: function () {
|
2489
|
var me = this;
|
2490
|
var popup = Ext.ComponentQuery.query('[name=LookupDocRef]')[0];
|
2491
|
var grid = Ext.ComponentQuery.query('[name=gridlookupdocref]')[0];
|
2492
|
if (grid !== undefined) {
|
2493
|
var selection = grid.getView().getSelectionModel();
|
2494
|
var dt = selection.getSelection();
|
2495
|
if (dt.length > 0) {
|
2496
|
var intdocref = [];
|
2497
|
var refheader = [];
|
2498
|
var refitems = [];
|
2499
|
for (var i = 0; i < dt.length; i++) {
|
2500
|
var d = dt[i];
|
2501
|
var trtype = d.data.TransType;
|
2502
|
var dctype = d.data.DocType;
|
2503
|
var trtyperef = d.data.TransTypeRef;
|
2504
|
var dctyperef = d.data.DocTypeRef;
|
2505
|
var dcno = d.data.DocNo;
|
2506
|
var company = d.data.CompanyID;
|
2507
|
var bu = d.data.BusinessUnit;
|
2508
|
var tblItem = "";
|
2509
|
var params = {
|
2510
|
serviceName: 'Logistic.asmx',
|
2511
|
methodName: 'GetReferenceDocNew',
|
2512
|
parameter: 'transType=' + trtype + '&docType=' + dctype +
|
2513
|
'&transTypeRef=' + trtyperef + '&docTypeRef=' + dctyperef + '&docNo=' + dcno + '&tableItem=' + tblItem
|
2514
|
};
|
2515
|
MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
|
2516
|
var result = Ext.decode(xhr.responseText);
|
2517
|
var dtref = Ext.decode(result.data);
|
2518
|
refheader.push(dtref.Header);
|
2519
|
if (trtype == "FIN" && dctype == "IP" && trtyperef == "FIN" && dctyperef == "AR") {
|
2520
|
var a = dtref.Items[0];
|
2521
|
var b = JSON.parse(JSON.stringify(dtref.Items[0]));
|
2522
|
a.GLAccountID = '';
|
2523
|
a.ItemStatus = '2';
|
2524
|
b.AmountCredit = b.AmountDebet;
|
2525
|
b.AmountCreditCompCurr = b.AmountDebetCompCurr;
|
2526
|
b.AmountDebet = '0';
|
2527
|
b.AmountDebetCompCurr = '0';
|
2528
|
b.ItemStatus = '2';
|
2529
|
var c = [a, b];
|
2530
|
refitems.push(c);
|
2531
|
}
|
2532
|
/*else if (dctype == "SORD")
|
2533
|
{ console.log('push item status sales 0');
|
2534
|
var a = dtref.Items[0];
|
2535
|
var b = JSON.parse(JSON.stringify(dtref.Items[0]));
|
2536
|
a.ItemStatus = '0';
|
2537
|
b.ItemStatus = '0';
|
2538
|
var c = [a, b];
|
2539
|
refitems.push(c);
|
2540
|
}*/
|
2541
|
else {
|
2542
|
refitems.push(dtref.Items);
|
2543
|
}
|
2544
|
intdocref.push(dcno);
|
2545
|
});
|
2546
|
};
|
2547
|
if (trtype = 'FIN') {
|
2548
|
popup.hide();
|
2549
|
me.createDocRef(refheader, refitems, intdocref);
|
2550
|
} else {
|
2551
|
me.getLookupItemDetailRef(trtype, dctype, trtyperef, dctyperef, refheader, refitems, intdocref);
|
2552
|
}
|
2553
|
}
|
2554
|
}
|
2555
|
},
|
2556
|
getLookupItemDetailRef: function (trtype, dctype, trtyperef, dctyperef, refheader, refitems, intdocref) {
|
2557
|
var me = this;
|
2558
|
var refTable = '';
|
2559
|
Ext.Ajax.request({
|
2560
|
async: false,
|
2561
|
method: 'POST',
|
2562
|
url: '/UserControl/GetStore',
|
2563
|
params: {
|
2564
|
tableName: 'PCMBSTRANSLIST',
|
2565
|
param: 'ItemDetailRef[=]' + '1' + ',TransType[=]' + trtyperef
|
2566
|
},
|
2567
|
success: function (response) {
|
2568
|
var results = Ext.decode(response.responseText);
|
2569
|
data_ = results.data;
|
2570
|
refTable = data_[0].TableName;
|
2571
|
}
|
2572
|
});
|
2573
|
var popupitemref = Ext.ComponentQuery.query('[name=LookupItemDetailRef]')[0];
|
2574
|
if (popupitemref === undefined) {
|
2575
|
popupitemref = Ext.create('MinovaUtil.MinovaES.LookupItemDetailRef', {
|
2576
|
targetField: "DocNo",
|
2577
|
fieldValue: "",
|
2578
|
LookupFunction: "",
|
2579
|
tableName: refTable,
|
2580
|
});
|
2581
|
}
|
2582
|
popupitemref.show();
|
2583
|
var storeItemm = Ext.data.StoreManager.lookup('storeadvanceitem');
|
2584
|
var p = [];
|
2585
|
for (var i = 0; i < intdocref.length; i++) {
|
2586
|
p.push('value == ' + '\'' + intdocref[i] + '\'');
|
2587
|
}
|
2588
|
storeItemm.filter(function (r) {
|
2589
|
var value = r.get('DocNo');
|
2590
|
return (eval(p.join(' || ')));
|
2591
|
});
|
2592
|
|
2593
|
var btnSelect = popupitemref.query('button[name=select]')[0];
|
2594
|
if (btnSelect !== undefined)
|
2595
|
btnSelect.on('click', me.selectItemDetailRef, me);
|
2596
|
},
|
2597
|
selectItemDetailRef: function () {
|
2598
|
var me = this;
|
2599
|
var popup = Ext.ComponentQuery.query('[name=LookupDocRef]')[0];
|
2600
|
var popupitemref = Ext.ComponentQuery.query('[name=LookupItemDetailRef]')[0];
|
2601
|
var grid = Ext.ComponentQuery.query('[name=gridlookupdocref]')[0];
|
2602
|
var griditemref = Ext.ComponentQuery.query('[name=gridlookupitemdetailref]')[0];
|
2603
|
if (grid !== undefined) {
|
2604
|
if (griditemref !== undefined) {
|
2605
|
var selection = grid.getView().getSelectionModel();
|
2606
|
var selectionitemref = griditemref.getView().getSelectionModel();
|
2607
|
var dt = selection.getSelection();
|
2608
|
var dtitemref = selectionitemref.getSelection();
|
2609
|
if (dt.length > 0 && dtitemref.length > 0) {
|
2610
|
var intdocref = [];
|
2611
|
var refheader = [];
|
2612
|
var refitems = [];
|
2613
|
var refitems2 = [];
|
2614
|
var dtref;
|
2615
|
for (var i = 0; i < dt.length; i++) {
|
2616
|
var d = dt[i];
|
2617
|
var trtype = d.data.TransType;
|
2618
|
var dctype = d.data.DocType;
|
2619
|
var trtyperef = d.data.TransTypeRef;
|
2620
|
var dctyperef = d.data.DocTypeRef;
|
2621
|
var dcno = d.data.DocNo;
|
2622
|
var params = {
|
2623
|
serviceName: 'Logistic.asmx',
|
2624
|
methodName: 'GetReferenceDoc',
|
2625
|
parameter: 'transType=' + trtype + '&docType=' + dctype +
|
2626
|
'&transTypeRef=' + trtyperef + '&docTypeRef=' + dctyperef + '&docNo=' + dcno
|
2627
|
};
|
2628
|
MinovaAjaxPostSync('/InvokeService/Invoke/', params, function (xhr) {
|
2629
|
var result = Ext.decode(xhr.responseText);
|
2630
|
dtref = Ext.decode(result.data);
|
2631
|
refheader.push(dtref.Header);
|
2632
|
//refitems.push(dtref.Items);
|
2633
|
for (var j = 0; j < dtref.Items.length; j++) {
|
2634
|
refitems.push(dtref.Items[j]);
|
2635
|
}
|
2636
|
intdocref.push(dcno);
|
2637
|
});
|
2638
|
};
|
2639
|
for (var k = 0; k < refitems.length; k++) {
|
2640
|
for (var l = 0; l < dtitemref.length; l++) {
|
2641
|
if (refitems[k].hasOwnProperty('MaterialID') == true && dtitemref[l].data.hasOwnProperty('MaterialID') == true) {
|
2642
|
if (refitems[k].MaterialID == dtitemref[l].data.MaterialID /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
2643
|
refitems2.push(refitems[k]);
|
2644
|
}
|
2645
|
} else if (refitems[k].hasOwnProperty('Material') == true && dtitemref[l].data.hasOwnProperty('MaterialID') == true) {
|
2646
|
if (refitems[k].Material == dtitemref[l].data.MaterialID /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
2647
|
refitems2.push(refitems[k]);
|
2648
|
}
|
2649
|
} else if (refitems[k].hasOwnProperty('MaterialID') == true && dtitemref[l].data.hasOwnProperty('Material') == true) {
|
2650
|
if (refitems[k].MaterialID == dtitemref[l].data.Material /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
2651
|
refitems2.push(refitems[k]);
|
2652
|
}
|
2653
|
} else {
|
2654
|
if (refitems[k].Material == dtitemref[l].data.Material /*&& refitems[k].DocItemRef == dtitemref[l].data.DocItemID*/) {
|
2655
|
refitems2.push(refitems[k]);
|
2656
|
}
|
2657
|
}
|
2658
|
}
|
2659
|
}
|
2660
|
popup.hide();
|
2661
|
popupitemref.hide();
|
2662
|
me.createDocRef(refheader, refitems2, intdocref);
|
2663
|
}
|
2664
|
}
|
2665
|
}
|
2666
|
},
|
2667
|
specialKey: function (f, e) {
|
2668
|
var me = this;
|
2669
|
if (e.getKey() == e.ENTER) {
|
2670
|
getLookupDoc(f);
|
2671
|
}
|
2672
|
},
|
2673
|
displayResultInfo: function () {
|
2674
|
var me = this;
|
2675
|
var gridInfo = Ext.ComponentQuery.query('[name=searchResultInfo]')[0];
|
2676
|
var grid = Ext.ComponentQuery.query('[name=searchResult]')[0];
|
2677
|
var selection = grid.getView().getSelectionModel().getSelection()[0];
|
2678
|
var documentno = selection.data.DocNo;
|
2679
|
//me.action = '2';
|
2680
|
me.docNo = documentno;
|
2681
|
var store = Ext.StoreMgr.lookup("storeadvance2");
|
2682
|
|
2683
|
var menuid = MinovaUtil.GetMenuID();
|
2684
|
var module = undefined;
|
2685
|
var tableItem = undefined;
|
2686
|
Ext.Ajax.request({
|
2687
|
async: false,
|
2688
|
method: 'POST',
|
2689
|
url: '/UserControl/GetStore',
|
2690
|
params: {
|
2691
|
tableName: 'PCMEPMODULETYPE',
|
2692
|
param: 'MenuID[=]' + menuid
|
2693
|
},
|
2694
|
success: function (response) {
|
2695
|
var results = Ext.decode(response.responseText);
|
2696
|
if (results.data.length > 0) {
|
2697
|
module = results.data[0].ModuleItem;
|
2698
|
}
|
2699
|
}
|
2700
|
});
|
2701
|
Ext.Ajax.request({
|
2702
|
async: false,
|
2703
|
method: 'POST',
|
2704
|
url: '/UserControl/GetStore',
|
2705
|
params: {
|
2706
|
tableName: 'PCMBSTRANSLIST',
|
2707
|
param: "TransType[=]" + module + ",Sequence[=]1"
|
2708
|
},
|
2709
|
success: function (response) {
|
2710
|
var results = Ext.decode(response.responseText);
|
2711
|
if (results.data.length > 0) {
|
2712
|
tableItem = results.data[0].TableName;
|
2713
|
}
|
2714
|
}
|
2715
|
});
|
2716
|
store.proxy.url = '/UserControl/GetStore';
|
2717
|
store.proxy.extraParams = {
|
2718
|
tableName: tableItem,
|
2719
|
param: "DocNo" + '[=]' + me.docNo
|
2720
|
};
|
2721
|
store.removeAll();
|
2722
|
store.reload();
|
2723
|
gridInfo.setHidden(false);
|
2724
|
},
|
2725
|
});
|
2726
|
|
2727
|
//# sourceURL=https://remote.minovais.com:61124/app/controller/logistic/documentlogistic.js
|