Import Fun Completed and Sticker Master
This commit is contained in:
@@ -23,7 +23,7 @@ class BlockImporter extends Importer
|
|||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Name')
|
||||||
->label('Plant Name')
|
->label('Plant Name')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing:'Name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,18 +30,6 @@ class ItemImporter extends Importer
|
|||||||
->label('Hourly Quantity')
|
->label('Hourly Quantity')
|
||||||
->numeric()
|
->numeric()
|
||||||
->rules(['required', 'integer']),
|
->rules(['required', 'integer']),
|
||||||
ImportColumn::make('line')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Line Name')
|
|
||||||
->label('Line Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('block')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Block Name')
|
|
||||||
->label('Block Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Name')
|
||||||
|
|||||||
@@ -24,18 +24,6 @@ class LineImporter extends Importer
|
|||||||
->exampleHeader('Line Type')
|
->exampleHeader('Line Type')
|
||||||
->label('Line Type')
|
->label('Line Type')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('shift')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Shift Name')
|
|
||||||
->label('Shift Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('block')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Block Name')
|
|
||||||
->label('Block Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Name')
|
||||||
|
|||||||
@@ -24,24 +24,6 @@ class LineStopImporter extends Importer
|
|||||||
->exampleHeader('Line Stop Reason')
|
->exampleHeader('Line Stop Reason')
|
||||||
->label('Line Stop Reason')
|
->label('Line Stop Reason')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('shift')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Shift Name')
|
|
||||||
->label('Shift Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('block')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Block Name')
|
|
||||||
->label('Block Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('plant')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Plant Name')
|
|
||||||
->label('Plant Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,16 +16,24 @@ class ProductionLineStopImporter extends Importer
|
|||||||
return [
|
return [
|
||||||
ImportColumn::make('from_datetime')
|
ImportColumn::make('from_datetime')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
|
->exampleHeader('From DateTime')
|
||||||
|
->label('From DateTime')
|
||||||
->rules(['required', 'datetime']),
|
->rules(['required', 'datetime']),
|
||||||
ImportColumn::make('to_datetime')
|
ImportColumn::make('to_datetime')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
|
->exampleHeader('To DateTime')
|
||||||
|
->label('To DateTime')
|
||||||
->rules(['required', 'datetime']),
|
->rules(['required', 'datetime']),
|
||||||
ImportColumn::make('stop_hour')
|
ImportColumn::make('stop_hour')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
|
->exampleHeader('Stop Hour')
|
||||||
|
->label('Stop Hour')
|
||||||
->numeric()
|
->numeric()
|
||||||
->rules(['required', 'integer']),
|
->rules(['required', 'integer']),
|
||||||
ImportColumn::make('stop_min')
|
ImportColumn::make('stop_min')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
|
->exampleHeader('Stop Min')
|
||||||
|
->label('Stop Min')
|
||||||
->numeric()
|
->numeric()
|
||||||
->rules(['required', 'integer']),
|
->rules(['required', 'integer']),
|
||||||
ImportColumn::make('linestop')
|
ImportColumn::make('linestop')
|
||||||
@@ -46,12 +54,6 @@ class ProductionLineStopImporter extends Importer
|
|||||||
->label('Shift Name')
|
->label('Shift Name')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing:'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('block')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Block Name')
|
|
||||||
->label('Block Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Name')
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ class ProductionPlanImporter extends Importer
|
|||||||
public static function getColumns(): array
|
public static function getColumns(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
ImportColumn::make('created_at')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Created DateTime')
|
||||||
|
->label('Created DateTime')
|
||||||
|
->rules(['required']),
|
||||||
ImportColumn::make('plan_quantity')
|
ImportColumn::make('plan_quantity')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plan Quantity')
|
->exampleHeader('Plan Quantity')
|
||||||
@@ -44,6 +49,11 @@ class ProductionPlanImporter extends Importer
|
|||||||
->label('Plant Name')
|
->label('Plant Name')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing:'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
|
ImportColumn::make('updated_at')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Updated DateTime')
|
||||||
|
->label('Updated DateTime')
|
||||||
|
->rules(['required']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,12 +48,6 @@ class ProductionQuantityImporter extends Importer
|
|||||||
->label('Shift Name')
|
->label('Shift Name')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing:'name')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('block')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Block Name')
|
|
||||||
->label('Block Name')
|
|
||||||
->relationship(resolveUsing:'name')
|
|
||||||
->rules(['required']),
|
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Name')
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ShiftImporter extends Importer
|
|||||||
->numeric()
|
->numeric()
|
||||||
->exampleHeader('Shift Duration')
|
->exampleHeader('Shift Duration')
|
||||||
->label('Shift Duration')
|
->label('Shift Duration')
|
||||||
->rules(['required', 'integer']),
|
->rules(['required']),
|
||||||
ImportColumn::make('end_time')
|
ImportColumn::make('end_time')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('End Time')
|
->exampleHeader('End Time')
|
||||||
|
|||||||
@@ -1,33 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
use Filament\Forms\Form;
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Form;
|
||||||
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
|
||||||
use Filament\Pages\Dashboard as BaseDashboard;
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use App\Models\Line;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Models\Plant;
|
||||||
|
|
||||||
class Dashboard extends BaseDashboard
|
|
||||||
|
class Dashboard extends \Filament\Pages\Dashboard
|
||||||
{
|
{
|
||||||
use HasFiltersForm;
|
use HasFiltersForm;
|
||||||
|
|
||||||
public function filtersForm(Form $form): Form
|
public function filtersForm(Form $form): Form
|
||||||
{
|
{
|
||||||
|
$selectedPlant = session('selected_plant', request()->input('filters.Plant'));
|
||||||
return $form->schema([
|
return $form->schema([
|
||||||
// Select::make('plant_id')
|
// Plant Filter
|
||||||
// ->relationship('plant', 'name')
|
Select::make('Plant')
|
||||||
// ->required()
|
->options(Plant::pluck('name', 'id')) // Fetch plant names with their IDs
|
||||||
// ->reactive(),
|
->label('Select Plant')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) use ($selectedPlant) {
|
||||||
|
// Update only in memory and not in the URL
|
||||||
|
session(['selected_plant' => $state]); // Store in session
|
||||||
|
session()->forget('selected_line'); // Reset line filter
|
||||||
|
$set('Plant', $state);
|
||||||
|
$set('Line', null);
|
||||||
|
$this->dispatch('filtersUpdated'); // Notify chart to refresh
|
||||||
|
}),
|
||||||
|
|
||||||
// Select::make('line_id')
|
// Line Filter
|
||||||
// ->relationship('line', 'name')
|
Select::make('Line')
|
||||||
// ->required()
|
->options(function ($get) {
|
||||||
// ->options(fn (callable $get) =>
|
$plantId = $get('Plant');
|
||||||
// Line::where('plant_id', $get('plant_id'))->pluck('name', 'id')
|
return $plantId ? Plant::find($plantId)->getLineNames()->pluck('name', 'id') : [];
|
||||||
// )
|
})
|
||||||
// ->reactive()
|
->label('Select Line')
|
||||||
// ->afterStateUpdated(fn ($set) => $set('line_id', null)),
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state) {
|
||||||
|
session(['selected_line' => $state]); // Store in session
|
||||||
|
$this->dispatch('filtersUpdated'); // Notify chart to refresh
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\AppFilamentResourcesStickerMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\AppFilamentResourcesStickerMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\Create;
|
||||||
|
|
||||||
|
// class SubmitNameLabel extends Create
|
||||||
|
// {
|
||||||
|
// protected static string $resource = AppFilamentResourcesStickerMasterResource::class;
|
||||||
|
// }
|
||||||
@@ -27,11 +27,12 @@ class BlockResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required()
|
->required(),
|
||||||
->unique(ignoreRecord: true),
|
// ->unique(ignoreRecord: true),
|
||||||
// ->columnSpanFull(),
|
// ->columnSpanFull(),
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
|
// ->unique(ignoreRecord: true)
|
||||||
->required(),
|
->required(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class CompanyResource extends Resource
|
|||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required()
|
->required()
|
||||||
//->citext('name')
|
//->citext('name')
|
||||||
->unique()
|
->unique(ignoreRecord: true)
|
||||||
->columnSpanFull(),
|
->columnSpanFull(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ class ItemResource extends Resource
|
|||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required(),
|
||||||
|
// ->nullable(),
|
||||||
Forms\Components\TextInput::make('code')
|
Forms\Components\TextInput::make('code')
|
||||||
->required()
|
->required()
|
||||||
->unique(ignoreRecord: true)
|
->unique(ignoreRecord: true)
|
||||||
@@ -38,38 +42,8 @@ class ItemResource extends Resource
|
|||||||
->numeric()
|
->numeric()
|
||||||
->minValue(1),
|
->minValue(1),
|
||||||
Forms\Components\Textarea::make('description')
|
Forms\Components\Textarea::make('description')
|
||||||
->required()
|
|
||||||
->columnSpanFull(),
|
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required()
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(fn ($set) => $set('block_id', null)), // Reset block_id when plant changes
|
|
||||||
|
|
||||||
Forms\Components\Select::make('block_id')
|
|
||||||
->relationship('block', 'name')
|
|
||||||
->required()
|
|
||||||
->options(fn (callable $get) =>
|
|
||||||
\App\Models\Block::where('plant_id', $get('plant_id'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray() // Convert collection to array
|
|
||||||
)
|
|
||||||
->reactive(), // Ensures the dropdown updates when plant_id changes
|
|
||||||
// Forms\Components\Select::make('plant_id')
|
|
||||||
// ->relationship('plant', 'name')
|
|
||||||
// ->required()
|
|
||||||
// ->reactive(),
|
|
||||||
// Forms\Components\Select::make('block_id')
|
|
||||||
// ->relationship('block', 'name')
|
|
||||||
// ->required()
|
|
||||||
// ->options(fn (callable $get) =>
|
|
||||||
// \App\Models\Block::where('plant_id', $get('plant_id'))->pluck('name', 'id')
|
|
||||||
// )
|
|
||||||
// ->reactive() // Updates dynamically when plant_id changes
|
|
||||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null)), // Reset block_id when plant_id changes
|
|
||||||
Forms\Components\Select::make('line_id')
|
|
||||||
->relationship('line', 'name')
|
|
||||||
->required(),
|
->required(),
|
||||||
|
// ->columnSpanFull(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,10 +62,6 @@ class ItemResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('description')
|
Tables\Columns\TextColumn::make('description')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('block.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
|||||||
@@ -27,21 +27,16 @@ class LineResource extends Resource
|
|||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required(),
|
||||||
|
// ->nullable(),
|
||||||
Forms\Components\Textarea::make('name')
|
Forms\Components\Textarea::make('name')
|
||||||
->required(),
|
->required(),
|
||||||
// ->columnSpanFull(),
|
// ->columnSpanFull(),
|
||||||
Forms\Components\Textarea::make('type')
|
Forms\Components\Textarea::make('type')
|
||||||
->required(),
|
->required(),
|
||||||
//->columnSpanFull(),
|
//->columnSpanFull(),
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('block_id')
|
|
||||||
->relationship('block', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +52,6 @@ class LineResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('type')
|
Tables\Columns\TextColumn::make('type')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('block.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
|||||||
@@ -33,15 +33,6 @@ class LineStopResource extends Resource
|
|||||||
Forms\Components\Textarea::make('reason')
|
Forms\Components\Textarea::make('reason')
|
||||||
->required(),
|
->required(),
|
||||||
//->columnSpanFull(),
|
//->columnSpanFull(),
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('block_id')
|
|
||||||
->relationship('block', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,12 +48,6 @@ class LineStopResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('reason')
|
Tables\Columns\TextColumn::make('reason')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('block.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
->dateTime()
|
->dateTime()
|
||||||
->sortable()
|
->sortable()
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ use Filament\Tables\Actions\ImportAction;
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
|
||||||
class ProductionLineStopResource extends Resource
|
class ProductionLineStopResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -21,43 +23,154 @@ class ProductionLineStopResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
// protected static ?string $navigationParentItem = 'Display Transactions';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Production';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
|
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('lineStop_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('linestop', 'code')
|
->relationship('plant', 'name')
|
||||||
->required(),
|
->required()
|
||||||
Forms\Components\Select::make('lineStop_id')
|
->nullable()
|
||||||
->relationship('linestop', 'reason')
|
->reactive(),
|
||||||
->required(),
|
Forms\Components\Select::make('block_name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('shift_id', null)),
|
||||||
|
Forms\Components\Select::make('shift_id')
|
||||||
|
->relationship('shift', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Shift::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Shift::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('line_id', null)),
|
||||||
|
Forms\Components\Select::make('line_id')
|
||||||
|
->relationship('line', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive(),
|
||||||
|
// Forms\Components\Select::make('linestop_id')
|
||||||
|
// ->label('Line Stop Code')
|
||||||
|
// ->relationship('linestop', 'code')
|
||||||
|
// ->searchable()
|
||||||
|
// ->required()
|
||||||
|
// ->nullable()
|
||||||
|
// ->reactive(),
|
||||||
|
Forms\Components\Select::make('linestop_id')
|
||||||
|
->label('Line Stop Code')
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\LineStop::where('id', $get('linestop_id'))
|
||||||
|
// ->pluck('code', 'id')
|
||||||
|
// )
|
||||||
|
->options(fn () => \App\Models\LineStop::pluck('code', 'id'))
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->reactive()
|
||||||
|
->searchable()
|
||||||
|
->live(debounce: 500) // Enable live updates
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$lineStopId = $get('linestop_id'); // Get entered linestop_id
|
||||||
|
|
||||||
|
// Ensure `linestop_id` is not cleared
|
||||||
|
if (!$lineStopId) {
|
||||||
|
$set('lineStop_reason', null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if item exists for the selected plant
|
||||||
|
$lineStop = \App\Models\LineStop::where('id', $lineStopId)
|
||||||
|
->where('id', $lineStopId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$set('lineStop_reason', $lineStop?->reason ?? null);
|
||||||
|
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('lineStop_reason')
|
||||||
|
->label('Line Stop Reason')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->readOnly(true),
|
||||||
Forms\Components\DateTimePicker::make('from_datetime')
|
Forms\Components\DateTimePicker::make('from_datetime')
|
||||||
->required(),
|
->label('From DateTime')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($state, callable $set, callable $get) =>
|
||||||
|
self::updateStopDuration($get, $set)
|
||||||
|
),
|
||||||
Forms\Components\DateTimePicker::make('to_datetime')
|
Forms\Components\DateTimePicker::make('to_datetime')
|
||||||
->required(),
|
->label('To DateTime')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($state, callable $set, callable $get) =>
|
||||||
|
self::updateStopDuration($get, $set) //self means it calling the function within the class
|
||||||
|
),
|
||||||
Forms\Components\TextInput::make('stop_hour')
|
Forms\Components\TextInput::make('stop_hour')
|
||||||
->required()
|
->required()
|
||||||
|
// ->dehydrated(false) // Don't send to backend
|
||||||
|
->readOnly(true)
|
||||||
->numeric(),
|
->numeric(),
|
||||||
Forms\Components\TextInput::make('stop_min')
|
Forms\Components\TextInput::make('stop_min')
|
||||||
->required()
|
->required()
|
||||||
|
// ->dehydrated(false)
|
||||||
|
->readOnly(true)
|
||||||
->numeric(),
|
->numeric(),
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('block_id')
|
|
||||||
->relationship('block', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('line_id')
|
|
||||||
->relationship('line', 'name')
|
|
||||||
->required(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function updateStopDuration(callable $get, callable $set)
|
||||||
|
{
|
||||||
|
$from = $get('from_datetime');
|
||||||
|
$to = $get('to_datetime');
|
||||||
|
|
||||||
|
// Carbon is a PHP date and time library.
|
||||||
|
|
||||||
|
if ($from && $to) {
|
||||||
|
$fromTime = Carbon::parse($from); //Carbon::parse($from) converts the from datetime string into a Carbon objec
|
||||||
|
$toTime = Carbon::parse($to);
|
||||||
|
|
||||||
|
if ($fromTime->lt($toTime)) {
|
||||||
|
$diffInMinutes = $fromTime->diffInMinutes($toTime);
|
||||||
|
$set('stop_hour', floor($diffInMinutes / 60));
|
||||||
|
$set('stop_min', $diffInMinutes % 60);
|
||||||
|
} else {
|
||||||
|
$set('stop_hour', 0);
|
||||||
|
$set('stop_min', 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
@@ -86,8 +199,6 @@ class ProductionLineStopResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
Tables\Columns\TextColumn::make('shift.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('block.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
|||||||
@@ -21,12 +21,63 @@ class ProductionPlanResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
// protected static ?string $navigationParentItem = 'Production Line Stops';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Production';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
->reactive(),
|
||||||
|
Forms\Components\Select::make('block_name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('shift_id', null)),
|
||||||
|
Forms\Components\Select::make('shift_id')
|
||||||
|
->relationship('shift', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Shift::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Shift::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('line_id', null)),
|
||||||
|
Forms\Components\Select::make('line_id')
|
||||||
|
->relationship('line', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('plan_quantity')
|
Forms\Components\TextInput::make('plan_quantity')
|
||||||
->required()
|
->required()
|
||||||
->numeric()
|
->numeric()
|
||||||
@@ -36,15 +87,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->numeric()
|
->numeric()
|
||||||
->readOnly()
|
->readOnly()
|
||||||
->default(0),
|
->default(0),
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('line_id')
|
|
||||||
->relationship('line', 'name')
|
|
||||||
->required(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,35 +21,121 @@ class ProductionQuantityResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
protected static ?string $navigationGroup = 'Master Entries';
|
// protected static ?string $navigationParentItem = 'Display Transactions';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Production';
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('item_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('item', 'code')
|
->relationship('plant', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
->reactive(),
|
||||||
|
Forms\Components\Select::make('block_name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('shift_id', null)),
|
||||||
|
Forms\Components\Select::make('shift_id')
|
||||||
|
->relationship('shift', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Shift::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Shift::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('line_id', null)),
|
||||||
|
Forms\Components\Select::make('line_id')
|
||||||
|
->relationship('line', 'name')
|
||||||
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive(),
|
||||||
|
// Forms\Components\Select::make('item_id')
|
||||||
|
// ->label('Item Code')
|
||||||
|
// ->relationship('item', 'code')
|
||||||
|
// ->required(),
|
||||||
|
// // Forms\Components\TextInput::make('item_code')
|
||||||
|
// // ->required()
|
||||||
|
// // ->autocapitalize('item_code'),
|
||||||
|
// // //->columnSpanFull(),
|
||||||
|
// Virtual field for code input (not stored in DB)
|
||||||
|
Forms\Components\TextInput::make('item_code')
|
||||||
|
->label('Item Code')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $get, callable $set) {
|
||||||
|
// Only search when all parent IDs are selected
|
||||||
|
if ($get('plant_id') && $get('line_id')) {
|
||||||
|
$item = \App\Models\Item::where('code', $state)
|
||||||
|
->where('plant_id', $get('plant_id'))
|
||||||
|
->where('line_id', $get('line_id'))
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($item) {
|
||||||
|
$set('item_id', $item->id); // Set actual foreign key
|
||||||
|
} else {
|
||||||
|
$set('item_id', null); // Clear item_id if not found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->rules([
|
||||||
|
function ($get) {
|
||||||
|
return function ($attribute, $value, $fail) use ($get) {
|
||||||
|
// Check if item exists with the given code and foreign keys
|
||||||
|
$exists = \App\Models\Item::where('code', $value)
|
||||||
|
->where('plant_id', $get('plant_id'))
|
||||||
|
->where('line_id', $get('line_id'))
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if (!$exists) {
|
||||||
|
// Custom error message
|
||||||
|
$fail("The item code '{$value}' does not exist for the selected Plant/Block/Line.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
|
||||||
|
Forms\Components\Hidden::make('item_id')
|
||||||
->required(),
|
->required(),
|
||||||
// Forms\Components\TextInput::make('item_code')
|
Forms\Components\TextInput::make('item_description')
|
||||||
// ->required()
|
->label('Description')
|
||||||
// ->autocapitalize('item_code'),
|
->required(),
|
||||||
// //->columnSpanFull(),
|
// Forms\Components\Select::make('item_id')
|
||||||
|
// ->label('Description')
|
||||||
|
// ->relationship('item', 'description')
|
||||||
|
// ->required(),
|
||||||
Forms\Components\TextInput::make('serial_number')
|
Forms\Components\TextInput::make('serial_number')
|
||||||
->required()
|
->required()
|
||||||
->autocapitalize('serial_number'),
|
->autocapitalize('serial_number'),
|
||||||
//->columnSpanFull(),
|
//->columnSpanFull(),
|
||||||
Forms\Components\Select::make('plant_id')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('block_id')
|
|
||||||
->relationship('block', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('shift_id')
|
|
||||||
->relationship('shift', 'name')
|
|
||||||
->required(),
|
|
||||||
Forms\Components\Select::make('line_id')
|
|
||||||
->relationship('line', 'name')
|
|
||||||
->required(),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,13 +147,7 @@ class ProductionQuantityResource extends Resource
|
|||||||
->label('ID')
|
->label('ID')
|
||||||
->numeric()
|
->numeric()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('plan_quantity')
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
->numeric()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('hourly_quantity')
|
|
||||||
->numeric()
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('item_code')
|
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('serial_number')
|
Tables\Columns\TextColumn::make('serial_number')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -75,8 +155,6 @@ class ProductionQuantityResource extends Resource
|
|||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('shift.name')
|
Tables\Columns\TextColumn::make('shift.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('block.name')
|
|
||||||
->sortable(),
|
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('created_at')
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
|||||||
126
app/Filament/Resources/QualityValidationResource.php
Normal file
126
app/Filament/Resources/QualityValidationResource.php
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\QualityValidationResource\Pages;
|
||||||
|
use App\Filament\Resources\QualityValidationResource\RelationManagers;
|
||||||
|
use App\Models\QualityValidation;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class QualityValidationResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = QualityValidation::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Display';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
|
->relationship('item', 'code')
|
||||||
|
->searchable()
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('stickermaster_id')
|
||||||
|
->relationship('stickermaster', 'id')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('scan_qr')
|
||||||
|
->label('Scan QR Code')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('production_order')
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('part_validation1'),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation2'),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation3'),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation4'),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation5'),
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('id')
|
||||||
|
->label('ID')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.id')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('stickermaster.id')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListQualityValidations::route('/'),
|
||||||
|
'create' => Pages\CreateQualityValidation::route('/create'),
|
||||||
|
'view' => Pages\ViewQualityValidation::route('/{record}'),
|
||||||
|
'edit' => Pages\EditQualityValidation::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\QualityValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateQualityValidation extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = QualityValidationResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\QualityValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditQualityValidation extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = QualityValidationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\QualityValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListQualityValidations extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = QualityValidationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\QualityValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\QualityValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewQualityValidation extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = QualityValidationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Imports\ShiftImporter;
|
||||||
use App\Filament\Resources\ShiftResource\Pages;
|
use App\Filament\Resources\ShiftResource\Pages;
|
||||||
use App\Models\Shift;
|
use App\Models\Shift;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
@@ -26,23 +29,53 @@ class ShiftResource extends Resource
|
|||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required(),
|
->required()
|
||||||
|
->nullable()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn ($set) => $set('block_id', null)), // Reset block_id when plant changes
|
||||||
Forms\Components\Select::make('block_id')
|
Forms\Components\Select::make('block_id')
|
||||||
->relationship('block', 'name')
|
->relationship('block', 'name')
|
||||||
->required(),
|
->required()
|
||||||
|
->nullable()
|
||||||
|
// ->options(fn (callable $get) =>
|
||||||
|
// \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
|
// ->pluck('name', 'id')
|
||||||
|
// ->toArray() // Convert collection to array
|
||||||
|
// )
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Block::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive(),
|
||||||
Forms\Components\TextInput::make('name')
|
Forms\Components\TextInput::make('name')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\TimePicker::make('start_time')
|
Forms\Components\TimePicker::make('start_time')
|
||||||
->required(),
|
->required()
|
||||||
// ->native(false),
|
->live()
|
||||||
|
->afterStateUpdated(fn (callable $set, callable $get, $state) =>
|
||||||
|
$set('end_time', self::calculateEndTime($state, $get('duration')))
|
||||||
|
),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('duration')
|
Forms\Components\TextInput::make('duration')
|
||||||
->required()
|
->required()
|
||||||
->inputMode('decimal')
|
->inputMode('decimal')
|
||||||
->minValue(1),
|
->minValue(0.01) // Minimum valid duration
|
||||||
|
->lazy()
|
||||||
|
->afterStateUpdated(fn (callable $set, callable $get, $state) =>
|
||||||
|
$set('end_time', self::calculateEndTime($get('start_time'), $state))
|
||||||
|
),
|
||||||
|
|
||||||
Forms\Components\TimePicker::make('end_time')
|
Forms\Components\TimePicker::make('end_time')
|
||||||
->required(),
|
->required(),
|
||||||
// ->native(false),
|
// ->native(false),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
@@ -90,6 +123,10 @@ class ShiftResource extends Resource
|
|||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->importer(ShiftImporter::class),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,4 +154,36 @@ class ShiftResource extends Resource
|
|||||||
SoftDeletingScope::class,
|
SoftDeletingScope::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function calculateEndTime(?string $startTime, ?string $duration): ?string
|
||||||
|
{
|
||||||
|
if (!$startTime || !$duration) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Convert start_time to Carbon instance
|
||||||
|
$startTimeCarbon = Carbon::createFromFormat('H:i:s', $startTime);
|
||||||
|
|
||||||
|
// Ensure duration is in a valid numeric format
|
||||||
|
$duration = str_replace(',', '.', $duration); // Handle decimal formats
|
||||||
|
if (!is_numeric($duration)) {
|
||||||
|
return null; // Invalid duration format
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract hours and minutes correctly
|
||||||
|
[$hours, $decimalMinutes] = explode('.', $duration) + [0, 0]; // Ensure two parts
|
||||||
|
$hours = (int) $hours; // Convert to integer hours
|
||||||
|
$minutes = (int) $decimalMinutes; // Directly use decimal part as minutes
|
||||||
|
|
||||||
|
// Calculate end time
|
||||||
|
$endTimeCarbon = $startTimeCarbon->addHours($hours)->addMinutes($minutes);
|
||||||
|
|
||||||
|
return $endTimeCarbon->format('H:i:s'); // Return formatted end time
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
291
app/Filament/Resources/StickerMasterResource.php
Normal file
291
app/Filament/Resources/StickerMasterResource.php
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\StickerMasterResource\Pages;
|
||||||
|
use App\Filament\Resources\StickerMasterResource\RelationManagers;
|
||||||
|
use App\Models\StickerMaster;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class StickerMasterResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = StickerMaster::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Master Entries';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(fn (callable $set) => $set('item_id', null))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
|
->label('Item Code')
|
||||||
|
->options(fn (callable $get) =>
|
||||||
|
\App\Models\Item::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('code', 'id')
|
||||||
|
)
|
||||||
|
->required()
|
||||||
|
->searchable()
|
||||||
|
->live(debounce: 500) // Enable live updates
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$plantId = $get('plant_id'); // Get selected plant_id
|
||||||
|
$itemId = $get('item_id'); // Get entered item_id
|
||||||
|
|
||||||
|
// Ensure `item_id` is not cleared
|
||||||
|
if (!$plantId || !$itemId) {
|
||||||
|
$set('item_description', null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if item exists for the selected plant
|
||||||
|
$item = \App\Models\Item::where('plant_id', $plantId)
|
||||||
|
->where('id', $itemId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($item) {
|
||||||
|
$set('item_description', $item->description);
|
||||||
|
} else {
|
||||||
|
$set('item_description', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}),
|
||||||
|
// ->validationAttribute('Item Code')
|
||||||
|
// ->rule('required')
|
||||||
|
// ->extraAttributes(fn ($get) => [
|
||||||
|
// 'class' => $get('validationError') ? 'border-red-500' : '',
|
||||||
|
// ])
|
||||||
|
// ->hint(fn ($get) => $get('validationError') ? $get('validationError') : null)
|
||||||
|
// ->hintColor('danger'), // Show error in red under the input field
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('item_description')
|
||||||
|
->label('Description')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->readOnly(true),
|
||||||
|
|
||||||
|
//Forms\Components\Textarea::make('serial_number_motor'),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation1')
|
||||||
|
->nullable(),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation2')
|
||||||
|
->nullable(),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation3')
|
||||||
|
->nullable(),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation4')
|
||||||
|
->nullable(),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('part_validation5')
|
||||||
|
->nullable(),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('serial_number_motor')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\Textarea::make('serial_number_pump')
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('serial_number_pump')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('serial_number_pumpset'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('serial_number_pumpset')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('pack_slip_motor'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('pack_slip_motor')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('pack_slip_pump'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('pack_slip_pump')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('pack_slip_pumpset'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('pack_slip_pumpset')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('name_plate_motor'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('name_plate_motor')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('name_plate_pump'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('name_plate_pump')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('name_plate_pumpset'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('name_plate_pumpset')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('tube_sticker_motor'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('tube_sticker_motor')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('tube_sticker_pump'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('tube_sticker_pump')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('tube_sticker_pumpset'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('tube_sticker_pumpset')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
//Forms\Components\TextInput::make('warranty_card'),
|
||||||
|
|
||||||
|
Forms\Components\Checkbox::make('warranty_card')
|
||||||
|
->nullable()
|
||||||
|
->dehydrateStateUsing(fn ($state) => $state ? $state : null),
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('id')
|
||||||
|
->label('ID')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.id')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
|
->numeric()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('serial_number_motor')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('serial_number_pump')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('serial_number_pumpset')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('pack_slip_motor')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('pack_slip_pump')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('pack_slip_pumpset')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('name_plate_motor')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('name_plate_pump')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('name_plate_pumpset')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('tube_sticker_motor')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('tube_sticker_pump')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('tube_sticker_pumpset')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\CheckboxColumn::make('warranty_card')
|
||||||
|
->disabled(true)
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('part_validation1')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('part_validation2')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('part_validation3')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('part_validation4')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('part_validation5')
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListStickerMasters::route('/'),
|
||||||
|
'create' => Pages\CreateStickerMaster::route('/create'),
|
||||||
|
'view' => Pages\ViewStickerMaster::route('/{record}'),
|
||||||
|
'edit' => Pages\EditStickerMaster::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\StickerMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\StickerMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateStickerMaster extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = StickerMasterResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\StickerMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\StickerMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditStickerMaster extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = StickerMasterResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\StickerMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\StickerMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListStickerMasters extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = StickerMasterResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\StickerMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\StickerMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewStickerMaster extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = StickerMasterResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,58 +8,73 @@ class ItemOverview extends ChartWidget
|
|||||||
{
|
{
|
||||||
protected static ?string $heading = 'Chart';
|
protected static ?string $heading = 'Chart';
|
||||||
|
|
||||||
|
|
||||||
protected int|string|array $columnSpan = 'full';
|
protected int|string|array $columnSpan = 'full';
|
||||||
|
|
||||||
|
//protected $listeners = ['filtersUpdated' => '$refresh']; // Listen for filter updates
|
||||||
|
|
||||||
protected function getData(): array
|
protected function getData(): array
|
||||||
{
|
{
|
||||||
$activeFilter = $this->filter;
|
$activeFilter = $this->filter;
|
||||||
|
// Get filter values from session
|
||||||
// Get selected values from the plant and line filter form inputs
|
$selectedPlant = session('selected_plant');
|
||||||
$selectedPlant = request()->input('plant'); // Assuming form input name is 'plant'
|
$selectedLine = session('selected_line');
|
||||||
$selectedLine = request()->input('line'); // Assuming form input name is 'line'
|
|
||||||
|
|
||||||
$query = \DB::table('production_quantities')
|
$query = \DB::table('production_quantities')
|
||||||
->selectRaw('EXTRACT(HOUR FROM created_at) AS hour, COUNT(*) AS total_quantity')
|
->join('plants', 'production_quantities.plant_id', '=', 'plants.id') // Join plants table
|
||||||
->whereBetween('created_at', [now()->startOfDay(), now()->endOfDay()]);
|
->join('lines', 'production_quantities.line_id', '=', 'lines.id') // Join lines table
|
||||||
|
->selectRaw('EXTRACT(HOUR FROM production_quantities.created_at) AS hour, count(*) AS total_quantity')
|
||||||
// Apply filters only if values are selected
|
->whereBetween('production_quantities.created_at', [now()->startOfDay(), now()->endOfDay()])
|
||||||
if (!empty($selectedPlant)) {
|
->when($selectedPlant, function ($q) use ($selectedPlant) {
|
||||||
$query->where('plant', $selectedPlant);
|
return $q->where('plants.id', $selectedPlant);
|
||||||
}
|
})
|
||||||
|
->when($selectedLine, function ($q) use ($selectedLine) {
|
||||||
if (!empty($selectedLine)) {
|
return $q->where('lines.id', $selectedLine);
|
||||||
$query->where('line', $selectedLine);
|
})
|
||||||
}
|
->groupByRaw('EXTRACT(HOUR FROM production_quantities.created_at)')
|
||||||
|
->orderByRaw('EXTRACT(HOUR FROM production_quantities.created_at)')
|
||||||
$query = $query->groupByRaw('EXTRACT(HOUR FROM created_at)')
|
|
||||||
->orderByRaw('EXTRACT(HOUR FROM created_at)')
|
|
||||||
->pluck('total_quantity', 'hour')
|
->pluck('total_quantity', 'hour')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
$data = array_fill(8, 12, 0);
|
// // Ensure all 24 hours are covered, filling missing ones with zero
|
||||||
|
// $data = array_replace(array_fill(8, 24, 0), $query);
|
||||||
|
|
||||||
// Populate actual values
|
// return [
|
||||||
// foreach ($query as $record) {
|
// 'datasets' => [
|
||||||
// $hour = (int) $record->hour;
|
// [
|
||||||
// if ($hour >= 8 && $hour <= 19) {
|
// 'label' => 'Hourly Production',
|
||||||
// $data[$hour] = $record->total_quantity; // Assign only the hourly production
|
// 'data' => array_values($data),
|
||||||
// }
|
// 'borderColor' => 'rgba(75, 192, 192, 1)',
|
||||||
// }
|
// 'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
|
||||||
|
// 'fill' => false,
|
||||||
|
// 'tension' => 0.3,
|
||||||
|
// ],
|
||||||
|
// ],
|
||||||
|
// // 'labels' => array_map(fn ($hour) => ($hour == 0 ? '12 AM' : ($hour == 12 ? '12 PM' : ($hour < 12 ? "{$hour} AM" : ($hour - 12) . " PM"))), array_keys($data)),
|
||||||
|
// // Labels in 24-hour format
|
||||||
|
// 'labels' => array_map(fn ($hour) => date("g A", strtotime("$hour:00")), array_keys($data)), // Improved hour formatting
|
||||||
|
// ];
|
||||||
|
|
||||||
|
$allHours = array_fill(0, 24, 0);
|
||||||
|
$data = array_replace($allHours, $query);
|
||||||
|
|
||||||
|
$shiftedKeys = range(8, 23); // 8 AM to 11 PM
|
||||||
|
$shiftedKeys = array_merge($shiftedKeys, range(0, 8));
|
||||||
|
|
||||||
|
$orderedData = array_map(fn($hour) => $data[$hour], $shiftedKeys);
|
||||||
|
|
||||||
// Convert data to chart format
|
|
||||||
return [
|
return [
|
||||||
'datasets' => [
|
'datasets' => [
|
||||||
[
|
[
|
||||||
'label' => 'Hourly Production',
|
'label' => 'Hourly Production',
|
||||||
'data' => array_values($data), // Values only
|
'data' => array_values($orderedData),
|
||||||
'borderColor' => 'rgba(75, 192, 192, 1)',
|
'borderColor' => 'rgba(75, 192, 192, 1)',
|
||||||
'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
|
'backgroundColor' => 'rgba(75, 192, 192, 0.2)',
|
||||||
'fill' => false, // No area fill, just the line
|
'fill' => false,
|
||||||
'tension' => 0.3, // Smooth curve
|
'tension' => 0.3,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'labels' => array_map(fn($h) => ($h <= 11 ? "$h AM" : ($h == 12 ? "12 PM" : ($h - 12) . " PM")), array_keys($data)),
|
// Correct label sequence from 8 AM to 7 AM
|
||||||
|
'labels' => array_map(fn ($hour) => date("g A", strtotime("$hour:00")), $shiftedKeys),
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -69,13 +84,24 @@ class ItemOverview extends ChartWidget
|
|||||||
return 'line';
|
return 'line';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getOptions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'scales' => [
|
||||||
|
'y' => [
|
||||||
|
'beginAtZero' => true, //Start Y-axis from 0
|
||||||
|
'ticks' => [
|
||||||
|
'stepSize' => 0.5,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
protected function getFilters(): ?array
|
protected function getFilters(): ?array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'today' => 'Today',
|
'today' => 'Today',
|
||||||
'week' => 'Last week',
|
|
||||||
'month' => 'Last month',
|
|
||||||
'year' => 'This year',
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ class Item extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
"block_id",
|
|
||||||
"line_id",
|
|
||||||
'code',
|
'code',
|
||||||
'description',
|
'description',
|
||||||
'hourly_quantity',
|
'hourly_quantity',
|
||||||
@@ -23,14 +21,4 @@ class Item extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function block(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Block::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function line(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Line::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,30 +13,12 @@ class Line extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
"block_id",
|
|
||||||
"shift_id",
|
|
||||||
"name",
|
"name",
|
||||||
"type",
|
"type",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function plant(): BelongsTo
|
public function plant(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function block(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Block::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shift(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Shift::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function line_stops(): HasMany
|
|
||||||
{
|
|
||||||
return $this->hasMany(LineStop::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,26 +11,7 @@ class LineStop extends Model
|
|||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
|
||||||
"block_id",
|
|
||||||
"shift_id",
|
|
||||||
"code",
|
"code",
|
||||||
"reason",
|
"reason",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function plant(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Plant::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function block(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Block::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shift(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Shift::class);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,4 +32,9 @@ class Plant extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(Line::class);
|
return $this->hasMany(Line::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLineNames()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Line::class, 'plant_id', 'id'); // Ensure 'plant_id' is the foreign key in 'lines' table
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,9 @@ class ProductionLineStop extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
"block_id",
|
|
||||||
"shift_id",
|
"shift_id",
|
||||||
"line_id",
|
"line_id",
|
||||||
"lineStop_id",
|
"linestop_id",
|
||||||
"from_datetime",
|
"from_datetime",
|
||||||
"to_datetime",
|
"to_datetime",
|
||||||
"stop_hour",
|
"stop_hour",
|
||||||
@@ -27,11 +26,6 @@ class ProductionLineStop extends Model
|
|||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function block(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Block::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shift(): BelongsTo
|
public function shift(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Shift::class);
|
return $this->belongsTo(Shift::class);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class ProductionQuantity extends Model
|
|||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
"plant_id",
|
"plant_id",
|
||||||
"block_id",
|
|
||||||
"shift_id",
|
"shift_id",
|
||||||
"line_id",
|
"line_id",
|
||||||
"item_id",
|
"item_id",
|
||||||
@@ -24,11 +23,6 @@ class ProductionQuantity extends Model
|
|||||||
return $this->belongsTo(Plant::class);
|
return $this->belongsTo(Plant::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function block(): BelongsTo
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Block::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shift(): BelongsTo
|
public function shift(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Shift::class);
|
return $this->belongsTo(Shift::class);
|
||||||
|
|||||||
51
app/Models/QualityValidation.php
Normal file
51
app/Models/QualityValidation.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class QualityValidation extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'item_id',
|
||||||
|
'plant_id',
|
||||||
|
'stickermaster_id ',
|
||||||
|
'serial_number_motor',
|
||||||
|
'serial_number_pump',
|
||||||
|
'serial_number_pumpset',
|
||||||
|
'pack_slip_motor',
|
||||||
|
'pack_slip_pump',
|
||||||
|
'pack_slip_pumpset',
|
||||||
|
'name_plate_motor',
|
||||||
|
'name_plate_pump',
|
||||||
|
'name_plate_pumpset',
|
||||||
|
'tube_sticker_motor',
|
||||||
|
'tube_sticker_pump',
|
||||||
|
'tube_sticker_pumpset',
|
||||||
|
'warranty_card',
|
||||||
|
'part_validation1',
|
||||||
|
'part_validation2',
|
||||||
|
'part_validation3',
|
||||||
|
'part_validation4',
|
||||||
|
'part_validation5',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function item(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Item::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function plant(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plant::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stickermaster(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(StickerMaster::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
46
app/Models/StickerMaster.php
Normal file
46
app/Models/StickerMaster.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class StickerMaster extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'item_id',
|
||||||
|
'plant_id',
|
||||||
|
'serial_number_motor',
|
||||||
|
'serial_number_pump',
|
||||||
|
'serial_number_pumpset',
|
||||||
|
'pack_slip_motor',
|
||||||
|
'pack_slip_pump',
|
||||||
|
'pack_slip_pumpset',
|
||||||
|
'name_plate_motor',
|
||||||
|
'name_plate_pump',
|
||||||
|
'name_plate_pumpset',
|
||||||
|
'tube_sticker_motor',
|
||||||
|
'tube_sticker_pump',
|
||||||
|
'tube_sticker_pumpset',
|
||||||
|
'warranty_card',
|
||||||
|
'part_validation1',
|
||||||
|
'part_validation2',
|
||||||
|
'part_validation3',
|
||||||
|
'part_validation4',
|
||||||
|
'part_validation5',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function item(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Item::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function plant(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plant::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ namespace App\Providers;
|
|||||||
|
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use URL;
|
||||||
|
|
||||||
// use Doctrine\DBAL\Types\Type;
|
// use Doctrine\DBAL\Types\Type;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
@@ -25,6 +27,8 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
return $user->hasRole('Super Admin') ? true : null;
|
return $user->hasRole('Super Admin') ? true : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// URL::forceScheme('https');
|
||||||
|
|
||||||
// if (!Type::hasType('citext')) {
|
// if (!Type::hasType('citext')) {
|
||||||
// Type::addType('citext', \Doctrine\DBAL\Platforms\PostgreSqlPlatform::class);
|
// Type::addType('citext', \Doctrine\DBAL\Platforms\PostgreSqlPlatform::class);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use Filament\Http\Middleware\Authenticate;
|
|||||||
use Filament\Http\Middleware\AuthenticateSession;
|
use Filament\Http\Middleware\AuthenticateSession;
|
||||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||||
|
use Filament\Navigation\NavigationGroup;
|
||||||
use Filament\Pages;
|
use Filament\Pages;
|
||||||
use Filament\Panel;
|
use Filament\Panel;
|
||||||
use Filament\PanelProvider;
|
use Filament\PanelProvider;
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ return new class extends Migration
|
|||||||
CREATE TABLE lines (
|
CREATE TABLE lines (
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
shift_id BIGINT NOT NULL,
|
|
||||||
block_id BIGINT NOT NULL,
|
|
||||||
plant_id BIGINT NOT NULL,
|
plant_id BIGINT NOT NULL,
|
||||||
|
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
@@ -25,9 +23,7 @@ return new class extends Migration
|
|||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
deleted_at TIMESTAMP,
|
deleted_at TIMESTAMP,
|
||||||
|
|
||||||
UNIQUE (name, shift_id, block_id, plant_id),
|
UNIQUE (name, plant_id),
|
||||||
FOREIGN KEY (shift_id) REFERENCES shifts (id),
|
|
||||||
FOREIGN KEY (block_id) REFERENCES blocks (id),
|
|
||||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||||
);
|
);
|
||||||
SQL;
|
SQL;
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ return new class extends Migration
|
|||||||
CREATE TABLE items (
|
CREATE TABLE items (
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
line_id BIGINT NOT NULL,
|
|
||||||
block_id BIGINT NOT NULL,
|
|
||||||
plant_id BIGINT NOT NULL,
|
plant_id BIGINT NOT NULL,
|
||||||
|
|
||||||
code TEXT NOT NULL CHECK (LENGTH(code) >= 6),
|
code TEXT NOT NULL CHECK (LENGTH(code) >= 6),
|
||||||
@@ -27,9 +25,7 @@ return new class extends Migration
|
|||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
deleted_at TIMESTAMP,
|
deleted_at TIMESTAMP,
|
||||||
|
|
||||||
UNIQUE (code, line_id, block_id, plant_id),
|
UNIQUE (code, plant_id),
|
||||||
FOREIGN KEY (line_id) REFERENCES lines (id),
|
|
||||||
FOREIGN KEY (block_id) REFERENCES blocks (id),
|
|
||||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||||
);
|
);
|
||||||
SQL;
|
SQL;
|
||||||
|
|||||||
@@ -15,21 +15,12 @@ return new class extends Migration
|
|||||||
CREATE TABLE line_stops (
|
CREATE TABLE line_stops (
|
||||||
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
shift_id BIGINT NOT NULL,
|
code TEXT NOT NULL UNIQUE,
|
||||||
block_id BIGINT NOT NULL,
|
|
||||||
plant_id BIGINT NOT NULL,
|
|
||||||
|
|
||||||
code TEXT NOT NULL,
|
|
||||||
reason TEXT NOT NULL,
|
reason TEXT NOT NULL,
|
||||||
|
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
deleted_at TIMESTAMP,
|
deleted_at TIMESTAMP
|
||||||
|
|
||||||
UNIQUE (code, shift_id, block_id, plant_id),
|
|
||||||
FOREIGN KEY (shift_id) REFERENCES shifts (id),
|
|
||||||
FOREIGN KEY (block_id) REFERENCES blocks (id),
|
|
||||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
|
||||||
);
|
);
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,8 @@ return new class extends Migration
|
|||||||
|
|
||||||
line_id BIGINT NOT NULL,
|
line_id BIGINT NOT NULL,
|
||||||
shift_id BIGINT NOT NULL,
|
shift_id BIGINT NOT NULL,
|
||||||
block_id BIGINT NOT NULL,
|
|
||||||
plant_id BIGINT NOT NULL,
|
plant_id BIGINT NOT NULL,
|
||||||
lineStop_id BIGINT NOT NULL,
|
linestop_id BIGINT NOT NULL,
|
||||||
|
|
||||||
from_datetime TIMESTAMP NOT NULL,
|
from_datetime TIMESTAMP NOT NULL,
|
||||||
to_datetime TIMESTAMP NOT NULL,
|
to_datetime TIMESTAMP NOT NULL,
|
||||||
@@ -31,9 +30,8 @@ return new class extends Migration
|
|||||||
|
|
||||||
FOREIGN KEY (line_id) REFERENCES lines (id),
|
FOREIGN KEY (line_id) REFERENCES lines (id),
|
||||||
FOREIGN KEY (shift_id) REFERENCES shifts (id),
|
FOREIGN KEY (shift_id) REFERENCES shifts (id),
|
||||||
FOREIGN KEY (block_id) REFERENCES blocks (id),
|
|
||||||
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||||
FOREIGN KEY (lineStop_id) REFERENCES line_stops (id)
|
FOREIGN KEY (linestop_id) REFERENCES line_stops (id)
|
||||||
);
|
);
|
||||||
SQL;
|
SQL;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ return new class extends Migration
|
|||||||
|
|
||||||
line_id BIGINT NOT NULL,
|
line_id BIGINT NOT NULL,
|
||||||
shift_id BIGINT NOT NULL,
|
shift_id BIGINT NOT NULL,
|
||||||
block_id BIGINT NOT NULL,
|
|
||||||
plant_id BIGINT NOT NULL,
|
plant_id BIGINT NOT NULL,
|
||||||
item_id BIGINT NOT NULL,
|
item_id BIGINT NOT NULL,
|
||||||
|
|
||||||
@@ -31,7 +30,6 @@ return new class extends Migration
|
|||||||
FOREIGN KEY (item_id) REFERENCES items (id),
|
FOREIGN KEY (item_id) REFERENCES items (id),
|
||||||
FOREIGN KEY (line_id) REFERENCES lines (id),
|
FOREIGN KEY (line_id) REFERENCES lines (id),
|
||||||
FOREIGN KEY (shift_id) REFERENCES shifts (id),
|
FOREIGN KEY (shift_id) REFERENCES shifts (id),
|
||||||
FOREIGN KEY (block_id) REFERENCES blocks (id),
|
|
||||||
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||||
);
|
);
|
||||||
SQL;
|
SQL;
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
CREATE TABLE sticker_masters (
|
||||||
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
|
item_id BIGINT NOT NULL,
|
||||||
|
plant_id BIGINT NOT NULL,
|
||||||
|
serial_number_motor TEXT DEFAULT NULL,
|
||||||
|
serial_number_pump TEXT DEFAULT NULL,
|
||||||
|
serial_number_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
pack_slip_motor TEXT DEFAULT NULL,
|
||||||
|
pack_slip_pump TEXT DEFAULT NULL,
|
||||||
|
pack_slip_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
name_plate_motor TEXT DEFAULT NULL,
|
||||||
|
name_plate_pump TEXT DEFAULT NULL,
|
||||||
|
name_plate_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
tube_sticker_motor TEXT DEFAULT NULL,
|
||||||
|
tube_sticker_pump TEXT DEFAULT NULL,
|
||||||
|
tube_sticker_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
warranty_card TEXT DEFAULT NULL,
|
||||||
|
part_validation1 TEXT DEFAULT NULL,
|
||||||
|
part_validation2 TEXT DEFAULT NULL,
|
||||||
|
part_validation3 TEXT DEFAULT NULL,
|
||||||
|
part_validation4 TEXT DEFAULT NULL,
|
||||||
|
part_validation5 TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
deleted_at TIMESTAMP,
|
||||||
|
|
||||||
|
FOREIGN KEY (item_id) REFERENCES items (id),
|
||||||
|
FOREIGN KEY (plant_id) REFERENCES plants (id)
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('sticker_masters');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
CREATE TABLE quality_validations (
|
||||||
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
|
item_id BIGINT NOT NULL,
|
||||||
|
plant_id BIGINT NOT NULL,
|
||||||
|
stickermaster_id BIGINT NOT NULL,
|
||||||
|
|
||||||
|
production_order TEXT NOT NULL,
|
||||||
|
|
||||||
|
serial_number_motor TEXT DEFAULT NULL,
|
||||||
|
serial_number_pump TEXT DEFAULT NULL,
|
||||||
|
serial_number_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
pack_slip_motor TEXT DEFAULT NULL,
|
||||||
|
pack_slip_pump TEXT DEFAULT NULL,
|
||||||
|
pack_slip_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
name_plate_motor TEXT DEFAULT NULL,
|
||||||
|
name_plate_pump TEXT DEFAULT NULL,
|
||||||
|
name_plate_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
tube_sticker_motor TEXT DEFAULT NULL,
|
||||||
|
tube_sticker_pump TEXT DEFAULT NULL,
|
||||||
|
tube_sticker_pumpset TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
warranty_card TEXT DEFAULT NULL,
|
||||||
|
part_validation1 TEXT DEFAULT NULL,
|
||||||
|
part_validation2 TEXT DEFAULT NULL,
|
||||||
|
part_validation3 TEXT DEFAULT NULL,
|
||||||
|
part_validation4 TEXT DEFAULT NULL,
|
||||||
|
part_validation5 TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
deleted_at TIMESTAMP,
|
||||||
|
|
||||||
|
FOREIGN KEY (item_id) REFERENCES items (id),
|
||||||
|
FOREIGN KEY (plant_id) REFERENCES plants (id),
|
||||||
|
FOREIGN KEY (stickerMaster_id) REFERENCES sticker_masters (id)
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('quality_validations');
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user