This commit is contained in:
ArifHilmi 2025-03-03 15:56:31 +08:00
parent b7ec8ab7af
commit eba3f6c5c4
11 changed files with 337 additions and 140 deletions

View File

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using PSTW_CentralSystem.Models;
namespace PSTW_CentralSystem.Areas.Inventory.Models
{
public class ProductModel

View File

@ -11,7 +11,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public int ProductId { get; set; }
[ForeignKey("ProductId")]
public virtual ProductModel? Product { get; set; }
public int StationId { get; set; }
public int? StationId { get; set; }
[ForeignKey("StationId")]
public virtual StationModel? Station { get; set; }
public int UserId { get; set; }
@ -23,7 +23,7 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public string? status { get; set; }
public DateTime requestDate { get; set; }
public DateTime? approvalDate { get; set; }
public int RequestQuantity { get; set; }
public int? RequestQuantity { get; set; }
public string? Document { get; set; }
}

View File

@ -78,12 +78,14 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label">Product</label>
<div class="col-sm-8">
<select class="btn btn-primary form-select" v-model="productId" required>
<option class="btn-light" value="" disabled selected>Select Product</option>
<option class="btn-light" v-for="(item, index) in products" :key="index" :value="item.productId">
{{ item.productName + ' (' + item.modelNo + ')' }}
</option>
</select>
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" data-toggle="dropdown" aria-expanded="false" v-model="productId" required>
<option class="btn-light" value="" disabled selected>Select Product</option>
<option class="btn-light" v-for="(item, index) in products" :key="index" :value="item.productId">
{{ item.productName + ' (' + item.modelNo + ')' }}
</option>
</select>
</div>
</div>
</div>
@ -91,12 +93,7 @@
<div class="form-group row">
<label class="col-sm-4 col-form-label">Category:</label>
<div class="col-sm-8">
<div class="">
<select class="btn btn-primary form-select" v-model="productCategory" required>
<option class="btn-light" value="" selected disabled>Select Category</option>
<option class="btn-light" v-for="(item, index) in categories" :key="item" :value="item">{{ item ?? 'Select Category' }}</option>
</select>
</div>
<input type="text" id="category" name="category" v-model="showProduct.category" class="form-control" readonly />
</div>
</div>
@ -108,16 +105,31 @@
</div>
</div>
<!-- Station Dropdown -->
@* Who will assign to *@
<div class="form-group row">
<label class="col-sm-4 col-form-label">Item Assignment : </label>
<div class="col-sm-8">
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" v-model="assign"required>
<option class="btn-light" value="" selected disabled>Select Assignment Type</option>
<option class="btn-light" v-for="(item, index) in assigns" :key="item" :value="item">{{ item ?? 'Select Assignment Type' }}</option>
</select>
</div>
</div>
</div>
<!-- Station Dropdown -->
<div class="form-group row" v-if="assign === 'Station'">
<label class="col-sm-4 col-form-label">Station:</label>
<div class="col-sm-8">
<select class="btn btn-primary form-select" v-model="stationId" required>
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(item, index) in stations" :key="index" :value="item.stationId">
{{ item.stationName }}
</option>
</select>
<div class="dropdown">
<select class="btn btn-primary dropdown-toggle col-md-12" data-toggle="dropdown" aria-expanded="false" v-model="stationId" required>
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(item, index) in stations" :key="index" :value="item.stationId">
{{ item.stationName }}
</option>
</select>
</div>
</div>
</div>
@ -180,8 +192,8 @@
return {
requestId : null,
userId : null,
stationId : null,
productId : null,
stationId : "",
productId : "",
remark: "",
document: null,
quantity: 0,
@ -189,14 +201,14 @@
requestDate : null,
approvalDate : null,
productCategory: "",
assign: "",
productName: null,
productCategory: null,
stations: [],
selectedProduct: "",
selectedStation: "",
selectedCategory: "",
categories: ["Asset", "Part", "Disposable"],
assigns: ["Self-Assign", "Station"],
showRequestModal: false,
loading: false,
products: [],
@ -213,12 +225,14 @@
]);
},
computed: {
showProduct() {
if (!this.selectedProduct) {
if (!this.productId) {
return []; // No company selected, return empty list
}
const product = this.products.find(c => c.productId === this.selectedProduct);
const product = this.products.find(c => c.productId === this.productId);
this.productCategory = product.category;
return product ? product : {};
},
},
@ -238,7 +252,7 @@
},
async addRequest() {
try {
const requiredFields = ['stationId', 'productId', 'quantity', 'productCategory'];
const requiredFields = ['productId', 'quantity', 'assign'];
// Loop through required fields and check if any are null or empty
for (let field of requiredFields) {
@ -248,6 +262,17 @@
}
}
if (this.assign === "Station"){
if (this.stationId == null) {
alert('Request Error', `Please fill in required fields : Station.`, 'warning');
return;
}
}
if (this.assign === "Self-Assign"){
this.stationId = null;
}
this.userId = this.currentUser.id;
this.status = "Requested";
@ -356,6 +381,13 @@
"title": "Remark",
"data": "remarkUser",
},
{
"title": "Station Deploy",
"data": "stationName",
"render": function (data, type, full, meta) {
return data ? data : "Self Assign";
}
},
{
"title": "Request Date",
"data": "requestDate",
@ -410,6 +442,13 @@
"title": "Request Quantity",
"data": "requestQuantity",
},
{
"title": "Station Deploy",
"data": "stationName",
"render": function (data, type, full, meta) {
return data ? data : "Self Assign";
}
},
{
"title": "Document / Picture",
"data": "document",
@ -562,8 +601,8 @@
},
resetForm() {
this.stationId = null;
this.productId = null;
this.stationId = "";
this.productId = "";
this.remark = "";
this.document = null;
this.quantity = 0;
@ -571,9 +610,9 @@
this.requestDate = null;
this.approvalDate = null;
this.productCategory = "";
this.assign = "",
this.productName = null;
this.productCategory = null;
this.selectedProduct = "";
this.selectedStation = "";
this.selectedCategory = "";
@ -615,6 +654,7 @@
this.loading = false;
}
},
},
});
</script>

