867 lines
28 KiB
JavaScript
867 lines
28 KiB
JavaScript
function otherReason(isOther) {
|
|
$('#otherReason').val('');
|
|
const otherReason = document.getElementById('otherReason')
|
|
otherReason.style.display = (isOther == "otherReason") ? "block" : "none";
|
|
}
|
|
function viewPONo(data) {
|
|
document.getElementById('c-supplierName').innerHTML = data.supplierName;
|
|
document.getElementById('c-supplierName1').innerHTML = data.supplierName;
|
|
|
|
$('#c-old-poNo').val(data.poNo);
|
|
$('#c-old-poNo2').val(data.poNo);
|
|
$('#potype-cancel').val(data.poTypeId);
|
|
|
|
viewPOItemList(data);
|
|
$('#viewPONo').modal('show');
|
|
$('#viewPONo').css('z-index', 1060);
|
|
}
|
|
function viewPOItemList(data) {
|
|
loader = $('#overlay, #loader').css('z-index', 1040);
|
|
tableElement = $('#updatePOItemTable');
|
|
tableDestroy(tableElement);
|
|
|
|
var POTypeId = data.poTypeId;
|
|
var SupplierId = data.supplierId;
|
|
var PONo = data.poNo;
|
|
var IsManual = data.isManual;
|
|
|
|
updatePOItemTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetCreatedPOPerSupId,
|
|
data: { SupplierId, POTypeId, PONo, IsManual },
|
|
}, beforeComplete(loader)),
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
initComplete: initCompleteCallback(),
|
|
columns: colPOItemDetail,
|
|
responsive: true,
|
|
error: errorHandler
|
|
});
|
|
}
|
|
|
|
//#PO PrepApproval Region
|
|
function viewPOTypeOption(data) {
|
|
poData = data;
|
|
$('#viewPOTypeOption').modal('show');
|
|
$('#viewPOTypeOption').css('z-index', 1050);
|
|
}
|
|
function viewPOFormSIPO(data, isModal, POTypeId) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPOFormSIPO').modal('show');
|
|
$('#viewPOFormSIPO').css('z-index', 1050);
|
|
//IS REFLECTED
|
|
const btnPrintSIPOApprove = document.getElementById('btnPrintSIPOApprove');
|
|
const btnSIPOApproveBoss = document.getElementById('btnSIPOApproveBoss');
|
|
|
|
if (IsArchived) {
|
|
btnPrintSIPOApprove.style.display = 'block';
|
|
}
|
|
if (UserRights == 'CnvssAppver') {
|
|
if (btnPrintSIPOApprove) {
|
|
btnPrintSIPOApprove.style.display = 'block';
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
}
|
|
} else {
|
|
btnSIPOApproveBoss.style.display = 'block';
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
}
|
|
tableElement = $('#ProductDataTable');
|
|
if (!tableElement.length) {
|
|
console.error("Table element not found");
|
|
return;
|
|
}
|
|
if (isModal == 1) {
|
|
EmailAddress = poData.emailAddress;
|
|
$('#supplierId').val(poData.supplierId);
|
|
PONo == poData.poNo;
|
|
} else {
|
|
EmailAddress = data.emailAddress;
|
|
$('#supplierId').val(data.supplierId);
|
|
PONo == data.poNo;
|
|
}
|
|
|
|
//dynamic PO Rerefence for SI/DR
|
|
poReference(POTypeId);
|
|
|
|
POTypeIdStored = POTypeId;
|
|
$('#poTypeId').val(POTypeId);
|
|
tableDestroy(tableElement);
|
|
try {
|
|
poDataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetForPOPerSuppEmail,
|
|
data: { EmailAddress, POTypeId, IsArchived, PONo },
|
|
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
searching: false,
|
|
lengthChange: false,
|
|
info: false,
|
|
pageLength: DynaPageLength,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colSIPOPerSuppEmail,
|
|
initComplete: function () {
|
|
console.log("DataTable initialization complete.");
|
|
},
|
|
rowCallback: rowSIPOCallback
|
|
});
|
|
} catch (error) {
|
|
console.error("DataTable initialization error:", error);
|
|
}
|
|
}
|
|
function createImportForm(poTypeId) {
|
|
$('#viewPOTypeOption').modal('hide');
|
|
POTypeIdStored = poTypeId;
|
|
clearTextModal();
|
|
populateImportPOElem();
|
|
//populateTerms();
|
|
$('#addNewImportPO').modal('show');
|
|
$('#addNewImportPO').css('z-index', 1060);
|
|
}
|
|
function addRemarks() {
|
|
document.getElementById("deliverTo").value = "Deliver To: 10 LLOYD AVE. FBIC TIKAY, MALOLOS, 3000 BULACAN";
|
|
|
|
$('#addRemarks').modal('show');
|
|
$('#addRemarks').css('z-index', 1065);
|
|
}
|
|
function viewPOFormImport(data, isModal) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPrintImportPO').modal('show');
|
|
$('#viewPrintImportPO').css('z-index', 1060);
|
|
|
|
document.getElementById('poNo-C-2ndPage').innerHTML = data.poNo;
|
|
document.getElementById('supplier-C-2ndPage').innerHTML = data.supplierName;
|
|
document.getElementById('countryOrigin-C-2ndPage').innerHTML = data.countryOrigin;
|
|
|
|
tableElement = $('#ImportPODataTable');
|
|
if (isModal == 1) {
|
|
EmailAddress = poData.emailAddress;
|
|
$('#supplierId').val(poData.supplierId);
|
|
} else {
|
|
EmailAddress = data.emailAddress;
|
|
$('#supplierId').val(data.supplierId);
|
|
}
|
|
tableDestroy(tableElement);
|
|
$('#poTypeId').val(3);
|
|
|
|
POTypeId = 3;
|
|
importPODataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetForPOPerSuppEmail,
|
|
data: { EmailAddress, POTypeId, IsArchived, PONo },
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
searching: false,
|
|
length: false,
|
|
responsive: true,
|
|
info: false,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
initComplete: initCompleteCallback(),
|
|
columns: colImportPOPerSuppEmail,
|
|
rowCallback: rowImportPOCallback,
|
|
error: errorHandler
|
|
});
|
|
}
|
|
function populateImportPOElem() {
|
|
var loader = $('#overlay, #loader').css('z-index', 1060);
|
|
EmailAddress = poData.emailAddress;
|
|
POTypeId = 3;
|
|
$('#poTypeId').val(3);
|
|
$.ajax($.extend({
|
|
url: endpoint.GetForPOPerSuppEmail,
|
|
type: 'POST',
|
|
data: { EmailAddress, POTypeId, IsArchived, PONo },
|
|
success: function (data) {
|
|
if (data && data.data && data.data.length > 0) {
|
|
var item = data.data[0];
|
|
$('#C-poNo').val(item.poNo);
|
|
$('#C-supplierName').val(item.supplierName);
|
|
$('#poNoHidden').val(item.poNo);
|
|
} else {
|
|
console.log('Data is null or undefined');
|
|
window.location.href = '/Home/Logout';
|
|
}
|
|
},
|
|
error: errorHandler
|
|
}, beforeComplete(loader)));
|
|
}
|
|
//#PO PrepApproval End Region
|
|
|
|
//#PO Approved Region
|
|
function viewApprovedPOFormSIPO(data, isApproved) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPOFormSIPO').modal('show');
|
|
$('#viewPOFormSIPO').css('z-index', 1050);
|
|
let btnPrintSIPOApprove = document.getElementById('btnPrintSIPOApprove');
|
|
|
|
let btnSIPOApproveBoss = document.getElementById('btnSIPOApproveBoss');
|
|
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
if (!UserRights == 'POApprover') {
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
} else {
|
|
if (isApproved == true) {
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
} else {
|
|
btnSIPOApproveBoss.style.display = 'block';
|
|
}
|
|
}
|
|
|
|
tableElement = $('#ProductDataTable');
|
|
if (!tableElement.length) {
|
|
console.error("Table element not found");
|
|
return;
|
|
}
|
|
var PONo = data.poNo;
|
|
POTypeId = data.poTypeId;
|
|
$('#poTypeId').val(data.poTypeId);
|
|
EmailAddress = data.emailAddress;
|
|
|
|
tableDestroy(tableElement);
|
|
if (IsArchived) {
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
}
|
|
//dynamic PO Rerefence for SI/DR
|
|
poReference(POTypeId);
|
|
try {
|
|
poDataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetApprovedPOPerEmail,
|
|
data: { EmailAddress, POTypeId, PONo, IsArchived },
|
|
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
searching: false,
|
|
lengthChange: false,
|
|
info: false,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colApprovedSIPOPerSuppEmail,
|
|
responsive: true,
|
|
initComplete: function () {
|
|
console.log("DataTable initialization complete.");
|
|
},
|
|
rowCallback: rowSIPOCallback
|
|
});
|
|
} catch (error) {
|
|
console.error("DataTable initialization error:", error);
|
|
}
|
|
}
|
|
function viewApprovedLocalPO(data, isModal, isApproved) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPOFormSIPO').modal('show');
|
|
$('#viewPOFormSIPO').css('z-index', 1060);
|
|
tableElement = $('#ProductDataTable');
|
|
let btnPrintSIPOApprove = document.getElementById('btnPrintSIPOApprove');
|
|
let btnSIPOApproveBoss = document.getElementById('btnSIPOApproveBoss');
|
|
if (isModal == 1) {
|
|
EmailAddress = poData.emailAddress;
|
|
PONo = poData.poNo;
|
|
POTypeId = poData.poTypeId;
|
|
} else {
|
|
EmailAddress = data.emailAddress;
|
|
PONo = data.poNo;
|
|
POTypeId = data.poTypeId;
|
|
}
|
|
if (!UserRights == 'POApprover') {
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
} else {
|
|
if (isApproved == true) {
|
|
btnPrintSIPOApprove.style.display = 'none';
|
|
btnSIPOApproveBoss.style.display = 'none';
|
|
} else {
|
|
btnApproveImport.style.display = 'block';
|
|
}
|
|
}
|
|
poReference(POTypeId);
|
|
tableDestroy(tableElement);
|
|
poDataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetApprovedPOPerEmail,
|
|
data: { EmailAddress, POTypeId, IsArchived, PONo },
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
searching: false,
|
|
length: false,
|
|
responsive: true,
|
|
info: false,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
initComplete: initCompleteCallback(),
|
|
columns: colApprovedLocalPerSuppEmail,
|
|
rowCallback: rowSIPOCallback,
|
|
error: errorHandler
|
|
});
|
|
}
|
|
function viewApprovedPOFormImport(data, isModal, isApproved) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPrintImportPO').modal('show');
|
|
$('#viewPrintImportPO').css('z-index', 1050);
|
|
|
|
let btnApproveImport = document.getElementById('btnApproveImport');
|
|
|
|
if (IsArchived) {
|
|
btnApproveImport.style.display = 'none';
|
|
}
|
|
|
|
if (!UserRights == 'POApprover') {
|
|
btnApproveImport.style.display = 'none';
|
|
} else {
|
|
if (isApproved == true) {
|
|
btnApproveImport.style.display = 'none';
|
|
} else {
|
|
btnApproveImport.style.display = 'block';
|
|
}
|
|
}
|
|
|
|
tableElement = $('#ImportPODataTable');
|
|
if (!tableElement.length) {
|
|
console.error("Table element not found");
|
|
return;
|
|
}
|
|
if (isModal == 1) {
|
|
EmailAddress = poData.emailAddress;
|
|
PONo = poData.poNo;
|
|
} else {
|
|
EmailAddress = data.emailAddress;
|
|
PONo = data.poNo;
|
|
}
|
|
if (!PONo) {
|
|
PONo = $('#C-poNo').val();
|
|
}
|
|
if (IsArchived) {
|
|
btnApproveImport.style.display = 'none';
|
|
btnPOToSupplierImport.style.display = 'none';
|
|
}
|
|
tableDestroy(tableElement);
|
|
POTypeId = 3;
|
|
$('#poTypeId').val(3);
|
|
try {
|
|
poDataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetApprovedPOPerEmail,
|
|
data: { EmailAddress, POTypeId, PONo, IsArchived },
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
searching: false,
|
|
lengthChange: false,
|
|
responsive: true,
|
|
info: false,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colApprovedImportPOPerSuppEmail,
|
|
initComplete: function () {
|
|
console.log("DataTable initialization complete.");
|
|
},
|
|
rowCallback: rowImportPOCallback
|
|
});
|
|
} catch (error) {
|
|
console.error("DataTable initialization error:", error);
|
|
}
|
|
}
|
|
|
|
//Custom PO
|
|
function viewManualSIDRPO(data) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPOFormSIPO').modal('show');
|
|
$('#viewPOFormSIPO').css('z-index', 1050);
|
|
document.getElementById('btnPrintSIPOApprove').style.display = 'none';
|
|
document.getElementById('btnSIPOApproveBoss').style.display = 'none';
|
|
const btnPrintSIPO = document.getElementById('btnPrintSIPO');
|
|
const btnPrintDRPO = document.getElementById('btnPrintDRPO');
|
|
|
|
POTypeId = data.poTypeId;
|
|
|
|
$('#poTypeId').val(data.poTypeId);
|
|
if (data.poTypeId = 1) {
|
|
btnPrintSIPO.style.display = 'block';
|
|
btnPrintDRPO.style.display = 'none';
|
|
} else {
|
|
btnPrintSIPO.style.display = 'none';
|
|
btnPrintDRPO.style.display = 'block';
|
|
}
|
|
tableElement = $('#ProductDataTable');
|
|
if (!tableElement.length) {
|
|
console.error("Table element not found");
|
|
return;
|
|
}
|
|
var PONo = data.poNo;
|
|
|
|
let SupplierId = data.supplierId;
|
|
let IsManual = data.isManual;
|
|
|
|
tableDestroy(tableElement);
|
|
//dynamic PO Rerefence for SI/DR
|
|
poReference(POTypeId);
|
|
try {
|
|
poDataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetCreatedPOPerSupId,
|
|
data: { SupplierId, POTypeId, PONo, IsArchived, IsManual },
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
paging: false,
|
|
searching: false,
|
|
lengthChange: false,
|
|
info: false,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colApprovedSIPOPerSuppEmail,
|
|
order: [[2, 'desc']],
|
|
responsive: true,
|
|
initComplete: function () {
|
|
console.log("DataTable initialization complete.");
|
|
},
|
|
rowCallback: rowSIPOCallback
|
|
});
|
|
} catch (error) {
|
|
console.error("DataTable initialization error:", error);
|
|
}
|
|
}
|
|
function viewManualImport(data) {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewPOTypeOption').modal('hide');
|
|
$('#viewPrintImportPO').modal('show');
|
|
$('#viewPrintImportPO').css('z-index', 1050);
|
|
|
|
document.getElementById('poNo-C-2ndPage').innerHTML = data.poNo;
|
|
document.getElementById('supplier-C-2ndPage').innerHTML = data.supplierName;
|
|
document.getElementById('countryOrigin-C-2ndPage').innerHTML = data.countryOrigin;
|
|
tableElement = $('#ImportPODataTable');
|
|
if (!tableElement.length) {
|
|
console.error("Table element not found");
|
|
return;
|
|
}
|
|
|
|
let btnApproveImport = document.getElementById('btnApproveImport');
|
|
|
|
btnApproveImport.style.display = 'none';
|
|
|
|
tableElement = $('#ImportPODataTable');
|
|
if (!tableElement.length) {
|
|
console.error("Table element not found");
|
|
return;
|
|
}
|
|
|
|
let SupplierId = data.supplierId;
|
|
let IsManual = data.isManual;
|
|
PONo = data.poNo;
|
|
|
|
tableDestroy(tableElement);
|
|
POTypeId = 3;
|
|
try {
|
|
poDataTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetCreatedPOPerSupId,
|
|
data: { SupplierId, POTypeId, PONo, IsArchived, IsManual },
|
|
}, beforeComplete(loader)),
|
|
dom: '<"top"i>rt<"bottom"f><"clear">',
|
|
paging: false,
|
|
searching: false,
|
|
lengthChange: false,
|
|
responsive: true,
|
|
info: false,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colApprovedImportPOPerSuppEmail,
|
|
order: [[1, 'desc']],
|
|
initComplete: function () {
|
|
console.log("DataTable initialization complete.");
|
|
},
|
|
rowCallback: rowImportPOCallback
|
|
});
|
|
} catch (error) {
|
|
console.error("DataTable initialization error:", error);
|
|
}
|
|
}
|
|
function viewCharges() {
|
|
loader = $('#overlay, #loader');
|
|
$('#addCharges').modal('show');
|
|
$('#addCharges').css('z-index', 1060);
|
|
|
|
tableName = '#SourceChargesTable';
|
|
tableDestroy($(tableName));
|
|
totalSelectedLabel = $('#totalSelected');
|
|
OtherChargesTable = $(tableName).DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetOtherCharges,
|
|
}, beforeComplete(loader)),
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colOtherCharges,
|
|
columnDefs: colDefOtherCharges,
|
|
responsive: true,
|
|
initComplete: initCompleteCallback,
|
|
});
|
|
$(tableName).on('change', '.selected-Item-checkbox', function () {
|
|
var row = $(this).closest('tr');
|
|
if ($(this).prop('checked')) {
|
|
row.addClass('selected-row');
|
|
} else {
|
|
row.removeClass('selected-row');
|
|
}
|
|
});
|
|
|
|
$('#selectAllCheckboxItem').on('change', function () {
|
|
var isChecked = $(this).prop('checked');
|
|
|
|
$('.selected-Item-checkbox').prop('checked', isChecked);
|
|
if (isChecked) {
|
|
$(table + ' tbody tr').addClass('selected-row');
|
|
} else {
|
|
$(table + ' tbody tr').removeClass('selected-row');
|
|
}
|
|
});
|
|
}
|
|
function viewDocRequired() {
|
|
loader = $('#overlay, #loader');
|
|
$('#docsRequired').modal('show');
|
|
$('#docsRequired').css('z-index', 1070);
|
|
tableElement = $('#DocRequiredTable');
|
|
tableDestroy(tableElement);
|
|
var totalSelectedLabel = $('#totalSelected');
|
|
docRequiredTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetDocRequired,
|
|
}, beforeComplete(loader)),
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colDocRequired,
|
|
pageLength: 5,
|
|
lengthMenu: [[5, 10, 25 -1], [5, 10, 25, "All"]],
|
|
initComplete: initCompleteCallback(),
|
|
});
|
|
$('#DocRequiredTable').on('change', '.select-DocRequired-checkbox', function () {
|
|
var row = $(this).closest('tr');
|
|
if ($(this).prop('checked')) {
|
|
row.addClass('selected-row');
|
|
} else {
|
|
row.removeClass('selected-row');
|
|
}
|
|
updateTotalSelectedCount();
|
|
});
|
|
|
|
$('#selectAllCheckbox').on('change', function () {
|
|
var isChecked = $(this).prop('checked');
|
|
$('.select-DocRequired-checkbox').prop('checked', isChecked);
|
|
|
|
if (isChecked) {
|
|
$('#DocRequiredTable tbody tr').addClass('selected-row');
|
|
} else {
|
|
$('#DocRequiredTable tbody tr').removeClass('selected-row');
|
|
}
|
|
|
|
updateTotalSelectedCount();
|
|
});
|
|
function updateTotalSelectedCount() {
|
|
var totalSelected = $('.select-DocRequired-checkbox:checked').length;
|
|
totalSelectedLabel.text(totalSelected);
|
|
}
|
|
}
|
|
function viewIncoterms() {
|
|
loader = $('#overlay, #loader');
|
|
$('#viewIncoterms').modal('show');
|
|
$('#viewIncoterms').css('z-index', 1070);
|
|
tableElement = $('#IncotermsTable');
|
|
tableDestroy(tableElement);
|
|
incotermsTable = tableElement.DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetIncoterms,
|
|
}, beforeComplete(loader)),
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
columns: colIncoterms,
|
|
pageLength: 5,
|
|
lengthMenu: [[5, 10, 25 - 1], [5, 10, 25, "All"]],
|
|
initComplete: initCompleteCallback(),
|
|
});
|
|
}
|
|
function viewIncotermsModal(isUpdate, data) {
|
|
$('#update-incotermsId').val(data.incotermsId);
|
|
const incotermsHeader = document.getElementById('incotermsHeader');
|
|
$('#update-incotermsName').val(data.incotermsName);
|
|
if (incotermsHeader) {
|
|
incotermsHeader.innerHTML = (isUpdate == 1)
|
|
? 'Update incoterms'
|
|
: 'Add new incoterms';
|
|
}
|
|
$('#viewIncotermsModal').modal('show');
|
|
$('#viewIncotermsModal').css('z-index', 1070);
|
|
}
|
|
function viewDocReqModal(isUpdate, data) {
|
|
$('#docRequirementId').val(data.docRequirementId);
|
|
const docsReqHeaderElement = document.getElementById('docsReqHeader');
|
|
$('#docName').val(data.docName);
|
|
if (docsReqHeaderElement) {
|
|
docsReqHeaderElement.innerHTML = (isUpdate == 1)
|
|
? 'Update document required'
|
|
: 'Add new document required';
|
|
}
|
|
|
|
$('#viewDocReqModal').modal('show');
|
|
$('#viewDocReqModal').css('z-index', 1070);
|
|
}
|
|
function viewOtherChargesModal(isUpdate, data) {
|
|
$('#otherChargesId').val(data.otherChargesId);
|
|
const headerElement = document.getElementById('otherChargesHeader');
|
|
$('#otherChargesName').val(data.otherChargesName);
|
|
if (headerElement) {
|
|
headerElement.innerHTML = (isUpdate == 1)
|
|
? 'Update other charges'
|
|
: 'Add new other charges';
|
|
}
|
|
|
|
$('#viewOtherChargesModal').modal('show');
|
|
$('#viewOtherChargesModal').css('z-index', 1070);
|
|
}
|
|
function toggleShippingInstructions() {
|
|
var container = $('#shippingInstructionsContainer');
|
|
var toggleButton = $('#toggleShippingInstructions');
|
|
|
|
container.toggle(); // Toggle visibility of the container
|
|
|
|
// Update the button text based on the visibility
|
|
if (container.is(':visible')) {
|
|
toggleButton.text('Hide Shipping Instructions');
|
|
} else {
|
|
toggleButton.text('Show Shipping Instructions');
|
|
}
|
|
}
|
|
function getPONoType(poType) {
|
|
let poTypeNo = '';
|
|
if (poType == 1)
|
|
poTypeNo = $('#si-poNo').val();
|
|
else if (poType == 2)
|
|
poTypeNo = $('#dr-poNo').val();
|
|
else
|
|
poTypeNo = $('#si-ImportPoNo').val();
|
|
|
|
$('#c-poNo').val(poTypeNo);
|
|
}
|
|
function getPOType(poType) {
|
|
var poNo = '';
|
|
|
|
if (poType == 1) {
|
|
poNo = $('#si-poNo').val();
|
|
calculateTotalPesoAmount(1);
|
|
calculateFinalPesoAmount(1);
|
|
} else if (poType == 2) {
|
|
poNo = $('#dr-poNo').val();
|
|
calculateTotalPesoAmount(2);
|
|
calculateFinalPesoAmount(2);
|
|
} else {
|
|
poNo = $('#si-ImportPoNo').val();
|
|
calculateTotalUsdAmount();
|
|
}
|
|
|
|
$('#remarks').val('');
|
|
$('#deliveryDate').val('');
|
|
$('#poNo').val(poNo);
|
|
$('#poNoFinal').val(poNo);
|
|
$('#poType').val(poType);
|
|
}
|
|
function poReferenceComponent(id) {
|
|
$.ajax({
|
|
url: endpoint.GetPOReference,
|
|
type: 'GET',
|
|
data: { id: id },
|
|
success: function (response) {
|
|
$('#DRSIContainer').html(response);
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error("Error loading component:", error);
|
|
}
|
|
});
|
|
}
|
|
function poInitializeDatatable(loader) {
|
|
totalSelectedLabel = $('#totalSelected');
|
|
forPOTable = $(dynamicTable).DataTable({
|
|
ajax: $.extend({
|
|
url: endpoint.GetForPO,
|
|
type: 'GET',
|
|
}, beforeComplete(loader)),
|
|
initComplete: function () {
|
|
cleanupColumnSearch(dynamicTable);
|
|
dynamicSearchEngine(dynamicTable);
|
|
},
|
|
columns: dynamicColumn,
|
|
responsive: true,
|
|
language: {
|
|
emptyTable: "No record available"
|
|
},
|
|
error: errorHandler
|
|
});
|
|
sellectTableRows(dynamicTable, '#selectAllCheckboxItem');
|
|
}
|
|
|
|
function dynamicSearchEngine(poTable) {
|
|
const tableConfigs = {
|
|
'#POApprovalTable': {
|
|
uniqueSearchClass: 'column-search-input-POApprovalTable',
|
|
supplierColumnIndex: 7,
|
|
searchableColumns: [
|
|
{
|
|
columnIndex: 3,
|
|
columnName: 'PR No',
|
|
placeholder: 'Enter PR Number...',
|
|
searchType: 'text',
|
|
searchMode: 'contains',
|
|
width: '150px'
|
|
},
|
|
{
|
|
columnIndex: 4,
|
|
columnName: 'Item No',
|
|
placeholder: 'Enter Item Number...',
|
|
searchType: 'text',
|
|
searchMode: 'contains',
|
|
width: '150px'
|
|
},
|
|
{
|
|
columnIndex: 5,
|
|
columnName: 'Item Name',
|
|
placeholder: 'Enter Item Name...',
|
|
searchType: 'text',
|
|
searchMode: 'contains',
|
|
width: '200px'
|
|
},
|
|
{
|
|
columnIndex: 7,
|
|
columnName: 'Supplier Name',
|
|
placeholder: 'Select Supplier...',
|
|
searchType: 'select',
|
|
searchMode: 'exact',
|
|
width: '150px'
|
|
}
|
|
]
|
|
},
|
|
'default': {
|
|
uniqueSearchClass: 'column-search-input-PrepPOTable',
|
|
supplierColumnIndex: 4,
|
|
searchableColumns: [
|
|
{
|
|
columnIndex: 0,
|
|
columnName: 'PR No',
|
|
placeholder: 'Enter PR Number...',
|
|
searchType: 'text',
|
|
searchMode: 'contains',
|
|
width: '150px'
|
|
},
|
|
{
|
|
columnIndex: 1,
|
|
columnName: 'Item No',
|
|
placeholder: 'Enter Item Number...',
|
|
searchType: 'text',
|
|
searchMode: 'contains',
|
|
width: '150px'
|
|
},
|
|
{
|
|
columnIndex: 2,
|
|
columnName: 'Item Name',
|
|
placeholder: 'Enter Item Name...',
|
|
searchType: 'text',
|
|
searchMode: 'contains',
|
|
width: '200px'
|
|
},
|
|
{
|
|
columnIndex: 4,
|
|
columnName: 'Supplier Name',
|
|
placeholder: 'Select Supplier...',
|
|
searchType: 'select',
|
|
searchMode: 'exact',
|
|
width: '150px'
|
|
}
|
|
]
|
|
}
|
|
};
|
|
|
|
const config = tableConfigs[poTable] || tableConfigs['default'];
|
|
|
|
initializeColumnSearch({
|
|
tableId: dynamicTable,
|
|
dataTable: forPOTable,
|
|
searchableColumns: config.searchableColumns
|
|
});
|
|
|
|
populateSelectOptions(
|
|
forPOTable,
|
|
config.supplierColumnIndex,
|
|
`.${config.uniqueSearchClass}[data-column="${config.supplierColumnIndex}"]`
|
|
);
|
|
|
|
restoreSearchFromURL(config.uniqueSearchClass, dynamicTable);
|
|
}
|
|
|
|
function poReference(POTypeId) {
|
|
const btnDRBtn = document.getElementById('btnPrintDRPO');
|
|
const btnSIBtn = document.getElementById('btnPrintSIPO');
|
|
if (POTypeId == 1) {
|
|
btnDRBtn.style.display = 'none';
|
|
if (IsPrint == false) {
|
|
btnSIBtn.style.display = 'none';
|
|
} else {
|
|
btnSIBtn.style.display = 'block';
|
|
}
|
|
DynaPageLength = 10;
|
|
poReferenceComponent(1);
|
|
} else {
|
|
btnSIBtn.style.display = 'none';
|
|
if (IsPrint == false) {
|
|
btnDRBtn.style.display = 'none';
|
|
} else {
|
|
btnDRBtn.style.display = 'block';
|
|
}
|
|
DynaPageLength = 8;
|
|
poReferenceComponent(2);
|
|
}
|
|
}
|
|
//#PO Approved End Region
|
|
// Function to toggle the visibility of btnSubmitPO
|
|
function toggleSubmitButton() {
|
|
var poDataTable = $('#PODataTable').DataTable();
|
|
var btnSubmitPO = document.getElementById('btnSubmitPO');
|
|
|
|
if (poDataTable.rows().count() > 0) {
|
|
btnSubmitPO.style.display = 'block';
|
|
} else {
|
|
btnSubmitPO.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
$('#PODataTable').on('draw.dt', function () {
|
|
toggleSubmitButton();
|
|
});
|
|
function refreshTable() {
|
|
if (typeof forPOTable !== 'undefined' && $.fn.dataTable.isDataTable(forPOTable.table().node())) {
|
|
forPOTable.ajax.reload();
|
|
}
|
|
}
|
|
function clearTextModal() {
|
|
document.getElementById("incoTermsId").value = "";
|
|
document.getElementById("shippingInstructionId").value = "";
|
|
document.getElementById("podId").value = "";
|
|
document.getElementById("paymentTermsId").value = "";
|
|
|
|
}
|