upd
This commit is contained in:
@ -1067,6 +1067,48 @@ class ProcJustificationAdapter extends Adapter {
|
||||
}
|
||||
}
|
||||
|
||||
async queryUpdateProcJustificationBoq(req, callback) {
|
||||
var apires = this.getApiResultDefined();
|
||||
try {
|
||||
let nik = req.body.nik;
|
||||
let vendors = JSON.parse(req.body.vendors);
|
||||
|
||||
let boqList = [];
|
||||
vendors.forEach(function (vendor) {
|
||||
if (vendor.boq && vendor.boq.length > 0) {
|
||||
vendor.boq.forEach(function (boq) {
|
||||
boqList.push(boq);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (boqList.length === 0) {
|
||||
apires.success = true;
|
||||
apires.meta.message = "No BOQ to update";
|
||||
callback(null, apires);
|
||||
return;
|
||||
}
|
||||
|
||||
let pending = boqList.length;
|
||||
boqList.forEach(function (boq) {
|
||||
let qry = "update tbl_procjustificationvendorboq ";
|
||||
qry += "set items='" + boq.items + "',qty='" + boq.qty + "',unitprice='" + boq.unitprice + "',units='" + boq.units + "',total='" + boq.total + "',uby='" + nik + "',udt=now() ";
|
||||
qry += "where _idx='" + boq._idx + "'";
|
||||
db.query(qry, [], function (err) {
|
||||
if (--pending === 0) {
|
||||
apires.success = true;
|
||||
apires.meta.message = "BOQ Updated";
|
||||
callback(null, apires);
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
apires.meta.code = 500;
|
||||
apires.meta.message = err.toString();
|
||||
callback("error", apires);
|
||||
}
|
||||
}
|
||||
|
||||
async queryUpdateStatusProcJustification(req, callback) {
|
||||
try {
|
||||
var apires = this.getApiResultDefined();
|
||||
|
||||
@ -156,6 +156,21 @@ exports.procJustificationList = ( req, res ) => {
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateProcJustificationBoq = ( req, res ) => {
|
||||
try{
|
||||
procjustificationadapter.queryUpdateProcJustificationBoq(req, function(err, data) {
|
||||
let statusCode = data != null ? data.meta.code : 200;
|
||||
if(err) statusCode = 500;
|
||||
procjustificationadapter.sendResponse(statusCode, data, res);
|
||||
});
|
||||
}
|
||||
catch(err){
|
||||
apireshandler.meta.code = 502;
|
||||
apireshandler.meta.message = " [21] : ProcJustification controller, " + err.toString();
|
||||
procjustificationadapter.sendResponse(502, apireshandler, res);
|
||||
}
|
||||
}
|
||||
|
||||
exports.updateStatusProcJustification = ( req, res ) => {
|
||||
try{
|
||||
|
||||
|
||||
@ -15,5 +15,6 @@ router.get('/detailprocjustification',[jwtauth], procjustificationcontroller.det
|
||||
router.post('/procjustificationlist',[jwtauth], procjustificationcontroller.procJustificationList);
|
||||
router.post('/updatestatusprocjustification',[jwtauth], procjustificationcontroller.updateStatusProcJustification);
|
||||
router.post('/signprocjustification',[jwtauth], procjustificationcontroller.SignedProcJustification);
|
||||
router.post('/updateprocjustificationboq',[jwtauth], procjustificationcontroller.updateProcJustificationBoq);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user