Sudah autoload ya Posisi Stock nya
UPDATE
Table = SDATATABLEFIELD > TableName = PTRPURCHITEM > FieldName = Material
Update SelectFunction
var store = Ext.StoreMgr.lookup("storePTRPURCHITEM");
if (store != undefined) {
var idx = store.getCount() - 1;
var materialID = val.value;
Ext.Ajax.request({
async: false,
method: 'POST',
url: '/UserControl/GetStore',
params: {
tableName: 'PMDMAT0003',
param: 'MaterialID[=]' + materialID
},
success: function (response) {
var results = Ext.decode(response.responseText);
dtgrid = results.data;
}
});
var max;
for (var i = 0; i < dtgrid.length; i++) {
if (!max || parseInt(dtgrid[i]["SeqID"]) > parseInt(max["SeqID"]))
max = dtgrid[i];
}
if (max != undefined) {
store.getAt(idx).set('PriceAmount', max.PurchasePrice);
store.getAt(idx).set('Discount', max.Discount);
} else {
store.getAt(idx).set('PriceAmount', map);
store.getAt(idx).set('Discount', 0);
}
// Set Unit Transaction
var map;
var unitmasurement;
Ext.Ajax.request({
async: false,
method: 'POST',
url: '/UserControl/GetStore',
params: {
tableName: 'PMDMAT0001',
param: 'MaterialID[=]' + materialID
},
success: function (response) {
var results = Ext.decode(response.responseText);
dtgrid1 = results.data;
}
});
var unitM;
try {
unitM = dtgrid1[0].UnitMeasurement;
}
catch(err){
store.getAt(idx).set('UnitTransaction', '1');
}
store.getAt(idx).set('UnitTransaction', unitM);
// Set Supplier
Ext.Ajax.request({
async: false,
method: 'POST',
url: '/UserControl/GetStore',
params: {
tableName: 'PMDVEN0002',
param: 'MaterialID[=]' + materialID
},
success: function (response) {
var results2 = Ext.decode(response.responseText);
dtgrid2 = results2.data;
}
});
var supplier;
try {
supplier = dtgrid2[0].VendorID;
}
catch(err){
store.getAt(idx).set('Supplier', '');
}
store.getAt(idx).set('Supplier', supplier);
// Set Posisi Stock
Ext.Ajax.request({
async: false,
method: 'POST',
url: '/UserControl/GetStore',
params: {
tableName: 'PMDMAT0004',
param: 'MaterialID[=]' + materialID
},
success: function (response) {
var results3 = Ext.decode(response.responseText);
dtgrid3 = results3.data;
}
});
var posisiStock;
try {
posisiStock = dtgrid3[0].Qty;
}
catch(err){
store.getAt(idx).set('StockPosition', '');
}
store.getAt(idx).set('StockPosition', posisiStock);
}