NonInventPurchasingSystem/CPRNIMS.WebApps/wwwroot/JsFunctions/PR/DetailedPRTrackingV7.js
2026-02-19 17:23:28 +08:00

106 lines
3.9 KiB
JavaScript

$(document).ready(function () {
loader = $('#overlay, #loader');
const reportTitle = `PR Tracking - as of ${getFormattedDateTime()}`;
prTable = $('#PRTable').DataTable({
ajax: $.extend({
url: '/PRMgmt/GetDetailedPRTracking',
type: 'GET',
}, beforeComplete(loader)),
language: {
emptyTable: "No record available"
},
columns: colOnPRtracking,
pageLength: 5,
lengthMenu: [[5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"]],
initComplete: function () {
initializeColumnSearch({
tableId: '#PRTable',
dataTable: prTable,
searchableColumns: [
{
columnIndex: 0,
columnName: 'Status',
placeholder: 'Select Status...',
searchType: 'select',
searchMode: 'exact',
width: '150px'
},
{
columnIndex: 1,
columnName: 'PR No',
placeholder: 'Enter PR Number...',
searchType: 'text',
searchMode: 'exact',
width: '150px'
},
{
columnIndex: 3,
columnName: 'Item No',
placeholder: 'Enter Item Number...',
searchType: 'text',
searchMode: 'exact',
width: '150px'
},
{
columnIndex: 6,
columnName: 'Item Name',
placeholder: 'Enter Item Name...',
searchType: 'text',
searchMode: 'contains',
width: '200px'
},
{
columnIndex: 13,
columnName: 'Department',
placeholder: 'Select Department...',
searchType: 'select',
searchMode: 'exact',
width: '150px'
}
]
});
const uniqueSearchClass = 'column-search-input-PRTable';
populateSelectOptions(prTable, 0, '.' + uniqueSearchClass + '[data-column="0"]');
populateSelectOptions(prTable, 13, '.' + uniqueSearchClass + '[data-column="13"]');
restoreSearchFromURL(uniqueSearchClass, '#PRTable');
},
dom: 'lBfrtip',
buttons: [
{
extend: 'csv',
title: reportTitle
},
{
extend: 'excel',
title: reportTitle
},
{
extend: 'pdf',
title: reportTitle
}
],
rowCallback: rowStatusColorCallback,
error: errorHandler,
columnDefs: [
{
targets: '_all',
render: function (data, type, row) {
if (type === 'display' && data && data.length > 50) {
return '<div style="white-space: normal; word-wrap: break-word;">' + data + '</div>';
}
return data;
}
}
]
});
});
function getFormattedDateTime() {
const now = new Date();
const yyyy = now.getFullYear();
const mm = String(now.getMonth() + 1).padStart(2, '0');
const dd = String(now.getDate()).padStart(2, '0');
const hh = String(now.getHours()).padStart(2, '0');
const min = String(now.getMinutes()).padStart(2, '0');
const ss = String(now.getSeconds()).padStart(2, '0');
return `${yyyy}-${mm}-${dd}_${hh}${min}${ss}`;
}