diff --git a/Areas/Inventory/Models/ItemModel.cs b/Areas/Inventory/Models/ItemModel.cs
index 419103f..721709d 100644
--- a/Areas/Inventory/Models/ItemModel.cs
+++ b/Areas/Inventory/Models/ItemModel.cs
@@ -36,9 +36,6 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public string PartNumber { get; set; } = string.Empty;
public int CreatedByUserId { get; set; }
[ForeignKey("CreatedByUserId")]
-
- public DateTime CreateDate { get; set; } = DateTime.Now;
-
public virtual UserModel? CreatedBy { get; set; }
[ForeignKey("CompanyId")]
public virtual CompanyModel? Company { get; set; }
diff --git a/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml b/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml
index 1670fa4..517d479 100644
--- a/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml
+++ b/Areas/Inventory/Views/InventoryMaster/ItemRegistration.cshtml
@@ -580,137 +580,140 @@
},
- 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": (row) => parseFloat(row.convertPrice).toFixed(2),
- },
- {
- "title": "Register Date",
- "data": "createDate",
- },
- {
- "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": "Edit",
- "data": "itemID",
- "render": function (data) {
- var editButton = ``;
- return editButton;
- },
- "className": "align-middle",
- },
- {
- "title": "Delete",
- "data": "itemID",
- "render": function (data) {
- var deleteButton = ``;
- return deleteButton;
- },
- "className": "align-middle",
- }
- ],
- responsive: true,
- drawCallback: function (settings) {
- setTimeout(() => {
- const api = this.api();
- api.rows().every(function () {
- const data = this.data();
- const containerId = `qr${data.uniqueID}`;
- const container = document.getElementById(containerId);
-
- if (!container) {
- return;
+ 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": (row) => parseFloat(row.convertPrice).toFixed(2),
+ },
+ // --- REMOVE ---
+ // {
+ // "title": "Register Date",
+ // "data": "createDate", // This is the problematic line
+ // },
+ // --------------
+ {
+ "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": "Edit",
+ "data": "itemID",
+ "render": function (data) {
+ var editButton = ``;
+ return editButton;
+ },
+ "className": "align-middle",
+ },
+ {
+ "title": "Delete",
+ "data": "itemID",
+ "render": function (data) {
+ var deleteButton = ``;
+ return deleteButton;
+ },
+ "className": "align-middle",
}
+ ],
+ responsive: true,
+ drawCallback: function (settings) {
+ setTimeout(() => {
+ const api = this.api();
+ api.rows().every(function () {
+ const data = this.data();
+ const containerId = `qr${data.uniqueID}`;
+ const container = document.getElementById(containerId);
- container.innerHTML = "";
- container.append(data.uniqueID);
+ if (!container) {
+ return;
+ }
- // Ensure qrString is valid before generating QR code
- if (!data.qrString) {
- return;
- }
+ container.innerHTML = "";
+ container.append(data.uniqueID);
+
+ // Ensure qrString is valid before generating QR code
+ if (!data.qrString) {
+ return;
+ }
+
+ // Generate QR Code
+ new QRCode(container, {
+ text: data.qrString,
+ width: 100,
+ height: 100,
+ colorDark: "#000000",
+ colorLight: "#ffffff",
+ correctLevel: QRCode.CorrectLevel.M
+ });
+ });
+ }, 100); // Small delay to ensure elements exist
+ }
+ })
- // Generate QR Code
- new QRCode(container, {
- text: data.qrString,
- width: 100,
- height: 100,
- colorDark: "#000000",
- colorLight: "#ffffff",
- correctLevel: QRCode.CorrectLevel.M
- });
- });
- }, 100); // Small delay to ensure elements exist
- }
- })
// Attach click event listener to the edit buttons
$('#itemDatatable tbody').off('click', '.edit-btn').on('click', '.edit-btn', function () {
diff --git a/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml b/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml
index f16ee3b..713c096 100644
--- a/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml
+++ b/Areas/Inventory/Views/ItemMovement/ItemMovementUser.cshtml
@@ -182,7 +182,7 @@
{{movement.action === 'Assign' ? 'Assign Date' : 'Send Date'}}
- {{ movement.sendDate }}
+ {{ formatDate(movement.sendDate) }}
@@ -277,7 +277,7 @@
{{movement.action === 'Assign' ? 'Assign Date' : 'Send Date'}}
- {{ movement.sendDate }}
+ {{ formatDate(movement.sendDate) }}
@@ -398,7 +398,7 @@
{{movement.action === 'Assign' ? 'Assign Date' : 'Send Date'}}
- {{ movement.sendDate }}
+ {{ formatDate(movement.sendDate) }}
@@ -490,7 +490,7 @@
{{movement.action === 'Assign' ? 'Assign Date' : 'Send Date'}}
- {{ movement.sendDate }}
+ {{ formatDate(movement.sendDate) }}
@@ -830,6 +830,17 @@
]);
},
methods: {
+ formatDate(dateString) {
+ if (!dateString) return '';
+ const date = new Date(dateString);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ const seconds = String(date.getSeconds()).padStart(2, '0');
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ },
paginatedItemsStation(item) {
const start = (this.currentPageStation - 1) * this.itemsPerPageStation;
const end = start + this.itemsPerPageStation;
@@ -1024,7 +1035,7 @@
{ title: "Product Name", data: "productName", render: (data, type, full) => { return `${data} ${renderFile(full.productImage)}`; } },
{ title: "Product Code", data: "uniqueID" },
{ title: "Action", data: "action" },
- { title: "Send Date", data: "sendDate" },
+ { title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Start Status", data: "toOther" },
{ title: "From User", data: "toUserName" },
{ title: "Last User", data: "lastUserName" },
@@ -1044,7 +1055,7 @@
{ title: "Unique Id", data: "id" },
{ title: "Product Name", data: "productName", render: (data, type, full) => { return `${data} ${renderFile(full.productImage)}`; } },
{ title: "Product Code", data: "uniqueID" },
- { title: "Send Date", data: "sendDate" },
+ { title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Receive Date", data: "receiveDate" },
{ title: "Action", data: "action" },
{ title: "Start Status", data: "toOther" },
@@ -1069,7 +1080,7 @@
{ title: "Unique Id", data: "id" },
{ title: "Product Name", data: "productName", render: (data, type, full) => { return `${data} ${renderFile(full.productImage)}`; }},
{ title: "Product Code", data: "uniqueID" },
- { title: "Assign Date", data: "sendDate" },
+ { title: "Assign Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Action", data: "action" },
{ title: "Station User PIC", data: "toUserName" },
{ title: "From Station", data: "toStationName" },
diff --git a/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml b/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml
index 0559026..055250e 100644
--- a/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml
+++ b/Areas/Inventory/Views/ItemMovement/ItemRequest.cshtml
@@ -468,6 +468,17 @@
function renderDeleteButton(data) {
return ``;
}
+ function formatDateTime(dateString) {
+ if (!dateString) return '';
+ const date = new Date(dateString);
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+ const hours = String(date.getHours()).padStart(2, '0');
+ const minutes = String(date.getMinutes()).padStart(2, '0');
+ const seconds = String(date.getSeconds()).padStart(2, '0');
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ }
this.pendingRequestDatatable = $('#requestDatatable').DataTable({
"data": this.request.filter(req => req.status === "Requested"),
@@ -479,7 +490,7 @@
{ "title": "Document / Picture", "data": "document", "render": (data, type, full) => renderDocument(data) },
{ "title": "Remark", "data": "remarkUser" },
{ "title": "Station Deploy", "data": "stationName", "render": (data) => data || "Self Assign" },
- { "title": "Request Date", "data": "requestDate" },
+ { "title": "Request Date", "data": "requestDate", "render": (data) => formatDateTime(data) }, // Apply formatting here
{ "title": "Status", "data": "status" },
{ "title": "Delete", "data": "requestID", "render": renderDeleteButton, "className": "align-middle" }
],
@@ -498,8 +509,8 @@
{ "title": "Document / Picture", "data": "document", "render": (data, type, full) => renderDocument(data) },
{ "title": "Remark", "data": "remarkUser" },
{ "title": "Remark (Master)", "data": "remarkMasterInv" },
- { "title": "Request Date", "data": "requestDate" },
- { "title": "Approval Date", "data": "approvalDate" }
+ { "title": "Request Date", "data": "requestDate", "render": (data) => formatDateTime(data) }, // Apply formatting here
+ { "title": "Approval Date", "data": "approvalDate", "render": (data) => formatDateTime(data) } // Apply formatting here
],
responsive: true,
});
diff --git a/Controllers/API/Inventory/InvMainAPI.cs b/Controllers/API/Inventory/InvMainAPI.cs
index 0cc7f6e..bb5f902 100644
--- a/Controllers/API/Inventory/InvMainAPI.cs
+++ b/Controllers/API/Inventory/InvMainAPI.cs
@@ -379,7 +379,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var userRole = await _userManager.GetRolesAsync(user);
var isAdmin = userRole.Contains("SystemAdmin") || userRole.Contains("SuperAdmin") || userRole.Contains("Finance");
List itemList = new List();
- List createDate = new List();
+
// Get the item list
if (isAdmin)
{
@@ -418,15 +418,10 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
// Get the departments list (DepartmentId references Departments)
var departments = await _centralDbContext.Departments.ToListAsync();
- var createDates = await _centralDbContext.ItemMovements.Where(r => r.Action == "Register").ToListAsync();
-
- // Buat dictionary agar lebih cepat dicari berdasarkan ItemID
- var createDateDict = await _centralDbContext.ItemMovements.Where(r => r.Action == "Register").GroupBy(r => r.ItemId).ToDictionaryAsync(g => g.Key, g => g.Min(m => m.Date));
-
// Now join items with users and departments manually
var itemListWithDetails = itemList.Select(item => new
{
- createDate = createDateDict.ContainsKey(item.ItemID) ? createDateDict[item.ItemID].ToString("dd/MM/yyyy HH:mm:ss") : null,
+ // createDate = createDateDict.ContainsKey(item.ItemID) ? createDateDict[item.ItemID].ToString("dd/MM/yyyy HH:mm:ss") : null,
item.ItemID,
item.UniqueID,
item.CompanyId,
@@ -450,7 +445,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
EndWDate = item.EndWDate.ToString("dd/MM/yyyy"),
InvoiceDate = item.InvoiceDate?.ToString("dd/MM/yyyy"),
item.Department?.DepartmentName,
- RegisterDate = createDate,
+ //RegisterDate = createDate,
CreatedBy =item.CreatedBy!.UserName,
item.Product!.ProductName,
item.Product!.ProductShortName,
@@ -497,9 +492,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
try
{
var product = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found");
- var inventoryMaster = await _centralDbContext.InventoryMasters
- .Include("User")
- .FirstOrDefaultAsync(i => i.UserId == item.CreatedByUserId) ?? new InventoryMasterModel { UserId = item.CreatedByUserId };
+ var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == item.CreatedByUserId) ?? new InventoryMasterModel { UserId = item.CreatedByUserId };
if (product.Category == "Disposable")
{
@@ -516,8 +509,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Quantity = 1; // Force quantity to 1 for Assets/Parts if it's not already
}
- item.CreateDate = DateTime.Now;
-
_centralDbContext.Items.Add(item);
_centralDbContext.Products.Update(product); // Update the product quantity
@@ -584,7 +575,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
savedItem.EndWDate,
savedItem.InvoiceDate,
savedItem.PartNumber,
- CreateDate = savedItem.CreateDate.ToString("dd/MM/yyyy HH:mm:ss")
};
return Json(updatedItem);
}
|