Added item id select box in wire master packing #797
@@ -65,30 +65,50 @@ class WireMasterPackingResource extends Resource
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
// return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
||||||
|
return CustomerPoMaster::where('plant_id', $plantId)->distinct()->pluck('customer_po', 'customer_po');
|
||||||
|
|
||||||
})
|
})
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
if (!$state) {
|
if (!$state) {
|
||||||
$set('item', null);
|
$set('item_id', null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$customerPo = CustomerPoMaster::find($state);
|
$set('item_id', null);
|
||||||
|
$set('wire_packing_number', null);
|
||||||
|
|
||||||
if ($customerPo && $customerPo->item_id) {
|
// $customerPo = CustomerPoMaster::find($state);
|
||||||
$item = Item::find($customerPo->item_id);
|
|
||||||
|
|
||||||
$set('item', $item?->code);
|
// if ($customerPo && $customerPo->item_id) {
|
||||||
} else {
|
// $item = Item::find($customerPo->item_id);
|
||||||
$set('item', null);
|
|
||||||
}
|
// $set('item', $item?->code);
|
||||||
|
// } else {
|
||||||
|
// $set('item', null);
|
||||||
|
// }
|
||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('item')
|
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
->reactive()
|
->reactive()
|
||||||
->readOnly()
|
->searchable()
|
||||||
->dehydrated(false),
|
->options(function (callable $get) {
|
||||||
|
|
||||||
|
$customerPoId = $get('customer_po_master_id');
|
||||||
|
|
||||||
|
if (!$customerPoId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::whereIn(
|
||||||
|
'id',
|
||||||
|
CustomerPoMaster::where('customer_po', $customerPoId)
|
||||||
|
->pluck('item_id')
|
||||||
|
)->pluck('code', 'id');
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
Forms\Components\TextInput::make('wire_packing_number')
|
Forms\Components\TextInput::make('wire_packing_number')
|
||||||
->label('Scan Wire Packing No')
|
->label('Scan Wire Packing No')
|
||||||
->reactive()
|
->reactive()
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
|
|
||||||
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
|
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
|
||||||
|
|
||||||
|
$selectedItem = trim($this->form->getState()['item_id'])?? null;
|
||||||
|
|
||||||
$wirePackNo = trim($this->form->getState()['wire_packing_number'])?? null;
|
$wirePackNo = trim($this->form->getState()['wire_packing_number'])?? null;
|
||||||
|
|
||||||
$wirePackNo = trim($wirePackNo) ?? null;
|
$wirePackNo = trim($wirePackNo) ?? null;
|
||||||
@@ -168,6 +170,26 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->value('id');
|
->value('id');
|
||||||
|
|
||||||
|
if($itemId != $selectedItem){
|
||||||
|
Notification::make()
|
||||||
|
->title("Item Code Mismatch")
|
||||||
|
->body("Scanned Item Code '$materialCode' does not match the selected Item in the form.")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
$icodeAgaCPoPlant = CustomerPoMaster::where('item_id', $itemId)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
if(!$icodeAgaCPoPlant)
|
if(!$icodeAgaCPoPlant)
|
||||||
@@ -214,23 +236,24 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$customerPoRecord = CustomerPoMaster::where('id', $customerPo)
|
$customerPoRecord = CustomerPoMaster::where('customer_po', $customerPo)
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
|
->where('item_id', $itemId)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
$customerPoName = $customerPoRecord->customer_po;
|
// $customerPoName = $customerPoRecord->customer_po;
|
||||||
|
|
||||||
if ($customerPoRecord) {
|
// if ($customerPoRecord) {
|
||||||
$customerPoName = $customerPoRecord->customer_po;
|
// $customerPoName = $customerPoRecord->customer_po;
|
||||||
} else {
|
// } else {
|
||||||
$customerPoName = null;
|
// $customerPoName = null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(!$customerPoRecord)
|
if(!$customerPoRecord)
|
||||||
{
|
{
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("PO Not Found")
|
->title("PO Not Found")
|
||||||
->body("Customer PO '$customerPoName' for Item '$materialCode' not found against Plant '$plantcode'")
|
->body("Customer PO '$customerPoRecord->customer_po' for Item '$materialCode' not found against Plant '$plantcode'")
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -247,7 +270,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPo)
|
$alreadyScannedQty = WireMasterPacking::where('customer_po_master_id', $customerPoRecord->id)
|
||||||
->where('plant_id', $plantId)
|
->where('plant_id', $plantId)
|
||||||
->where('item_id', $itemId)
|
->where('item_id', $itemId)
|
||||||
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
->selectRaw('SUM(CAST(weight AS NUMERIC)) as total_weight')
|
||||||
@@ -259,7 +282,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
{
|
{
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Scanned Weight Exceeds PO Quantity")
|
->title("Scanned Weight Exceeds PO Quantity")
|
||||||
->body("Scanned weight '$weight' and already scanned weight '$alreadyScannedQty' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPoName' and Item '$materialCode'")
|
->body("Scanned weight '$weight' and already scanned weight '$alreadyScannedQty' exceeds allowed quantity '{$customerPoRecord->quantity}' for PO '$customerPoRecord->name' and Item '$materialCode'")
|
||||||
->danger()
|
->danger()
|
||||||
->duration(5000)
|
->duration(5000)
|
||||||
->send();
|
->send();
|
||||||
@@ -268,6 +291,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
'process_order' => null,
|
'process_order' => null,
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'Sno_quantity' => 0,
|
'Sno_quantity' => 0,
|
||||||
'created_by' => $operatorName,
|
'created_by' => $operatorName,
|
||||||
@@ -294,7 +318,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => $processOrderId . '-' . $coilNo,
|
'process_order' => $processOrderId . '-' . $coilNo,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPoRecord->id,
|
||||||
'weight' => $weight,
|
'weight' => $weight,
|
||||||
'created_by' => $createdBy,
|
'created_by' => $createdBy,
|
||||||
'scanned_by' => $operatorName,
|
'scanned_by' => $operatorName,
|
||||||
@@ -314,6 +338,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => null,
|
'process_order' => null,
|
||||||
// 'pending_pallet_list' => $pendingPallet,
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
@@ -334,6 +359,7 @@ class CreateWireMasterPacking extends CreateRecord
|
|||||||
$this->form->fill([
|
$this->form->fill([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'customer_po_master_id' => $customerPo,
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'item_id' => $itemId,
|
||||||
'wire_packing_number' => $wirePackNo,
|
'wire_packing_number' => $wirePackNo,
|
||||||
'process_order' => null,
|
'process_order' => null,
|
||||||
// 'pending_pallet_list' => $pendingPallet,
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
|
|||||||
Reference in New Issue
Block a user