ranjith-dev #349
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Imports;
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionPlan;
|
use App\Models\ProductionPlan;
|
||||||
@@ -23,11 +24,33 @@ class ProductionPlanImporter extends Importer
|
|||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
ImportColumn::make('created_at')
|
// ImportColumn::make('created_at')
|
||||||
|
// ->requiredMapping()
|
||||||
|
// ->exampleHeader('Created DateTime')
|
||||||
|
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||||
|
// ->label('Created DateTime')
|
||||||
|
// ->rules(['required']),
|
||||||
|
|
||||||
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Created DateTime')
|
->exampleHeader('Plant Code')
|
||||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
->example(['1000', '1000'])
|
||||||
->label('Created DateTime')
|
->label('Plant Code')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('line')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Line Name')
|
||||||
|
->example(['4 inch pump line', '4 inch pump line'])
|
||||||
|
->label('Line Name')
|
||||||
|
->relationship(resolveUsing: 'name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('item')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Item Code')
|
||||||
|
->example(['123456', '210987'])
|
||||||
|
->label('Item Code')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plan_quantity')
|
ImportColumn::make('plan_quantity')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -36,52 +59,40 @@ class ProductionPlanImporter extends Importer
|
|||||||
->label('Plan Quantity')
|
->label('Plan Quantity')
|
||||||
->numeric()
|
->numeric()
|
||||||
->rules(['required', 'integer']),
|
->rules(['required', 'integer']),
|
||||||
ImportColumn::make('production_quantity')
|
// ImportColumn::make('production_quantity')
|
||||||
->requiredMapping()
|
// ->requiredMapping()
|
||||||
->exampleHeader('Production Quantity')
|
// ->exampleHeader('Production Quantity')
|
||||||
->example(['0', '0'])
|
// ->example(['0', '0'])
|
||||||
->label('Production Quantity')
|
// ->label('Production Quantity')
|
||||||
->numeric()
|
// ->numeric()
|
||||||
->rules(['required', 'integer']),
|
// ->rules(['required', 'integer']),
|
||||||
ImportColumn::make('line')
|
|
||||||
->requiredMapping()
|
// ImportColumn::make('block_reference')
|
||||||
->exampleHeader('Line Name')
|
// ->requiredMapping() // Or optionalMapping() if not always present
|
||||||
->example(['4 inch pump line', '4 inch pump line'])
|
// ->exampleHeader('Block Name')
|
||||||
->label('Line Name')
|
// ->example(['Block A', 'Block A'])
|
||||||
->relationship(resolveUsing: 'name')
|
// ->label('Block Name')
|
||||||
->rules(['required']),
|
// ->rules(['required']), // Or remove if not required
|
||||||
ImportColumn::make('block_reference')
|
// ImportColumn::make('shift')
|
||||||
->requiredMapping() // Or optionalMapping() if not always present
|
// ->requiredMapping()
|
||||||
->exampleHeader('Block Name')
|
// ->exampleHeader('Shift Name') // ID
|
||||||
->example(['Block A', 'Block A'])
|
// ->example(['Day', 'Night']) // '2', '7'
|
||||||
->label('Block Name')
|
// ->label('Shift Name') // ID
|
||||||
->rules(['required']), // Or remove if not required
|
// ->relationship(resolveUsing: 'name')
|
||||||
ImportColumn::make('shift')
|
// ->rules(['required']),
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Shift Name') // ID
|
// ImportColumn::make('updated_at')
|
||||||
->example(['Day', 'Night']) // '2', '7'
|
// ->requiredMapping()
|
||||||
->label('Shift Name') // ID
|
// ->exampleHeader('Updated DateTime')
|
||||||
->relationship(resolveUsing: 'name')
|
// ->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
||||||
->rules(['required']),
|
// ->label('Updated DateTime')
|
||||||
ImportColumn::make('plant')
|
// ->rules(['required']),
|
||||||
->requiredMapping()
|
// ImportColumn::make('operator_id')
|
||||||
->exampleHeader('Plant Code')
|
// ->requiredMapping()
|
||||||
->example(['1000', '1000'])
|
// ->exampleHeader('Operator ID')
|
||||||
->label('Plant Code')
|
// ->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
||||||
->relationship(resolveUsing: 'code')
|
// ->label('Operator ID')
|
||||||
->rules(['required']),
|
// ->rules(['required']),
|
||||||
ImportColumn::make('updated_at')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Updated DateTime')
|
|
||||||
->example(['01-01-2025 08:00:00', '01-01-2025 19:30:00'])
|
|
||||||
->label('Updated DateTime')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('operator_id')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Operator ID')
|
|
||||||
->example([Filament::auth()->user()->name, Filament::auth()->user()->name])
|
|
||||||
->label('Operator ID')
|
|
||||||
->rules(['required']),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,6 +100,7 @@ class ProductionPlanImporter extends Importer
|
|||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$plantCod = $this->data['plant'];
|
$plantCod = $this->data['plant'];
|
||||||
|
$itemCod = $this->data['item'];
|
||||||
$plant = null;
|
$plant = null;
|
||||||
$line = null;
|
$line = null;
|
||||||
$block = null;
|
$block = null;
|
||||||
@@ -103,113 +115,52 @@ class ProductionPlanImporter extends Importer
|
|||||||
$warnMsg[] = 'Plant not found';
|
$warnMsg[] = 'Plant not found';
|
||||||
} else {
|
} else {
|
||||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||||
// block_reference
|
|
||||||
$block = Block::where('name', $this->data['block_reference'])->where('plant_id', $plant->id)->first();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $line) {
|
if (! $line) {
|
||||||
$warnMsg[] = 'Line not found';
|
$warnMsg[] = 'Line not found';
|
||||||
}
|
}
|
||||||
|
|
||||||
$shift = null;
|
if (Str::length($itemCod) < 6 || ! is_numeric($itemCod)) {
|
||||||
if (! $block) {
|
$warnMsg[] = 'Invalid item code found';
|
||||||
$warnMsg[] = 'Block not found';
|
} else {
|
||||||
} elseif ($plant) {
|
$item = Item::where('code', $itemCod)->first();
|
||||||
$shift = Shift::where('name', $this->data['shift'])->where('plant_id', $plant->id)->where('block_id', $block->id)->first();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// $shift = Shift::where('id', $this->data['shift'])->where('plant_id', $plant->id)->first();
|
if (! $item) {
|
||||||
if (! $shift) {
|
$warnMsg[] = 'Item not found';
|
||||||
$warnMsg[] = 'Shift not found';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$plantId = $plant->id;
|
||||||
|
|
||||||
|
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCod)->first();
|
||||||
|
|
||||||
|
if(!$itemAgaPlant){
|
||||||
|
$warnMsg[] = 'Item not found against plant code';
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
if (Str::length($this->data['plan_quantity']) < 0 || ! is_numeric($this->data['plan_quantity']) || $this->data['plan_quantity'] <= 0) {
|
||||||
$warnMsg[] = 'Invalid plan quantity found';
|
$warnMsg[] = 'Invalid plan quantity found';
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['production_quantity']) < 0 || ! is_numeric($this->data['production_quantity']) || $this->data['production_quantity'] < 0) {
|
|
||||||
$warnMsg[] = 'Invalid production quantity found';
|
|
||||||
}
|
|
||||||
|
|
||||||
$fromDate = $this->data['created_at'];
|
|
||||||
$toDate = $this->data['updated_at'];
|
|
||||||
|
|
||||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
|
||||||
|
|
||||||
$fdateTime = null;
|
|
||||||
$tdateTime = null;
|
|
||||||
// Try parsing with multiple formats
|
|
||||||
foreach ($formats as $format) {
|
|
||||||
try {
|
|
||||||
$fdateTime = Carbon::createFromFormat($format, $fromDate);
|
|
||||||
break;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// Optionally collect warning messages
|
|
||||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($formats as $format) {
|
|
||||||
try {
|
|
||||||
$tdateTime = Carbon::createFromFormat($format, $toDate);
|
|
||||||
break;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// Optionally collect warning messages
|
|
||||||
// $warnMsg[] = "Date format mismatch with format: $format";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$fDateOnly = '';
|
|
||||||
if (! isset($fdateTime)) {
|
|
||||||
// throw new \Exception('Invalid date time format');
|
|
||||||
$warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
} else {
|
|
||||||
$fDateOnly = $fdateTime->toDateString();
|
|
||||||
}
|
|
||||||
if (! isset($tdateTime)) {
|
|
||||||
$warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($fdateTime) && isset($tdateTime)) {
|
|
||||||
if ($fdateTime->greaterThan($tdateTime)) {
|
|
||||||
$warnMsg[] = "'Created DataTime' is greater than 'Updated DateTime'.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (!$fromDate) {
|
|
||||||
// $warnMsg[] = "Invalid 'Created DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
// }
|
|
||||||
// else if (!$toDate) {
|
|
||||||
// $warnMsg[] = "Invalid 'Updated DateTime' format. Expected DD-MM-YYYY HH:MM:SS";
|
|
||||||
// }
|
|
||||||
|
|
||||||
$user = User::where('name', $this->data['operator_id'])->first();
|
|
||||||
if (! $user) {
|
|
||||||
$warnMsg[] = 'Operator ID not found';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
} else { // if (empty($warnMsg))
|
} else {
|
||||||
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
$productionPlan = ProductionPlan::where('plant_id', $plant->id)
|
||||||
->where('shift_id', $shift->id)
|
|
||||||
->where('line_id', $line->id)
|
->where('line_id', $line->id)
|
||||||
->whereDate('created_at', $fDateOnly)
|
->where('item_id', $itemAgaPlant->id)
|
||||||
// ->where('plan_quantity', $productionQuantity->plan_quantity)
|
|
||||||
->latest()
|
->latest()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($productionPlan) {
|
if ($productionPlan) {
|
||||||
// if($productionPlan->production_quantity)
|
|
||||||
// {
|
|
||||||
// throw new RowImportFailedException("{$productionPlan->created_at}, {$productionPlan->production_quantity}");
|
|
||||||
// }
|
|
||||||
// $warnMsg[] = "Production plan already exist on '{$fDateOnly}'!";
|
|
||||||
|
|
||||||
$productionPlan->update([
|
$productionPlan->update([
|
||||||
'plan_quantity' => $this->data['plan_quantity'],
|
'plan_quantity' => $this->data['plan_quantity'],
|
||||||
// 'production_quantity' => $productionPlan->production_quantity,
|
'operator_id' => $operatorName,
|
||||||
// 'created_at' => $productionPlan->created_at,//$fdateTime->format('Y-m-d H:i:s'),
|
|
||||||
// 'updated_at' => $tdateTime->format('Y-m-d H:i:s'),
|
|
||||||
'operator_id' => $this->data['operator_id'],
|
|
||||||
]);
|
]);
|
||||||
$productionPlan->save();
|
$productionPlan->save();
|
||||||
|
|
||||||
@@ -220,21 +171,15 @@ class ProductionPlanImporter extends Importer
|
|||||||
ProductionPlan::updateOrCreate([
|
ProductionPlan::updateOrCreate([
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'line_id' => $line->id,
|
'line_id' => $line->id,
|
||||||
'shift_id' => $shift->id,
|
'item_id' => $itemAgaPlant->id,
|
||||||
|
// 'shift_id' => $shift->id,
|
||||||
'plan_quantity' => $this->data['plan_quantity'],
|
'plan_quantity' => $this->data['plan_quantity'],
|
||||||
'production_quantity' => $this->data['production_quantity'],
|
'created_at' =>now(),
|
||||||
'created_at' => $fdateTime->format('Y-m-d H:i:s'), // $this->data['created_at'],
|
'updated_at' => now(),
|
||||||
'updated_at' => $tdateTime->format('Y-m-d H:i:s'), // $this->data['updated_at'],
|
'operator_id' => $operatorName,
|
||||||
'operator_id' => $this->data['operator_id'],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
// return ProductionPlan::firstOrNew([
|
|
||||||
// // Update existing records, matching them by `$this->data['column_name']`
|
|
||||||
// 'email' => $this->data['email'],
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// return new ProductionPlan();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCompletedNotificationBody(Import $import): string
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\LineExporter;
|
use App\Filament\Exports\LineExporter;
|
||||||
use App\Filament\Imports\LineImporter;
|
use App\Filament\Imports\LineImporter;
|
||||||
use App\Filament\Resources\LineResource\Pages;
|
use App\Filament\Resources\LineResource\Pages;
|
||||||
|
use App\Models\Block;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\WorkGroupMaster;
|
use App\Models\WorkGroupMaster;
|
||||||
@@ -71,6 +72,38 @@ class LineResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
->hint(fn ($get) => $get('lPlantError') ? $get('lPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\Select::make('block_id')
|
||||||
|
->label('Block')
|
||||||
|
->relationship('block', 'name')
|
||||||
|
// ->required()
|
||||||
|
// ->nullable(),
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (! $get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Block::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->default(function () {
|
||||||
|
return optional(Block::latest()->first())->plant_id;
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$blockId = $get('block_id');
|
||||||
|
if (! $blockId) {
|
||||||
|
$set('lblockError', 'Please select a Block first.');
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$set('lblockError', null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->extraAttributes(fn ($get) => [
|
||||||
|
'class' => $get('lblockError') ? 'border-red-500' : '',
|
||||||
|
])
|
||||||
|
->hint(fn ($get) => $get('lblockError') ? $get('lblockError') : null)
|
||||||
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required()
|
->required()
|
||||||
->placeholder('Scan the valid name')
|
->placeholder('Scan the valid name')
|
||||||
@@ -1012,6 +1045,11 @@ class LineResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('block.name')
|
||||||
|
->label('Block')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('name')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->label('Line')
|
->label('Line')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use App\Filament\Exports\ProductionPlanExporter;
|
|||||||
use App\Filament\Imports\ProductionPlanImporter;
|
use App\Filament\Imports\ProductionPlanImporter;
|
||||||
use App\Filament\Resources\ProductionPlanResource\Pages;
|
use App\Filament\Resources\ProductionPlanResource\Pages;
|
||||||
use App\Models\Block;
|
use App\Models\Block;
|
||||||
|
use App\Models\Item;
|
||||||
use App\Models\Line;
|
use App\Models\Line;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionPlan;
|
use App\Models\ProductionPlan;
|
||||||
@@ -77,97 +78,6 @@ class ProductionPlanResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Select::make('block_name')
|
|
||||||
->required()
|
|
||||||
// ->nullable()
|
|
||||||
->label('Block')
|
|
||||||
->options(function (callable $get) {
|
|
||||||
if (! $get('plant_id')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Block::where('plant_id', $get('plant_id'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->default(function () {
|
|
||||||
$latestShiftId = optional(ProductionPlan::latest()->first())->shift_id;
|
|
||||||
|
|
||||||
return optional(Shift::where('id', $latestShiftId)->first())->block_id;
|
|
||||||
})
|
|
||||||
// ->afterStateUpdated(fn ($set) => $set('shift_id', null))
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
if ($get('id')) {
|
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
|
||||||
$getBlock = Shift::where('id', $getShift->shift_id)->first();
|
|
||||||
if ($getBlock->block_id) {
|
|
||||||
$set('block_name', $getBlock->block_id);
|
|
||||||
$set('ppBlockError', null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$blockId = $get('block_name');
|
|
||||||
$set('shift_id', null);
|
|
||||||
|
|
||||||
if (! $blockId) {
|
|
||||||
$set('ppBlockError', 'Please select a block first.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$set('ppBlockError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('ppBlockError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('ppBlockError') ? $get('ppBlockError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required()
|
|
||||||
// ->nullable()
|
|
||||||
->autofocus(true)
|
|
||||||
->options(function (callable $get) {
|
|
||||||
if (! $get('plant_id') || ! $get('block_name')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return Shift::where('plant_id', $get('plant_id'))
|
|
||||||
->where('block_id', $get('block_name'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->default(function () {
|
|
||||||
return optional(ProductionPlan::latest()->first())->shift_id;
|
|
||||||
})
|
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null))
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
|
||||||
if ($get('id')) {
|
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
|
||||||
if ($getShift->shift_id) {
|
|
||||||
$set('shift_id', $getShift->shift_id);
|
|
||||||
$set('ppShiftError', null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$curShiftId = $get('shift_id');
|
|
||||||
$set('line_id', null);
|
|
||||||
|
|
||||||
if (! $curShiftId) {
|
|
||||||
$set('ppShiftError', 'Please select a shift first.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$set('ppShiftError', null);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->extraAttributes(fn ($get) => [
|
|
||||||
'class' => $get('ppShiftError') ? 'border-red-500' : '',
|
|
||||||
])
|
|
||||||
->hint(fn ($get) => $get('ppShiftError') ? $get('ppShiftError') : null)
|
|
||||||
->hintColor('danger'),
|
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->relationship('line', 'name')
|
->relationship('line', 'name')
|
||||||
->required()
|
->required()
|
||||||
@@ -178,7 +88,7 @@ class ProductionPlanResource extends Resource
|
|||||||
// ->toArray() // Convert collection to array
|
// ->toArray() // Convert collection to array
|
||||||
// )
|
// )
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
if (! $get('plant_id') || ! $get('block_name') || ! $get('shift_id')) {
|
if (! $get('plant_id')) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,239 +100,257 @@ class ProductionPlanResource extends Resource
|
|||||||
// ->default(function () {
|
// ->default(function () {
|
||||||
// return optional(ProductionPlan::latest()->first())->line_id;
|
// return optional(ProductionPlan::latest()->first())->line_id;
|
||||||
// })
|
// })
|
||||||
|
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
// if ($get('id')) {
|
||||||
|
// $getShift = ProductionPlan::where('id', $get('id'))->first();
|
||||||
|
// if ($getShift->line_id) {
|
||||||
|
// $set('line_id', $getShift->line_id);
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// $currentDT = Carbon::now()->toDateTimeString();
|
||||||
|
// $set('created_at', $currentDT);
|
||||||
|
// $set('update_date', null);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $lineId = $get('line_id');
|
||||||
|
// // $set('plan_quantity', null);
|
||||||
|
|
||||||
|
// if (! $lineId) {
|
||||||
|
// $set('ppLineError', 'Please select a line first.');
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $isUpdate = ! empty($get('id'));
|
||||||
|
// if (! $isUpdate) {
|
||||||
|
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// ->where('shift_id', $get('shift_id'))
|
||||||
|
// ->where('line_id', $get('line_id'))
|
||||||
|
// ->whereDate('created_at', today())
|
||||||
|
// ->latest()
|
||||||
|
// ->exists();
|
||||||
|
|
||||||
|
// if ($exists) {
|
||||||
|
// $set('line_id', null);
|
||||||
|
// $set('ppLineError', 'Production plan already updated.');
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// ->where('shift_id', $get('shift_id'))
|
||||||
|
// ->where('line_id', $get('line_id'))
|
||||||
|
// ->whereDate('created_at', Carbon::yesterday())
|
||||||
|
// ->latest()
|
||||||
|
// ->exists();
|
||||||
|
|
||||||
|
// if ($existShifts) { // if ($existShifts->count() > 0)
|
||||||
|
// // $currentDate = date('Y-m-d');
|
||||||
|
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $yesterday.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// $set('line_id', null);
|
||||||
|
// $set('ppLineError', 'Production plan already updated.');
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $currentDate = date('Y-m-d');
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $currentDate.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// $set('line_id', null);
|
||||||
|
// $set('ppLineError', 'Choosed a invalid shift.');
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// // $currentDate = date('Y-m-d');
|
||||||
|
// $yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $yesterday.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// // here i'm updating created as yesterday
|
||||||
|
// $set('created_at', $from_dt);
|
||||||
|
// $set('update_date', '1');
|
||||||
|
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// } else {
|
||||||
|
// $currentDate = date('Y-m-d');
|
||||||
|
|
||||||
|
// $shiftId = Shift::where('id', $get('shift_id'))
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// $hRs = (int) $hRs;
|
||||||
|
// // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// $from_dt = $currentDate.' '.$shiftId->start_time;
|
||||||
|
|
||||||
|
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // Check if current date time is within the range
|
||||||
|
// if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||||
|
// // echo "Choosed a valid shift...";
|
||||||
|
|
||||||
|
// $set('line_id', null);
|
||||||
|
// $set('ppLineError', 'Choosed a invalid shift.');
|
||||||
|
|
||||||
|
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// // //->where('shift_id', $get('shift_id'))
|
||||||
|
// // ->where('line_id', $get('line_id'))
|
||||||
|
// // ->whereDate('created_at', today())
|
||||||
|
// // ->latest() // Orders by created_at DESC
|
||||||
|
// // ->first();
|
||||||
|
|
||||||
|
// // if ($exists)
|
||||||
|
// // {
|
||||||
|
// // $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
||||||
|
// // //->where('shift_id', $get('shift_id'))
|
||||||
|
// // ->where('line_id', $get('line_id'))
|
||||||
|
// // // ->whereDate('created_at', today())
|
||||||
|
// // ->whereDate('created_at', today())
|
||||||
|
// // ->get();
|
||||||
|
|
||||||
|
// // foreach ($existingShifts as $shift) {
|
||||||
|
// // $curShiftId = $shift->shift_id;
|
||||||
|
|
||||||
|
// // $currentDate = date('Y-m-d');
|
||||||
|
|
||||||
|
// // $shiftId = \App\Models\Shift::where('id', $curShiftId)
|
||||||
|
// // ->first();
|
||||||
|
|
||||||
|
// // [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||||
|
// // $hRs = (int) $hRs;
|
||||||
|
// // // $miNs = (int) $miNs;-*/
|
||||||
|
|
||||||
|
// // $totalMinutes = $hRs * 60 + $miNs;
|
||||||
|
|
||||||
|
// // $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||||
|
|
||||||
|
// // $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||||
|
|
||||||
|
// // $currentDateTime = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// // // Check if current date time is within the range
|
||||||
|
// // if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||||
|
// // //echo "Choosed a valid shift...";
|
||||||
|
// // // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||||
|
|
||||||
|
// // $set('line_id', null);
|
||||||
|
// // $set('ppLineError', 'Production plan already updated.');
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
// // // else {
|
||||||
|
// // // $set('ppLineError', 'Choosed a invalid shift...');
|
||||||
|
// // // return;
|
||||||
|
// // // }
|
||||||
|
// // }
|
||||||
|
// // $set('ppLineError', null);
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// $set('ppLineError', null);
|
||||||
|
// }
|
||||||
|
// })
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if ($get('id')) {
|
$set('item_id', null);
|
||||||
$getShift = ProductionPlan::where('id', $get('id'))->first();
|
$set('plan_quantity', null);
|
||||||
if ($getShift->line_id) {
|
|
||||||
$set('line_id', $getShift->line_id);
|
|
||||||
$set('ppLineError', null);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$currentDT = Carbon::now()->toDateTimeString();
|
|
||||||
$set('created_at', $currentDT);
|
|
||||||
$set('update_date', null);
|
|
||||||
}
|
|
||||||
|
|
||||||
$lineId = $get('line_id');
|
|
||||||
// $set('plan_quantity', null);
|
|
||||||
|
|
||||||
if (! $lineId) {
|
|
||||||
$set('ppLineError', 'Please select a line first.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$isUpdate = ! empty($get('id'));
|
|
||||||
if (! $isUpdate) {
|
|
||||||
$exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
|
||||||
->where('shift_id', $get('shift_id'))
|
|
||||||
->where('line_id', $get('line_id'))
|
|
||||||
->whereDate('created_at', today())
|
|
||||||
->latest()
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($exists) {
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Production plan already updated.');
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$existShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
|
||||||
->where('shift_id', $get('shift_id'))
|
|
||||||
->where('line_id', $get('line_id'))
|
|
||||||
->whereDate('created_at', Carbon::yesterday())
|
|
||||||
->latest()
|
|
||||||
->exists();
|
|
||||||
|
|
||||||
if ($existShifts) { // if ($existShifts->count() > 0)
|
|
||||||
// $currentDate = date('Y-m-d');
|
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $yesterday.' '.$shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
|
||||||
// echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Production plan already updated.');
|
|
||||||
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$currentDate = date('Y-m-d');
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $currentDate.' '.$shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
|
||||||
// echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Choosed a invalid shift.');
|
|
||||||
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$set('ppLineError', null);
|
|
||||||
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// $currentDate = date('Y-m-d');
|
|
||||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $yesterday.' '.$shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
|
||||||
// echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
// here i'm updating created as yesterday
|
|
||||||
$set('created_at', $from_dt);
|
|
||||||
$set('update_date', '1');
|
|
||||||
|
|
||||||
$set('ppLineError', null);
|
|
||||||
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$currentDate = date('Y-m-d');
|
|
||||||
|
|
||||||
$shiftId = Shift::where('id', $get('shift_id'))
|
|
||||||
->first();
|
|
||||||
|
|
||||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
$hRs = (int) $hRs;
|
|
||||||
// $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
$totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
$from_dt = $currentDate.' '.$shiftId->start_time;
|
|
||||||
|
|
||||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt." + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
$currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// Check if current date time is within the range
|
|
||||||
if (! ($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
|
||||||
// echo "Choosed a valid shift...";
|
|
||||||
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('ppLineError', 'Choosed a invalid shift.');
|
|
||||||
|
|
||||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$set('ppLineError', null);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $exists = ProductionPlan::where('plant_id', $get('plant_id'))
|
|
||||||
// //->where('shift_id', $get('shift_id'))
|
|
||||||
// ->where('line_id', $get('line_id'))
|
|
||||||
// ->whereDate('created_at', today())
|
|
||||||
// ->latest() // Orders by created_at DESC
|
|
||||||
// ->first();
|
|
||||||
|
|
||||||
// if ($exists)
|
|
||||||
// {
|
|
||||||
// $existingShifts = ProductionPlan::where('plant_id', $get('plant_id'))
|
|
||||||
// //->where('shift_id', $get('shift_id'))
|
|
||||||
// ->where('line_id', $get('line_id'))
|
|
||||||
// // ->whereDate('created_at', today())
|
|
||||||
// ->whereDate('created_at', today())
|
|
||||||
// ->get();
|
|
||||||
|
|
||||||
// foreach ($existingShifts as $shift) {
|
|
||||||
// $curShiftId = $shift->shift_id;
|
|
||||||
|
|
||||||
// $currentDate = date('Y-m-d');
|
|
||||||
|
|
||||||
// $shiftId = \App\Models\Shift::where('id', $curShiftId)
|
|
||||||
// ->first();
|
|
||||||
|
|
||||||
// [$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
|
||||||
// $hRs = (int) $hRs;
|
|
||||||
// // $miNs = (int) $miNs;-*/
|
|
||||||
|
|
||||||
// $totalMinutes = $hRs * 60 + $miNs;
|
|
||||||
|
|
||||||
// $from_dt = $currentDate . ' ' . $shiftId->start_time;
|
|
||||||
|
|
||||||
// $to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
|
||||||
|
|
||||||
// $currentDateTime = date('Y-m-d H:i:s');
|
|
||||||
|
|
||||||
// // Check if current date time is within the range
|
|
||||||
// if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
|
||||||
// //echo "Choosed a valid shift...";
|
|
||||||
// // $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
|
||||||
|
|
||||||
// $set('line_id', null);
|
|
||||||
// $set('ppLineError', 'Production plan already updated.');
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// // else {
|
|
||||||
// // $set('ppLineError', 'Choosed a invalid shift...');
|
|
||||||
// // return;
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
// $set('ppLineError', null);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$set('ppLineError', null);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
->extraAttributes(fn ($get) => [
|
->extraAttributes(fn ($get) => [
|
||||||
'class' => $get('ppLineError') ? 'border-red-500' : '',
|
'class' => $get('ppLineError') ? 'border-red-500' : '',
|
||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('ppLineError') ? $get('ppLineError') : null)
|
->hint(fn ($get) => $get('ppLineError') ? $get('ppLineError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
|
->label('Item')
|
||||||
|
->reactive()
|
||||||
|
->searchable()
|
||||||
|
->required()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (! $get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('code', 'id')
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
Forms\Components\TextInput::make('plan_quantity')
|
Forms\Components\TextInput::make('plan_quantity')
|
||||||
->required()
|
->required()
|
||||||
->integer()
|
->integer()
|
||||||
@@ -453,29 +381,19 @@ class ProductionPlanResource extends Resource
|
|||||||
])
|
])
|
||||||
->hint(fn ($get) => $get('ppPlanQuanError') ? $get('ppPlanQuanError') : null)
|
->hint(fn ($get) => $get('ppPlanQuanError') ? $get('ppPlanQuanError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('production_quantity')
|
// Forms\Components\TextInput::make('production_quantity')
|
||||||
->required()
|
// ->required()
|
||||||
->integer()
|
// ->integer()
|
||||||
->label('Production Quantity')
|
// ->label('Production Quantity')
|
||||||
->readOnly(fn (callable $get) => ! $get('id'))
|
// ->readOnly(fn (callable $get) => ! $get('id'))
|
||||||
->default(0),
|
// ->default(0),
|
||||||
Forms\Components\TextInput::make('id')
|
Forms\Components\TextInput::make('id')
|
||||||
->hidden()
|
->hidden()
|
||||||
->readOnly(),
|
->readOnly(),
|
||||||
Forms\Components\TextInput::make('update_date')
|
|
||||||
->hidden()
|
|
||||||
->reactive()
|
|
||||||
->readOnly(),
|
|
||||||
Forms\Components\DateTimePicker::make('created_at')
|
|
||||||
->label('Created DateTime')
|
|
||||||
->hidden()
|
|
||||||
->reactive()
|
|
||||||
->required()
|
|
||||||
->readOnly(),
|
|
||||||
Forms\Components\Hidden::make('operator_id')
|
Forms\Components\Hidden::make('operator_id')
|
||||||
->default(Filament::auth()->user()->name),
|
->default(Filament::auth()->user()->name),
|
||||||
])
|
])
|
||||||
->columns(2),
|
->columns(4),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,32 +431,52 @@ class ProductionPlanResource extends Resource
|
|||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
|
->label('Item')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('plan_quantity')
|
Tables\Columns\TextColumn::make('plan_quantity')
|
||||||
->label('Plan Quantity')
|
->label('Plan Quantity')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
Tables\Columns\TextColumn::make('working_days')
|
||||||
|
->label('Working Days')
|
||||||
|
->alignCenter()
|
||||||
|
->numeric()
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('production_quantity')
|
Tables\Columns\TextColumn::make('production_quantity')
|
||||||
->label('Production Quantity')
|
->label('Production Quantity')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable()
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
->searchable(),
|
||||||
->label('Line')
|
// Tables\Columns\TextColumn::make('line.name')
|
||||||
->alignCenter()
|
// ->label('Line')
|
||||||
->sortable(), // ->searchable(),
|
// ->alignCenter()
|
||||||
Tables\Columns\TextColumn::make('shift.block.name')
|
// ->sortable(), // ->searchable(),
|
||||||
->label('Block')
|
// Tables\Columns\TextColumn::make('shift.block.name')
|
||||||
->alignCenter()
|
// ->label('Block')
|
||||||
->sortable(),
|
// ->alignCenter()
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
// ->sortable(),
|
||||||
->label('Shift')
|
// Tables\Columns\TextColumn::make('shift.name')
|
||||||
->alignCenter()
|
// ->label('Shift')
|
||||||
->sortable(), // ->searchable(),
|
// ->alignCenter()
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
// ->sortable(), // ->searchable(),
|
||||||
->label('Plant')
|
|
||||||
->alignCenter()
|
|
||||||
->sortable(), // ->searchable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->label('Created At')
|
->label('Created At')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
{{ $this->form }}
|
{{ $this->form }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{-- <livewire:notification-sound /> --}}
|
||||||
|
|
||||||
{{-- <input
|
{{-- <input
|
||||||
type="text"
|
type="text"
|
||||||
id="qr-scan-input"
|
id="qr-scan-input"
|
||||||
@@ -15,7 +17,7 @@
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
autofocus
|
autofocus
|
||||||
/> --}}
|
/> --}}
|
||||||
<div class="mb-4">
|
{{-- <div class="mb-4">
|
||||||
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
SCAN QR CODE
|
SCAN QR CODE
|
||||||
</label>
|
</label>
|
||||||
@@ -27,11 +29,64 @@
|
|||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
autofocus
|
autofocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div> --}}
|
||||||
|
{{-- <div class="mb-4">
|
||||||
|
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
SCAN QR CODE
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="qr-scan-input"
|
||||||
|
class="border border-gray-300 rounded px-4 py-2 text-sm w-1/2"
|
||||||
|
placeholder="Scan QR Code & Press Enter"
|
||||||
|
autocomplete="off"
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
|
</div> --}}
|
||||||
|
<div class="flex gap-6 -mt-6">
|
||||||
|
<!-- Scan QR Code -->
|
||||||
|
<div class="w-full">
|
||||||
|
<label for="qr-scan-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
SCAN QR CODE
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="qr-scan-input"
|
||||||
|
class="border border-gray-300 rounded px-4 py-2 text-sm w-full"
|
||||||
|
placeholder="Scan QR Code & Press Enter"
|
||||||
|
autocomplete="off"
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Last Scanned QR -->
|
||||||
|
{{-- <div class="w-1/2">
|
||||||
|
<label for="recent-qr-input" class="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
LAST SCANNED QR
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="recent-qr-input"
|
||||||
|
class="border border-gray-300 rounded px-4 py-2 text-sm w-full bg-white-100 text-black"
|
||||||
|
readonly
|
||||||
|
wire:model="recent_qr"
|
||||||
|
/>
|
||||||
|
</div> --}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
window.addEventListener('focus-production-order', () => {
|
||||||
|
const wrapper = document.getElementById('production_order');
|
||||||
|
const input = wrapper?.querySelector('input,textarea');
|
||||||
|
if (input) {
|
||||||
|
input.focus();
|
||||||
|
input.select();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const scanInput = document.getElementById('qr-scan-input');
|
const scanInput = document.getElementById('qr-scan-input');
|
||||||
if (!scanInput) return;
|
if (!scanInput) return;
|
||||||
@@ -48,6 +103,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
Reference in New Issue
Block a user