NonInventPurchasingSystem/CPRNIMS.WebApps/wwwroot/JsFunctions/PO/BiddingV2.js
2026-01-20 07:44:30 +08:00

119 lines
4.6 KiB
JavaScript

function viewSuppBidding(data) {
var loader = $('#overlay, #loader').css('z-index', 1060);
var CanvassDetailId = data.canvassDetailId;
PRDetailsId = data.prDetailsId;
$('#PODetailId').val(PODetailId);
$.ajax($.extend({
url: endpoint.GetSupplierBidById,
type: 'POST',
data: { CanvassDetailId: CanvassDetailId },
success: function (data) {
if (data && data.data && data.data.length > 0) {
var item = data.data[0];
$('#itemName').val(item.itemName);
$('#itemSpecs').val(item.itemSpecs);
$('#itemNo').val(item.itemNo);
$('#itemQty').val(item.qty);
$('#supplierId').val(item.supplierId);
$('#canvassId').val(item.canvassId);
$('#canvassDetailId').val(item.canvassDetailId);
$('#itemQty').val(item.qty);
$('#unitPrice').val(item.price);
$('#terms').val(item.terms);
$('#supplierRemarks').val(item.remarks);
$('#manufacturer').val(item.manufacturer);
$('#currencyId').val(item.currencyId);
const commitmentDate = new Date(item.commitmentDate);
const formattedDate = commitmentDate.toISOString().split('T')[0];
$('#commitmentDate').val(formattedDate);
var itemPicturePath = item.itemAttachPath;
if (!itemPicturePath || itemPicturePath === 'N/A' || itemPicturePath === 'None') {
$('#itemPictureImage').attr('src', '/Content/Common/empty.jpg'); // Default image path
} else {
var imageUrl = item.urlImg + itemPicturePath; // Use HTTPS protocol
$('#itemPictureImage').attr('src', imageUrl);
}
$('#viewSupplierBid').modal('show');
$('#viewSupplierBid').css('z-index', 1060);
} else {
console.log('Data is null or undefined');
}
},
error: errorHandler
}, beforeComplete(loader)));
}
function viewBidForApproval(data) {
var loader = $('#overlay, #loader');
$('#viewSupplierByItem').modal('show');
$('#viewSupplierByItem').css('z-index', 1050);
var tableElement = $('#SuppBidddingDataTable');
tableDestroy(tableElement);
ItemNo = data.itemNo;
$('#canvassDetailId').val(data.canvassDetailId);
$('#canvassId').val(data.canvassId);
document.getElementById('label-itemNo').innerHTML = data.itemNo;
let PRDetailsId = data.prDetailsId;
CanvassId = data.canvassId;
PODetailId = (data.poDetailId);
bidDataTable = tableElement.DataTable({
ajax: $.extend({
url: endpoint.GetSupplierBidByItem,
data: { ItemNo, CanvassId, PRDetailsId, IsHistory },
}, beforeComplete(loader)),
language: {
emptyTable: "No record available"
},
initComplete: initCompleteCallback(),
columns: colSuppBidByItem,
rowCallback: function (row, data) {
if (data.suggestedSupplier === true) {
$(row).css('color', 'white');
$(row).css('background-color', 'green');
hasAnySuggestedSupplier = true;
}
document.getElementById('label-prNo').innerHTML = data.prNo;
document.getElementById('label-itemName').innerHTML = data.itemName;
document.getElementById('label-specification').innerHTML = data.itemSpecs;
document.getElementById('label-qty').innerHTML = data.qty;
},
drawCallback: function () {
let btnPostApproved = document.getElementById('btnPostApproved');
if (hasAnySuggestedSupplier) {
btnPostApproved.style.display = 'block';
} else {
btnPostApproved.style.display = 'none';
}
hasAnySuggestedSupplier = false;
},
error: errorHandler
});
}
$(document).ready(function () {
var loader = $('#overlay, #loader');
UserRights = document.getElementById("roleRights").value;
canvassTable = $('#BiddingApprovalTable').DataTable({
ajax: $.extend({
url: endpoint.GetForBiddingApproval,
type: 'GET',
},beforeComplete(loader)),
initComplete: initCompleteCallback(),
columns: colBiddingApproval,
order: [6, 'asc'],
responsive: true,
language: {
emptyTable: "No record available"
},
error: errorHandler
});
})
function refreshTable() {
canvassTable.ajax.reload();
bidDataTable.ajax.reload();
}