diff --git a/app/Filament/Pages/ProductionQuantityPage.php b/app/Filament/Pages/ProductionQuantityPage.php
index 35e93b3..780f37e 100644
--- a/app/Filament/Pages/ProductionQuantityPage.php
+++ b/app/Filament/Pages/ProductionQuantityPage.php
@@ -6,9 +6,9 @@ use App\Models\Item;
use App\Models\Line;
use App\Models\Machine;
use App\Models\Plant;
+use App\Models\ProductionPlan;
use App\Models\ProductionQuantity;
use App\Models\Shift;
-use App\Models\Block;
use Carbon\Carbon;
use Filament\Facades\Filament;
use Filament\Forms\Components\Hidden;
@@ -17,19 +17,18 @@ use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
+use Filament\Notifications\Notification;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Pages\Page;
-use Route;
-use Illuminate\Support\Facades\Request;
-use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Request;
use Livewire\Attributes\On;
-
+use Route;
class ProductionQuantityPage extends Page implements HasForms
{
-
use InteractsWithForms;
+
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.production-quantity';
@@ -40,12 +39,43 @@ class ProductionQuantityPage extends Page implements HasForms
protected static ?string $navigationGroup = 'Production';
- public $qrData, $pId, $bId, $sId, $lId, $iId, $succId, $sNoId, $succStat, $recQr, $prodOrder, $workCenter, $mId;
+ public $qrData;
+
+ public $pId;
+
+ public $mId;
+
+ public $mNam;
+
+ public $bId;
+
+ public $bNam;
+
+ public $sId;
+
+ public $sNam;
+
+ public $lId;
+
+ public $lNam;
+
+ public $iId;
+
+ public $succId;
+
+ public $sNoId;
+
+ public $succStat;
+
+ public $recQr;
+
+ public $prodOrder;
+
+ public $workCenter;
public $recent_qr;
- // public $recent_qr, $clear_qr;
-
+ // public $recent_qr, $clear_qr;
use HasFiltersForm;
@@ -58,6 +88,7 @@ class ProductionQuantityPage extends Page implements HasForms
'line' => null,
]);
}
+
public function boot(): void
{
Filament::registerRenderHook(
@@ -65,7 +96,7 @@ class ProductionQuantityPage extends Page implements HasForms
function () {
// Check if the current route matches '/admin/production-quantity'
if (Request::is('admin/production-quantity*')) {
- echo <<
/* Hide sidebar and topbar */
.fi-sidebar,
@@ -142,12 +173,12 @@ class ProductionQuantityPage extends Page implements HasForms
->default(function () {
return optional(ProductionQuantity::latest()->first())->plant_id;
})
- ->afterStateUpdated(function ($state, $set, callable $get,$livewire) {
+ ->afterStateUpdated(function ($state, $set, callable $get, $livewire) {
$plantId = $get('plant_id');
$set('block_name', null);
$now = Carbon::now()->format('H:i:s');
- $shiftType = ($now >= '08:00:00' && $now <= '19:29:59')
+ $shiftType = ($now >= '08:00:00' && $now <= '19:29:59')
? 'Day'
: 'Night';
@@ -155,27 +186,25 @@ class ProductionQuantityPage extends Page implements HasForms
session(['select_plant' => $state]);
- if (!$plantId)
- {
+ if (! $plantId) {
$set('pqPlantError', 'Please select a plant first.');
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> null,
- 'shift_id'=> null,
- 'line_id'=> null,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'block_name' => null,
+ 'shift_id' => null,
+ 'line_id' => null,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
+
return;
- }
- else
- {
+ } else {
$this->pId = $plantId;
$set('validationError', null);
$set('pqPlantError', null);
@@ -223,7 +252,6 @@ class ProductionQuantityPage extends Page implements HasForms
// $set('shift', $shiftType);
-
// session(['select_line' => $state]);
// // dd(session('select_line'));
@@ -249,7 +277,6 @@ class ProductionQuantityPage extends Page implements HasForms
// ->hint(fn ($get) => $get('pqLineError') ? $get('pqLineError') : null)
// ->hintColor('danger'),
-
TextInput::make('machine_id')
->label('Machine')
->required()
@@ -259,174 +286,168 @@ class ProductionQuantityPage extends Page implements HasForms
$plantId = $get('plant_id');
$machineId = $get('machine_id');
- $this->mId = $machineId;
+ $this->mNam = $machineId;
})
->extraAttributes(fn ($get) => [
// 'class' => $get('pqLineError') ? 'border-red-500' : '',
'wire:keydown.enter' => 'processMachine($event.target.value)',
]),
- // ->hint(fn ($get) => $get('pqLineError') ? $get('pqLineError') : null)
- // ->hintColor('danger'),
+ // ->hint(fn ($get) => $get('pqLineError') ? $get('pqLineError') : null)
+ // ->hintColor('danger'),
- TextInput::make('line_id')
- ->label('Line')
- ->reactive()
- ->readOnly()
- ->required()
- ->afterStateUpdated(fn ($state) => $this->lId = $state),
+ TextInput::make('line_id')
+ ->label('Line')
+ ->reactive()
+ ->readOnly()
+ ->required()
+ ->afterStateUpdated(fn ($state) => $this->lNam = $state),
- TextInput::make('block_name')
- ->label('Block')
- ->reactive()
- ->readOnly()
- ->required(),
+ TextInput::make('block_name')
+ ->label('Block')
+ ->reactive()
+ ->readOnly()
+ ->required()
+ ->afterStateUpdated(fn ($state) => $this->bNam = $state),
- TextInput::make('shift_id')
- ->label('Shift')
- ->reactive()
- ->readOnly()
- ->required()
- ->afterStateUpdated(fn ($state) => $this->sId = $state),
- TextInput::make('production_order')
- ->label('Production Order')
- ->reactive()
- ->required()
- ->minLength(7)
- ->maxLength(14)
- //->columnSpan(1)
- ->columnSpan(['default' => 1, 'sm' => 1])
- ->afterStateUpdated(function ($state, callable $get, callable $set): void {
- if(!is_numeric($get('production_order')) || !preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order')))
- {
- $set('productionError', "Must be a numeric value with 7 to 14 digits.");
- $set('production_order', null);
- $set('item_code', null);
- $set('item_id', null);
- // $set('item_description', null);
- $set('serial_number', null);
- $set('validationError', null);
- $this->prodOrder = null;
- }
- else
- {
- $set('productionError', null);
- $set('production_order', $state);
- $set('item_code', null);
- $set('item_id', null);
- // $set('item_description', null);
- $set('serial_number', null);
- $set('validationError', null);
- $this->prodOrder = $state;
- // if (empty($state)) {
- // }
- }
- })
- ->extraAttributes(fn ($get) => [
- 'id' => 'scan_locator_no',
- 'class' => $get('productionError') ? 'border-red-500' : '',
- ])
- ->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
- ->hintColor('danger'),
+ TextInput::make('shift_id')
+ ->label('Shift')
+ ->reactive()
+ ->readOnly()
+ ->required()
+ ->afterStateUpdated(fn ($state) => $this->sNam = $state),
+ TextInput::make('production_order')
+ ->label('Production Order')
+ ->reactive()
+ ->required()
+ ->minLength(7)
+ ->maxLength(14)
+ // ->columnSpan(1)
+ ->columnSpan(['default' => 1, 'sm' => 1])
+ ->afterStateUpdated(function ($state, callable $get, callable $set): void {
+ if (! is_numeric($get('production_order')) || ! preg_match('/^[1-9][0-9]{6,13}$/', $get('production_order'))) {
+ $set('productionError', 'Must be a numeric value with 7 to 14 digits.');
+ $set('production_order', null);
+ $set('item_code', null);
+ $set('item_id', null);
+ // $set('item_description', null);
+ $set('serial_number', null);
+ $set('validationError', null);
+ $this->prodOrder = null;
+ } else {
+ $set('productionError', null);
+ $set('production_order', $state);
+ $set('item_code', null);
+ $set('item_id', null);
+ // $set('item_description', null);
+ $set('serial_number', null);
+ $set('validationError', null);
+ $this->prodOrder = $state;
+ // if (empty($state)) {
+ // }
+ }
+ })
+ ->extraAttributes(fn ($get) => [
+ 'id' => 'scan_locator_no',
+ 'class' => $get('productionError') ? 'border-red-500' : '',
+ ])
+ ->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
+ ->hintColor('danger'),
- Hidden::make('serial_number')
+ Hidden::make('serial_number')
->required(),
- Hidden::make('success_msg')
+ Hidden::make('success_msg')
->required(),
- Hidden::make('item_id')
+ Hidden::make('item_id')
->required(),
- Hidden::make('sap_msg_status'),
- Hidden::make('sap_msg_description'),
+ Hidden::make('sap_msg_status'),
+ Hidden::make('sap_msg_description'),
- TextInput::make('recent_qr')
+ TextInput::make('recent_qr')
->label('Last scanned QR')
->reactive()
->columnSpan(['default' => 1, 'sm' => 2])
- //->columnSpan(2)
- // ->default(function () {
- // // Get the latest 'item_id' foreign key from 'production_quantities' table
- // $latestProductionQuantity = ProductionQuantity::latest()->first();
- // if (!$latestProductionQuantity) {
- // return null; // Return null if no production quantities exist
- // }
+ // ->columnSpan(2)
+ // ->default(function () {
+ // // Get the latest 'item_id' foreign key from 'production_quantities' table
+ // $latestProductionQuantity = ProductionQuantity::latest()->first();
+ // if (!$latestProductionQuantity) {
+ // return null; // Return null if no production quantities exist
+ // }
- // // Get the corresponding 'code' from 'items' table where 'id' matches 'item_id'
- // $itemCode = optional(Item::find($latestProductionQuantity->item_id))->code;
+ // // Get the corresponding 'code' from 'items' table where 'id' matches 'item_id'
+ // $itemCode = optional(Item::find($latestProductionQuantity->item_id))->code;
- // // Get the latest 'serial_number' from 'production_quantities' table
- // $serialNumber = $latestProductionQuantity->serial_number;
+ // // Get the latest 'serial_number' from 'production_quantities' table
+ // $serialNumber = $latestProductionQuantity->serial_number;
- // // Combine 'code' and 'serial_number' into the desired format
- // // return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
+ // // Combine 'code' and 'serial_number' into the desired format
+ // // return $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
- // $this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
+ // $this->recQr = $itemCode && $serialNumber ? "{$itemCode} | {$serialNumber}" : null;
- // })
+ // })
->default(fn () => $this->recQr)
->readOnly(true),
-
- TextInput::make('id')
+ TextInput::make('id')
->hidden()
->readOnly(),
- Hidden::make('operator_id')
+ Hidden::make('operator_id')
->default(Filament::auth()->user()->name),
])
// ->columns(6);
- ->columns(['default' => 1, 'sm' => 8]);
+ ->columns(['default' => 1, 'sm' => 8]);
}
- public function processMachine($value){
-
+ public function processMachine($value)
+ {
$plantId = $this->pId;
- $workCenter = $value;
+ $this->mNam = $value;
$now = Carbon::now()->format('H:i:s');
- $this->sId = ($now >= '08:00:00' && $now <= '19:29:59')
+ $this->sNam = ($now >= '08:00:00' && $now <= '19:29:59')
? 'Day'
: 'Night';
-
- $machine = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->with('line.block')->first();
+ $machine = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->with('line.block')->first();
if ($machine) {
- $this->lId = Line::where('id', $machine->line_id)->value('name');
- $this->bId = $machine->line->block->name ?? null;
+ $this->lNam = Line::where('id', $machine->line_id)->value('name');
+ $this->bNam = $machine->line->block->name ?? null;
- // dd($lineName, $blockName);
+ // dd($lineName, $blockName);
session(['select_line' => $machine->line_id]);
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id' => $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
$this->triggerChartUpdate();
- }
- else
- {
+ } else {
- Notification::make()
+ Notification::make()
->title('Unknown WorkCenter')
- ->body("Work Center not found")
+ ->body('Work Center not found')
->danger()
->send();
+
return;
}
}
-
// Method to process the value when Enter is pressed
#[On('handleQrScan')]
@@ -438,21 +459,21 @@ class ProductionQuantityPage extends Page implements HasForms
public function processAllValues($formQRData)
{
- //dd($formQRData);
- //$formValues = [];
+ // dd($formQRData);
+ // $formValues = [];
// This will get all form data from the request
- //$this->clear_qr = null;
+ // $this->clear_qr = null;
$this->qrData = null;
$this->iId = null;
$this->succId = null;
$this->sNoId = null;
$this->succStat = null;
- $this->validateAndProcessForm( $formQRData); // Process the form values
+ $this->validateAndProcessForm($formQRData); // Process the form values
}
public function validateAndProcessForm($formQRData)
{
- $user = Filament::auth()->user(); //->name
+ $user = Filament::auth()->user(); // ->name
$operatorName = $user->name;
$this->qrData = $formQRData;
@@ -466,67 +487,66 @@ class ProductionQuantityPage extends Page implements HasForms
if (empty($formQRData)) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid QR')
- ->body("Scan the valid QR code.
(Ex: Item_Code|Serial_Number )")
+ ->body('Scan the valid QR code.
(Ex: Item_Code|Serial_Number )')
->danger()
->send();
+
return;
- }
- else
- {
- if (!$this->pId) {
+ } else {
+ if (! $this->pId) {
$this->form->fill([
- 'plant_id'=> null,
- 'machine_id'=> null,
- 'block_name'=> null,
- 'shift_id'=> null,
- 'line_id'=> null,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => null,
+ 'machine_id' => null,
+ 'block_name' => null,
+ 'shift_id' => null,
+ 'line_id' => null,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Choose Plant')
- ->body("Please select a plant first.")
+ ->body('Please select a plant first.')
->danger()
->send();
+
return;
- }
- else if (!$this->mId) {
+ } elseif (! $this->mNam) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> null,
- 'block_name'=> null,
- 'shift_id'=> null,
- 'line_id'=> null,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'machine_id' => null,
+ 'block_name' => null,
+ 'shift_id' => null,
+ 'line_id' => null,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -534,153 +554,152 @@ class ProductionQuantityPage extends Page implements HasForms
->body("Machine can't be empty!")
->danger()
->send();
+
return;
- }
- else if (!$this->lId) {
+ } elseif (! $this->lNam) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id' => $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> null,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => null,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Choose Line')
- ->body("Please select a line first.")
+ ->body('Please select a line first.')
->danger()
->send();
+
return;
- }
- else if (!$this->bId) {
+ } elseif (! $this->bNam) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id' => $this->mId,
- 'block_name'=> null,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => null,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Choose Line')
- ->body("Please select a Block first.")
+ ->body('Please select a Block first.')
->danger()
->send();
+
return;
- }
- else if (!$this->sId) {
+ } elseif (! $this->sNam) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id' => $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> null,
- 'line_id'=> null,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => null,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Choose Shift')
- ->body("Please select a shift first.")
+ ->body('Please select a shift first.')
->danger()
->send();
+
return;
- }
- else if (!$this->prodOrder) {
+ } elseif (! $this->prodOrder) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Please scan the production order first.')
->danger()
->send();
+
return;
}
- if(!is_numeric($this->prodOrder))
- {
+ if (! is_numeric($this->prodOrder)) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid Production Order')
- ->body("Must contain numeric values only.")
+ ->body('Must contain numeric values only.')
->danger()
->send();
+
return;
- }
- else if (!preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder))
- {
+ } elseif (! preg_match('/^[1-9][0-9]{6,13}$/', $this->prodOrder)) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> null,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => null,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid Production Order')
- ->body("Must be a numeric value with 7 to 14 digits.
Must start with a non-zero digit.")
+ ->body('Must be a numeric value with 7 to 14 digits.
Must start with a non-zero digit.')
->danger()
->send();
+
return;
}
-
// $exists = \App\Models\ProductionPlan::where('plant_id', $this->pId)
// ->where('shift_id', $this->sId)
// ->where('line_id', $this->lId)
@@ -1012,177 +1031,220 @@ class ProductionQuantityPage extends Page implements HasForms
// 'operator_id'=> $operatorName,
// 'recent_qr' => $this->recQr,
// ]);
+
}
- if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData)) {
+ if (! preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData)) {
- if (strpos($formQRData, '|') === false) {
+ if (strpos($formQRData, '|') == false) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Invalid QR')
- ->body("Scan the valid QR code.
(Ex: Item_Code|Serial_Number )")
+ ->body('Scan the valid QR code.
(Ex: Item_Code|Serial_Number )')
->danger()
->send();
+
return;
- }
- else
- {
+ } else {
$splits = explode('|', $formQRData);
$iCode = trim($splits[0]);
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
- if (!ctype_alnum($iCode)) {
+ // $machine = Machine::where('work_center', $this->mNam)->where('plant_id', $this->pId)->first();
+
+ // $this->mId = $machine->id;
+
+ // $lineId = $machine->line_id;
+ // $this->lId = $lineId;
+
+ // $line = Line::find($lineId);
+ // if (! $line) {
+ // Notification::make()
+ // ->title('Invalid Line')
+ // ->body('Line associated with the machine not found.')
+ // ->danger()
+ // ->send();
+
+ // return;
+ // }
+
+ // $blockId = $line->block_id;
+ // $this->bId = $blockId;
+
+ // $shift = Shift::where('block_id', $blockId)->first();
+ // if (! $shift) {
+ // Notification::make()
+ // ->title('No Shift Found')
+ // ->body('No shift associated with this block.')
+ // ->danger()
+ // ->send();
+
+ // return;
+ // }
+
+ // $shiftId = $shift->id;
+ // $this->sId = $shiftId;
+
+ // $line = Line::with('block')->find($lineId);
+
+ // $lineName = $line?->name;
+ // $blockName = $line?->block?->name;
+ // $shiftName = $shift?->name;
+
+ if (! ctype_alnum($iCode)) {
+
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
- 'recent_qr' => $this->recQr,
+ 'operator_id' => $operatorName,
+ 'recent_qr' => $this->recent_qr,
]);
Notification::make()
->title('Invalid Item Code')
- ->body("Item code must contain alpha-numeric values only.")
+ ->body('Item code must contain alpha-numeric values only.')
->danger()
->send();
+
return;
- }
- else if (strlen($iCode) < 6) {
+ } elseif (strlen($iCode) < 6) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
- 'recent_qr' => $this->recQr,
+ 'operator_id' => $operatorName,
+ 'recent_qr' => $this->recent_qr,
]);
Notification::make()
->title('Invalid Item Code')
- ->body("Item code must be at least 6 digits.")
+ ->body('Item code must be at least 6 digits.')
->danger()
->send();
+
return;
- }
- else if (!ctype_alnum($sNumber)) {
+ } elseif (! ctype_alnum($sNumber)) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
- 'recent_qr' => $this->recQr,
+ 'operator_id' => $operatorName,
+ 'recent_qr' => $this->recent_qr,
]);
Notification::make()
->title('Invalid Serial Number')
- ->body("Serial Number must contain alpha-numeric values only.")
+ ->body('Serial Number must contain alpha-numeric values only.')
->danger()
->duration(800)
->send();
+
return;
- }
- else if (strlen($sNumber) < 9) {
+ } elseif (strlen($sNumber) < 9) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
- 'recent_qr' => $this->recQr,
+ 'operator_id' => $operatorName,
+ 'recent_qr' => $this->recent_qr,
]);
Notification::make()
->title('Invalid Serial Number')
- ->body("Serial Number must be at least 9 digits.")
+ ->body('Serial Number must be at least 9 digits.')
->danger()
->duration(800)
->send();
+
return;
}
}
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $this->mId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
- 'recent_qr' => $this->recQr,
+ 'operator_id' => $operatorName,
+ 'recent_qr' => $this->recent_qr,
]);
Notification::make()
->title('Invalid QR')
- ->body("Scan the valid QR code.
(Ex: Item_Code|Serial_Number )")
+ ->body('Scan the valid QR code.
(Ex: Item_Code|Serial_Number )')
->danger()
->send();
+
return;
- }
- else
- {
+ } else {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
}
@@ -1194,27 +1256,28 @@ class ProductionQuantityPage extends Page implements HasForms
// Fetch item using item code and plant_id
$masItem = Item::where('code', $itemCode)->first();
- if (!$masItem)
- {
+ if (! $masItem) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Unknown Item Code')
- ->body("Item code does not exist in master data.")
+ ->body('Item code does not exist in master data.')
->danger()
->send();
+
return;
}
@@ -1222,103 +1285,102 @@ class ProductionQuantityPage extends Page implements HasForms
->where('plant_id', $this->pId)
->first();
- if ($item)
- {
+ if ($item) {
$sNo = ProductionQuantity::where('serial_number', $serialNumber)->where('plant_id', $this->pId)->exists();
- if (!$sNo)
- {
+ if (! $sNo) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> $item->id,
- 'serial_number'=> null,
- 'success_msg'=> 'Y',
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => $item->id,
+ 'serial_number' => null,
+ 'success_msg' => 'Y',
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
$this->succId = 'Y';
$this->iId = $item->id;
- }
- else
- {
+ } else {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Duplicate Serial Number')
- ->body("Serial number already exist in database for choosed plant.")
+ ->body('Serial number already exist in database for choosed plant.')
->danger()
->send();
+
return;
}
- }
- else
- {
+ } else {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
->title('Unknown Item Code')
- ->body("Item code does not exist in master data for choosed plant.")
+ ->body('Item code does not exist in master data for choosed plant.')
->danger()
->send();
+
return;
}
- if ($this->succId === null) {
+ if ($this->succId == null) {
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'block_name'=> $this->bId,
- 'shift_id'=> $this->sId,
- 'line_id'=> $this->lId,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recQr,
]);
Notification::make()
- ->title("Invalid QR Found") // {$operatorName}
- ->body("Please, scan the valid QR code.")
- ->danger()
+ ->title('Invalid QR Found') // {$operatorName}
+ ->body('Please, scan the valid QR code.')
+ ->danger()
// ->persistent()
- ->send();
+ ->send();
+
return;
- }
- else
- {
+ } else {
// // Perform any additional processing or database operations
// $this->saveFormData($formValues);
@@ -1326,91 +1388,125 @@ class ProductionQuantityPage extends Page implements HasForms
$itemCode = trim($parts[0]);
$this->sNoId = isset($parts[1]) ? trim($parts[1]) : null;
- $machine = Machine::where('work_center', $this->mId)->where('plant_id', $this->pId)->first();
+ $machine = Machine::where('work_center', $this->mNam)->where('plant_id', $this->pId)->first();
- $workCenter = $this->mId;
-
- if (!$machine) {
+ if (! $machine) {
Notification::make()
->title('Unknown Machine')
- ->body("Work center {$this->mId} not found for this plant.")
+ ->body("Work center {$this->mNam} not found for this plant.")
->danger()
->send();
+
return;
}
- $machineId = $machine->id;
- $this->mId = $machineId;
+ $this->mId = $machine->id;
- $lineId = $machine->line_id;
- $this->lId = $lineId;
+ $this->lId = $machine->line_id;
- $line = Line::find($lineId);
- if (!$line) {
+ $line = Line::find($this->lId);
+ if (! $line) {
Notification::make()
->title('Invalid Line')
->body('Line associated with the machine not found.')
->danger()
->send();
+
return;
}
- $blockId = $line->block_id;
- $this->bId = $blockId;
+ $this->bId = $line->block_id;
- $shift = Shift::where('block_id', $blockId)->first();
- if (!$shift) {
+ $shift = Shift::where('block_id', $this->bId)->first();
+ if (! $shift) {
Notification::make()
->title('No Shift Found')
->body('No shift associated with this block.')
->danger()
->send();
+
return;
}
- $shiftId = $shift->id;
- $this->sId = $shiftId;
+ $this->sId = $shift->id;
+
+ $currentMonth = Carbon::now()->month;
+ $currentYear = Carbon::now()->year;
+
+ // $line = Line::with('block')->find($this->lId);
+
+ // $this->lNam = $line?->name;
+ // $this->bNam = $line?->block?->name;
+ // $this->sNam = $shift?->name;
+
+ $hasPlan = ProductionPlan::where('plant_id', $this->pId)
+ ->where('line_id', $this->lId)
+ ->where('item_id', $this->iId)
+ ->whereMonth('created_at', $currentMonth)
+ ->whereYear('created_at', $currentYear)
+ ->where('plan_quantity', '>', 0)
+ ->exists();
+
+ if (! $hasPlan) {
+ Notification::make()
+ ->title('No Production Plan')
+ ->body('Scanned Item Code has no plan quantity for current month/year.')
+ ->danger()
+ ->send();
+
+ $this->form->fill([
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
+ 'sap_msg_status' => null,
+ 'sap_msg_description' => null,
+ 'operator_id' => $operatorName,
+ 'recent_qr' => $this->recent_qr,
+ ]);
+
+ return;
+ }
ProductionQuantity::create([
- 'plant_id'=> $this->pId,
+ 'plant_id' => $this->pId,
'machine_id' => $this->mId,
- 'shift_id'=> $this->sId,
+ 'shift_id' => $this->sId,
'line_id' => $this->lId,
- 'item_id'=> $this->iId,
+ 'item_id' => $this->iId,
'serial_number' => $this->sNoId,
- 'production_order'=> $this->prodOrder,
- 'operator_id'=> $operatorName,
+ 'production_order' => $this->prodOrder,
+ 'operator_id' => $operatorName,
]);
$this->iId = null;
- $line = Line::with('block')->find($lineId);
-
- $lineName = $line?->name;
- $blockName = $line?->block?->name;
- $shiftName = $shift?->name;
-
- $this->recent_qr = $itemCode.' | '.$this->sNoId;
+ // $this->recent_qr = $itemCode.' | '.$this->sNoId;
// after success insertion
$this->form->fill([
- 'plant_id'=> $this->pId,
- 'machine_id'=> $workCenter,
- 'block_name'=> $blockName,
- 'shift_id'=> $shiftName,
- 'line_id'=> $lineName,
- 'item_id'=> null,
- 'serial_number'=> null,
- 'success_msg'=> null,
- 'production_order'=> $this->prodOrder,
+ 'plant_id' => $this->pId,
+ 'machine_id' => $this->mNam,
+ 'block_name' => $this->bNam,
+ 'shift_id' => $this->sNam,
+ 'line_id' => $this->lNam,
+ 'item_id' => null,
+ 'serial_number' => null,
+ 'success_msg' => null,
+ 'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
]);
Notification::make()
- ->title("Valid QR Found") // {$operatorName}
+ ->title('Valid QR Found') // {$operatorName}
->body("Valid QR code scanned: {$this->qrData}.")
->success()
->duration(200)
@@ -1431,6 +1527,7 @@ class ProductionQuantityPage extends Page implements HasForms
// // Optionally, you can emit an event or perform a redirect after saving
// $this->emit('formSaved', $model->id);
}
+
public function triggerChartUpdate(): void
{
if (session()->has('select_plant') && session()->has('select_line')) {
@@ -1453,5 +1550,4 @@ class ProductionQuantityPage extends Page implements HasForms
{
return Auth::check() && Auth::user()->can('create ProductionQuantities');
}
-
}