fix itemmovementmaster

update qrmaster
This commit is contained in:
ameerulrasyid 2025-02-25 16:23:45 +08:00
parent 0f2b065c66
commit ca46776473
6 changed files with 362 additions and 765 deletions

View File

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

View File

@ -20,7 +20,7 @@
</div> </div>
<div class="row card"> <div class="row card">
<div class="card-header"> <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> *@ @* <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>
<div class="card-body"> <div class="card-body">
@ -240,6 +240,31 @@
{ {
"title": "Document/Picture", "title": "Document/Picture",
"data": "document", "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", "title": "User Remark",
@ -331,6 +356,31 @@
{ {
"title": "Document/Picture", "title": "Document/Picture",
"data": "document", "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", "title": "User Remark",
@ -361,7 +411,6 @@
// data-remark="${row.remark || ''}"> // data-remark="${row.remark || ''}">
// Reject // Reject
// </button>`; // </button>`;
// }, // },
// "className": "align-middle", // "className": "align-middle",
// }, // },

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Authorization; using Azure.Core;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -643,7 +644,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
[HttpPost("AddItemMovement")] [HttpPost("AddItemMovement")]
public async Task<IActionResult> AddItemMovement([FromBody] ItemMovementModel itemmovement) public async Task<IActionResult> AddItemMovement([FromBody] ItemMovementModel itemmovement)
//public async Task<IActionResult> AddItemMovement()
{ {
@ -655,6 +655,32 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
try 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); _centralDbContext.ItemMovements.Add(itemmovement);
await _centralDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID 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