NonInventPurchasingSystem/CPRNIMS.WebApps/Views/Components/PRMgmt/PRTabbedTable/ApprovedPR.cshtml
2026-02-19 17:23:28 +08:00

175 lines
5.8 KiB
Plaintext

<div class="tab-content-wrapper">
<table id="ApprovedPRTable" class="row-border" cellspacing="0" width="100%">
<thead>
<tr>
<th>Status</th>
<th>Remaining Days</th>
<th>PRNo</th>
<th>ItemNo</th>
<th>ItemName</th>
<th>Qty</th>
<th>PR By</th>
<th>PR Date</th>
<th>Attested By</th>
<th>Attested Date</th>
<th>Approved By</th>
<th>Approved Date</th>
<th>Charge To</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script>
$(document).ready(function() {
const reportTitle = `Approved Purchase Request (No PO) - as of ${getFormattedDateTime()}`;
var approvedPRTable = $('#ApprovedPRTable').DataTable({
ajax: {
url: '/PRMgmt/GetApprovedPR',
type: 'GET',
beforeSend: function () {
loader.show();
},
complete: function () {
loader.hide();
},
error: function (xhr, error, thrown) {
loader.hide();
console.error('Error loading data:', error);
if (typeof toastr !== 'undefined') {
toastr.error('Failed to load data. Please try again.');
}
}
},
dom: 'lBfrtip',
buttons: [
{
extend: 'csv',
title: reportTitle
},
{
extend: 'excel',
title: reportTitle
},
{
extend: 'pdf',
title: reportTitle
}
],
initComplete: function () {
initializeColumnSearch({
tableId: '#ApprovedPRTable',
dataTable: approvedPRTable,
searchableColumns: [
{
columnIndex: 0,
columnName: 'Status',
placeholder: 'Select Status...',
searchType: 'select',
searchMode: 'exact',
width: '150px'
},
{
columnIndex: 2,
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: 4,
columnName: 'Item Name',
placeholder: 'Enter Item Name...',
searchType: 'text',
searchMode: 'contains',
width: '200px'
},
{
columnIndex: 12,
columnName: 'Department',
placeholder: 'Select Department...',
searchType: 'select',
searchMode: 'exact',
width: '150px'
}
]
});
const uniqueSearchClass = 'column-search-input-ApprovedPRTable';
populateSelectOptions(approvedPRTable, 0, '.' + uniqueSearchClass + '[data-column="0"]');
populateSelectOptions(approvedPRTable, 12, '.' + uniqueSearchClass + '[data-column="12"]');
restoreSearchFromURL(uniqueSearchClass, '#ApprovedPRTable');
},
columns: [
{ data: 'statusName' },
{ data: 'remainingDays', searchable: false },
{ data: 'prNo' },
{ data: 'itemNo' },
{ data: 'itemName' },
{
searchable: false,
data: 'qty',
render: function (data) {
return numberWithCommas(data);
}
},
{ data: 'createdBy' },
{
searchable: false,
data: 'createdDate',
render: function (data) {
return formatDateTime(data);
}
},
{ data: 'attestedBy' },
{
searchable: false,
data: 'attestedDate',
render: function (data) {
return formatStrDateTime(data);
}
},
{ data: 'approvedBy' },
{
searchable: false,
data: 'approvedDate',
render: function (data) {
return formatStrDateTime(data);
}
},
{ data: 'department' }
],
order: [[11, 'asc']],
responsive: true,
language: {
emptyTable: "No approved records available"
}
});
});
function formatStrDateTime(dateString) {
if (!dateString || dateString === "None") return "None";
let date = new Date(dateString);
let month = ('0' + (date.getMonth() + 1)).slice(-2);
let day = ('0' + date.getDate()).slice(-2);
let year = date.getFullYear();
let hours = ('0' + date.getHours()).slice(-2);
let minutes = ('0' + date.getMinutes()).slice(-2);
let seconds = ('0' + date.getSeconds()).slice(-2);
return `${month}/${day}/${year} ${hours}:${minutes}:${seconds}`;
}
</script>