292 lines
11 KiB
JavaScript
292 lines
11 KiB
JavaScript
function rowSIPOCallback(row, data) {
|
|
document.getElementById('to').innerText = data.supplierName;
|
|
document.getElementById('address').innerText = data.supplierAddress;
|
|
document.getElementById('loc-preparedBy').innerText = data.requestedBy;
|
|
document.getElementById('purchasedby').innerText = data.purchaseBy;
|
|
document.getElementById('department').innerText = data.department;
|
|
|
|
document.getElementById('poNo').innerText = data.poNo;
|
|
document.getElementById('poSIDRRemarks').innerText = data.poRemarks;
|
|
//console.log('data.delilverTo', data.deliverTo);
|
|
const deliverTo = document.getElementById('deliverTo');
|
|
if (deliverTo) {
|
|
deliverTo.innerText = data.deliverTo;
|
|
}
|
|
|
|
const prNumber = document.getElementById('pr-Number');
|
|
if (prNumber) {
|
|
prNumber.innerText = data.stringPRNo;
|
|
}
|
|
const poNumber = document.getElementById('poNumber');
|
|
if (poNumber) {
|
|
poNumber.innerText = data.poNo;
|
|
}
|
|
const terms = document.getElementById('terms');
|
|
if (terms) {
|
|
terms.innerText = data.terms;
|
|
}
|
|
$('#poNoHidden').val(data.poNo);
|
|
$('#totalAmountSIPO').text(data.itemCategoryName + numberWithCommas(data.totalAmount));
|
|
|
|
let formattedDate = formatDate(data.createdDate ?? data.currentDate);
|
|
let formattedDelDate = formatDate(data.deliveryDate);
|
|
|
|
document.getElementById('C-poDate').innerText = formattedDate;
|
|
document.getElementById('C-deliveryDate').innerText = formattedDelDate;
|
|
|
|
poData = data;
|
|
approvalSIPOSignature(data);
|
|
}
|
|
function rowApprovedSIPOCallback(row, data) {
|
|
document.getElementById('to').innerText = data.supplierName;
|
|
document.getElementById('address').innerText = data.supplierAddress;
|
|
document.getElementById('loc-preparedBy').innerText = data.requestedBy;
|
|
document.getElementById('purchasedby').innerText = data.purchaseBy;
|
|
|
|
document.getElementById('poSIDRRemarks').innerText = data.poRemarks;
|
|
document.getElementById('poNo').innerText = data.poNo;
|
|
|
|
const prNumber = document.getElementById('pr-Number');
|
|
if (prNumber) {
|
|
prNumber.innerText = data.stringPRNo;
|
|
}
|
|
const poNumber = document.getElementById('poNumber');
|
|
if (poNumber) {
|
|
poNumber.innerText = data.poNo;
|
|
}
|
|
const terms = document.getElementById('terms');
|
|
if (terms) {
|
|
terms.innerText = data.terms;
|
|
}
|
|
$('#poNoHidden').val(data.poNo);
|
|
$('#totalAmountSIPO').text(data.itemCategoryName + numberWithCommas(data.totalAmount));
|
|
|
|
let formattedDate = formatDate(data.createdDate ?? data.currentDate);
|
|
let formattedDelDate = formatDate(data.deliveryDate);
|
|
|
|
document.getElementById('C-poDate').innerText = formattedDate;
|
|
document.getElementById('C-deliveryDate').innerText = formattedDelDate;
|
|
|
|
poData = data;
|
|
approvalSIPOSignature(data);
|
|
}
|
|
function approvalSIPOSignature(data) {
|
|
if (poData.url) {
|
|
imagesUrl = poData.url;
|
|
}
|
|
if (poData.isApproved==undefined ) {
|
|
poData = data[0];
|
|
}
|
|
var imageUrl2 = poData.isPrepared ? imagesUrl + 'ivySignature.png' : imagesUrl + blankImage;
|
|
$('#purchasedbyImage').attr('src', imageUrl2);
|
|
|
|
var imageUrl3 = poData.isApproved ? imagesUrl + 'signature2.png' : imagesUrl + blankImage;
|
|
$('#poApproverSIPOImage').attr('src', imageUrl3);
|
|
}
|
|
function approvalSIPOSignResponse(data) {
|
|
|
|
// Check if the data contains a URL for images
|
|
if (data.url) {
|
|
imagesUrl = data.url;
|
|
}
|
|
// Loop through the items in the data array
|
|
if (Array.isArray(data)) {
|
|
data.forEach(item => {
|
|
|
|
document.getElementById('poSIDRRemarks').innerText = item.poRemarks;
|
|
// Process each item according to your needs
|
|
var imageUrl2 = item.isPrepared ? imagesUrl + 'ivySignature.png' : imagesUrl + blankImage;
|
|
$('#purchasedbyImage').attr('src', imageUrl2);
|
|
|
|
var imageUrl3 = item.isApproved ? imagesUrl + 'signature2.png' : imagesUrl + blankImage;
|
|
$('#poApproverSIPOImage').attr('src', imageUrl3);
|
|
});
|
|
} else {
|
|
console.error('Expected an array but got:', typeof data);
|
|
}
|
|
}
|
|
|
|
function approvedSIPOSignature(data) {
|
|
|
|
if (data[0].url) {
|
|
imagesUrl = data[0].url;
|
|
}
|
|
if (data[0].isApproved) {
|
|
let btnPrintSIPOApprove = document.getElementById('btnPrintSIPOApprove');
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
let btnSIPOApproveBoss = document.getElementById('btnSIPOApproveBoss');
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
}
|
|
|
|
document.getElementById('poSIDRRemarks').innerText = data[0].poRemarks;
|
|
|
|
var imageUrl2 = data[0].isPrepared ? imagesUrl + 'ivySignature.png' : imagesUrl + blankImage;
|
|
$('#purchasedbyImage').attr('src', imageUrl2);
|
|
|
|
var imageUrl3 = data[0].isApproved ? imagesUrl + 'signature2.png' : imagesUrl + blankImage;
|
|
$('#poApproverSIPOImage').attr('src', imageUrl3);
|
|
}
|
|
function rowImportPOCallback(row, data) {
|
|
|
|
document.getElementById('requestedBy').innerText = data.requestedBy;
|
|
document.getElementById('department').innerText = data.department;
|
|
document.getElementById('poNo').innerText = data.poNo;
|
|
document.getElementById('poNoHidden').value = data.poNo;
|
|
document.getElementById('portOfDischarge').innerText = data.portOfDischarge;
|
|
document.getElementById('paymentTerms').innerText = data.paymentTerms;
|
|
document.getElementById('shippingInstruction').innerText = data.shippingInstruction;
|
|
document.getElementById('profInvoiceNo').innerText = data.profInvoiceNo;
|
|
|
|
//document.getElementById('poNo-C-2ndPage').innerText = data.poNo;
|
|
//document.getElementById('supplier-C-2ndPage').innerText = data.supplierName;
|
|
|
|
document.getElementById('preparedBy').innerText = data.purchaseBy;
|
|
|
|
const incoTerms = document.getElementById('incoTerms');
|
|
if (incoTerms) {
|
|
incoTerms.innerText = data.incoTerms;
|
|
}
|
|
|
|
const shippingInstructionId = document.getElementById('shippingInstructionId');
|
|
if (shippingInstructionId) {
|
|
|
|
shippingInstructionId.value = data.shippingInstructionId;
|
|
}
|
|
|
|
const docRequirements = document.getElementById('docRequirements');
|
|
if (docRequirements) {
|
|
docRequirements.innerHTML = data.docRequirements;
|
|
}
|
|
shippingInstructsComponent(data.shippingInstructionId)
|
|
document.getElementById('incoTermsId').value = data.incoTermsId;
|
|
const paymentTermsId = document.getElementById('C-paymentTermsId');
|
|
if (paymentTermsId) {
|
|
paymentTermsId.value = data.paymentTermsId;
|
|
}
|
|
const poNumber = document.getElementById('poNumber');
|
|
if (poNumber) {
|
|
poNumber.innerText = data.poNo;
|
|
}
|
|
document.getElementById('supplierAddress').innerText = data.supplierAddress;
|
|
document.getElementById('supplierName').innerText = data.supplierName;
|
|
/* document.getElementById('contactPerson').innerText = data.contactPerson;*/
|
|
document.getElementById('contactNo').innerText = data.contactNo;
|
|
/* document.getElementById('suppEmailAddress').innerText = data.emailAddress;*/
|
|
document.getElementById('poRemarks').innerText = data.poRemarks;
|
|
document.getElementById('amountInWords').innerText = data.amountInWords;
|
|
$('#totalAmount').text(numberWithCommas(data.totalAmount));
|
|
|
|
let formattedPODate = formatDate(data.createdDate);
|
|
let formattedprofInvoiceDate = formatDate(data.profInvoiceDate);
|
|
let formattedDelDate = formatDate(data.deliveryDate);
|
|
|
|
document.getElementById('poDate').innerText = formattedPODate;
|
|
document.getElementById('deliveryDate').innerText = formattedDelDate;
|
|
document.getElementById('profInvoiceDate').innerText = formattedprofInvoiceDate;
|
|
poData = data;
|
|
approvalImportPOSignature(data);
|
|
}
|
|
function approvalImportPOSignature(data) {
|
|
if (poData.url) {
|
|
imagesUrl = poData.url;
|
|
}
|
|
if (poData.isApproved == undefined) {
|
|
poData = data[0];
|
|
}
|
|
var blankImage = 'blank_signature.png';
|
|
|
|
if (data.isApproved) {
|
|
let btnPrintSIPOApprove = document.getElementById('btnApproveImport');
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
}
|
|
|
|
var imageUrl1 = imagesUrl + blankImage;
|
|
$('#requestedByImage').attr('src', imageUrl1);
|
|
|
|
var imageUrl2 = imagesUrl + blankImage;
|
|
$('#preparedByImage').attr('src', imageUrl2);
|
|
|
|
var imageUrl3 = imagesUrl + blankImage;
|
|
$('#poApproverImportPOImage').attr('src', imageUrl3);
|
|
}
|
|
function updateESignature(POTypeId, EmailAddress) {
|
|
var loader = $('#overlay, #loader').css('z-index', 1080);
|
|
$.ajax($.extend({
|
|
url: '/POMgmt/GetForPOPerSuppEmail',
|
|
type: 'POST',
|
|
data: { EmailAddress, POTypeId },
|
|
success: function (data) {
|
|
if (data && data.data && data.data.length > 0) {
|
|
// approvalSIPOSignature(data.data);
|
|
approvalSIPOSignResponse(data.data);
|
|
} else {
|
|
console.log('Data is null or undefined');
|
|
}
|
|
},
|
|
error: errorHandler
|
|
}, beforeComplete(loader)));
|
|
}
|
|
function updateESignatureApproved(POTypeId, EmailAddress, PONo) {
|
|
loader = $('#overlay, #loader').css('z-index', 1080);
|
|
$.ajax($.extend({
|
|
url: '/POMgmt/GetApprovedPOPerEmail',
|
|
type: 'POST',
|
|
data: { EmailAddress, POTypeId, PONo },
|
|
success: function (response) {
|
|
if (response.success) {
|
|
approvedSIPOSignature(response.data);
|
|
} else {
|
|
console.log('Data is null or undefined');
|
|
}
|
|
},
|
|
error: errorHandler
|
|
}, beforeComplete(loader)));
|
|
}
|
|
function rowPOTypeCallback(row, data) {
|
|
|
|
var poTypeIdCell = $('td:eq(1)', row);
|
|
var POTypeId = poTypeIdCell.text();
|
|
var POTypeIdNumer = parseInt(POTypeId, 10);
|
|
|
|
if (!isNaN(POTypeIdNumer)) {
|
|
if (POTypeIdNumer === 1) {
|
|
poTypeIdCell.text('PO-SI').addClass('next-facilitator');
|
|
} else if (POTypeIdNumer === 2) {
|
|
poTypeIdCell.text('PO-DR').addClass('next-facilitator');
|
|
} else {
|
|
poTypeIdCell.text('Import-PO').addClass('next-facilitator');
|
|
}
|
|
}
|
|
}
|
|
function rowCPOCallback(row, data) {
|
|
|
|
var poTypeIdCell = $('td:eq(1)', row);
|
|
var POTypeId = poTypeIdCell.text();
|
|
var POTypeIdNumer = parseInt(POTypeId, 10);
|
|
|
|
var appsIdCell = $('td:eq(2)', row);
|
|
var appsId = appsIdCell.text();
|
|
var AppsIdNumer = parseInt(appsId, 10);
|
|
|
|
if (!isNaN(POTypeIdNumer)) {
|
|
if (POTypeIdNumer === 1) {
|
|
poTypeIdCell.text('PO-SI').addClass('next-facilitator');
|
|
} else if (POTypeIdNumer === 2) {
|
|
poTypeIdCell.text('PO-DR').addClass('next-facilitator');
|
|
} else {
|
|
poTypeIdCell.text('Import-PO').addClass('next-facilitator');
|
|
}
|
|
}
|
|
if (!isNaN(AppsIdNumer)) {
|
|
if (AppsIdNumer === 1) {
|
|
appsIdCell.text('New Purchasing(non-Ivent)').addClass('next-facilitator');
|
|
} else if (AppsIdNumer === 3) {
|
|
appsIdCell.text('OLD Puchasing (non-Ivent)').addClass('next-facilitator');
|
|
} else if (AppsIdNumer === 4) {
|
|
appsIdCell.text('OLD Puchasing (Inventory)').addClass('next-facilitator');
|
|
} else {
|
|
appsIdCell.text('New Purchasing(Iventory)').addClass('next-facilitator');
|
|
}
|
|
}
|
|
}
|