diff --git a/app/Filament/Resources/ProductionQuantityResource.php b/app/Filament/Resources/ProductionQuantityResource.php index ff35a51..67ba5ee 100644 --- a/app/Filament/Resources/ProductionQuantityResource.php +++ b/app/Filament/Resources/ProductionQuantityResource.php @@ -46,6 +46,7 @@ class ProductionQuantityResource extends Resource ->required() // ->nullable() ->reactive() + ->columnSpan(1) // ->default(fn () => optional(ProductionQuantity::latest()->first())->plant_id) ->default(function () { return optional(ProductionQuantity::latest()->first())->plant_id; @@ -99,6 +100,7 @@ class ProductionQuantityResource extends Resource Forms\Components\Select::make('block_name') ->required() // ->nullable() + ->columnSpan(1) ->options(function (callable $get) { if (!$get('plant_id')) { return []; @@ -830,11 +832,10 @@ class ProductionQuantityResource extends Resource ->hidden() ->readOnly(), ]) - ->columns(2), + ->columns(6), ]); } - public static function table(Table $table): Table { return $table @@ -883,7 +884,8 @@ class ProductionQuantityResource extends Resource ->headerActions([ ImportAction::make() ->importer(ProductionQuantityImporter::class) - ->maxRows(100000), + ->chunkSize(1000), + // ->maxRows(100000), ExportAction::make() ->exporter(ProductionQuantityExporter::class), ]); diff --git a/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php b/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php index 9048d6f..f0cadb6 100644 --- a/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php +++ b/app/Filament/Resources/ProductionQuantityResource/Pages/CreateProductionQuantity.php @@ -11,11 +11,62 @@ use Filament\Facades\Filament; use Filament\Notifications\Notification; use Filament\Resources\Pages\CreateRecord; use Livewire\Livewire; +use Route; class CreateProductionQuantity extends CreateRecord { protected static string $resource = ProductionQuantityResource::class; + // public function getTitle(): string + // { + // return 'Create'; // This should display in the breadcrumb as "Production Quantities > Create" + // } + + // Hide only the big H1 heading on the page + public function getHeading(): string + { + return ''; + } + + public function boot(): void + { + Filament::registerRenderHook( + 'panels::body.start', + function () { + if (str_contains(Route::currentRouteName(), 'filament.admin.resources.production-quantities')) { + echo << + /* Hide sidebar and topbar */ + .fi-sidebar, + .fi-topbar { + display: none !important; + } + + /* Expand main container to full screen */ + .fi-main { + margin: 0 !important; + padding: 0 !important; + height: 100vh; + overflow-y: auto; /* Allow vertical scrolling */ + } + + /* Expand page area fully */ + .fi-main > .fi-page { + padding: 0 !important; + max-width: 100% !important; + } + + /* Allow scroll on body again */ + body { + overflow: auto; + } + + HTML; + } + } + ); + } + protected function getFooterWidgets(): array { return [ @@ -35,9 +86,10 @@ class CreateProductionQuantity extends CreateRecord public function getFormActions(): array { // return parent::getFormActions(); //return []; - return [ - $this->getCancelFormAction(), - ]; + // return [ + // $this->getCancelFormAction(), + // ]; + return []; } public function processAllValues($formData) diff --git a/app/Models/ProductionQuantity.php b/app/Models/ProductionQuantity.php index 1f4ef87..93cea1f 100644 --- a/app/Models/ProductionQuantity.php +++ b/app/Models/ProductionQuantity.php @@ -11,6 +11,8 @@ class ProductionQuantity extends Model { use SoftDeletes; + public static $importing = false; // Add this flag + protected $fillable = [ "plant_id", "shift_id", @@ -42,6 +44,11 @@ class ProductionQuantity extends Model protected static function booted() { static::created(function ($productionQuantity) { + + if (static::$importing) { // Check flag here + return; + } + $productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id) ->where('shift_id', $productionQuantity->shift_id) ->where('line_id', $productionQuantity->line_id) @@ -53,12 +60,12 @@ class ProductionQuantity extends Model if (!$productionPlan) { $productionPlan = ProductionPlan::where('plant_id', $productionQuantity->plant_id) - ->where('shift_id', $productionQuantity->shift_id) - ->where('line_id', $productionQuantity->line_id) - ->whereDate('created_at', Carbon::yesterday()) - // ->where('plan_quantity', $productionQuantity->plan_quantity) - ->latest() - ->first(); + ->where('shift_id', $productionQuantity->shift_id) + ->where('line_id', $productionQuantity->line_id) + ->whereDate('created_at', Carbon::yesterday()) + // ->where('plan_quantity', $productionQuantity->plan_quantity) + ->latest() + ->first(); } if ($productionPlan) {