View File

@ -53,11 +53,22 @@
</div>
<!--RECEIVE OR RETURN INTERFACE -->
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived'">
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem.currentStationId != null">
<h2>Item Receive Information :</h2>
<h3>Station Assign</h3>
</div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return'">
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem.currentStationId == null">
<h2>Item Receive Information :</h2>
<h3>Self Assign</h3>
</div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return' && thisItem.currentStationId != null">
<h2>Item Return Information :</h2>
<h3>Station</h3>
</div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'return' && thisItem.currentStationId == null">
<h2>Item Return Information :</h2>
<h3>Self Assign</h3>
</div>
<div v-if="displayStatus === 'arrived' || displayStatus === 'return'" style="display: flex; justify-content: center; align-items: center;">
@ -102,7 +113,7 @@
<div class="col-12 mb-3">
<p class="h5 fw-bold">
<i class="fas fa-user-tie me-2 text-secondary"></i>PIC:
<span class="text-muted">Station PIC</span>
<span class="text-muted">{{thisItem.currentStation || 'No Station Deploy (Self Assign)' }}</span>
</p>
</div>
@ -126,21 +137,13 @@
</div>
</li>
<!-- Store -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="mdi mdi-factory me-2 text-secondary"></i>Store:
</span>
<span class="text-muted">{{ thisItem.currentStore }}</span>
</li>
<!-- Station -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station:
</span>
<span class="text-muted">{{ thisItem.currentStation || 'N/A' }}</span>
</li>
<!-- <li class="list-group-item d-flex justify-content-between align-items-center"> -->
<!-- <span class="fw-bold"> -->
<!-- <i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station: -->
<!-- </span> -->
<!-- <span class="text-muted">{{ thisItem.currentStation || 'N/A' }}</span> -->
<!-- </li> -->
</ul>
</div>
</div>
@ -166,21 +169,6 @@
</div>
</li>
<!-- Store -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="mdi mdi-factory me-2 text-secondary"></i>Store:
</span>
<span class="text-muted">{{ thisItem.toStoreName }}</span>
</li>
<!-- Station -->
<li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold">
<i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station:
</span>
<span class="text-muted">{{ thisItem.toStationName || 'N/A' }}</span>
</li>
</ul>
</div>
</div>
@ -200,32 +188,15 @@
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<br><br>
<h3 style="text-align: center; margin: 20px 0; padding: 20px;" class="register-heading" style="margin: auto">Station Deploy :</h3>
<div class="row register-form">
<div class="col-md-3"></div>
<div class="col-md-6">
<!-- Station Dropdown -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Deploy Station : </label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation">
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select>
</div>
</div>
</div>
@* Submit and Reset Buttons *@
<div class="form-group row">
<div class="col-sm-8 offset-sm-3">
<button type="button" v-on:click="receiveReturnMessage" class="btn btn-secondary m-1">Return Item</button>
<button type="submit" class="btn btn-primary m-1">Receive Item</button>
</div>
@* Submit and Reset Buttons *@
<div class="form-group row">
<div class="col-sm-8 offset-sm-3">
<button type="button" v-on:click="ReturnMessage" class="btn btn-secondary m-1">Return Item</button>
<button type="submit" class="btn btn-primary m-1">Receive Item</button>
</div>
</div>
</div>
</div>
</div>
@ -235,7 +206,7 @@
</form>
<!--RETURN INTERFACE -->
<form v-on:submit.prevent="returnItemMovement" v-if="displayStatus === 'return'" data-aos="fade-right">
<form v-on:submit.prevent="" v-if="displayStatus === 'return'" data-aos="fade-right">
<div class=" register" data-aos="fade-right">
<div class="row" data-aos="fade-right">
@ -244,35 +215,14 @@
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<br><br>
<h3 style="text-align: center; margin: 20px 0; padding: 20px;" class="register-heading" style="margin: auto">Station Deploy :</h3>
<div class="row register-form">
<div class="col-md-3"></div>
<div class="col-md-6">
<!-- Remark Input -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Remark : </label>
<div class="col-sm-8">
<input type="text" class="form-control col-md-10" v-model="remark" />
</div>
</div>
<!-- Consignment Note input -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Consignment Note : </label>
<div class="col-sm-8">
<input type="file" v-on:change="handleFileUpload" class="form-control-file" accept="image/png, image/jpeg, application/pdf" />
</div>
</div>
</div>
@* Submit and Reset Buttons *@
<div class="form-group row">
<div class="col-sm-8 offset-sm-3">
<button type="submit" class="btn btn-primary m-1">Return Item</button>
</div>
@* Submit and Reset Buttons *@
<div class="form-group row">
<div class="col-sm-8 offset-sm-3">
<button type="submit" v-on:click="ReturnMessage" class="btn btn-primary m-1">Return Item</button>
<button type="submit" v-on:click="StationMessage" class="btn btn-primary m-1" v-if="thisItem.currentStationId == null">Deploy Station</button>
</div>
</div>
</div>
</div>
</div>
@ -280,6 +230,68 @@
</div>
</form>
<!--STATION DEPLOY MESSAGE BOX INTERFACE-->
<div class="modal fade" id="stationMessage" tabindex="-1" role="dialog" aria-labelledby="stationModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="stationModalLabel">Deploy Station</h5>
<button type="button" class="close" data-dismiss="modal" v-on:click="closeStationMessageModal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form v-on:submit.prevent="updateStationItemMovement">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Deploy Station : </label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation">
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select>
</div>
</div>
<button type="submit" class="btn btn-primary">Deploy Station</button>
</form>
</div>
</div>
</div>
</div>
<!--RETURN MESSAGE BOX INTERFACE-->
<div class="modal fade" id="returnMessage" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="returnModalLabel">Return Item</h5>
<button type="button" class="close" data-dismiss="modal" v-on:click="closeMessageModal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form v-on:submit.prevent="returnItemMovement">
<div class="form-group row">
<label class="col-sm-4 col-form-label">Remark:</label>
<div class="col-sm-8">
<input type="text" class="form-control" v-model="remark" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Consignment Note:</label>
<div class="col-sm-8">
<input type="file" class="form-control-file" v-on:change="handleFileUpload" accept="image/png, image/jpeg, application/pdf" />
</div>
</div>
<button type="submit" class="btn btn-primary">Return Item</button>
</form>
</div>
</div>
</div>
</div>
<!--RECEIVE THEN RETURN INTERFACE -->
<div class="modal fade" id="returnModal" tabindex="-1" role="dialog" aria-labelledby="returnModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
@ -293,17 +305,6 @@
<div class="modal-body">
<form v-on:submit.prevent="receiveReturnAPI">
<!-- Station Dropdown -->
<div class="form-group row">
<label class="col-sm-4 col-form-label">Deploy Station : </label>
<div class="col-sm-8">
<select class="btn btn-primary dropdown-toggle col-md-10" v-model="selectedStation">
<option class="btn-light" value="" disabled selected>Select Station</option>
<option class="btn-light" v-for="(station, index) in stationList" :key="index" :value="station.stationId">{{ station.stationName}}</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4 col-form-label">Remark:</label>
<div class="col-sm-8">
@ -418,8 +419,8 @@
this.consignmentNote = null;
}
},
async updateItemMovement() {
async updateStationItemMovement() {
const requiredFields = ['selectedStation'];
for (let field of requiredFields) {
@ -429,6 +430,52 @@
}
}
try {
const now = new Date();
const formData = {
ItemId: this.thisItem.itemID,
ToStation: this.thisItem.currentStationId,
ToStore: this.thisItem.currentStoreId,
ToUser: this.currentUserId,
ToOther: "Delivered",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Action: "Assign",
Quantity: this.thisItem.quantity,
Remark: this.remark,
ConsignmentNote: this.consignmentNote,
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LastUser: this.currentUserId,
LastStore: this.thisItem.currentStoreId,
LastStation: this.selectedStation,
LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true,
};
const response = await fetch('/InvMainAPI/StationItemMovementUser', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(formData)
});
if (response.ok) {
alert('Success! Item assign to the Station.');
$('#stationMessage').modal('hide');
this.displayStatus = "return";
this.thisItem = await response.json();
} else {
throw new Error('Failed to submit form.');
}
} catch (error) {
console.error('Error:', error);
alert('Inventory PSTW Error: An error occurred.');
}
},
async updateItemMovement() {
if (this.receiveReturn == null) {
if (!confirm("Are you sure you already received this item?")) {
return false;
@ -438,8 +485,7 @@
try {
const now = new Date();
const formData = {
Id: this.thisItem.movementId,
LastStation: this.selectedStation,
Id : this.thisItem.id,
LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true
@ -471,6 +517,7 @@
alert('Inventory PSTW Error: An error occurred.');
}
},
async returnItemMovement() {
const requiredFields = ['remark', 'consignmentNote'];
@ -542,7 +589,7 @@
if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus == null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.movementComplete == 0) {
this.displayStatus = "arrived";
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "On Delivery" && this.thisItem.latestStatus != null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.latestStatus != "Ready To Deploy") {
} else if (this.thisItem.movementId != null && this.thisItem.latestStatus != null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.latestStatus != "Ready To Deploy") {
this.displayStatus = "return";
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "Return" && this.thisItem.latestStatus == null && this.thisItem.toUser == this.currentUserId) {
this.displayStatus = "requestAgain";
@ -697,6 +744,22 @@
closeModal() {
$('#returnModal').modal('hide'); // Manually hide the modal
},
ReturnMessage() {
$("#returnMessage").modal("show");
},
closeMessageModal() {
$('#returnMessage').modal('hide'); // Manually hide the modal
},
StationMessage() {
$("#stationMessage").modal("show");
},
closeStationMessageModal() {
$('#stationMessage').modal('hide'); // Manually hide the modal
},
},
});
app.component("qrcode-stream", VueQrcodeReader.QrcodeStream);

View File

@ -496,6 +496,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
}
var singleItem = new
{
item.Movement?.Id,
item.ItemID,
item.MovementId,
item.UniqueID,
@ -852,20 +853,24 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{
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 = "";
string uniqueName = $"{request.ProductId}_{Guid.NewGuid()}";
var uniqueAbjad = new string(Enumerable.Range(0, 8).Select(_ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[new Random().Next(36)]).ToArray());
if (IsImage(bytes))
{
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + request.UserId + "_Request.jpg");
request.Document = "/media/inventory/request/" + uniqueName + request.UserId + "_Request.jpg";
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.jpg");
request.Document = "/media/inventory/request/" + findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.jpg";
}
else if (IsPdf(bytes))
{
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + request.UserId + "_Request.pdf");
request.Document = "/media/inventory/request/" + uniqueName + request.UserId + "_Request.pdf";
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "_Request.pdf");
request.Document = "/media/inventory/request/" + findUniqueUser.FullName + " " + findUniqueCode.ModelNo + "(" + uniqueAbjad + ") Request.pdf";
}
else
{
@ -916,16 +921,17 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
public async Task<IActionResult> ItemRequestListEachUser(int userId)
{
var requests = await _centralDbContext.Requests
.Include(i => i.Product).Where(r => r.UserId == userId).ToListAsync();
.Include(i => i.Product).Include(i => i.Station).Where(r => r.UserId == userId).ToListAsync();
return Json(requests.Select(i => new
{
i.requestId,
productName = i.Product?.ProductName,
i.ProductId,
productName = i.Product?.ProductName,
i.UserId,
i.status,
i.StationId,
stationName = i.Station?.StationName,
i.RequestQuantity,
i.requestDate,
i.ProductCategory,
@ -1193,7 +1199,6 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return NotFound("Item movement record not found.");
}
updatedList.LastStation = receiveMovement.LastStation;
updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.MovementComplete = receiveMovement.MovementComplete;
@ -1306,6 +1311,95 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return BadRequest(ex.Message);
}
}
[HttpPost("StationItemMovementUser")]
public async Task<IActionResult> StationItemMovementUser([FromBody] ItemMovementModel stationMovement)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
try
{
if (!string.IsNullOrEmpty(stationMovement.ConsignmentNote))
{
var bytes = Convert.FromBase64String(stationMovement.ConsignmentNote);
string filePath = "";
string uniqueName = $"{stationMovement.Id}_{Guid.NewGuid()}";
if (IsImage(bytes))
{
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + stationMovement.ItemId + "_Request.jpg");
stationMovement.ConsignmentNote = "/media/inventory/request/" + uniqueName + stationMovement.ItemId + "_Request.jpg";
}
else if (IsPdf(bytes))
{
filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/media/inventory/request", uniqueName + stationMovement.ItemId + "_Request.pdf");
stationMovement.ConsignmentNote = "/media/inventory/request/" + uniqueName + stationMovement.ItemId + "_Request.pdf";
}
else
{
return BadRequest("Unsupported file format.");
}
await System.IO.File.WriteAllBytesAsync(filePath, bytes);
}
// 1. Simpan returnMovement dalam database
_centralDbContext.ItemMovements.Add(stationMovement);
await _centralDbContext.SaveChangesAsync();
// 2. Cari item movement yang ada ItemId & MovementComplete = false
var updateItemIdMovement = await _centralDbContext.ItemMovements
.FirstOrDefaultAsync(m => m.Id == stationMovement.Id);
// 3. Jika wujud, update MovementId
if (updateItemIdMovement != null)
{
var returnItems = await _centralDbContext.Items.FindAsync(updateItemIdMovement.ItemId);
if (returnItems != null)
{
returnItems.MovementId = updateItemIdMovement.Id;
returnItems.ItemStatus = 3;
_centralDbContext.Items.Update(returnItems);
await _centralDbContext.SaveChangesAsync(); // Simpan perubahan
}
}
return Json(new
{
updateItemIdMovement.Id,
updateItemIdMovement.ItemId,
updateItemIdMovement.ToStation,
updateItemIdMovement.ToStore,
updateItemIdMovement.ToUser,
updateItemIdMovement.ToOther,
updateItemIdMovement.sendDate,
updateItemIdMovement.Action,
updateItemIdMovement.Quantity,
updateItemIdMovement.Remark,
updateItemIdMovement.ConsignmentNote,
updateItemIdMovement.Date,
updateItemIdMovement.LastUser,
updateItemIdMovement.LastStore,
updateItemIdMovement.LastStation,
updateItemIdMovement.LatestStatus,
updateItemIdMovement.receiveDate,
updateItemIdMovement.MovementComplete
});
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
}
#endregion
}
}

View File

@ -4,7 +4,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://192.168.11.127:26468",
"applicationUrl": "http://localhost:26468",
"sslPort": 44356
}
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB