-
+
- {{thisQRInfo.uniqueID}}
+
+
+ {{thisQRInfo.uniqueID}}
+
@@ -607,8 +607,8 @@
// Generate QR code only if not already generated
new QRCode(container[0], {
text: data.qrString,
- width: 150,
- height: 150,
+ width: 100,
+ height: 100,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.M
@@ -847,7 +847,7 @@
// Safely set image content
const sanitizedImgSrc = encodeURI(imgSrc); // Sanitize the URL
- container.innerHTML = `

`;
+ container.innerHTML = `

`;
// Fetch QR information
const qrInfo = this.getPrintedQR(uniqueQR);
@@ -893,72 +893,33 @@
}
return this.items.find(item => item.uniqueID === uniqueID);
},
- // printQRInfo() {
- // const qrElement = this.$refs.qrInfo;
-
- // if (qrElement) {
- // const qrElement = this.$refs.qrInfo;
- // if (qrElement) {
- // domtoimage.toPng(qrElement,{
- // quality: 1,
- // })
- // .then(function (dataUrl) {
- // // Print the image using printJS
- // printJS({
- // printable: dataUrl, // Image data URL
- // type: 'image',
- // css: '/../lib/bootstrap/dist/css/bootstrap.css',
- // style: `
- // @@media print {
- // @@page { margin-top: 15px; margin-bottom: 15px; }
- // body { margin: 0; }
- // img {
- // display: block;
- // margin: auto;
- // width: auto;
- // max-width: 100%;
- // height: auto;
- // max-height: 100vh;
- // }
- // }
- // `
- // });
- // })
- // .catch(function (error) {
- // console.error("Error generating image:", error);
- // });
- // }
- // else {
- // console.error("QR Info element not found.");
- // }
- // }
- // },
printQRInfo() {
// Create a virtual DOM element
const virtualElement = document.createElement('div');
- virtualElement.style.width = '340px '; // Match label size for 2 inches at 203 DPI
- virtualElement.style.height = '180px';
+ virtualElement.style.width = '330px '; // Match label size for 2 inches at 203 DPI
+ virtualElement.style.height = '160px';
virtualElement.style.position = 'absolute';
virtualElement.style.left = '-9999px'; // Position offscreen to avoid rendering on the main UI
// virtualElement.style.border = '1px solid #000'; // Optional: Add a border for debugging dimensions
// Populate the virtual DOM with content
virtualElement.innerHTML = `
-
-
+
+
-
+
${this.thisQRInfo.imgContainer}
+
${this.thisQRInfo.uniqueID}
-
-
${this.thisQRInfo.uniqueID}
-
${this.thisQRInfo.departmentName}
-
${this.thisQRInfo.productName}
-
${this.thisQRInfo.endWDate}
+
+
${this.thisQRInfo.departmentName}
+
${this.thisQRInfo.serialNumber}
+
${this.thisQRInfo.productName}
+
${this.thisQRInfo.endWDate}
@@ -989,7 +950,7 @@
style: `
@@media print {
@@page {
- margin: 2px;
+ margin: 5px 5px 0px 5px;
}
body { margin: 0; }
}
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
index 9e61f25..e6e731c 100644
--- a/Controllers/API/Inventory/InvMainAPI.cs
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -299,7 +299,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Department?.DepartmentName,
item.CreatedBy!.UserName,
item.Product!.ProductName,
- QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/Inventory/ItemInformation/{item.UniqueID}" // Generate QR String
+ QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
}).ToList();
return Json(itemListWithDetails);
@@ -411,6 +411,42 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return Ok(new { success = true, message = "Item deleted successfully" });
}
+ [HttpPost("GetItem/{id}")] // Endpoint to retrieve an item by its ID
+ public async Task
GetItem(string id)
+ {
+ var item = await _centralDbContext.Items.Include("CreatedBy").Include("Department").Include("Product").FirstOrDefaultAsync(i => i.UniqueID == id);
+ if (item == null){
+ return NotFound(new { success = false, message = "Item not found" });
+ }
+ var singleItem = new
+ {
+ item.ItemID,
+ item.UniqueID,
+ item.CompanyId,
+ item.DepartmentId,
+ item.ProductId,
+ item.SerialNumber,
+ item.Quantity,
+ item.Supplier,
+ PurchaseDate = item.PurchaseDate.ToString("dd/MM/yyyy"),
+ item.PONo,
+ item.Currency,
+ item.DefaultPrice,
+ item.CurrencyRate,
+ item.ConvertPrice,
+ item.DODate,
+ item.Warranty,
+ EndWDate = item.EndWDate.ToString("dd/MM/yyyy"),
+ item.InvoiceDate,
+ item.Department?.DepartmentName,
+ item.CreatedBy!.UserName,
+ item.Product!.ProductName,
+ item.Product!.ImageProduct,
+ QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
+ };
+ return Json(singleItem);
+ }
+
#endregion Item
}
}
diff --git a/Controllers/InventoryController.cs b/Controllers/InventoryController.cs
index 7d6cb4e..79b5d3d 100644
--- a/Controllers/InventoryController.cs
+++ b/Controllers/InventoryController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PSTW_CentralSystem.Areas.Inventory.Models;
@@ -17,15 +18,16 @@ namespace PSTW_CentralSystem.Controllers
_centralDbContext = centralDbContext;
}
- [HttpGet("ItemInformation/{Id}")]
- public async Task ItemInformation(int Id)
+ [HttpGet("/i/{Id}")]
+ public IActionResult ItemInformation(string Id)
{
- var item = await _centralDbContext.Items.FindAsync(Id);
- return View(Json(item));
+ ViewData["ItemId"] = Id;
+ return View("ItemInformation");
}
- [HttpPost("ItemInformation/{id}")]
- public IActionResult ItemInformation(int id, [FromBody] ItemModel item)
+ [Authorize]
+ [HttpPost("/i/{id}")]
+ public IActionResult ItemInformation(string id, [FromBody] ItemModel item)
{
return View();
}
diff --git a/Views/Inventory/ItemInformation.cshtml b/Views/Inventory/ItemInformation.cshtml
new file mode 100644
index 0000000..2b49830
--- /dev/null
+++ b/Views/Inventory/ItemInformation.cshtml
@@ -0,0 +1,159 @@
+@*
+ For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
+*@
+@{
+ ViewData["Item"] = "Item Information";
+ Layout = null;
+ var itemId = ViewData["ItemId"];
+}
+
+
+
+
+
+
+
+
+
+
+ Matrix Admin Lite Free Versions Template by WrapPixel
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @* *@
+
+
+
+
+
+
+
+
+
+
+
+
+
![Product Image]()
+
+
+
{{thisItem.uniqueID}}
+
+
+
+
+
+
+
+ Item Name: {{thisItem.productName}}
+
+
+
+
+ Part Number: Part Number
+
+
+
+
+ Serial Number: {{thisItem.serialNumber}}
+
+
+
+
+
+ Location: Item Location
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+