diff --git a/app/Filament/Pages/CurrentPrice.php b/app/Filament/Pages/CurrentPrice.php index 20e372d..4671f55 100644 --- a/app/Filament/Pages/CurrentPrice.php +++ b/app/Filament/Pages/CurrentPrice.php @@ -2,10 +2,21 @@ namespace App\Filament\Pages; +use App\Models\Producer; +use App\Models\Product; +use App\Models\ProductGroup; +use App\Models\Supplier; +use Filament\Forms\Components\Select; +use Filament\Forms\Concerns\InteractsWithForms; +use Filament\Forms\Contracts\HasForms; +use Filament\Schemas\Schema; use Filament\Pages\Page; +use Illuminate\Support\Facades\DB; -class CurrentPrice extends Page +class CurrentPrice extends Page implements HasForms { + use InteractsWithForms; + protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-currency-dollar'; protected static ?string $title = 'Aktuális ár'; @@ -14,14 +25,9 @@ class CurrentPrice extends Page protected static string | \UnitEnum | null $navigationGroup = 'Statisztika'; - public function getHeader(): ?\Illuminate\Contracts\View\View + public function getHeading(): string|\Illuminate\Contracts\Support\Htmlable { - return null; - } - - public function getFooter(): ?\Illuminate\Contracts\View\View - { - return null; + return ''; } public function getBreadcrumbs(): array @@ -30,4 +36,71 @@ public function getBreadcrumbs(): array } protected string $view = 'filament.pages.current-price'; + + public ?array $data = []; + + public function mount(): void + { + $this->form->fill(); + } + + public function form(Schema $form): Schema + { + return $form + ->schema([ + Select::make('supplier') + ->label('Beszállító:') + ->options(Supplier::orderBy('name')->pluck('name', 'id')) + ->multiple() + ->searchable() + ->placeholder('Válasszon beszállítót...'), + Select::make('productGroup') + ->label('Termékcsoport:') + ->options(ProductGroup::orderBy('name')->pluck('name', 'id')) + ->multiple() + ->searchable() + ->placeholder('Válasszon termékcsoportot...'), + Select::make('product') + ->label('Termék:') + ->multiple() + ->searchable() + ->getSearchResultsUsing(function (string $search, ?array $state) { + $query = Product::where('name', 'like', "%{$search}%"); + return $query->limit(50)->pluck('name', 'name')->toArray(); + }) + ->getOptionLabelsUsing(fn (array $values): array => Product::whereIn('name', $values) + ->pluck('name', 'name') + ->toArray()) + ->placeholder('Válasszon terméket...'), + Select::make('hooreycaName') + ->label('Hooreyca megnevezés :') + ->options(function () { + DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));"); + $options = Product::orderBy('buyerProductName') + ->where('buyerProductName', '!=', '') + ->groupBy('buyerProductName') + ->pluck('buyerProductName', 'buyerProductName') + ->toArray(); + DB::statement("SET sql_mode=(SELECT CONCAT(@@sql_mode, ',ONLY_FULL_GROUP_BY'));"); + return $options; + }) + ->multiple() + ->searchable() + ->placeholder('Válasszon megnevezést...'), + Select::make('producer') + ->label('Gyártó :') + ->options(Producer::orderBy('name')->pluck('name', 'id')) + ->multiple() + ->searchable() + ->placeholder('Válasszon gyártót...'), + ]) + ->statePath('data'); + } + + public function submit(): void + { + $data = $this->form->getState(); + // Itt lehet majd feldolgozni a szűrést + // dd($data); + } } diff --git a/resources/views/filament/pages/current-price.blade.php b/resources/views/filament/pages/current-price.blade.php index 06dcd53..c0a60a3 100644 --- a/resources/views/filament/pages/current-price.blade.php +++ b/resources/views/filament/pages/current-price.blade.php @@ -8,6 +8,17 @@ .fi-main { padding-left: 0 !important; } .fi-topbar { z-index: 10 !important; } + /* A Filament wrapper elemeinek nullázása a pontos illeszkedés érdekében */ + .fi-page, .fi-page-header-main-ctn, .fi-page-main, .fi-page-content, .fi-page-header, .fi-header { + padding: 0 !important; + margin: 0 !important; + gap: 0 !important; + } + + .fi-page-header, .fi-header { + display: none !important; + } + /* A legacy sidebar stílusaihoz szükséges alapok */ .page-wrapper.chiller-theme .page-content { padding-left: 260px; @@ -18,9 +29,14 @@ } } - /* Biztosítjuk a szürke hátteret */ + /* Biztosítjük a szürke hátteret és eltüntetjük a felső üres részt */ .fi-main-ctn { background-color: #f4f4f4 !important; + min-height: 100vh; + } + .fi-main { + padding-top: 0 !important; + margin-top: 0 !important; } .statistic-card { @@ -28,15 +44,17 @@ border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 20px; + border: 1px solid #dee2e6; } .statistic-card-header { - padding: 15px 20px; + padding: 10px 15px; border-bottom: 1px solid #eee; - font-weight: bold; + font-weight: 600; color: #333; + background-color: #f8f9fa; } .statistic-card-body { - padding: 20px; + padding: 15px; } /* Navigációs gombok stílusa (a modern nézetből átemelve, de a legacy-hoz igazítva) */ @@ -90,33 +108,22 @@ }); -
-
+
+
- Statisztikai navigáció (Legacy) + Szűrés
-
-
- - - Rendelés gyakoriság - +
+ {{ $this->form }} + +
+
- - -
+
diff --git a/tests/Feature/CurrentPricePageTest.php b/tests/Feature/CurrentPricePageTest.php new file mode 100644 index 0000000..ba02ccf --- /dev/null +++ b/tests/Feature/CurrentPricePageTest.php @@ -0,0 +1,22 @@ + 'admin', 'display_name' => 'Admin', 'description' => 'Admin']); + $user = User::factory()->create(); + $user->addRole($adminRole); + + $this->actingAs($user); + + Livewire::test(CurrentPrice::class) + ->assertOk() + ->assertFormExists(); +});