This commit is contained in:
ArifHilmi 2025-02-25 16:24:34 +08:00
commit ea4666690e
6 changed files with 360 additions and 764 deletions

View File

@ -407,23 +407,23 @@
// Generate QR codes after rows are rendered
const api = this.api();
api.rows().every(function () {
const data = this.data(); // Row data
const containerId = `qr${data.id}`;
const data = this.data();
const containerId = `qr${data.id}`; //containerid is by increments from API
const container = $(`#${containerId}`);
container.empty();
container.append(`${data.item.itemId}`);
// console.log(container[0]);
if (container) {
// Generate QR code only if not already generated
if (container.length) {
new QRCode(container[0], {
text: data.qrString,
width: 100,
height: 100,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.M
correctLevel: QRCode.CorrectLevel.M,
});
}
// container.on('click', function() {

View File

@ -20,7 +20,7 @@
</div>
<div class="row card">
<div class="card-header">
<h2>Item Request</h2>
<h2>Complete Request</h2>
@* <button id="addRequestBtn" class="btn btn-success col-md-3 col-lg-3 m-1 col-12"><i class="fa fa-plus"></i>&nbsp;Add Request</button> *@
</div>
<div class="card-body">
@ -240,6 +240,31 @@
{
"title": "Document/Picture",
"data": "document",
"render": function (data, type, full, meta) {
if (!data) {
return "No Document";
}
// Check if the document is an image based on file extension
var isImage = /\.(jpeg|jpg|png|gif)$/i.test(data);
var isPdf = /\.pdf$/i.test(data);
if (isImage) {
return `<a href="${data}" target="_blank" data-lightbox="image-1">
<img src="${data}" alt="Image" class="img-thumbnail" style="width: 100px; height: 100px;" />
</a>`;
}
else if (isPdf) {
return `<a href="${data}" target="_blank">
<img src="https://upload.wikimedia.org/wikipedia/commons/8/87/PDF_file_icon.svg"
alt="PDF Document" class="img-thumbnail"
style="width: 50px; height: 50px;" />
<br>View PDF
</a>`;
} else {
return `<a href="${data}" target="_blank">Download File</a>`;
}
},
},
{
"title": "User Remark",
@ -331,6 +356,31 @@
{
"title": "Document/Picture",
"data": "document",
"render": function (data, type, full, meta) {
if (!data) {
return "No Document";
}
// Check if the document is an image based on file extension
var isImage = /\.(jpeg|jpg|png|gif)$/i.test(data);
var isPdf = /\.pdf$/i.test(data);
if (isImage) {
return `<a href="${data}" target="_blank" data-lightbox="image-1">
<img src="${data}" alt="Image" class="img-thumbnail" style="width: 100px; height: 100px;" />
</a>`;
}
else if (isPdf) {
return `<a href="${data}" target="_blank">
<img src="https://upload.wikimedia.org/wikipedia/commons/8/87/PDF_file_icon.svg"
alt="PDF Document" class="img-thumbnail"
style="width: 50px; height: 50px;" />
<br>View PDF
</a>`;
} else {
return `<a href="${data}" target="_blank">Download File</a>`;
}
},
},
{
"title": "User Remark",
@ -361,7 +411,6 @@
// data-remark="${row.remark || ''}">
// Reject
// </button>`;
// },
// "className": "align-middle",
// },

File diff suppressed because it is too large Load Diff

View File

@ -661,7 +661,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("AddItemMovement")]
public async Task<IActionResult> AddItemMovement([FromBody] ItemMovementModel itemmovement)
//public async Task<IActionResult> AddItemMovement()
{
@ -673,6 +672,32 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
try
{
if (!string.IsNullOrEmpty(itemmovement.ConsignmentNote))
{
var bytes = Convert.FromBase64String(itemmovement.ConsignmentNote);
string filePath = "";
string uniqueName = $"{itemmovement.ItemId}_{Guid.NewGuid()}";
if (IsImage(bytes))
{
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/itemmovement", uniqueName + itemmovement.ItemId + "_Request.jpg");
itemmovement.ConsignmentNote = "/media/inventory/itemmovement/" + uniqueName + itemmovement.ItemId + "_Request.jpg";
}
else if (IsPdf(bytes))
{
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/itemmovement", uniqueName + itemmovement.ItemId + "_Request.pdf");
itemmovement.ConsignmentNote = "/media/inventory/itemmovement/" + uniqueName + itemmovement.ItemId + "_Request.pdf";
}
else
{
return BadRequest("Unsupported file format.");
}
await System.IO.File.WriteAllBytesAsync(filePath, bytes);
}
_centralDbContext.ItemMovements.Add(itemmovement);
await _centralDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB