Item Movement User

This commit is contained in:
ArifHilmi 2025-03-06 12:18:18 +08:00
parent dd23c13644
commit ce941d5d53
7 changed files with 1175 additions and 43 deletions

View File

@ -7,7 +7,8 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public class RequestModel public class RequestModel
{ {
[Key] [Key]
public int requestId { get; set; } [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int requestID { get; set; }
public int ProductId { get; set; } public int ProductId { get; set; }
[ForeignKey("ProductId")] [ForeignKey("ProductId")]
public virtual ProductModel? Product { get; set; } public virtual ProductModel? Product { get; set; }

View File

@ -472,7 +472,8 @@
<div class="row"> <div class="row">
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render Start Icon --> <!-- Conditionally render Start Icon -->
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i>
<i v-else class="fas fa-warehouse fa-2x"></i> <i v-else class="fas fa-warehouse fa-2x"></i>
<p><strong>Start</strong></p> <p><strong>Start</strong></p>
<p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>

View File

@ -191,7 +191,7 @@
const app = Vue.createApp({ const app = Vue.createApp({
data() { data() {
return { return {
requestId : null, requestID : null,
userId : null, userId : null,
stationId : "", stationId : "",
productId : "", productId : "",
@ -288,11 +288,12 @@
UserId: this.userId, UserId: this.userId,
ProductCategory: this.productCategory, ProductCategory: this.productCategory,
RequestQuantity: this.quantity, RequestQuantity: this.quantity,
remark: this.remark || '', remarkUser: this.remark || '',
remarkMasterInv: '',
status: this.status, status: this.status,
requestDate: this.requestDate, requestDate: this.requestDate,
approvalDate: this.approvalDate ? this.approvalDate : null, approvalDate: null,
document: this.document Document: this.document
}; };
$('.modal').modal('hide'); $('.modal').modal('hide');
@ -330,7 +331,7 @@
"columns": [ "columns": [
{ {
"title": "Request ID", "title": "Request ID",
"data": "requestId", "data": "requestID",
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
// Assign a unique ID to the <td> element // Assign a unique ID to the <td> element
$(td).attr('id', `qr${cellData}`); $(td).attr('id', `qr${cellData}`);
@ -399,14 +400,14 @@
}, },
{ {
"title": "Delete", "title": "Delete",
"data": "requestId", "data": "requestID",
"render": function (data) { "render": function (data) {
var deleteButton = `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`; var deleteButton = `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`;
return deleteButton; return deleteButton;
}, },
"className": "align-middle", "className": "align-middle",
// "title": "Delete", // "title": "Delete",
// "data": "requestId", // "data": "requestID",
// "render": function (data, type, row) { // "render": function (data, type, row) {
// if (row.status === "Approved" || row.status === "Rejected") { // if (row.status === "Approved" || row.status === "Rejected") {
// return `<button type="button" class="btn btn-danger delete-btn" data-id="${data}" disabled>Delete</button>`; // return `<button type="button" class="btn btn-danger delete-btn" data-id="${data}" disabled>Delete</button>`;
@ -425,7 +426,7 @@
"columns": [ "columns": [
{ {
"title": "Request ID", "title": "Request ID",
"data": "requestId", "data": "requestID",
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
// Assign a unique ID to the <td> element // Assign a unique ID to the <td> element
$(td).attr('id', `qr${cellData}`); $(td).attr('id', `qr${cellData}`);
@ -506,8 +507,8 @@
$('#requestDatatable tbody').off('click', '.delete-btn'); $('#requestDatatable tbody').off('click', '.delete-btn');
$('#requestDatatable tbody').on('click', '.delete-btn', function () { $('#requestDatatable tbody').on('click', '.delete-btn', function () {
const requestId = $(this).data('id'); const requestID = $(this).data('id');
self.deleteRequestItem(requestId); self.deleteRequestItem(requestID);
}); });
@ -623,12 +624,12 @@
this.loading = false; this.loading = false;
}, },
async deleteRequestItem(requestId) { async deleteRequestItem(requestID) {
if (!confirm("Are you sure you want to delete this request?")) { if (!confirm("Are you sure you want to delete this request?")) {
return false; return false;
} }
try { try {
const response = await fetch(`/InvMainAPI/DeleteRequest/${requestId}`, { const response = await fetch(`/InvMainAPI/DeleteRequest/${requestID}`, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@ -641,10 +642,10 @@
if ($.fn.dataTable.isDataTable('#requestDatatable')) { if ($.fn.dataTable.isDataTable('#requestDatatable')) {
const table = $('#requestDatatable').DataTable(); const table = $('#requestDatatable').DataTable();
table.row($(`.delete-btn[data-id="${requestId}"]`).closest('tr')).remove().draw(); table.row($(`.delete-btn[data-id="${requestID}"]`).closest('tr')).remove().draw();
} }
this.request = this.request.filter(req => req.requestId !== requestId); this.request = this.request.filter(req => req.requestID !== requestID);
} else { } else {
alert(result.message); alert(result.message);
} }

View File

@ -852,13 +852,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
return BadRequest(ModelState); return BadRequest(ModelState);
} }
try try
{ {
var findUniqueCode = _centralDbContext.Products.FirstOrDefault(r => r.ProductId == request.ProductId);
var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == request.UserId);
if (!string.IsNullOrEmpty(request.Document)) if (!string.IsNullOrEmpty(request.Document))
{ {
var findUniqueCode = _centralDbContext.Products.FirstOrDefault(r => r.ProductId == request.ProductId);
var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == request.UserId);
var bytes = Convert.FromBase64String(request.Document); var bytes = Convert.FromBase64String(request.Document);
string filePath = ""; string filePath = "";
@ -891,7 +891,20 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
.Where(r => r.UserId == request.UserId) .Where(r => r.UserId == request.UserId)
.ToListAsync(); .ToListAsync();
return Json(updatedList); return Json(updatedList.Select(i => new
{
i.ProductId,
i.UserId,
i.status,
i.StationId,
i.RequestQuantity,
i.requestDate,
i.ProductCategory,
i.Document,
i.approvalDate,
i.remarkMasterInv,
i.remarkUser,
}));
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -929,7 +942,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return Json(requests.Select(i => new return Json(requests.Select(i => new
{ {
i.requestId, i.requestID,
i.ProductId, i.ProductId,
productName = i.Product?.ProductName, productName = i.Product?.ProductName,
i.UserId, i.UserId,
@ -971,7 +984,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).Include(i => i.User).ToListAsync(); var itemRequestList = await _centralDbContext.Requests.Include(i => i.Product).Include(i => i.User).ToListAsync();
return Json(itemRequestList.Select(i => new return Json(itemRequestList.Select(i => new
{ {
i.requestId, i.requestID,
productName = i.Product?.ProductName, productName = i.Product?.ProductName,
i.ProductId, i.ProductId,
userName = i.User?.FullName, userName = i.User?.FullName,

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,63 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PSTW_CentralSystem.Migrations
{
/// <inheritdoc />
public partial class UpdateRequestTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "requestId",
table: "request",
newName: "requestID");
migrationBuilder.AlterColumn<int>(
name: "requestID",
table: "request",
nullable: false)
.Annotation("SqlServer:Identity", "1, 1"); // Auto Increment
migrationBuilder.AddPrimaryKey("PK_request", "request", "requestID");
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "d801514b-2c36-4df7-9bb5-1c7e351ed27e", "AQAAAAIAAYagAAAAEBSoDiGEYlobLgzVcffYwvTtm1WnXpqrBBT1yYP+kruV4OTtizW7Sel94qAfqUjGcw==", "6132b0af-6a7f-4f38-8959-d049ed486e8f" });
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "14f11e89-bb92-49dd-a8df-ec5b0d49df2d", "AQAAAAIAAYagAAAAEEvcS1SY+9pxZKH/P1l4TaodgW3SFSRfcZ+PnjB3MiMmEUSyYoo64AQtX0bOxFSX2g==", "6dca2498-5150-4369-9923-6f19a48258d4" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "requestID",
table: "request",
newName: "requestId");
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "402e8e19-59a4-4fae-8ffe-4d935bcb1104", "AQAAAAIAAYagAAAAEM22wL5Kx9mwPIJilJAgzudLHg+HduDhJaq+BjD3jh5bqPzi+OnTzAEN49l1IeBqcw==", "4a127c4f-3199-4037-8c02-0a21b750351b" });
migrationBuilder.UpdateData(
table: "AspNetUsers",
keyColumn: "Id",
keyValue: 2,
columns: new[] { "ConcurrencyStamp", "PasswordHash", "SecurityStamp" },
values: new object[] { "05ebfe99-3f46-43b8-9aaa-e01c5bb31a86", "AQAAAAIAAYagAAAAEF3NUsfCVQ3KOv0uND7ech54XBz7+ffJ5x1YYuN0eaBciYQ/K2Jlah/KQR19ykaHbQ==", "42178537-99cc-4701-a488-8f1c0e774855" });
}
}
}

View File

@ -150,7 +150,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("UserId") b.HasIndex("UserId")
.IsUnique(); .IsUnique();
b.ToTable("InventoryMasters", (string)null); b.ToTable("InventoryMasters");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
@ -251,7 +251,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("ProductId"); b.HasIndex("ProductId");
b.ToTable("Items", (string)null); b.ToTable("Items");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
@ -332,7 +332,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("ToUser"); b.HasIndex("ToUser");
b.ToTable("ItemMovements", (string)null); b.ToTable("ItemMovements");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
@ -349,7 +349,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasKey("ManufacturerId"); b.HasKey("ManufacturerId");
b.ToTable("Manufacturers", (string)null); b.ToTable("Manufacturers");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
@ -390,16 +390,16 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("ManufacturerId"); b.HasIndex("ManufacturerId");
b.ToTable("Products", (string)null); b.ToTable("Products");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.RequestModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.RequestModel", b =>
{ {
b.Property<int>("requestId") b.Property<int>("requestID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("requestId")); MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("requestID"));
b.Property<string>("Document") b.Property<string>("Document")
.HasColumnType("longtext"); .HasColumnType("longtext");
@ -434,7 +434,7 @@ namespace PSTW_CentralSystem.Migrations
b.Property<string>("status") b.Property<string>("status")
.HasColumnType("longtext"); .HasColumnType("longtext");
b.HasKey("requestId"); b.HasKey("requestID");
b.HasIndex("ProductId"); b.HasIndex("ProductId");
@ -442,7 +442,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("UserId"); b.HasIndex("UserId");
b.ToTable("request", (string)null); b.ToTable("request");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b =>
@ -468,7 +468,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("StationPicID"); b.HasIndex("StationPicID");
b.ToTable("Stations", (string)null); b.ToTable("Stations");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b =>
@ -490,7 +490,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("CompanyId"); b.HasIndex("CompanyId");
b.ToTable("Stores", (string)null); b.ToTable("Stores");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b => modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
@ -520,7 +520,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasKey("SupplierId"); b.HasKey("SupplierId");
b.ToTable("Suppliers", (string)null); b.ToTable("Suppliers");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b => modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
@ -537,7 +537,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasKey("CompanyId"); b.HasKey("CompanyId");
b.ToTable("Companies", (string)null); b.ToTable("Companies");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b => modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
@ -563,7 +563,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasIndex("CompanyId"); b.HasIndex("CompanyId");
b.ToTable("Departments", (string)null); b.ToTable("Departments");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Models.ModuleSettingModel", b => modelBuilder.Entity("PSTW_CentralSystem.Models.ModuleSettingModel", b =>
@ -593,7 +593,7 @@ namespace PSTW_CentralSystem.Migrations
b.HasKey("SettingId"); b.HasKey("SettingId");
b.ToTable("ModuleSettings", (string)null); b.ToTable("ModuleSettings");
}); });
modelBuilder.Entity("PSTW_CentralSystem.Models.RoleModel", b => modelBuilder.Entity("PSTW_CentralSystem.Models.RoleModel", b =>
@ -754,16 +754,16 @@ namespace PSTW_CentralSystem.Migrations
{ {
Id = 1, Id = 1,
AccessFailedCount = 0, AccessFailedCount = 0,
ConcurrencyStamp = "402e8e19-59a4-4fae-8ffe-4d935bcb1104", ConcurrencyStamp = "d801514b-2c36-4df7-9bb5-1c7e351ed27e",
Email = "admin@pstw.com.my", Email = "admin@pstw.com.my",
EmailConfirmed = true, EmailConfirmed = true,
FullName = "MAAdmin", FullName = "MAAdmin",
LockoutEnabled = false, LockoutEnabled = false,
NormalizedEmail = "ADMIN@PSTW.COM.MY", NormalizedEmail = "ADMIN@PSTW.COM.MY",
NormalizedUserName = "ADMIN@PSTW.COM.MY", NormalizedUserName = "ADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEM22wL5Kx9mwPIJilJAgzudLHg+HduDhJaq+BjD3jh5bqPzi+OnTzAEN49l1IeBqcw==", PasswordHash = "AQAAAAIAAYagAAAAEBSoDiGEYlobLgzVcffYwvTtm1WnXpqrBBT1yYP+kruV4OTtizW7Sel94qAfqUjGcw==",
PhoneNumberConfirmed = false, PhoneNumberConfirmed = false,
SecurityStamp = "4a127c4f-3199-4037-8c02-0a21b750351b", SecurityStamp = "6132b0af-6a7f-4f38-8959-d049ed486e8f",
TwoFactorEnabled = false, TwoFactorEnabled = false,
UserInfoStatus = 1, UserInfoStatus = 1,
UserName = "admin@pstw.com.my" UserName = "admin@pstw.com.my"
@ -772,16 +772,16 @@ namespace PSTW_CentralSystem.Migrations
{ {
Id = 2, Id = 2,
AccessFailedCount = 0, AccessFailedCount = 0,
ConcurrencyStamp = "05ebfe99-3f46-43b8-9aaa-e01c5bb31a86", ConcurrencyStamp = "14f11e89-bb92-49dd-a8df-ec5b0d49df2d",
Email = "sysadmin@pstw.com.my", Email = "sysadmin@pstw.com.my",
EmailConfirmed = true, EmailConfirmed = true,
FullName = "SysAdmin", FullName = "SysAdmin",
LockoutEnabled = false, LockoutEnabled = false,
NormalizedEmail = "SYSADMIN@PSTW.COM.MY", NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
NormalizedUserName = "SYSADMIN@PSTW.COM.MY", NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
PasswordHash = "AQAAAAIAAYagAAAAEF3NUsfCVQ3KOv0uND7ech54XBz7+ffJ5x1YYuN0eaBciYQ/K2Jlah/KQR19ykaHbQ==", PasswordHash = "AQAAAAIAAYagAAAAEEvcS1SY+9pxZKH/P1l4TaodgW3SFSRfcZ+PnjB3MiMmEUSyYoo64AQtX0bOxFSX2g==",
PhoneNumberConfirmed = false, PhoneNumberConfirmed = false,
SecurityStamp = "42178537-99cc-4701-a488-8f1c0e774855", SecurityStamp = "6dca2498-5150-4369-9923-6f19a48258d4",
TwoFactorEnabled = false, TwoFactorEnabled = false,
UserInfoStatus = 1, UserInfoStatus = 1,
UserName = "sysadmin@pstw.com.my" UserName = "sysadmin@pstw.com.my"