NonInventPurchasingSystem/CPRNIMS.WebApps/Views/Components/PRMgmt/PRTabbedTable/AllPR.cshtml

150 lines
6.0 KiB
Plaintext

<div class="tab-content-wrapper">
<div class="d-flex flex-wrap gap-2 mb-2">
<div class="search-wrapper" style="min-width:180px; flex:1;">
<div class="search-inner">
<span class="search-icon">
<svg width="14" height="14" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2.5">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.35-4.35" />
</svg>
</span>
<input id="srchPRNo" class="search-input"
placeholder="PR Number…" autocomplete="off" />
<span class="search-clear pr-search-clear"
data-target="#srchPRNo" title="Clear">✕</span>
</div>
</div>
<div class="search-wrapper" style="min-width:220px; flex:2;">
<div class="search-inner">
<span class="search-icon">
<svg width="14" height="14" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2.5">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.35-4.35" />
</svg>
</span>
<input id="srchItem" class="search-input"
placeholder="Item Name…" autocomplete="off" />
<span class="search-clear pr-search-clear"
data-target="#srchItem" title="Clear">✕</span>
</div>
</div>
<div class="search-wrapper" style="min-width:180px; flex:1;">
<div class="search-inner">
<span class="search-icon">
<svg width="14" height="14" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2.5">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.35-4.35" />
</svg>
</span>
<input id="srchDept" class="search-input"
placeholder="Department…" autocomplete="off" />
<span class="search-clear pr-search-clear"
data-target="#srchDept" title="Clear">✕</span>
</div>
</div>
</div>
<table id="PRTable" class="row-border" cellspacing="0" width="100%">
<thead >
<tr>
<th style="width:7%">PRNo</th>
<th style="width:7%">New PRNo</th>
<th style="width:50%">ItemName's</th>
<th style="width:9%">Req. Date</th>
<th style="width:14%">Req. By</th>
<th style="width:8%">DateNeeded</th>
<th style="width:7%">ChargeTo</th>
<th style="width:7%">Action</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script>
$(document).ready(function () {
loader = $('#overlay, #loader');
UserRights = document.getElementById("roleRights").value;
const reportTitle = `All Purchase Request - as of ${getFormattedDateTime()}`;
prTable = $('#PRTable').DataTable({
serverSide: true,
processing: true,
searching: false,
ajax: {
url: endpoint.GetAllPR,
type: 'GET',
data: function (d) {
return {
draw: d.draw,
searchPRNo: ($('#srchPRNo').val() || '').trim(),
searchItemName:($('#srchItem').val()|| '').trim(),
searchDept: ($('#srchDept').val() || '').trim(),
pageNumber: Math.floor(d.start / d.length) + 1,
pageSize: d.length
};
},
dataSrc: function (json) { return json.data; },
beforeSend: function () { loader.show(); },
complete: function () { loader.hide(); },
error: function (xhr, error) {
loader.hide();
console.error('Error loading data:', error);
if (typeof toastr !== 'undefined')
toastr.error('Failed to load data. Please try again.');
}
},
dom: 'lBfrtip',
buttons: [
{
text: '<i class="fas fa-file-csv"></i> CSV',
className: 'btn btn-sm btn-secondary',
action: function () { exportAllData('csv', endpoint.GetAllPR, loader, reportTitle, colOnPRTable); }
},
{
text: '<i class="fas fa-file-excel"></i> Excel',
className: 'btn btn-sm btn-success',
action: function () { exportAllData('excel', endpoint.GetAllPR, loader, reportTitle, colOnPRTable); }
},
{
text: '<i class="fas fa-file-pdf"></i> PDF',
className: 'btn btn-sm btn-danger',
action: function () { exportAllData('pdf', endpoint.GetAllPR, loader ,reportTitle, colOnPRTable); }
}
],
columns: colOnPRTable,
order: [[0, 'asc']],
rowCallback: rowStatusColorCallback,
language: {
emptyTable: "No record available",
processing: "Loading…"
},
error: errorHandler
});
function debounce(fn, delay) {
let t;
return function (...args) {
clearTimeout(t);
t = setTimeout(() => fn.apply(this, args), delay);
};
}
$('#srchPRNo, #srchItem, #srchDept')
.on('keyup', debounce(function () {
prTable.ajax.reload();
}, 400));
$('.pr-search-clear').on('click', function () {
const target = $(this).data('target');
$(target).val('');
prTable.ajax.reload();
});
});
</script>