Item Movement User
This commit is contained in:
parent
dd23c13644
commit
ce941d5d53
@ -7,7 +7,8 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
|
||||
public class RequestModel
|
||||
{
|
||||
[Key]
|
||||
public int requestId { get; set; }
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int requestID { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual ProductModel? Product { get; set; }
|
||||
|
||||
@ -472,7 +472,8 @@
|
||||
<div class="row">
|
||||
<div class="col-md-4 text-center">
|
||||
<!-- 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>
|
||||
<p><strong>Start</strong></p>
|
||||
<p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
|
||||
|
||||
@ -191,7 +191,7 @@
|
||||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
requestId : null,
|
||||
requestID : null,
|
||||
userId : null,
|
||||
stationId : "",
|
||||
productId : "",
|
||||
@ -288,11 +288,12 @@
|
||||
UserId: this.userId,
|
||||
ProductCategory: this.productCategory,
|
||||
RequestQuantity: this.quantity,
|
||||
remark: this.remark || '',
|
||||
remarkUser: this.remark || '',
|
||||
remarkMasterInv: '',
|
||||
status: this.status,
|
||||
requestDate: this.requestDate,
|
||||
approvalDate: this.approvalDate ? this.approvalDate : null,
|
||||
document: this.document
|
||||
approvalDate: null,
|
||||
Document: this.document
|
||||
};
|
||||
|
||||
$('.modal').modal('hide');
|
||||
@ -330,7 +331,7 @@
|
||||
"columns": [
|
||||
{
|
||||
"title": "Request ID",
|
||||
"data": "requestId",
|
||||
"data": "requestID",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
// Assign a unique ID to the <td> element
|
||||
$(td).attr('id', `qr${cellData}`);
|
||||
@ -399,14 +400,14 @@
|
||||
},
|
||||
{
|
||||
"title": "Delete",
|
||||
"data": "requestId",
|
||||
"data": "requestID",
|
||||
"render": function (data) {
|
||||
var deleteButton = `<button type="button" class="btn btn-danger delete-btn" data-id="${data}">Delete</button>`;
|
||||
return deleteButton;
|
||||
},
|
||||
"className": "align-middle",
|
||||
// "title": "Delete",
|
||||
// "data": "requestId",
|
||||
// "data": "requestID",
|
||||
// "render": function (data, type, row) {
|
||||
// if (row.status === "Approved" || row.status === "Rejected") {
|
||||
// return `<button type="button" class="btn btn-danger delete-btn" data-id="${data}" disabled>Delete</button>`;
|
||||
@ -425,7 +426,7 @@
|
||||
"columns": [
|
||||
{
|
||||
"title": "Request ID",
|
||||
"data": "requestId",
|
||||
"data": "requestID",
|
||||
"createdCell": function (td, cellData, rowData, row, col) {
|
||||
// Assign a unique ID to the <td> element
|
||||
$(td).attr('id', `qr${cellData}`);
|
||||
@ -506,8 +507,8 @@
|
||||
$('#requestDatatable tbody').off('click', '.delete-btn');
|
||||
|
||||
$('#requestDatatable tbody').on('click', '.delete-btn', function () {
|
||||
const requestId = $(this).data('id');
|
||||
self.deleteRequestItem(requestId);
|
||||
const requestID = $(this).data('id');
|
||||
self.deleteRequestItem(requestID);
|
||||
});
|
||||
|
||||
|
||||
@ -623,12 +624,12 @@
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
async deleteRequestItem(requestId) {
|
||||
async deleteRequestItem(requestID) {
|
||||
if (!confirm("Are you sure you want to delete this request?")) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(`/InvMainAPI/DeleteRequest/${requestId}`, {
|
||||
const response = await fetch(`/InvMainAPI/DeleteRequest/${requestID}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -641,10 +642,10 @@
|
||||
|
||||
if ($.fn.dataTable.isDataTable('#requestDatatable')) {
|
||||
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 {
|
||||
alert(result.message);
|
||||
}
|
||||
|
||||
@ -852,13 +852,13 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
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);
|
||||
string filePath = "";
|
||||
@ -891,7 +891,20 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
.Where(r => r.UserId == request.UserId)
|
||||
.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)
|
||||
{
|
||||
@ -929,7 +942,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
|
||||
return Json(requests.Select(i => new
|
||||
{
|
||||
i.requestId,
|
||||
i.requestID,
|
||||
i.ProductId,
|
||||
productName = i.Product?.ProductName,
|
||||
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();
|
||||
return Json(itemRequestList.Select(i => new
|
||||
{
|
||||
i.requestId,
|
||||
i.requestID,
|
||||
productName = i.Product?.ProductName,
|
||||
i.ProductId,
|
||||
userName = i.User?.FullName,
|
||||
|
||||
1053
Migrations/20250306041117_UpdateRequestTable.Designer.cs
generated
Normal file
1053
Migrations/20250306041117_UpdateRequestTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
63
Migrations/20250306041117_UpdateRequestTable.cs
Normal file
63
Migrations/20250306041117_UpdateRequestTable.cs
Normal 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" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,7 +150,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
b.HasIndex("UserId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("InventoryMasters", (string)null);
|
||||
b.ToTable("InventoryMasters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemModel", b =>
|
||||
@ -251,7 +251,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("Items", (string)null);
|
||||
b.ToTable("Items");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ItemMovementModel", b =>
|
||||
@ -332,7 +332,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("ToUser");
|
||||
|
||||
b.ToTable("ItemMovements", (string)null);
|
||||
b.ToTable("ItemMovements");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ManufacturerModel", b =>
|
||||
@ -349,7 +349,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasKey("ManufacturerId");
|
||||
|
||||
b.ToTable("Manufacturers", (string)null);
|
||||
b.ToTable("Manufacturers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.ProductModel", b =>
|
||||
@ -390,16 +390,16 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("ManufacturerId");
|
||||
|
||||
b.ToTable("Products", (string)null);
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.RequestModel", b =>
|
||||
{
|
||||
b.Property<int>("requestId")
|
||||
b.Property<int>("requestID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("requestId"));
|
||||
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("requestID"));
|
||||
|
||||
b.Property<string>("Document")
|
||||
.HasColumnType("longtext");
|
||||
@ -434,7 +434,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
b.Property<string>("status")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("requestId");
|
||||
b.HasKey("requestID");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
@ -442,7 +442,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("request", (string)null);
|
||||
b.ToTable("request");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StationModel", b =>
|
||||
@ -468,7 +468,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("StationPicID");
|
||||
|
||||
b.ToTable("Stations", (string)null);
|
||||
b.ToTable("Stations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.StoreModel", b =>
|
||||
@ -490,7 +490,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("Stores", (string)null);
|
||||
b.ToTable("Stores");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Areas.Inventory.Models.SupplierModel", b =>
|
||||
@ -520,7 +520,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasKey("SupplierId");
|
||||
|
||||
b.ToTable("Suppliers", (string)null);
|
||||
b.ToTable("Suppliers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.CompanyModel", b =>
|
||||
@ -537,7 +537,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasKey("CompanyId");
|
||||
|
||||
b.ToTable("Companies", (string)null);
|
||||
b.ToTable("Companies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.DepartmentModel", b =>
|
||||
@ -563,7 +563,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasIndex("CompanyId");
|
||||
|
||||
b.ToTable("Departments", (string)null);
|
||||
b.ToTable("Departments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.ModuleSettingModel", b =>
|
||||
@ -593,7 +593,7 @@ namespace PSTW_CentralSystem.Migrations
|
||||
|
||||
b.HasKey("SettingId");
|
||||
|
||||
b.ToTable("ModuleSettings", (string)null);
|
||||
b.ToTable("ModuleSettings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PSTW_CentralSystem.Models.RoleModel", b =>
|
||||
@ -754,16 +754,16 @@ namespace PSTW_CentralSystem.Migrations
|
||||
{
|
||||
Id = 1,
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "402e8e19-59a4-4fae-8ffe-4d935bcb1104",
|
||||
ConcurrencyStamp = "d801514b-2c36-4df7-9bb5-1c7e351ed27e",
|
||||
Email = "admin@pstw.com.my",
|
||||
EmailConfirmed = true,
|
||||
FullName = "MAAdmin",
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "ADMIN@PSTW.COM.MY",
|
||||
NormalizedUserName = "ADMIN@PSTW.COM.MY",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAEM22wL5Kx9mwPIJilJAgzudLHg+HduDhJaq+BjD3jh5bqPzi+OnTzAEN49l1IeBqcw==",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAEBSoDiGEYlobLgzVcffYwvTtm1WnXpqrBBT1yYP+kruV4OTtizW7Sel94qAfqUjGcw==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "4a127c4f-3199-4037-8c02-0a21b750351b",
|
||||
SecurityStamp = "6132b0af-6a7f-4f38-8959-d049ed486e8f",
|
||||
TwoFactorEnabled = false,
|
||||
UserInfoStatus = 1,
|
||||
UserName = "admin@pstw.com.my"
|
||||
@ -772,16 +772,16 @@ namespace PSTW_CentralSystem.Migrations
|
||||
{
|
||||
Id = 2,
|
||||
AccessFailedCount = 0,
|
||||
ConcurrencyStamp = "05ebfe99-3f46-43b8-9aaa-e01c5bb31a86",
|
||||
ConcurrencyStamp = "14f11e89-bb92-49dd-a8df-ec5b0d49df2d",
|
||||
Email = "sysadmin@pstw.com.my",
|
||||
EmailConfirmed = true,
|
||||
FullName = "SysAdmin",
|
||||
LockoutEnabled = false,
|
||||
NormalizedEmail = "SYSADMIN@PSTW.COM.MY",
|
||||
NormalizedUserName = "SYSADMIN@PSTW.COM.MY",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAEF3NUsfCVQ3KOv0uND7ech54XBz7+ffJ5x1YYuN0eaBciYQ/K2Jlah/KQR19ykaHbQ==",
|
||||
PasswordHash = "AQAAAAIAAYagAAAAEEvcS1SY+9pxZKH/P1l4TaodgW3SFSRfcZ+PnjB3MiMmEUSyYoo64AQtX0bOxFSX2g==",
|
||||
PhoneNumberConfirmed = false,
|
||||
SecurityStamp = "42178537-99cc-4701-a488-8f1c0e774855",
|
||||
SecurityStamp = "6dca2498-5150-4369-9923-6f19a48258d4",
|
||||
TwoFactorEnabled = false,
|
||||
UserInfoStatus = 1,
|
||||
UserName = "sysadmin@pstw.com.my"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user