initial itemmovement and initial itemrequest
This commit is contained in:
parent
f8ef2b449c
commit
5f4e8c6c22
@ -17,6 +17,16 @@ namespace PSTW_CentralSystem.Areas.Inventory.Controllers.Admin
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ItemMovement()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ItemRequest()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ProductRegistration()
|
||||
{
|
||||
return View();
|
||||
|
||||
1204
Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml
Normal file
1204
Areas/Inventory/Views/InventoryMaster/ItemMovement.cshtml
Normal file
File diff suppressed because it is too large
Load Diff
1204
Areas/Inventory/Views/InventoryMaster/ItemRequest.cshtml
Normal file
1204
Areas/Inventory/Views/InventoryMaster/ItemRequest.cshtml
Normal file
File diff suppressed because it is too large
Load Diff
@ -48,4 +48,30 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6 col-md-6 col-lg-3">
|
||||
<div class="card card-hover">
|
||||
<a asp-area="Inventory" asp-controller="InventoryMaster" asp-action="ItemMovement">
|
||||
<div class="box bg-success text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-checkbox-multiple-blank-circle"></i>
|
||||
</h1>
|
||||
<h6 class="text-white">Item Movement</h6>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6 col-md-6 col-lg-3">
|
||||
<div class="card card-hover">
|
||||
<a asp-area="Inventory" asp-controller="InventoryMaster" asp-action="ItemRequest">
|
||||
<div class="box bg-success text-center">
|
||||
<h1 class="font-light text-white">
|
||||
<i class="mdi mdi-checkbox-multiple-blank-circle"></i>
|
||||
</h1>
|
||||
<h6 class="text-white">Item Request</h6>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -518,6 +518,115 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
|
||||
|
||||
#endregion Item
|
||||
|
||||
#region ItemMovement
|
||||
|
||||
[HttpPost("ItemMovementList")]
|
||||
public async Task<IActionResult> ItemMovementList()
|
||||
{
|
||||
|
||||
var itemMovementList = await _centralDbContext.ItemMovements.ToListAsync();
|
||||
Console.WriteLine(Json(itemMovementList));
|
||||
return Json(itemMovementList);
|
||||
|
||||
|
||||
//try
|
||||
//{
|
||||
// var user = await _userManager.GetUserAsync(User);
|
||||
// if (user == null)
|
||||
// {
|
||||
// return BadRequest("User not found");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// user.departmentId = user.departmentId != null ? user.departmentId : 0;
|
||||
// }
|
||||
|
||||
// var userRole = await _userManager.GetRolesAsync(user);
|
||||
// var isAdmin = userRole.Contains("SystemAdmin") || userRole.Contains("SuperAdmin") || userRole.Contains("Finance");
|
||||
// List<ItemModel> itemList = new List<ItemModel>();
|
||||
// // Get the item list
|
||||
// if (isAdmin)
|
||||
// {
|
||||
// itemList = await _centralDbContext.Items
|
||||
// .AsNoTracking()
|
||||
// .Include("CreatedBy")
|
||||
// .Include("Department")
|
||||
// .Include("Product")
|
||||
// .Include(i => i.Movement)
|
||||
// .ThenInclude(m => m!.FromStore)
|
||||
// .Include(i => i.Movement)
|
||||
// .ThenInclude(m => m!.FromStation)
|
||||
// .Include(i => i.Movement)
|
||||
// .ThenInclude(m => m!.FromUser)
|
||||
// .ToListAsync();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// itemList = await _centralDbContext.Items
|
||||
// .AsNoTracking()
|
||||
// .Include("CreatedBy")
|
||||
// .Include("Department")
|
||||
// .Include("Product")
|
||||
// .Include(i => i.Movement)
|
||||
// .ThenInclude(m => m!.FromStore)
|
||||
// .Include(i => i.Movement)
|
||||
// .ThenInclude(m => m!.FromStation)
|
||||
// .Include(i => i.Movement)
|
||||
// .ThenInclude(m => m!.FromUser)
|
||||
// .Where(i => i.DepartmentId == user.departmentId)
|
||||
// .ToListAsync();
|
||||
// }
|
||||
|
||||
// // Get the departments list (DepartmentId references Departments)
|
||||
// var departments = await _centralDbContext.Departments.ToListAsync();
|
||||
|
||||
// // Now join items with users and departments manually
|
||||
// var itemListWithDetails = itemList.Select(item => 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,
|
||||
// item.PartNumber,
|
||||
// EndWDate = item.EndWDate.ToString("dd/MM/yyyy"),
|
||||
// InvoiceDate = item.InvoiceDate?.ToString("dd/MM/yyyy"),
|
||||
// item.Department?.DepartmentName,
|
||||
// CreatedBy = item.CreatedBy!.UserName,
|
||||
// item.Product!.ProductName,
|
||||
// item.Product!.ProductShortName,
|
||||
// item.Product!.Category,
|
||||
// //CurrentUser = item.Movement?.FromUser?.UserName,
|
||||
// CurrentUser = item.Movement?.FromUser?.UserName,
|
||||
// CurrentStore = item.Movement?.FromStore?.StoreName,
|
||||
// CurrentStation = item.Movement?.FromStation?.StationName,
|
||||
|
||||
// QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}" // Generate QR String
|
||||
// }).ToList();
|
||||
|
||||
// return Json(itemListWithDetails);
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// return BadRequest(ex.Message);
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion ItemMovement
|
||||
|
||||
#region ItemReport
|
||||
|
||||
[HttpPost("GetInventoryReport/{deptId}")]
|
||||
|
||||
@ -145,6 +145,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p v-if="isAdmin">Welcome, Admin! You have full access.</p>
|
||||
<p v-else-if="userRole === 'user'">Welcome, User! You have limited access.</p>
|
||||
<p v-else>Guest View: Please log in.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -187,11 +193,13 @@
|
||||
return {
|
||||
thisItem: null,
|
||||
itemId: '@itemId',
|
||||
isAdmin: false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// Fetch companies, depts, and products from the API
|
||||
this.fetchItem();
|
||||
this.fetchUser();
|
||||
},
|
||||
methods: {
|
||||
async fetchItem() {
|
||||
@ -210,6 +218,35 @@
|
||||
console.error('Error fetching item information:', error);
|
||||
}
|
||||
},
|
||||
async fetchUser() {
|
||||
try {
|
||||
// var isAdmin = userRole.Contains("SystemAdmin") || userRole.Contains("SuperAdmin") || userRole.Contains("Finance");
|
||||
|
||||
const adminRoles = ["SystemAdmin", "SuperAdmin", "Finance"];
|
||||
|
||||
|
||||
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 || "";
|
||||
this.isAdmin = adminRoles.some(role => this.currentUser.role.includes(role));
|
||||
|
||||
}
|
||||
else {
|
||||
console.error(`Failed to fetch user: ${response.statusText}`);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user