update inv master > inv master , to/last

This commit is contained in:
Naz 2026-02-23 15:26:52 +08:00
parent b8540d6f0b
commit 2735cfdf99
7 changed files with 533 additions and 277 deletions

View File

@ -9,9 +9,9 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
[Key] [Key]
public int Id { get; set; } public int Id { get; set; }
public int? ItemId { get; set; } public int? ItemId { get; set; }
public int? ToStation { get; set; } public int? LastStation { get; set; }
public int? ToStore { get; set; } public int? LastStore { get; set; }
public int? ToUser { get; set; } public int? LastUser { get; set; }
[Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")] [Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")]
public string? ToOther { get; set; } public string? ToOther { get; set; }
public DateTime? sendDate { get; set; } public DateTime? sendDate { get; set; }
@ -21,15 +21,15 @@ namespace PSTW_CentralSystem.Areas.Inventory.Models
public string? Remark { get; set; } public string? Remark { get; set; }
public string? ConsignmentNote { get; set; } public string? ConsignmentNote { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public int? LastUser { get; set; } public int? ToUser { get; set; }
public int? LastStore{ get; set; } public int? ToStore{ get; set; }
public int? LastStation{ get; set; } public int? ToStation{ get; set; }
[Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")] [Comment("Repair, Calibration, Faulty, Ready To Deploy, On Delivery")]
public string? LatestStatus { get; set; } public string? LatestStatus { get; set; }
public DateTime? receiveDate { get; set; } public DateTime? receiveDate { get; set; }
public bool MovementComplete { get; set; } = false; public bool MovementComplete { get; set; } = false;
//public virtual ItemModel? Item { get; set; } //public virtual ItemModel? Item { get; set; }
//[ForeignKey("ToStore")] //[ForeignKey("LastStore")]
[ForeignKey("ItemId")] [ForeignKey("ItemId")]
public virtual ItemModel? Item { get; set; } public virtual ItemModel? Item { get; set; }
[ForeignKey("ToStore")] [ForeignKey("ToStore")]

View File

@ -228,12 +228,12 @@
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type --> <!-- Movement Type -->
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null, 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null,
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair', 'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
'text-weird': movement.action === 'Register'}" 'text-weird': movement.action === 'Register'}"
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
</h3> </h3>
@ -278,13 +278,13 @@
<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.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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><strong>User:</strong> {{ movement.toUserName }}</p> <p><strong>User:</strong> {{ movement.lastUserName }}</p>
<p><strong>Station:</strong> {{ movement.toStationName }}</p> <p><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p><strong>Store:</strong> {{ movement.toStoreName }}</p> <p><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
@ -303,13 +303,13 @@
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -327,13 +327,13 @@
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type --> <!-- Movement Type -->
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null, 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null,
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair', 'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
'text-weird': movement.action === 'Register'}" 'text-weird': movement.action === 'Register'}"
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' :
( movement.toStation !== null ? 'Change' : ( movement.lastStation !== null ? 'Change' :
( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther :
( movement.action == 'Register' ? 'Register' : 'Assign')))) }} ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
</h3> </h3>
@ -384,13 +384,13 @@
<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.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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><strong>User:</strong> {{ movement.toUserName }}</p> <p><strong>User:</strong> {{ movement.lastUserName }}</p>
<p><strong>Station:</strong> {{ movement.toStationName }}</p> <p><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p><strong>Store:</strong> {{ movement.toStoreName }}</p> <p><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
@ -409,13 +409,13 @@
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -458,12 +458,12 @@
<strong>Latest Movement</strong> <strong>Latest Movement</strong>
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null, 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null,
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair', 'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
'text-weird': movement.action === 'Register'}" 'text-weird': movement.action === 'Register'}"
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
</h3> </h3>
@ -506,13 +506,13 @@
<div v-show="detailsVisible[movement.id]" class="col-md-12 mt-2"> <div v-show="detailsVisible[movement.id]" class="col-md-12 mt-2">
<div class="row"> <div class="row">
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<i v-if="movement.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<i class="fas fa-arrow-right fa-2x"></i> <i class="fas fa-arrow-right fa-2x"></i>
@ -529,13 +529,13 @@
</p> </p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -552,12 +552,12 @@
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type --> <!-- Movement Type -->
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null, 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null,
'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair', 'text-numb': movement.toOther === 'Faulty' || movement.toOther === 'Calibration' || movement.toOther === 'Repair',
'text-weird': movement.action === 'Register'}" 'text-weird': movement.action === 'Register'}"
class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:140px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : ( movement.toOther == 'Faulty' || movement.toOther == 'Calibration' || movement.toOther == 'Repair' ? movement.toOther : ( movement.action == 'Register' ? 'Register' : 'Assign')))) }}
</h3> </h3>
@ -606,9 +606,9 @@
<i v-if="movement.toOther !== 'On Delivery'" class="fas fa-user fa-2x"></i> <i v-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.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
@ -627,13 +627,13 @@
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -741,7 +741,7 @@
selectedCompany: "", selectedCompany: "",
selectedDepartment: "", selectedDepartment: "",
selectedTeamType: "", selectedTeamType: "",
selectedtoStation: "", selectedlastStation: "",
consignmentNoteUrl: "", consignmentNoteUrl: "",
assignStationDatatable: null, assignStationDatatable: null,
showItemModal: false, showItemModal: false,
@ -844,7 +844,7 @@
if (movements.length > 0) { if (movements.length > 0) {
let latestMovement = movements[0]; let latestMovement = movements[0];
let station = latestMovement.lastStationName || latestMovement.toStationName || "Not Assigned"; let station = latestMovement.toStationName || latestMovement.lastStationName || "Not Assigned";
if (!groupedByStation[station]) { groupedByStation[station] = {}; } if (!groupedByStation[station]) { groupedByStation[station] = {}; }
@ -963,13 +963,13 @@
"columns": [ "columns": [
{ title: "Unique Id", data: "id" }, { title: "Unique Id", data: "id" },
{ title: "Product Code", data: "uniqueID" }, { title: "Product Code", data: "uniqueID" },
{ title: "From User", data: "toUserName" }, { title: "From User", data: "lastUserName" },
{ title: "Last User", data: "lastUserName" }, { title: "Last User", data: "toUserName" },
{ title: "Completion", data: "movementComplete", render: function (data) {return data ? "Completed" : "Pending";}}, { title: "Completion", data: "movementComplete", render: function (data) {return data ? "Completed" : "Pending";}},
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "Last Station", data: "lastStationName" }, { title: "Last Station", data: "toStationName" },
{ title: "From Store", data: "toStoreName" }, { title: "From Store", data: "lastStoreName" },
{ title: "Last Store", data: "lastStoreName" }, { title: "Last Store", data: "toStoreName" },
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "Start Status", data: "toOther" }, { title: "Start Status", data: "toOther" },
{ title: "Latest Status", data: "latestStatus" }, { title: "Latest Status", data: "latestStatus" },
@ -1063,10 +1063,10 @@
} else { } else {
const data = await response.json(); const data = await response.json();
this.items = data.filter(item => this.items = data.filter(item =>
item.toUser === this.currentUser.id ||
item.lastUser === this.currentUser.id || item.lastUser === this.currentUser.id ||
item.toStore === this.currentUser.store || item.toUser === this.currentUser.id ||
item.lastStore === this.currentUser.store item.lastStore === this.currentUser.store ||
item.toStore === this.currentUser.store
); );
this.initAllTables(); this.initAllTables();
@ -1163,10 +1163,10 @@
{ title: "Product Code", data: "uniqueID" }, { title: "Product Code", data: "uniqueID" },
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "Send Date", data: "sendDate" , render: this.formatDate.bind(this)}, { title: "Send Date", data: "sendDate" , render: this.formatDate.bind(this)},
{ title: "From User", data: "toUserName" }, { title: "From User", data: "lastUserName" },
{ title: "Last User", data: "lastUserName" }, { title: "Last User", data: "toUserName" },
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "From Store", data: "toStoreName" }, { title: "From Store", data: "lastStoreName" },
{ title: "Start Status", data: "toOther" }, { title: "Start Status", data: "toOther" },
{ title: "Product Category", data: "productCategory" }, { title: "Product Category", data: "productCategory" },
{ title: "Qty", data: "quantity" }, { title: "Qty", data: "quantity" },
@ -1186,12 +1186,12 @@
{ title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) }, { title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Receive Date", data: "receiveDate", render: this.formatDate.bind(this) }, { title: "Receive Date", data: "receiveDate", render: this.formatDate.bind(this) },
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "From User", data: "toUserName" }, { title: "From User", data: "lastUserName" },
{ title: "Last User", data: "lastUserName" }, { title: "Last User", data: "toUserName" },
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "Last Station", data: "lastStationName" }, { title: "Last Station", data: "toStationName" },
{ title: "From Store", data: "toStoreName" }, { title: "From Store", data: "lastStoreName" },
{ title: "Last Store", data: "lastStoreName" }, { title: "Last Store", data: "toStoreName" },
{ title: "Start Status", data: "toOther" }, { title: "Start Status", data: "toOther" },
{ title: "Latest Status", data: "latestStatus" }, { title: "Latest Status", data: "latestStatus" },
{ title: "Product Category", data: "productCategory" }, { title: "Product Category", data: "productCategory" },
@ -1210,9 +1210,9 @@
{ title: "Product Code", data: "uniqueID" }, { title: "Product Code", data: "uniqueID" },
{ title: "Assign Date", data: "sendDate", render: this.formatDate.bind(this) }, { title: "Assign Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "Station User PIC", data: "toUserName" }, { title: "Station User PIC", data: "lastUserName" },
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "Last Station", data: "lastStationName" }, { title: "Last Station", data: "toStationName" },
{ title: "Qty", data: "quantity" }, { title: "Qty", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile }, { title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" }, { title: "Remark", data: "remark" },

View File

@ -107,7 +107,7 @@
<i class="fas fa-user me-2 text-secondary"></i>User: <i class="fas fa-user me-2 text-secondary"></i>User:
</span> </span>
<span class="text-muted text-end" style="max-width: 70%; word-wrap: break-word;"> <span class="text-muted text-end" style="max-width: 70%; word-wrap: break-word;">
{{ thisItem.toUserName }} {{ thisItem.lastUserName }}
</span> </span>
</div> </div>
</li> </li>
@ -116,14 +116,14 @@
<span class="fw-bold"> <span class="fw-bold">
<i class="mdi mdi-factory me-2 text-secondary"></i>Store: <i class="mdi mdi-factory me-2 text-secondary"></i>Store:
</span> </span>
<span class="text-muted">{{ thisItem.toStoreName }}</span> <span class="text-muted">{{ thisItem.lastStoreName }}</span>
</li> </li>
<li class="list-group-item d-flex justify-content-between align-items-center"> <li class="list-group-item d-flex justify-content-between align-items-center">
<span class="fw-bold"> <span class="fw-bold">
<i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station: <i class="fas fa-map-marker-alt me-2 text-secondary"></i>Station:
</span> </span>
<span class="text-muted">{{ thisItem.toStationName || 'N/A' }}</span> <span class="text-muted">{{ thisItem.lastStationName || 'N/A' }}</span>
</li> </li>
</ul> </ul>
</div> </div>
@ -148,7 +148,7 @@
</div> </div>
@* Inv Master Receive Item *@ @* Inv Master Receive Item *@
<div v-if="itemlateststatus == 'On Delivery' && this.thisItem.lastUser == this.currentUser.id"> <div v-if="itemlateststatus == 'On Delivery' && this.thisItem.toUser == this.currentUser.id">
<h2 class="register-heading">Receive Item</h2> <h2 class="register-heading">Receive Item</h2>
<div class="col-sm-3"></div> <div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3"> <div class="col-sm-6 offset-sm-3">
@ -165,7 +165,7 @@
</div> </div>
</div> </div>
<div v-if="itemlateststatus == 'On Delivery' && this.thisItem.toUser == this.currentUser.id"> <div v-if="itemlateststatus == 'On Delivery' && this.thisItem.lastUser == this.currentUser.id">
<h3 class="register-heading">Cancel Item Movement</h3> <h3 class="register-heading">Cancel Item Movement</h3>
<div class="col-sm-3"></div> <div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3"> <div class="col-sm-6 offset-sm-3">
@ -185,7 +185,7 @@
</div> </div>
</div> </div>
<div v-if="itemlateststatus == 'On Delivery' && thisItem.lastStore == currentUser.store"> <div v-if="itemlateststatus == 'On Delivery' && thisItem.toStore == currentUser.store">
<h2 class="register-heading">Receive Item</h2> <h2 class="register-heading">Receive Item</h2>
<div class="col-sm-3"></div> <div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3"> <div class="col-sm-6 offset-sm-3">
@ -227,7 +227,7 @@
</div> </div>
@* Inv Master Return Item & Deploy to Station*@ @* Inv Master Return Item & Deploy to Station*@
<div v-if="itemlateststatus == 'Delivered' && thisItem.lastUser == currentUser.id"> <div v-if="itemlateststatus == 'Delivered' && thisItem.toUser == currentUser.id">
<h2 class="text-center register-heading">Item Actions</h2> <h2 class="text-center register-heading">Item Actions</h2>
<div class="col-sm-12 d-flex justify-content-center mt-3"> <div class="col-sm-12 d-flex justify-content-center mt-3">
<button type="button" v-on:click="ReturnMessage" class="btn btn-warning m-2" style="width: 200px; padding: 10px;"> <button type="button" v-on:click="ReturnMessage" class="btn btn-warning m-2" style="width: 200px; padding: 10px;">
@ -256,7 +256,7 @@
</div> </div>
</div> </div>
<div v-if="itemlateststatus == 'Faulty' && this.itemassignedtouser"> @* <div v-if="itemlateststatus == 'Faulty' && this.itemassignedtouser">
<h2 class="register-heading">Add Item Movement</h2> <h2 class="register-heading">Add Item Movement</h2>
<div class="col-sm-3"></div> <div class="col-sm-3"></div>
<div class="col-sm-6 offset-sm-3"> <div class="col-sm-6 offset-sm-3">
@ -268,7 +268,7 @@
</select> </select>
</div> </div>
</div> </div>
</div> </div> *@
<div v-if="itemlateststatus == 'Ready To Deploy' && this.itemassignedtouser"> <div v-if="itemlateststatus == 'Ready To Deploy' && this.itemassignedtouser">
<h2 class="register-heading">Add Item Movement</h2> <h2 class="register-heading">Add Item Movement</h2>
@ -652,7 +652,7 @@
<div class="col-sm-8"> <div class="col-sm-8">
<select class="form-select" v-model="selectedStation" required> <select class="form-select" v-model="selectedStation" required>
<option value="" disabled>-- Select Station --</option> <option value="" disabled>-- Select Station --</option>
<option v-for="station in stationlist" :key="station.stationId" :value="station.stationId"> <option v-for="station in filteredStationList" :key="station.stationId" :value="station.stationId">
{{ station.stationName }} {{ station.stationName }}
</option> </option>
</select> </select>
@ -804,6 +804,19 @@
showSerialNumber() { showSerialNumber() {
return this.showProduct.category === 'Asset' || this.showProduct.category === 'Part'; return this.showProduct.category === 'Asset' || this.showProduct.category === 'Part';
}, },
filteredStationList() {
if (!this.stationlist || !this.currentUser) return [];
return this.stationlist.filter(station => {
// Check 1: Must match User's Department
// const isSameDept = station.departmentId === this.selectedDepartment;
// Check 2: Must match User's ID as the Station PIC
const isPIC = station.stationPicID === this.currentUser.id;
return isPIC;
});
},
}, },
methods: { methods: {
// Split Url dapatkan unique ID Je // Split Url dapatkan unique ID Je
@ -960,11 +973,20 @@
const now = new Date(); const now = new Date();
const formData = { const formData = {
...(this.selectedAction === 'user' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'user' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, toUser: this.selectedUser, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'station' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStation: this.selectedStation, lastUser: this.selectedStationPIC, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), ...(this.selectedAction === 'station' ? {
...(this.selectedAction === 'store' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, lastStore: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}), lastStore: this.currentUser.store,
...(this.selectedAction === 'supplier' ? { toStore: this.currentUser.store, toUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, lastUser: this.currentUser.id, lastStore: this.currentUser.store, MovementComplete: false, } : {}), lastUser: this.currentUser.id,
...(this.selectedAction === 'faulty' ? { toStore: this.currentUser.store, toUser: this.currentUser.id,toOther: 'Faulty', SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}), toOther: 'On Delivery',
SendDate: this.assigndate,
toStation: this.selectedStation,
toUser: this.selectedStationPIC,
MovementComplete: false,
Remark: this.remark,
ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'store' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id, toOther: 'On Delivery', SendDate: this.assigndate, toStore: this.selectedStore, MovementComplete: false, Remark: this.remark, ConsignmentNote: this.document} : {}),
...(this.selectedAction === 'supplier' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id, toOther: this.selectedOther, SendDate: this.assigndate, Remark: this.remark + '. Item sent to ' + this.selectedSupplier + ' for ' + this.selectedOther, ConsignmentNote: this.document, toUser: this.currentUser.id, toStore: this.currentUser.store, MovementComplete: false, } : {}),
...(this.selectedAction === 'faulty' ? { lastStore: this.currentUser.store, lastUser: this.currentUser.id,toOther: 'Faulty', SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Remark: this.remark, ConsignmentNote: this.document, MovementComplete: true, } : {}),
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
Action: 'Stock Out', Action: 'Stock Out',
@ -1012,11 +1034,13 @@
// Determine the status based on specific conditions // Determine the status based on specific conditions
let statusToSave = ""; let statusToSave = "";
// 1. YOUR NEW LOGIC: If it's On Delivery and the current user is the target lastUser, set to Delivered // If it's On Delivery and the current user/store is the target toUser/toStore, set to Delivered
if (this.thisItem.toOther === "On Delivery" && this.thisItem.lastUser == this.currentUser.id) { if (this.thisItem.toOther === "On Delivery" &&
(this.thisItem.toUser == this.currentUser.id || this.thisItem.toStore == this.currentUser.store))
{
statusToSave = "Delivered"; statusToSave = "Delivered";
} }
// 2. KEEP EXISTING LOGIC: Calibration/Repair/Return/General Delivery goes to Ready to Deploy // Calibration/Repair/Return/General Delivery goes to Ready to Deploy
else if ( else if (
this.thisItem.toOther === "Return" || this.thisItem.toOther === "Return" ||
this.thisItem.toOther === "Calibration" || this.thisItem.toOther === "Calibration" ||
@ -1025,16 +1049,13 @@
) { ) {
statusToSave = "Ready To Deploy"; statusToSave = "Ready To Deploy";
} }
// 3. KEEP EXISTING LOGIC: Store-to-Store delivery check
else if (this.itemlateststatus == 'On Delivery' && this.thisItem.lastStore == this.currentUser.store) {
statusToSave = "Delivered";
}
const formData = { const formData = {
Id: this.thisItem.movementId, Id: this.thisItem.movementId,
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Remark: this.thisItem.remark, Remark: this.thisItem.remark,
LastUser: this.thisItem.lastuser == null ? this.currentUser.id : this.thisItem.lastuser, ToUser: this.thisItem.touser == null ? this.currentUser.id : this.thisItem.touser,
ToStore: this.currentUser.store,
LatestStatus: statusToSave // Uses the prioritized status from above LatestStatus: statusToSave // Uses the prioritized status from above
}; };
@ -1075,11 +1096,12 @@
this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther; this.itemlateststatus = this.thisItem.latestStatus ? this.thisItem.latestStatus : this.thisItem.toOther;
this.itemassignedtouser = ( this.itemassignedtouser = (
(this.thisItem.toStore === this.currentUser.store || this.thisItem.lastStore === this.currentUser.store) this.thisItem.departmentId === this.selectedDepartment &&
&& this.currentUser.store != null this.selectedDepartment != null &&
this.selectedDepartment !== ""
); );
// Debugging logs to help you verify in the browser console // Debugging logs to help you verify in the browser console
console.log('Item Store ID:', this.thisItem.toStore); console.log('Item Store ID:', this.thisItem.lastStore);
console.log('User Master Store ID:', this.currentUser.store); console.log('User Master Store ID:', this.currentUser.store);
console.log('Is User Authorized Master for this item?', this.itemassignedtouser); console.log('Is User Authorized Master for this item?', this.itemassignedtouser);
@ -1151,16 +1173,16 @@
// Second Movement: Re-registration/Re-stock Record // Second Movement: Re-registration/Re-stock Record
const registrationMovementData = { const registrationMovementData = {
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
ToStore: this.currentUser.store, LastStore: this.currentUser.store,
ToUser: this.currentUser.id, LastUser: this.currentUser.id,
ToOther: null, ToOther: null,
sendDate: null, sendDate: null,
Action: 'Register', Action: 'Register',
Quantity: this.thisItem.movementQuantity, Quantity: this.thisItem.movementQuantity,
Remark: null, Remark: null,
ConsignmentNote: null, ConsignmentNote: null,
LastUser: this.currentUser.id, ToUser: this.currentUser.id,
LastStore: this.currentUser.store, ToStore: this.currentUser.store,
LatestStatus: 'Ready To Deploy', LatestStatus: 'Ready To Deploy',
receiveDate: null, receiveDate: null,
MovementComplete: true, MovementComplete: true,
@ -1320,20 +1342,39 @@
const now = new Date(); const now = new Date();
const formData = { const formData = {
// ItemId: this.thisItem.itemID,
// LastStore: this.thisItem.lastStore,
// LastUser: this.thisItem.lastUser, This will be handled by the API logic
// ToOther: "Return",
// SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
// Action: "StockIn",
// Quantity: this.thisItem.quantity || 1,
// Remark: this.remark + " (Returned)",
// ConsignmentNote: this.document, The base64 string from handleFileUpload
// Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
// ToUser: this.currentUser.id,
// ToStore: this.thisItem.lastStore,
// LatestStatus: null,
// MovementComplete: false
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
ToStore: this.thisItem.toStore, LastStation: this.thisItem.currentStationId,
ToUser: this.thisItem.toUser, // This will be handled by the API logic LastStore: this.thisItem.currentStoreId,
LastUser: this.currentUser.id,
ToOther: "Return", ToOther: "Return",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Action: "StockIn", Action: "StockIn",
Quantity: this.thisItem.quantity || 1, // Quantity: this.thisItem.quantity,
Remark: this.remark + " (Returned)", Quantity: this.thisItem.movementQuantity || 1,
ConsignmentNote: this.document, // The base64 string from handleFileUpload Remark: this.remark,
ConsignmentNote: this.consignmentNote,
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LastUser: this.currentUser.id, ToUser: this.thisItem.lastUser,
LastStore: this.thisItem.toStore, ToStore: this.thisItem.lastStore,
// ToStation: this.thisItem.lastStation,
LatestStatus: null, LatestStatus: null,
MovementComplete: false ReceiveDate: null,
MovementComplete: false,
}; };
try { try {
@ -1373,9 +1414,9 @@
const now = new Date(); const now = new Date();
const formData = { const formData = {
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
ToStation: this.thisItem.ToStation, LastStation: this.thisItem.lastStation || this.thisItem.currentStationId || null,
ToStore: this.thisItem.toStore, LastStore: this.currentUser.store,
ToUser: this.currentUser.id, LastUser: this.currentUser.id,
ToOther: "Delivered", ToOther: "Delivered",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Action: "Assign", Action: "Assign",
@ -1383,9 +1424,9 @@
Remark: this.remark || "Deployed to station", Remark: this.remark || "Deployed to station",
ConsignmentNote: this.document, // Base64 from file upload ConsignmentNote: this.document, // Base64 from file upload
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LastUser: this.currentUser.id, ToUser: this.currentUser.id,
LastStore: this.thisItem.toStore, ToStore: this.currentUser.store,
LastStation: this.selectedStation, // The new station ID selected in modal ToStation: this.selectedStation, // The new station ID selected in modal
LatestStatus: "Delivered", LatestStatus: "Delivered",
receiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), receiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true MovementComplete: true

View File

@ -172,10 +172,10 @@
<strong>Latest Movement</strong> <strong>Latest Movement</strong>
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null}" 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null}"
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
</h3> </h3>
@ -220,13 +220,13 @@
<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.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
@ -245,13 +245,13 @@
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -267,10 +267,10 @@
<div v-for="(movement, i) in group.movements.slice(1)" :key="i" class="row mt-2"> <div v-for="(movement, i) in group.movements.slice(1)" :key="i" class="row mt-2">
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null}" 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null}"
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
</h3> </h3>
@ -314,13 +314,13 @@
<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.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
@ -339,13 +339,13 @@
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -388,10 +388,10 @@
<strong>Latest Movement</strong> <strong>Latest Movement</strong>
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null}" 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null}"
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
</h3> </h3>
@ -434,13 +434,13 @@
<div v-show="detailsVisible[movement.id]" class="col-md-12 mt-2"> <div v-show="detailsVisible[movement.id]" class="col-md-12 mt-2">
<div class="row"> <div class="row">
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<i v-if="movement.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<i class="fas fa-arrow-right fa-2x"></i> <i class="fas fa-arrow-right fa-2x"></i>
@ -457,13 +457,13 @@
</p> </p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -480,10 +480,10 @@
<div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom"> <div class="col-md-12 d-flex flex-wrap align-items-center gap-3 p-2 border-bottom">
<!-- Movement Type --> <!-- Movement Type -->
<h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return', <h3 :class="{'text-primary': movement.toOther === 'On Delivery', 'text-warning': movement.toOther === 'Return',
'text-success': movement.toStation !== null, 'text-info': movement.action === 'Assign' && movement.toStation === null}" 'text-success': movement.lastStation !== null, 'text-info': movement.action === 'Assign' && movement.lastStation === null}"
class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;"> class="flex-shrink-0 text-nowrap" style="max-width:90px; min-width:90px;">
{{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.toStation !== null ? 'Change' : 'Assign')) }} {{ movement.toOther === 'Return' ? 'Return' : (movement.toOther === 'On Delivery' ? 'Receive' : ( movement.lastStation !== null ? 'Change' : 'Assign')) }}
</h3> </h3>
@ -529,13 +529,13 @@
<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.toStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.lastStation" 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-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.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p>
<p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p> <p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p>
<p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p> <p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p>
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<p></p> <p></p>
@ -554,13 +554,13 @@
</div> </div>
<div class="col-md-4 text-center"> <div class="col-md-4 text-center">
<!-- Conditionally render End Icon --> <!-- Conditionally render End Icon -->
<i v-if="movement.lastStation" class="fas fa-map-marker-alt"></i> <i v-if="movement.toStation" class="fas fa-map-marker-alt"></i>
<i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i> <i v-else-if="movement.toOther !== 'On Delivery'" class="fas fa-warehouse fa-2x"></i>
<i v-else class="fas fa-user fa-2x"></i> <i v-else class="fas fa-user fa-2x"></i>
<p><strong>End</strong></p> <p><strong>End</strong></p>
<p v-if="movement.lastUser !== null"><strong>User:</strong> {{ movement.lastUserName }}</p> <p v-if="movement.toUser !== null"><strong>User:</strong> {{ movement.toUserName }}</p>
<p v-if="movement.lastStation !== null"><strong>Station:</strong> {{ movement.lastStationName }}</p> <p v-if="movement.toStation !== null"><strong>Station:</strong> {{ movement.toStationName }}</p>
<p v-if="movement.lastStore !== null"><strong>Store:</strong> {{ movement.lastStoreName }}</p> <p v-if="movement.toStore !== null"><strong>Store:</strong> {{ movement.toStoreName }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -761,7 +761,7 @@
if (movements.length > 0) { if (movements.length > 0) {
let latestMovement = movements[0]; let latestMovement = movements[0];
let station = latestMovement.lastStationName || latestMovement.toStationName || "Self Assigned"; let station = latestMovement.toStationName || latestMovement.lastStationName || "Self Assigned";
if (!groupedByStation[station]) { if (!groupedByStation[station]) {
groupedByStation[station] = {}; groupedByStation[station] = {};
@ -1037,10 +1037,10 @@
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) }, { title: "Send Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Start Status", data: "toOther" }, { title: "Start Status", data: "toOther" },
{ title: "From User", data: "toUserName" }, { title: "From User", data: "lastUserName" },
{ title: "Last User", data: "lastUserName" }, { title: "Last User", data: "toUserName" },
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "From Store", data: "toStoreName" }, { title: "From Store", data: "lastStoreName" },
{ title: "Quantity", data: "quantity" }, { title: "Quantity", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile }, { title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" }, { title: "Remark", data: "remark" },
@ -1060,12 +1060,12 @@
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "Start Status", data: "toOther" }, { title: "Start Status", data: "toOther" },
{ title: "Latest Status", data: "latestStatus" }, { title: "Latest Status", data: "latestStatus" },
{ title: "From User", data: "toUserName" }, { title: "From User", data: "lastUserName" },
{ title: "Last User", data: "lastUserName" }, { title: "Last User", data: "toUserName" },
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "Last Station", data: "lastStationName" }, { title: "Last Station", data: "toStationName" },
{ title: "From Store", data: "toStoreName" }, { title: "From Store", data: "lastStoreName" },
{ title: "Last Store", data: "lastStoreName" }, { title: "Last Store", data: "toStoreName" },
{ title: "Qty", data: "quantity" }, { title: "Qty", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile }, { title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" }, { title: "Remark", data: "remark" },
@ -1082,9 +1082,9 @@
{ title: "Product Code", data: "uniqueID" }, { title: "Product Code", data: "uniqueID" },
{ title: "Assign Date", data: "sendDate", render: this.formatDate.bind(this) }, { title: "Assign Date", data: "sendDate", render: this.formatDate.bind(this) },
{ title: "Action", data: "action" }, { title: "Action", data: "action" },
{ title: "Station User PIC", data: "toUserName" }, { title: "Station User PIC", data: "lastUserName" },
{ title: "From Station", data: "toStationName" }, { title: "From Station", data: "lastStationName" },
{ title: "Last Station", data: "lastStationName" }, { title: "Last Station", data: "toStationName" },
{ title: "Qty", data: "quantity" }, { title: "Qty", data: "quantity" },
{ title: "Note", data: "consignmentNote", render: renderFile }, { title: "Note", data: "consignmentNote", render: renderFile },
{ title: "Remark", data: "remark" }, { title: "Remark", data: "remark" },

View File

@ -54,11 +54,11 @@
</div> </div>
<!--RECEIVE OR RETURN INTERFACE --> <!--RECEIVE OR RETURN INTERFACE -->
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem.currentStationId != null"> <div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem?.currentStationId != null">
<h2>Item Receive Information :</h2> <h2>Item Receive Information :</h2>
<h3>Station Assign</h3> <h3>Station Assign</h3>
</div> </div>
<div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem.currentStationId == null"> <div style="text-align: center; margin: 20px 0;" v-if="displayStatus === 'arrived' && thisItem?.currentStationId == null">
<h2>Item Receive Information :</h2> <h2>Item Receive Information :</h2>
<h3>Self Assign</h3> <h3>Self Assign</h3>
</div> </div>
@ -220,7 +220,9 @@
<div class="form-group row"> <div class="form-group row">
<div class="col-sm-8 offset-sm-5"> <div class="col-sm-8 offset-sm-5">
<button type="submit" v-on:click="ReturnMessage" class="btn btn-primary m-1">Return Item</button> <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">{{ thisItem?.currentStationId == null ? "Deploy Station" : "Change Station" }}</button> <button type="submit" v-on:click="StationMessage" class="btn btn-primary m-1">
{{ (thisItem?.currentStationId || thisItem?.toStationId) ? "Change Station" : "Deploy Station" }}
</button>
</div> </div>
</div> </div>
@ -236,7 +238,9 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="stationModalLabel">{{ thisItem?.currentStationId == null ? "Deploy Station" : "Change Station" }}</h5> <h5 class="modal-title" id="stationModalLabel">
{{ (thisItem?.currentStationId || thisItem?.toStationId) ? "Change Station" : "Deploy Station" }}
</h5>
<button type="button" class="close" data-dismiss="modal" v-on:click="closeStationMessageModal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" v-on:click="closeStationMessageModal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
@ -446,9 +450,9 @@
const now = new Date(); const now = new Date();
const formData = { const formData = {
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
ToStation: this.thisItem.currentStationId, LastStation: this.thisItem.currentStationId,
ToStore: this.thisItem.toStore, LastStore: this.thisItem.lastStore,
ToUser: this.currentUserId, LastUser: this.currentUserId,
ToOther: "Delivered", ToOther: "Delivered",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Action: "Assign", Action: "Assign",
@ -456,9 +460,9 @@
Remark: this.remark, Remark: this.remark,
ConsignmentNote: this.consignmentNote, ConsignmentNote: this.consignmentNote,
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LastUser: this.currentUserId, ToUser: this.currentUserId,
LastStore: this.thisItem.toStore, ToStore: this.thisItem.lastStore,
LastStation: this.selectedStation, ToStation: this.selectedStation,
LatestStatus: "Delivered", LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true, MovementComplete: true,
@ -499,7 +503,7 @@
const now = new Date(); const now = new Date();
const formData = { const formData = {
Id: this.thisItem.id, Id: this.thisItem.id,
LastStore: this.thisItem.toStore, ToStore: this.thisItem.lastStore,
LatestStatus: "Delivered", LatestStatus: "Delivered",
ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), ReceiveDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
MovementComplete: true, MovementComplete: true,
@ -542,9 +546,9 @@
const now = new Date(); const now = new Date();
const formData = { const formData = {
ItemId: this.thisItem.itemID, ItemId: this.thisItem.itemID,
ToStation: this.thisItem.currentStationId, LastStation: this.thisItem.currentStationId,
ToStore: this.thisItem.currentStoreId, LastStore: this.thisItem.currentStoreId,
ToUser: this.currentUserId, LastUser: this.currentUserId,
ToOther: "Return", ToOther: "Return",
SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), SendDate: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
Action: "StockIn", Action: "StockIn",
@ -553,9 +557,9 @@
Remark: this.remark, Remark: this.remark,
ConsignmentNote: this.consignmentNote, ConsignmentNote: this.consignmentNote,
Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(), Date: new Date(now.getTime() + 8 * 60 * 60 * 1000).toISOString(),
LastUser: this.InventoryMasterId, ToUser: this.InventoryMasterId,
LastStore: this.thisItem.toStore, ToStore: this.thisItem.lastStore,
LastStation: this.thisItem.toStation, ToStation: this.thisItem.lastStation,
LatestStatus: null, LatestStatus: null,
ReceiveDate: null, ReceiveDate: null,
MovementComplete: false, MovementComplete: false,
@ -588,21 +592,42 @@
try { try {
const response = await fetch('/InvMainAPI/GetItem/' + itemid, { const response = await fetch('/InvMainAPI/GetItem/' + itemid, {
method: 'POST', method: 'POST',
} });
);
if (response.ok) { if (response.ok) {
this.thisItem = await response.json(); this.thisItem = await response.json();
this.fetchStore(this.thisItem.toStore); // this.fetchStore(this.thisItem.lastStore);
console.log("Current Station ID:", this.thisItem.currentStationId);
console.log("To Station ID:", this.thisItem.toStationId);
// 1. ARRIVED/RECEIVE LOGIC: Check if YOU are the "ToUser"
if (this.thisItem.movementId != null &&
this.thisItem.toOther === "On Delivery" &&
this.thisItem.latestStatus == null &&
this.thisItem.toUser == this.currentUserId && // Check ToUser, not LastUser/CurrentUserId
this.thisItem.movementComplete == 0) {
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"; this.displayStatus = "arrived";
} else if (this.thisItem.movementId != null && this.thisItem.latestStatus != null && this.thisItem.currentUserId == this.currentUserId && this.thisItem.latestStatus != "Ready To Deploy") {
// 2. RETURN/OWNED LOGIC: Check if YOU currently hold the item
} else if (this.thisItem.movementId != null &&
this.thisItem.latestStatus != null &&
this.thisItem.toUser == this.currentUserId &&
this.thisItem.latestStatus != "Ready To Deploy") {
this.displayStatus = "return"; this.displayStatus = "return";
} else if (this.thisItem.movementId != null && this.thisItem.toOther === "Return" && this.thisItem.latestStatus == null && this.thisItem.toUser == this.currentUserId) {
// 3. REQUEST AGAIN LOGIC
} else if (this.thisItem.movementId != null &&
this.thisItem.toOther === "Return" &&
this.thisItem.latestStatus == null &&
this.thisItem.lastUser == this.currentUserId) {
this.displayStatus = "requestAgain"; this.displayStatus = "requestAgain";
} else { } else {
// FALLBACK: If none of the above matches, it means someone else is the ToUser
this.displayStatus = "differentUser"; this.displayStatus = "differentUser";
this.thisItem = null; this.thisItem = null;
} }

View File

@ -85,15 +85,13 @@
<div class="tab-content"> <div class="tab-content">
@* Overview *@ @* Overview *@
<div v-if="activeTab === 'overview'" class="row"> <div v-if="activeTab === 'overview'" class="row">
<div class="col-md-3"> <div class="col-md-4">
<div class="card bg-light"> <div class="card bg-light mb-3">
<div class="card-body text-center"> <div class="card-body text-center">
<h6>Total Products Registered</h6> <h6>Total Products Registered</h6>
<h3>{{ reportData.itemCountRegistered }}</h3> <h3>{{ reportData.itemCountRegistered }}</h3>
</div> </div>
</div> </div>
</div>
<div class="col-md-3">
<div class="card bg-success text-white"> <div class="card bg-success text-white">
<div class="card-body text-center"> <div class="card-body text-center">
<h6>Items Still In Stock</h6> <h6>Items Still In Stock</h6>
@ -101,10 +99,32 @@
</div> </div>
</div> </div>
</div> </div>
@* Chart Section *@
<div class="col-md-8">
<div class="card shadow-sm">
<div class="card-body">
<canvas id="inventoryChart" style="max-height: 250px;"></canvas>
</div>
</div>
</div>
</div> </div>
@* Stock Receive *@ @* Stock Receive *@
<div v-if="activeTab === 'stockReceive'"> <div v-if="activeTab === 'stockReceive'">
<div class="row mb-4">
<div class="col-12">
<div class="card shadow-sm">
<div class="card-header bg-white">
<h5 class="card-title mb-0">Total Receiving Cost by Category (RM)</h5>
</div>
<div class="card-body">
<canvas id="stockReceiveChart" style="max-height: 300px;"></canvas>
</div>
</div>
</div>
</div>
<h5>Stock Receive Listing</h5> <h5>Stock Receive Listing</h5>
<table class="table table-sm table-bordered"> <table class="table table-sm table-bordered">
<thead class="table-primary"> <thead class="table-primary">
@ -245,6 +265,7 @@
@{ @{
await Html.RenderPartialAsync("_ValidationScriptsPartial"); await Html.RenderPartialAsync("_ValidationScriptsPartial");
} }
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script> <script>
$(function () { $(function () {
app.mount('#invAdmin'); app.mount('#invAdmin');
@ -277,7 +298,9 @@
selectedMonth: [], selectedMonth: [],
selectedDepartment: [], selectedDepartment: [],
selectedItem: [], selectedItem: [],
selectedCategory: [] selectedCategory: [],
chartInstance: null,
receiveChartInstance: null,
} }
}, },
mounted() { mounted() {
@ -286,6 +309,15 @@
this.fetchDepartmentsCompaniesList(); this.fetchDepartmentsCompaniesList();
}, },
watch: { watch: {
activeTab(val) {
if (val === 'overview') {
this.$nextTick(() => this.initChart());
}
// Add this condition
if (val === 'stockReceive') {
this.$nextTick(() => this.initStockReceiveChart());
}
},
isMonthMode() { isMonthMode() {
this.selectedDate = null; // Reset date when switching modes this.selectedDate = null; // Reset date when switching modes
}, },
@ -359,11 +391,106 @@
if (response.ok) { if (response.ok) {
this.reportData = await response.json(); this.reportData = await response.json();
// Initialize chart after data is loaded and DOM updated
if (this.activeTab === 'overview') {
this.$nextTick(() => this.initChart());
}
} }
} catch (error) { } catch (error) {
console.error('Fetch Error:', error); console.error('Fetch Error:', error);
} }
}, },
initChart() {
const ctx = document.getElementById('inventoryChart');
if (!ctx) return;
// Destroy previous chart instance if it exists
if (this.chartInstance) {
this.chartInstance.destroy();
}
const available = this.reportData.itemCountStillInStock;
const total = this.reportData.itemCountRegistered;
const stockOut = total - available;
this.chartInstance = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['In Stock', 'Stock Out'],
datasets: [{
data: [available, stockOut > 0 ? stockOut : 0],
backgroundColor: ['#28a745', '#dc3545'],
hoverOffset: 4
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { position: 'bottom' },
title: { display: true, text: 'Inventory Status' }
}
}
});
},
initStockReceiveChart() {
const ctx = document.getElementById('stockReceiveChart');
if (!ctx || !this.reportData.receivedItems) return;
// Destroy previous instance to prevent overlapping
if (this.receiveChartInstance) {
this.receiveChartInstance.destroy();
}
// 1. Process Data: Group by Category and Sum (Quantity * Price)
const summary = {};
this.reportData.receivedItems.forEach(item => {
const cat = item.category || 'Uncategorized';
const total = item.quantity * item.convertPrice;
summary[cat] = (summary[cat] || 0) + total;
});
const labels = Object.keys(summary);
const dataValues = Object.values(summary);
// 2. Create the Bar Chart
this.receiveChartInstance = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: 'Total RM',
data: dataValues,
backgroundColor: '#4e73df',
borderColor: '#4e73df',
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
tooltip: {
callbacks: {
label: function(context) {
return 'Total: RM ' + context.parsed.y.toLocaleString(undefined, {minimumFractionDigits: 2});
}
}
}
},
scales: {
y: {
beginAtZero: true,
ticks: {
callback: function(value) { return 'RM ' + value; }
}
}
}
}
});
},
async fetchDepartmentsCompaniesList(){ async fetchDepartmentsCompaniesList(){
try { try {
const response = await fetch(`/AdminAPI/GetDepartmentWithCompanyList/`, { const response = await fetch(`/AdminAPI/GetDepartmentWithCompanyList/`, {

View File

@ -528,9 +528,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.Product!.ProductName, item.Product!.ProductName,
item.Product!.ProductShortName, item.Product!.ProductShortName,
item.Product!.Category, item.Product!.Category,
FromUser = item.Movement?.ToUser, FromUser = item.Movement?.LastUser,
FromStore = item.Movement?.ToStore, FromStore = item.Movement?.LastStore,
FromStation = item.Movement?.ToStation, FromStation = item.Movement?.LastStation,
CurrentUser = item.Movement?.FromUser?.UserName, CurrentUser = item.Movement?.FromUser?.UserName,
CurrentStore = item.Movement?.FromStore?.StoreName, CurrentStore = item.Movement?.FromStore?.StoreName,
CurrentStation = item.Movement?.FromStation?.StationName, CurrentStation = item.Movement?.FromStation?.StationName,
@ -570,14 +570,20 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var product = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("Product not found"); 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 };
// --- NEW LOGIC FOR DEPT CODE ---
var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId);
string? deptCode = companyDepartment!.DepartmentCode?.ToString();
if (product.Category == "Disposable") if (product.Category == "Disposable")
{ {
product.QuantityProduct += item.Quantity; product.QuantityProduct += item.Quantity;
UpdateQuantityJson(product, deptCode, item.Quantity); // <--- ADDED
item.SerialNumber = null; item.SerialNumber = null;
} }
else if (product.Category == "Asset" || product.Category == "Part") else if (product.Category == "Asset" || product.Category == "Part")
{ {
product.QuantityProduct = (product.QuantityProduct ?? 0) + 1; product.QuantityProduct = (product.QuantityProduct ?? 0) + 1;
UpdateQuantityJson(product, deptCode, 1); // <--- ADDED
item.Quantity = 1; item.Quantity = 1;
} }
@ -594,10 +600,10 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
ItemMovementModel itemMovement = new ItemMovementModel ItemMovementModel itemMovement = new ItemMovementModel
{ {
ItemId = item.ItemID, ItemId = item.ItemID,
ToUser = inventoryMaster.UserId,
ToStore = inventoryMaster.StoreId,
LastStore = inventoryMaster.StoreId,
LastUser = inventoryMaster.UserId, LastUser = inventoryMaster.UserId,
LastStore = inventoryMaster.StoreId,
ToStore = inventoryMaster.StoreId,
ToUser = inventoryMaster.UserId,
LatestStatus = "Ready To Deploy", LatestStatus = "Ready To Deploy",
Quantity = item.Quantity, Quantity = item.Quantity,
Action = "Register", Action = "Register",
@ -614,12 +620,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
if (savedItem != null) if (savedItem != null)
{ {
var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId); // (Existing UniqueID logic kept exactly as provided)
var itemProduct = _centralDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault(); var itemProduct = _centralDbContext.Products.Where(p => p.ProductId == item.ProductId).FirstOrDefault();
string? companyInitial = companyDepartment!.CompanyName?.ToString().Substring(0, 1).ToUpper();
string? departmentInitial = companyDepartment!.DepartmentName?.ToString().Substring(0, 1).ToUpper();
string? deptCode = companyDepartment!.DepartmentCode?.ToString();
char? initialCategory = itemProduct!.Category.ToString().Substring(0, 1).ToUpper().FirstOrDefault(); char? initialCategory = itemProduct!.Category.ToString().Substring(0, 1).ToUpper().FirstOrDefault();
string? productId = itemProduct!.ProductId.ToString("D3"); string? productId = itemProduct!.ProductId.ToString("D3");
string? itemIdString = item.ItemID.ToString("D5"); string? itemIdString = item.ItemID.ToString("D5");
@ -653,7 +655,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
savedItem.InvoiceDate, savedItem.InvoiceDate,
savedItem.PartNumber, savedItem.PartNumber,
savedItem.CreatedDate, savedItem.CreatedDate,
savedItem.ModifiedDate // This will now be null for new items savedItem.ModifiedDate
}; };
return Json(updatedItem); return Json(updatedItem);
} }
@ -685,42 +687,65 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var oldProduct = savedItem.Product; var oldProduct = savedItem.Product;
var newProduct = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("New Product not found"); var newProduct = await _centralDbContext.Products.FirstOrDefaultAsync(p => p.ProductId == item.ProductId) ?? throw new Exception("New Product not found");
// Quantity adjustment logic based on category changes // --- PREPARE DEPT CODES FOR JSON ---
var oldDept = await GetDepartmentWithCompany(savedItem.CompanyId, savedItem.DepartmentId);
var newDept = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId);
string oldDeptCode = oldDept?.DepartmentCode ?? "UNKNOWN";
string newDeptCode = newDept?.DepartmentCode ?? "UNKNOWN";
// Quantity adjustment logic based on category changes (JSON logic added inside each block)
if (oldProduct?.Category == "Disposable" && newProduct.Category == "Disposable") if (oldProduct?.Category == "Disposable" && newProduct.Category == "Disposable")
{ {
int quantityDifference = item.Quantity - savedItem.Quantity; int quantityDifference = item.Quantity - savedItem.Quantity;
newProduct.QuantityProduct += quantityDifference; newProduct.QuantityProduct += quantityDifference;
// If changing department but same product
if (savedItem.DepartmentId != item.DepartmentId)
{
UpdateQuantityJson(newProduct, oldDeptCode, -savedItem.Quantity);
UpdateQuantityJson(newProduct, newDeptCode, item.Quantity);
}
else
{
UpdateQuantityJson(newProduct, newDeptCode, quantityDifference);
}
} }
else if ((oldProduct?.Category == "Asset" || oldProduct?.Category == "Part") && newProduct.Category == "Disposable") else if ((oldProduct?.Category == "Asset" || oldProduct?.Category == "Part") && newProduct.Category == "Disposable")
{ {
if (oldProduct != null && oldProduct.QuantityProduct > 0) if (oldProduct != null && oldProduct.QuantityProduct > 0)
{ {
oldProduct.QuantityProduct = (oldProduct.QuantityProduct ?? 0) - 1; oldProduct.QuantityProduct = (oldProduct.QuantityProduct ?? 0) - 1;
UpdateQuantityJson(oldProduct, oldDeptCode, -1); // <--- ADDED
_centralDbContext.Products.Update(oldProduct); _centralDbContext.Products.Update(oldProduct);
} }
newProduct.QuantityProduct += item.Quantity; newProduct.QuantityProduct += item.Quantity;
UpdateQuantityJson(newProduct, newDeptCode, item.Quantity); // <--- ADDED
} }
else if (oldProduct?.Category == "Disposable" && (newProduct.Category == "Asset" || newProduct.Category == "Part")) else if (oldProduct?.Category == "Disposable" && (newProduct.Category == "Asset" || newProduct.Category == "Part"))
{ {
if (oldProduct != null) if (oldProduct != null)
{ {
oldProduct.QuantityProduct = (oldProduct.QuantityProduct ?? 0) - savedItem.Quantity; oldProduct.QuantityProduct = (oldProduct.QuantityProduct ?? 0) - savedItem.Quantity;
UpdateQuantityJson(oldProduct, oldDeptCode, -savedItem.Quantity); // <--- ADDED
if (oldProduct.QuantityProduct < 0) oldProduct.QuantityProduct = 0; if (oldProduct.QuantityProduct < 0) oldProduct.QuantityProduct = 0;
_centralDbContext.Products.Update(oldProduct); _centralDbContext.Products.Update(oldProduct);
} }
newProduct.QuantityProduct = (newProduct.QuantityProduct ?? 0) + 1; newProduct.QuantityProduct = (newProduct.QuantityProduct ?? 0) + 1;
UpdateQuantityJson(newProduct, newDeptCode, 1); // <--- ADDED
item.Quantity = 1; item.Quantity = 1;
} }
else if ((oldProduct?.Category == "Asset" || oldProduct?.Category == "Part") && (newProduct.Category == "Asset" || newProduct.Category == "Part")) else if ((oldProduct?.Category == "Asset" || oldProduct?.Category == "Part") && (newProduct.Category == "Asset" || newProduct.Category == "Part"))
{ {
if (savedItem.ProductId != item.ProductId) if (savedItem.ProductId != item.ProductId || savedItem.DepartmentId != item.DepartmentId)
{ {
if (oldProduct != null && oldProduct.QuantityProduct > 0) if (oldProduct != null && oldProduct.QuantityProduct > 0)
{ {
oldProduct.QuantityProduct = (oldProduct.QuantityProduct ?? 0) - 1; oldProduct.QuantityProduct = (oldProduct.QuantityProduct ?? 0) - 1;
UpdateQuantityJson(oldProduct, oldDeptCode, -1); // <--- ADDED
_centralDbContext.Products.Update(oldProduct); _centralDbContext.Products.Update(oldProduct);
} }
newProduct.QuantityProduct = (newProduct.QuantityProduct ?? 0) + 1; newProduct.QuantityProduct = (newProduct.QuantityProduct ?? 0) + 1;
UpdateQuantityJson(newProduct, newDeptCode, 1); // <--- ADDED
} }
item.Quantity = 1; item.Quantity = 1;
} }
@ -731,7 +756,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
item.SerialNumber = null; item.SerialNumber = null;
} }
// Update savedItem properties from item model // Update savedItem properties (Existing logic kept exactly as provided)
savedItem.DefaultPrice = item.DefaultPrice; savedItem.DefaultPrice = item.DefaultPrice;
savedItem.CompanyId = item.CompanyId; savedItem.CompanyId = item.CompanyId;
savedItem.DepartmentId = item.DepartmentId; savedItem.DepartmentId = item.DepartmentId;
@ -753,10 +778,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
savedItem.InvoiceDate = item.InvoiceDate; savedItem.InvoiceDate = item.InvoiceDate;
savedItem.PartNumber = item.PartNumber; savedItem.PartNumber = item.PartNumber;
// Set ModifiedDate when editing an item
savedItem.ModifiedDate = DateTime.Now; savedItem.ModifiedDate = DateTime.Now;
// Re-generate UniqueID based on updated fields (if PartNumber is part of it)
var companyDepartment = await GetDepartmentWithCompany(savedItem.CompanyId, savedItem.DepartmentId); var companyDepartment = await GetDepartmentWithCompany(savedItem.CompanyId, savedItem.DepartmentId);
string? deptCode = companyDepartment!.DepartmentCode?.ToString(); string? deptCode = companyDepartment!.DepartmentCode?.ToString();
char? initialCategory = newProduct!.Category.ToString().Substring(0, 1).ToUpper().FirstOrDefault(); char? initialCategory = newProduct!.Category.ToString().Substring(0, 1).ToUpper().FirstOrDefault();
@ -790,8 +813,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
savedItem.EndWDate, savedItem.EndWDate,
savedItem.InvoiceDate, savedItem.InvoiceDate,
savedItem.PartNumber, savedItem.PartNumber,
savedItem.CreatedDate, // Include in response savedItem.CreatedDate,
savedItem.ModifiedDate // Include in response savedItem.ModifiedDate
}; };
return Json(updatedItem); return Json(updatedItem);
} }
@ -813,25 +836,28 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
var products = _centralDbContext.Products var products = _centralDbContext.Products
.FirstOrDefault(i => i.ProductId == item.ProductId); .FirstOrDefault(i => i.ProductId == item.ProductId);
products.QuantityProduct = products.QuantityProduct - item.Quantity; if (products != null)
{
// --- ADDED JSON LOGIC ---
var companyDepartment = await GetDepartmentWithCompany(item.CompanyId, item.DepartmentId);
string? deptCode = companyDepartment?.DepartmentCode?.ToString();
products.QuantityProduct = products.QuantityProduct - item.Quantity;
UpdateQuantityJson(products, deptCode, -item.Quantity); // <--- ADDED
_centralDbContext.Products.Update(products);
}
// Get related item movements
var itemMovements = await _centralDbContext.ItemMovements var itemMovements = await _centralDbContext.ItemMovements
.Where(i => i.ItemId == item.ItemID) .Where(i => i.ItemId == item.ItemID)
.ToListAsync(); .ToListAsync();
// Remove all related item movements
if (itemMovements.Any()) if (itemMovements.Any())
{ {
_centralDbContext.ItemMovements.RemoveRange(itemMovements); _centralDbContext.ItemMovements.RemoveRange(itemMovements);
await _centralDbContext.SaveChangesAsync(); await _centralDbContext.SaveChangesAsync();
} }
//Handle Rules kalau itemMovement dia xde kat store
_centralDbContext.Products.Update(products);
// Remove the item itself
_centralDbContext.Items.Remove(item); _centralDbContext.Items.Remove(item);
await _centralDbContext.SaveChangesAsync(); await _centralDbContext.SaveChangesAsync();
@ -839,6 +865,39 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
} }
// --- ADDED THIS FUNCTION TO HANDLE JSON DATA ---
private void UpdateQuantityJson(ProductModel product, string? deptCode, int amount)
{
if (string.IsNullOrEmpty(deptCode)) return;
var quantities = new Dictionary<string, int>();
if (!string.IsNullOrEmpty(product.QuantityJSON))
{
try
{
// Explicitly use System.Text.Json to avoid the ambiguity error
quantities = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, int>>(product.QuantityJSON) ?? new Dictionary<string, int>();
}
catch { quantities = new Dictionary<string, int>(); }
}
if (quantities.ContainsKey(deptCode))
{
quantities[deptCode] += amount;
}
else
{
quantities[deptCode] = amount;
}
// Never allow negative numbers in the JSON
if (quantities[deptCode] < 0) quantities[deptCode] = 0;
product.QuantityJSON = System.Text.Json.JsonSerializer.Serialize(quantities);
}
[HttpPost("GetItem/{id}")] // Endpoint to retrieve an item by its ID [HttpPost("GetItem/{id}")] // Endpoint to retrieve an item by its ID
public async Task<IActionResult> GetItem(string id) public async Task<IActionResult> GetItem(string id)
{ {
@ -900,17 +959,20 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
CurrentStore = item.Movement?.FromStore?.StoreName, CurrentStore = item.Movement?.FromStore?.StoreName,
CurrentStoreId = item.Movement?.FromStore?.Id, CurrentStoreId = item.Movement?.FromStore?.Id,
CurrentStation = item.Movement?.FromStation?.StationName, CurrentStation = item.Movement?.FromStation?.StationName,
CurrentStationId = item.Movement?.FromStation?.StationId,
ToUser = item.Movement?.ToUser, CurrentStationId = item.Movement?.ToStation ?? item.Movement?.LastStation,
ToStationId = item.Movement?.ToStation,
LastUser = item.Movement?.LastUser,
ToUserName = item.Movement?.NextUser?.UserName, ToUserName = item.Movement?.NextUser?.UserName,
ToStore = item.Movement?.ToStore, LastStore = item.Movement?.LastStore,
ToStoreName = item.Movement?.NextStore?.StoreName, ToStoreName = item.Movement?.NextStore?.StoreName,
ToStation = item.Movement?.ToStation, LastStation = item.Movement?.LastStation,
ToStationName = item.Movement?.NextStation?.StationName, ToStationName = item.Movement?.NextStation?.StationName,
item.Movement?.ToOther, item.Movement?.ToOther,
item.Movement?.LatestStatus, item.Movement?.LatestStatus,
item.Movement?.LastUser, item.Movement?.ToUser,
item.Movement?.LastStore, item.Movement?.ToStore,
item.Movement?.MovementComplete, item.Movement?.MovementComplete,
remark = item.Movement?.Remark, remark = item.Movement?.Remark,
QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}", // Generate QR String QRString = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.Value}/I/{item.UniqueID}", // Generate QR String
@ -959,9 +1021,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
i.Id, i.Id,
i.ItemId, i.ItemId,
i.ToStation, i.LastStation,
i.ToStore, i.LastStore,
i.ToUser, i.LastUser,
UniqueID = i.Item?.UniqueID, UniqueID = i.Item?.UniqueID,
ProductName = i.Item?.Product?.ProductName, ProductName = i.Item?.Product?.ProductName,
ProductCategory = i.Item?.Product?.Category, ProductCategory = i.Item?.Product?.Category,
@ -979,9 +1041,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
i.Remark, i.Remark,
i.ConsignmentNote, i.ConsignmentNote,
i.Date, i.Date,
i.LastUser, i.ToUser,
i.LastStore, i.ToStore,
i.LastStation, i.ToStation,
i.LatestStatus, i.LatestStatus,
i.receiveDate, i.receiveDate,
i.MovementComplete i.MovementComplete
@ -1001,10 +1063,10 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
itemmovement.sendDate = DateTime.Now; // This ensures hours/minutes/seconds are captured itemmovement.sendDate = DateTime.Now; // This ensures hours/minutes/seconds are captured
itemmovement.Date = DateTime.Now; // Set the general record date as well itemmovement.Date = DateTime.Now; // Set the general record date as well
var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.ToUser); var inventoryMaster = await _centralDbContext.InventoryMasters.Include("User").FirstOrDefaultAsync(i => i.UserId == itemmovement.LastUser);
if (inventoryMaster != null) if (inventoryMaster != null)
{ {
itemmovement.ToStore = inventoryMaster.StoreId; itemmovement.LastStore = inventoryMaster.StoreId;
} }
@ -1084,9 +1146,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
itemmovement.Id, itemmovement.Id,
itemmovement.ItemId, itemmovement.ItemId,
itemmovement.ToStation, itemmovement.LastStation,
itemmovement.ToStore, itemmovement.LastStore,
itemmovement.ToUser, itemmovement.LastUser,
itemmovement.ToOther, itemmovement.ToOther,
itemmovement.sendDate, itemmovement.sendDate,
itemmovement.Action, itemmovement.Action,
@ -1094,9 +1156,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
itemmovement.Remark, itemmovement.Remark,
itemmovement.ConsignmentNote, itemmovement.ConsignmentNote,
itemmovement.Date, itemmovement.Date,
itemmovement.LastUser, itemmovement.ToUser,
itemmovement.LastStore, itemmovement.ToStore,
itemmovement.LastStation, itemmovement.ToStation,
itemmovement.LatestStatus, itemmovement.LatestStatus,
itemmovement.receiveDate, itemmovement.receiveDate,
itemmovement.MovementComplete itemmovement.MovementComplete
@ -1122,7 +1184,8 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
return NotFound("Item movement record not found."); return NotFound("Item movement record not found.");
} }
updatedList.LastUser = receiveMovement.LastUser; updatedList.ToUser = receiveMovement.ToUser;
updatedList.ToStore = receiveMovement.ToStore;
updatedList.LatestStatus = receiveMovement.LatestStatus; updatedList.LatestStatus = receiveMovement.LatestStatus;
updatedList.receiveDate = receiveMovement.receiveDate; updatedList.receiveDate = receiveMovement.receiveDate;
updatedList.Remark = receiveMovement.Remark; updatedList.Remark = receiveMovement.Remark;
@ -1248,16 +1311,16 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
.Include(i => i.NextStore) .Include(i => i.NextStore)
.Include(i => i.NextStation) .Include(i => i.NextStation)
.Include(i => i.NextUser) .Include(i => i.NextUser)
.Where(i => i.ToUser == user.Id || i.LastUser == user.Id) .Where(i => i.LastUser == user.Id || i.ToUser == user.Id)
.ToListAsync(); .ToListAsync();
return Json(itemMovementUser.Select(i => new return Json(itemMovementUser.Select(i => new
{ {
i.Id, i.Id,
i.ItemId, i.ItemId,
i.ToStation, i.LastStation,
i.ToStore, i.LastStore,
i.ToUser, i.LastUser,
UniqueID = i.Item?.UniqueID, UniqueID = i.Item?.UniqueID,
ProductName = i.Item?.Product?.ProductName, ProductName = i.Item?.Product?.ProductName,
ProductImage = i.Item?.Product?.ImageProduct, ProductImage = i.Item?.Product?.ImageProduct,
@ -1274,9 +1337,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
i.Remark, i.Remark,
i.ConsignmentNote, i.ConsignmentNote,
i.Date, i.Date,
i.LastUser, i.ToUser,
i.LastStore, i.ToStore,
i.LastStation, i.ToStation,
i.LatestStatus, i.LatestStatus,
i.receiveDate, i.receiveDate,
i.MovementComplete i.MovementComplete
@ -1874,7 +1937,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
if (!string.IsNullOrEmpty(returnMovement.ConsignmentNote)) if (!string.IsNullOrEmpty(returnMovement.ConsignmentNote))
{ {
var findUniqueCode = _centralDbContext.Items.Include(i => i.Product).FirstOrDefault(r => r.ItemID == returnMovement.ItemId); var findUniqueCode = _centralDbContext.Items.Include(i => i.Product).FirstOrDefault(r => r.ItemID == returnMovement.ItemId);
var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == returnMovement.ToUser); var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == returnMovement.LastUser);
var bytes = Convert.FromBase64String(returnMovement.ConsignmentNote); var bytes = Convert.FromBase64String(returnMovement.ConsignmentNote);
@ -1922,9 +1985,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
{ {
updateItemIdMovement.Id, updateItemIdMovement.Id,
updateItemIdMovement.ItemId, updateItemIdMovement.ItemId,
updateItemIdMovement.ToStation, updateItemIdMovement.LastStation,
updateItemIdMovement.ToStore, updateItemIdMovement.LastStore,
updateItemIdMovement.ToUser, updateItemIdMovement.LastUser,
updateItemIdMovement.ToOther, updateItemIdMovement.ToOther,
updateItemIdMovement.sendDate, updateItemIdMovement.sendDate,
updateItemIdMovement.Action, updateItemIdMovement.Action,
@ -1932,9 +1995,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
updateItemIdMovement.Remark, updateItemIdMovement.Remark,
updateItemIdMovement.ConsignmentNote, updateItemIdMovement.ConsignmentNote,
updateItemIdMovement.Date, updateItemIdMovement.Date,
updateItemIdMovement.LastUser, updateItemIdMovement.ToUser,
updateItemIdMovement.LastStore, updateItemIdMovement.ToStore,
updateItemIdMovement.LastStation, updateItemIdMovement.ToStation,
updateItemIdMovement.LatestStatus, updateItemIdMovement.LatestStatus,
updateItemIdMovement.receiveDate, updateItemIdMovement.receiveDate,
updateItemIdMovement.MovementComplete updateItemIdMovement.MovementComplete
@ -1960,7 +2023,7 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
if (!string.IsNullOrEmpty(stationMovement.ConsignmentNote)) if (!string.IsNullOrEmpty(stationMovement.ConsignmentNote))
{ {
var findUniqueCode = _centralDbContext.Items.Include(i => i.Product).FirstOrDefault(r => r.ItemID == stationMovement.ItemId); var findUniqueCode = _centralDbContext.Items.Include(i => i.Product).FirstOrDefault(r => r.ItemID == stationMovement.ItemId);
var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == stationMovement.ToUser); var findUniqueUser = _centralDbContext.Users.FirstOrDefault(r => r.Id == stationMovement.LastUser);
var bytes = Convert.FromBase64String(stationMovement.ConsignmentNote); var bytes = Convert.FromBase64String(stationMovement.ConsignmentNote);
string filePath = ""; string filePath = "";
@ -2012,9 +2075,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
updateItemIdMovement.Id, updateItemIdMovement.Id,
updateItemIdMovement.ItemId, updateItemIdMovement.ItemId,
updateItemIdMovement.Item?.UniqueID, updateItemIdMovement.Item?.UniqueID,
updateItemIdMovement.ToStation, updateItemIdMovement.LastStation,
updateItemIdMovement.ToStore, updateItemIdMovement.LastStore,
updateItemIdMovement.ToUser, updateItemIdMovement.LastUser,
updateItemIdMovement.ToOther, updateItemIdMovement.ToOther,
updateItemIdMovement.sendDate, updateItemIdMovement.sendDate,
updateItemIdMovement.Action, updateItemIdMovement.Action,
@ -2022,9 +2085,9 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
updateItemIdMovement.Remark, updateItemIdMovement.Remark,
updateItemIdMovement.ConsignmentNote, updateItemIdMovement.ConsignmentNote,
updateItemIdMovement.Date, updateItemIdMovement.Date,
updateItemIdMovement.LastUser, updateItemIdMovement.ToUser,
updateItemIdMovement.LastStore, updateItemIdMovement.ToStore,
updateItemIdMovement.LastStation, updateItemIdMovement.ToStation,
updateItemIdMovement.LatestStatus, updateItemIdMovement.LatestStatus,
updateItemIdMovement.receiveDate, updateItemIdMovement.receiveDate,
updateItemIdMovement.MovementComplete updateItemIdMovement.MovementComplete