From 8b7a4d539093257681c56dc5c91c9a17bcd0e2fe Mon Sep 17 00:00:00 2001 From: ameerulrasyid Date: Fri, 21 Feb 2025 16:15:29 +0800 Subject: [PATCH] update qr --- .../Controllers/ItemMovementController.cs | 5 - Areas/Inventory/Views/ItemMovement/Qr.cshtml | 1105 +++++++++++++++-- Controllers/API/Inventory/InvMainAPI.cs | 91 ++ Views/PublicInventory/ItemInformation.cshtml | 12 +- 4 files changed, 1107 insertions(+), 106 deletions(-) diff --git a/Areas/Inventory/Controllers/ItemMovementController.cs b/Areas/Inventory/Controllers/ItemMovementController.cs index 8d45e5c..e12df88 100644 --- a/Areas/Inventory/Controllers/ItemMovementController.cs +++ b/Areas/Inventory/Controllers/ItemMovementController.cs @@ -20,11 +20,6 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers return View(); } - public ActionResult Qr() - { - return View(); - } - [Authorize] [HttpPost("/i/{id}")] public IActionResult ItemRecognization(string id, [FromBody] ItemModel item) diff --git a/Areas/Inventory/Views/ItemMovement/Qr.cshtml b/Areas/Inventory/Views/ItemMovement/Qr.cshtml index b7e421d..8e61127 100644 --- a/Areas/Inventory/Views/ItemMovement/Qr.cshtml +++ b/Areas/Inventory/Views/ItemMovement/Qr.cshtml @@ -1,107 +1,1022 @@ @{ - ViewData["Title"] = "QR & Barcode Scanner"; + ViewData["Title"] = "QR Scanner"; Layout = "~/Views/Shared/_Layout.cshtml"; } + +@await Html.PartialAsync("~/Areas/Inventory/Views/_InventoryPartial.cshtml"); +
+
+
+ @* *@ +
+
+ @*
+
+ Loading... +
+
*@ + @*
*@ + +
+

QR & Barcode Scanner

+
+

Scan Result:

+
+

Scan Result:

+
+
+ +
+
+ +
+

+ Item Name: + {{ thisItem.productName }} +

+
+ + +
+

+ Part Number: + {{ thisItem.partNumber }} +

+
+ + +
+

+ Serial Number: + {{ thisItem.serialNumber }} +

+
+ + +
+

+ PIC: + Station PIC +

+
+ + +
+
+
+
+ Current Information +
+
    + +
  • +
    + + User: + + + {{ thisItem.currentUser }} + +
    +
  • + + +
  • + + Store: + + {{ thisItem.currentStore }} +
  • + + +
  • + + Station: + + {{ thisItem.currentStation || 'N/A' }} +
  • +
+
+
+
+ + @*
*@ + @*

Welcome, Admin! You have full access.

*@ + @*

Welcome, User! You have limited access.

*@ + @*

Guest View: Please log in.

*@ + @*
*@ +
+ + + + + +
+ +
+
+
+ + @*Right Side*@ +
+
+
+

REGISTRATION ITEM

+
+
+
+ + +
+ +
+ +
+
+ + +
+ +
+ +
+
+ + @* Remark *@ +
+ +
+ +
+
+ + +
+ + @* Submit and Reset Buttons *@ +
+
+ + +
+
+
+
+
+
+
+
+
+ + +
- - this.html5QrCodeScanner = new Html5QrcodeScanner( - "reader", config, false - ); - this.html5QrCodeScanner.render( - (decodedText, decodedResult) => { - if (!this.debounceTimeout) { - this.debounceTimeout = setTimeout(() => { - this.qrCodeResult = decodedText; - this.sendDataToBackend(decodedText); - this.debounceTimeout = null; - }, this.debounceTime); - } - } - ); - }, - sendDataToBackend(data) { - fetch("/api/Qr", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ data: data }), - }) - .then((response) => response.json()) - .then((result) => { - console.log("Response from server:", result); - }) - .catch((error) => { - console.error("Error sending data to the backend:", error); - }); - }, - decodeWithApi(barcodeData) { - fetch(`https://api.qrserver.com/v1/read-qr-code/?fileurl=${encodeURIComponent(barcodeData)}`) - .then(response => response.json()) - .then(data => { - console.log("Decoded using API:", data); - if (data[0].symbol[0].data) { - this.qrCodeResult = data[0].symbol[0].data; // Update result with API response - } - }) - .catch(error => { - console.error("Error decoding with API:", error); - }); - }, - decodeWithZxing() { - const reader = new ZXing.BrowserQRCodeReader(); - reader.decodeFromInputVideoDevice(undefined, 'reader').then(result => { - this.qrCodeResult = result.text; - this.sendDataToBackend(result.text); - }).catch(err => { - console.error("ZXing decoding failed:", err); + \ No newline at end of file + mounted() { + this.fetchUser(); + this.fetchItems(); + this.fetchCurrencyData(); + this.fetchCompanies(); + this.fetchProducts(); + this.fetchSuppliers(); + this.startScanner(); + this.fetchUsers(); + this.fetchStores(); + this.fetchItem('ARA00500008'); // for testing only. clear this + }, + computed: { + filteredDepartments() { + if (!this.selectedCompany) { + return []; // No company selected, return empty list + } + const company = this.companies.find(c => c.companyId === this.selectedCompany); + // this.selectedDepartment = ''; + return company ? company.departments : []; + }, + showProduct() { + if (!this.selectedProduct) { + return []; // No company selected, return empty list + } + const product = this.products.find(c => c.productId === this.selectedProduct); + return product ? product : {}; + }, + showSerialNumber() { + return this.showProduct.category === 'Asset' || this.showProduct.category === 'Part'; + }, + }, + methods: { + async addItemMovement() { + if (this.showProduct.category == "Disposable") { + this.serialNumber = ""; + } + const formData = { + + toUser: this.selectedUser, + toStore: this.selectedStore, + Remark: this.remark, + + }; + + try { + + // Additional specific checks + if (this.showSerialNumber) { + this.quantity = 0; + if (this.serialNumber === null || this.serialNumber === '') { + alert('Serial Number Error', 'Serial Number must be filled when selecting Item or Part.', 'warning'); + return; + } + } + else { + this.serialNumber = null; + if (this.quantity === 0 || this.quantity === null || this.quantity === '') { + alert('quantity Error', 'Quantity is required when selecting Disposable.', 'warning'); + return; + } + } + + // Proceed to send the data to the API + const response = await fetch('/InvMainAPI/AddItemMovement', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + // 'Authorization': `Bearer ${this.token}` + }, + body: JSON.stringify(formData) + }); + if (response.ok) { + // If the form submission was successful, display a success message + alert('Success!', 'Item form has been successfully submitted.', 'success'); + const updatedItem = await response.json(); + this.items.push(updatedItem); + + this.fetchItem(); + + // Reset the form + this.resetForm(); + } else { + throw new Error('Failed to submit form.'); + } + + } catch (error) { + console.error('Error:', error); + + // Displaying error message + alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error'); + } + + }, + startScanner() { + const config = { + fps: 60, + qrbox: 200 + }; + + navigator.mediaDevices.getUserMedia({ + video: { + width: { ideal: 1920 }, // Higher resolution + height: { ideal: 1080 }, + } + }) + + .catch((err) => { + console.error("Error accessing camera:", err); + }); + + this.html5QrCodeScanner = new Html5QrcodeScanner( + "reader", config, false + ); + + this.html5QrCodeScanner.render( + (decodedText, decodedResult) => { + if (!this.debounceTimeout) { + this.debounceTimeout = setTimeout(() => { + this.qrCodeResult = decodedText; + // this.sendDataToBackend(decodedText); + this.fetchItem(decodedText.split('/').pop()); + this.debounceTimeout = null; + }, this.debounceTime); + } + } + ); + }, + async fetchItem(itemid) { + try { + const response = await fetch('/InvMainAPI/GetItem/' + itemid, { + method: 'POST',} + ); + if (response.ok) { + this.thisItem = await response.json(); + + } else { + console.error('Failed to fetch item information'); + this.responseMessage = await response.text(); + } + } catch (error) { + console.error('Error fetching item information:', error); + } + }, + async addItem() { + + if (this.showProduct.category == "Disposable") { + this.serialNumber = ""; + } + const formData = { + CompanyId: this.selectedCompany, + DepartmentId: this.selectedDepartment, + ProductId: this.selectedProduct, + SerialNumber: this.serialNumber, + Quantity: this.quantity, + Supplier: this.selectedSupplier, + PurchaseDate: this.purchaseDate, + PONo: this.PO, + Currency: this.currency, + DefaultPrice: this.DefaultPrice, + CurrencyRate: this.currencyRate, + ConvertPrice: this.convertPrice, + DODate: this.DODate, + Warranty: this.warranty, + EndWDate: this.EndWDate, + InvoiceDate: this.invoiceDate, + CreatedByUserId: this.currentUser.id, + TeamType: this.selectedTeamType, + PartNumber: this.partNumber, + }; + + try { + + // Additional specific checks + if (this.showSerialNumber) { + this.quantity = 0; + if (this.serialNumber === null || this.serialNumber === '') { + alert('Serial Number Error', 'Serial Number must be filled when selecting Item or Part.', 'warning'); + return; + } + } + else { + this.serialNumber = null; + if (this.quantity === 0 || this.quantity === null || this.quantity === '') { + alert('quantity Error', 'Quantity is required when selecting Disposable.', 'warning'); + return; + } + } + + // Proceed to send the data to the API + const response = await fetch('/InvMainAPI/AddItem', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + // 'Authorization': `Bearer ${this.token}` + }, + body: JSON.stringify(formData) + }); + if (response.ok) { + // If the form submission was successful, display a success message + alert('Success!', 'Item form has been successfully submitted.', 'success'); + const updatedItem = await response.json(); + this.items.push(updatedItem); + + this.fetchItems(); + + // Reset the form + this.resetForm(); + } else { + throw new Error('Failed to submit form.'); + } + + } catch (error) { + console.error('Error:', error); + + // Displaying error message + alert('Inventory PSTW Error', `An error occurred: ${error.message}`, 'error'); + } + + }, + + initiateTable() { + self = this; + this.itemDatatable = $('#itemDatatable').DataTable({ + "data": this.items, + "columns": [ + { + "title": "Unique Id", + "data": "uniqueID", + "createdCell": function (td, cellData, rowData, row, col) { + // Assign a unique ID to the element + $(td).attr('id', `qr${cellData}`); + }, + }, + { + "title": "Print", + "data": "uniqueID", + "render": function (data, type, full, meta) { + var printButton = ``; + return printButton; + }, + "className": "align-middle", + }, + { + "title": "Item Short Name", + "data": "productShortName", + }, + { + "title": "Serial Number", + "data": "serialNumber", + }, + { + "title": "Part Number", + "data": "partNumber", + }, + { + "title": "Category", + "data": "category", + }, + { + "title": "Quantity", + "data": "quantity", + }, + { + "title": "Supplier", + "data": "supplier", + }, + { + "title": "Purchase Date", + "data": "purchaseDate", + }, + { + "title": "Price(RM)", + "data": "convertPrice", + }, + { + "title": "Invoice Date", + "data": "invoiceDate", + }, + { + "title": "Warranty Until", + "data": "warranty", + "render": function (data, type, full, meta) { + if (data > 0) { return full.endWDate } + else { return data } + } + }, + { + "title": "Location", + "data": "currentUser", + "render": function (data, type, full, meta) { + currentUser = data ?? null; + currentStore = full.currentStore ?? 'N/A'; + currentStation = full.currentStation ?? 'N/A'; + return `User: ${currentUser}
+ Store: ${currentStore}
+ Station: ${currentStation}` + } + }, + { + "title": "Delete", + "data": "itemID", + "render": function (data) { + var deleteButton = ``; + return deleteButton; + }, + "className": "align-middle", + } + ], + responsive: true, + drawCallback: function (settings) { + // 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.uniqueID}`; + const container = $(`#${containerId}`); + container.empty(); + container.append(`${data.uniqueID}`); + // console.log(container[0]); + if (container) { + // Generate QR code only if not already generated + new QRCode(container[0], { + text: data.qrString, + width: 100, + height: 100, + colorDark: "#000000", + colorLight: "#ffffff", + correctLevel: QRCode.CorrectLevel.M + }); + } + // container.on('click', function() { + // window.open(data.qrString, '_blank'); + // }); + }); + }, + }) + + // Attach click event listener to the delete buttons + $('#itemDatatable tbody').on('click', '.delete-btn', function () { + const itemId = $(this).data('id'); + self.deleteItem(itemId); + }); + + $('#itemDatatable tbody').on('click', '.print-btn', function () { + const $button = $(this); // The clicked button + const $row = $button.closest('tr'); // The parent row of the button + const itemId = $button.data('id'); // Get the item ID from the button's data attribute + + let imageSrc; + + // Check if the table is collapsed + if ($row.hasClass('child')) { + // For collapsed view: Look for the closest `.dtr-data` that contains the img + imageSrc = $row.prev('tr').find('td:nth-child(1) img').attr('src'); + } else { + // For expanded view: Find the img in the first column of the current row + imageSrc = $row.find('td:nth-child(1) img').attr('src'); + } + + if (imageSrc) { + self.printItem(itemId, imageSrc); // Call the print function with the itemId and imageSrc + } else { + console.error("Image source not found."); + } + }); + + this.loading = false; + }, + + async fetchItems() { + + try { + // const token = localStorage.getItem('token'); // Get the token from localStorage + const response = await fetch('/InvMainAPI/ItemList', { + method: 'POST', // Specify the HTTP method + headers: { + 'Content-Type': 'application/json', // Set content type + // 'Authorization': `Bearer ${token}` // Include the token in the headers + } + }); + + if (!response.ok) { + throw new Error('Failed to fetch item'); + } + this.items = await response.json(); + + if (this.itemDatatable) { + this.itemDatatable.clear().destroy(); + } + this.initiateTable(); + } + catch (error) { + console.error('Error fetching item:', error); + } + }, + + async fetchProducts() { + try { + // const token = localStorage.getItem('token'); // Get the token from localStorage + const response = await fetch('/InvMainAPI/ProductList', { + method: 'POST', // Specify the HTTP method + headers: { + 'Content-Type': 'application/json', // Set content type + // 'Authorization': `Bearer ${token}` // Include the token in the headers + } + }); + + if (!response.ok) { + throw new Error('Failed to fetch products'); + } + + this.products = await response.json(); + } + catch (error) { + console.error('Error fetching products:', error); + } + }, + + async fetchCompanies() { + try { + const response = await fetch('/AdminAPI/GetDepartmentWithCompanyList', { + method: 'POST', // Specify the HTTP method + headers: { + 'Content-Type': 'application/json' + } + }); + if (!response.ok) { + throw new Error('Failed to fetch companies'); + } + + this.companies = await response.json(); + + } catch (error) { + console.error('Error fetching products:', error); + } + }, + + async fetchSuppliers() { + try { + const response = await fetch('/InvMainAPI/SupplierList', { + method: 'POST', // Specify the HTTP method + headers: { + 'Content-Type': 'application/json' + } + }); + if (!response.ok) { + throw new Error('Failed to fetch suppliers'); + } + this.suppliers = await response.json(); // Get the full response object + + } catch (error) { + console.error('Error fetching suppliers:', error); + } + }, + async fetchCurrencyData() { + try { + // Fetch currency data from the API + const response = await fetch('https://openexchangerates.org/api/currencies.json'); // Example API + this.currencies = await response.json(); + } catch (error) { + console.error('Error fetching currency data:', error); + } + }, + convertCurrency() { + // Your currency conversion logic here + console.log('Selected currency:', this.currency); + }, + resetForm() { + this.selectedUser = null; + this.selectedStore = null; + this.remark = ''; + + + }, + + // FRONT END FUNCTIONS + //----------------------// + //Calculate Total Price + convertCurrency() { + const total = this.DefaultPrice * this.currencyRate; + this.convertPrice = total.toFixed(2); + this.DefaultPrice = this.DefaultPrice + // .replace(/[^0-9.]/g, '') // Remove non-numeric characters except decimal points + // .replace(/(\..*)\..*/g, '$1') // Allow only one decimal point + // .replace(/^(\d*\.\d{0,2})\d*$/, '$1'); // Limit to two decimal places + + }, + calculateWarrantyEndDate() { + // Check if DODate and warranty are valid + if (!this.DODate || isNaN(Date.parse(this.DODate))) { + this.EndWDate = null; + return; + } + + const DODates = new Date(this.DODate); + const warrantyMonth = parseInt(this.warranty); + + // Ensure warranty is a valid number + if (!isNaN(warrantyMonth)) { + DODates.setMonth(DODates.getMonth() + warrantyMonth); + this.EndWDate = DODates.toISOString().split('T')[0]; + } else { + this.EndWDate = null; + } + }, + async deleteItem(itemId) { + if (!confirm("Are you sure you want to delete this item?")) { + return; + } + try { + const response = await fetch(`/InvMainAPI/DeleteItem/${itemId}`, { + method: 'DELETE', + headers: { + 'Content-Type': 'application/json', + }, + }); + const result = await response.json(); + + if (result.success) { + alert(result.message); + // Remove the row from DataTables + this.itemDatatable + .row($(`.delete-btn[data-id="${itemId}"]`).closest('tr')) + .remove() + .draw(); + } else { + alert(result.message); + } + } + catch (error) { + console.error("Error deleting item:", error); + alert("An error occurred while deleting the item."); + } + finally { + this.loading = false; + } + }, + async printItem(itemId, imgSrc) { + try { + this.thisQRInfo.uniqueID = itemId; + const uniqueQR = itemId; + const container = document.getElementById("QrContainer"); + + if (!container) { + console.error("Container not found."); + return; + } + + // Safely set image content + const sanitizedImgSrc = encodeURI(imgSrc); // Sanitize the URL + container.innerHTML = `QR Code`; + + // Fetch QR information + const qrInfo = this.getPrintedQR(uniqueQR); + if (!qrInfo) { + console.error("QR Info not found."); + return; + } + + this.thisQRInfo = qrInfo; + this.thisQRInfo.imgSrc = sanitizedImgSrc + this.thisQRInfo.imgContainer = container.innerHTML + $(`#QrItemModal`).modal('show'); // Show modal + } + catch (error) { + console.error("Error generating QR code:", error); + alert("An error occurred while generating the QR code."); + } + }, + async fetchUser() { + try { + const response = await fetch(`/IdentityAPI/GetUserInformation/`, { + method: 'POST', + }); + if (response.ok) { + const data = await response.json(); + this.currentUser = data?.userInfo || null; + const companyDeptData = await this.currentUser.department; + this.currentUserCompanyDept = companyDeptData; + this.selectedCompany = companyDeptData?.companyId || ""; + this.selectedDepartment = companyDeptData?.departmentId || ""; + } + else { + console.error(`Failed to fetch user: ${response.statusText}`); + } + } + catch (error) { + console.error('There was a problem with the fetch operation:', error); + } + }, + getPrintedQR(uniqueID) { + if (!this.items || !Array.isArray(this.items)) { + console.error("Items list is not available or is not an array."); + return null; + } + return this.items.find(item => item.uniqueID === uniqueID); + }, + printQRInfo() { + // Create a virtual DOM element + const virtualElement = document.createElement('div'); + 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.departmentName}
+
${this.thisQRInfo.productShortName}
+
${this.thisQRInfo.serialNumber??"-"}
+
${this.thisQRInfo.partNumber}
+
+
+
+
+ `; + + // Append the virtual DOM to the body (temporarily) + document.body.appendChild(virtualElement); + + // Wait for the font to be loaded (important for custom fonts like OCR-A) + document.fonts.load('1em "OCR A"').then(() => { + // Use html2canvas to convert the virtual DOM to an image + html2canvas(virtualElement, { + scale: 1, // Increase scale for sharper images + }).then((canvas) => { + // Convert the canvas to an image + const imgData = canvas.toDataURL('image/png'); + // Open the image in a new tab for preview (optional) + // const newWindow = window.open(); + // newWindow.location.href = imgData; + // console.log(imgData) + // Use printJS to print the image + printJS({ + printable: imgData, + type: 'image', + css: '/../lib/bootstrap/dist/css/bootstrap.css', + style: ` + @@media print { + @@page { + margin: 5px 5px 0px 5px; + } + body { margin: 0; } + } + ` + }); + + // Remove the virtual DOM from the body after use + document.body.removeChild(virtualElement); + }).catch((error) => { + console.error("Error generating image:", error); + // Remove the virtual DOM if an error occurs + document.body.removeChild(virtualElement); + }); + }).catch((error) => { + console.error("Error loading font:", error); + // Remove the virtual DOM if font loading fails + document.body.removeChild(virtualElement); + }); + }, + async fetchUsers() { + try { + // const token = localStorage.getItem('token'); // Get the token from localStorage + const response = await fetch('/InvMainAPI/UserList', { + method: 'POST', // Specify the HTTP method + headers: { + 'Content-Type': 'application/json', // Set content type + // 'Authorization': `Bearer ${token}` // Include the token in the headers + } + }); + + if (!response.ok) { + throw new Error('Failed to fetch item'); + } + this.userlist = await response.json(); + + + } + catch (error) { + console.error('Error fetching item:', error); + } + }, + async fetchStores() { + try { + // const token = localStorage.getItem('token'); // Get the token from localStorage + const response = await fetch('/InvMainAPI/StoreList', { + method: 'POST', // Specify the HTTP method + headers: { + 'Content-Type': 'application/json', // Set content type + // 'Authorization': `Bearer ${token}` // Include the token in the headers + } + }); + + if (!response.ok) { + throw new Error('Failed to fetch item'); + } + this.storelist = await response.json(); + + + } + catch (error) { + console.error('Error fetching item:', error); + } + }, + }, + }); + + + + +} \ No newline at end of file diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs index dd0bcab..42c4781 100644 --- a/Controllers/API/Inventory/InvMainAPI.cs +++ b/Controllers/API/Inventory/InvMainAPI.cs @@ -636,6 +636,97 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory } + [HttpPost("AddItemMovement")] + public async Task AddItemMovement([FromBody] ItemMovementModel itemmovement) + //public async Task AddItemMovement() + { + + + + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + try + { + _centralDbContext.ItemMovements.Add(itemmovement); + + await _centralDbContext.SaveChangesAsync(); // This generates the auto-incremented ItemID + + + //ItemMovementModel itemMovement = new ItemMovementModel + //{ + // ItemId = item.ItemID, + // ToUser = inventoryMaster.UserId, + // ToStore = inventoryMaster.StoreId, + // LastStore = inventoryMaster.StoreId, + // LastUser = inventoryMaster.UserId, + // LatestStatus = "Ready To Deploy", + // Quantity = item.Quantity, + // Action = "Register", + // Date = DateTime.Now, + // MovementComplete = true, + //}; + + //_centralDbContext.ItemMovements.Add(itemMovement); + //await _centralDbContext.SaveChangesAsync(); + + // Fetch the generated ItemID + //var savedItem = await _centralDbContext.Items.FirstOrDefaultAsync(i => i.ItemID == item.ItemID); + //// Fetch the generated itemMovement + //var savedMovement = await _centralDbContext.ItemMovements.FirstOrDefaultAsync(i => i.Id == itemMovement.Id); + + //if (savedItem != null) + //{ + // var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId); + // var itemProduct = _centralDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault(); + + // string? companyInitial = companyDepartment!.CompanyName?.ToString().Substring(0, 1).ToUpper(); + // string? departmentInitial = companyDepartment!.DepartmentName?.ToString().Substring(0, 1).ToUpper(); + // string? deptCode = companyDepartment!.DepartmentCode?.ToString(); + // char? initialCategory = itemProduct!.Category.ToString().Substring(0, 1).ToUpper().FirstOrDefault(); + // string? productId = itemProduct!.ProductId.ToString("D3"); + // string? itemId = item.ItemID.ToString("D5"); + // var uniqueId = $"{deptCode}{initialCategory}{productId}{itemId}".ToUpper(); + // savedItem.UniqueID = uniqueId; + // savedItem.MovementId = savedMovement?.Id; + + // _centralDbContext.Items.Update(savedItem); + // await _centralDbContext.SaveChangesAsync(); + //} + + //var updatedItem = new + //{ + // savedItem!.ItemID, + // savedItem.UniqueID, + // savedItem.CompanyId, + // savedItem.DepartmentId, + // savedItem.ProductId, + // savedItem.SerialNumber, + // savedItem.Quantity, + // savedItem.Supplier, + // savedItem.PurchaseDate, + // savedItem.PONo, + // savedItem.Currency, + // savedItem.DefaultPrice, + // savedItem.CurrencyRate, + // savedItem.ConvertPrice, + // savedItem.DODate, + // savedItem.Warranty, + // savedItem.EndWDate, + // savedItem.InvoiceDate, + // savedItem.PartNumber, + //}; + return Json(itemmovement); + } + catch (Exception ex) + { + return BadRequest(ex.Message); + } + + } + #endregion ItemMovement #region ItemRequestUser diff --git a/Views/PublicInventory/ItemInformation.cshtml b/Views/PublicInventory/ItemInformation.cshtml index b725499..2d9e21b 100644 --- a/Views/PublicInventory/ItemInformation.cshtml +++ b/Views/PublicInventory/ItemInformation.cshtml @@ -146,11 +146,11 @@ -
-

Welcome, Admin! You have full access.

-

Welcome, User! You have limited access.

-

Guest View: Please log in.

-
+ @*
*@ + @*

Welcome, Admin! You have full access.

*@ + @*

Welcome, User! You have limited access.

*@ + @*

Guest View: Please log in.

*@ + @*
*@ @@ -209,7 +209,7 @@ ); if (response.ok) { this.thisItem = await response.json(); - // console.log(this.thisItem); + } else { console.error('Failed to fetch item information'); this.responseMessage = await response.text();