ADD EV3-358 statisztika modul bővítése aktuális ár megjelenítéssel phase 4 egymásra ható szűrők.
This commit is contained in:
parent
c408e02054
commit
e0876e4f25
@ -9,6 +9,7 @@
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
use Filament\Forms\Contracts\HasForms;
|
use Filament\Forms\Contracts\HasForms;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@ -53,19 +54,47 @@ public function form(Schema $form): Schema
|
|||||||
->options(Supplier::orderBy('name')->pluck('name', 'id'))
|
->options(Supplier::orderBy('name')->pluck('name', 'id'))
|
||||||
->multiple()
|
->multiple()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('productGroup', []);
|
||||||
|
$set('product', []);
|
||||||
|
$set('hooreycaName', []);
|
||||||
|
$set('producer', []);
|
||||||
|
})
|
||||||
->placeholder('Válasszon beszállítót...'),
|
->placeholder('Válasszon beszállítót...'),
|
||||||
Select::make('productGroup')
|
Select::make('productGroup')
|
||||||
->label('Termékcsoport:')
|
->label('Termékcsoport:')
|
||||||
->options(ProductGroup::orderBy('name')->pluck('name', 'id'))
|
->options(function (Get $get) {
|
||||||
|
$supplierIds = $get('supplier') ?? [];
|
||||||
|
$query = ProductGroup::query();
|
||||||
|
if (filled($supplierIds)) {
|
||||||
|
$query->whereIn('id', Product::whereIn('supplier_id', $supplierIds)->whereNotNull('product_group_id')->distinct()->pluck('product_group_id'));
|
||||||
|
}
|
||||||
|
return $query->orderBy('name')->pluck('name', 'id');
|
||||||
|
})
|
||||||
->multiple()
|
->multiple()
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('product', []);
|
||||||
|
$set('hooreycaName', []);
|
||||||
|
$set('producer', []);
|
||||||
|
})
|
||||||
->placeholder('Válasszon termékcsoportot...'),
|
->placeholder('Válasszon termékcsoportot...'),
|
||||||
Select::make('product')
|
Select::make('product')
|
||||||
->label('Termék:')
|
->label('Termék:')
|
||||||
->multiple()
|
->multiple()
|
||||||
->searchable()
|
->searchable()
|
||||||
->getSearchResultsUsing(function (string $search, ?array $state) {
|
->getSearchResultsUsing(function (string $search, Get $get) {
|
||||||
|
$supplierIds = $get('supplier') ?? [];
|
||||||
|
$productGroupIds = $get('productGroup') ?? [];
|
||||||
$query = Product::where('name', 'like', "%{$search}%");
|
$query = Product::where('name', 'like', "%{$search}%");
|
||||||
|
if (filled($supplierIds)) {
|
||||||
|
$query->whereIn('supplier_id', $supplierIds);
|
||||||
|
}
|
||||||
|
if (filled($productGroupIds)) {
|
||||||
|
$query->whereIn('product_group_id', $productGroupIds);
|
||||||
|
}
|
||||||
return $query->limit(50)->pluck('name', 'name')->toArray();
|
return $query->limit(50)->pluck('name', 'name')->toArray();
|
||||||
})
|
})
|
||||||
->getOptionLabelsUsing(fn (array $values): array => Product::whereIn('name', $values)
|
->getOptionLabelsUsing(fn (array $values): array => Product::whereIn('name', $values)
|
||||||
@ -74,10 +103,18 @@ public function form(Schema $form): Schema
|
|||||||
->placeholder('Válasszon terméket...'),
|
->placeholder('Válasszon terméket...'),
|
||||||
Select::make('hooreycaName')
|
Select::make('hooreycaName')
|
||||||
->label('Hooreyca megnevezés :')
|
->label('Hooreyca megnevezés :')
|
||||||
->options(function () {
|
->options(function (Get $get) {
|
||||||
|
$supplierIds = $get('supplier') ?? [];
|
||||||
|
$productGroupIds = $get('productGroup') ?? [];
|
||||||
DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
|
DB::statement("SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));");
|
||||||
$options = Product::orderBy('buyerProductName')
|
$query = Product::where('buyerProductName', '!=', '');
|
||||||
->where('buyerProductName', '!=', '')
|
if (filled($supplierIds)) {
|
||||||
|
$query->whereIn('supplier_id', $supplierIds);
|
||||||
|
}
|
||||||
|
if (filled($productGroupIds)) {
|
||||||
|
$query->whereIn('product_group_id', $productGroupIds);
|
||||||
|
}
|
||||||
|
$options = $query->orderBy('buyerProductName')
|
||||||
->groupBy('buyerProductName')
|
->groupBy('buyerProductName')
|
||||||
->pluck('buyerProductName', 'buyerProductName')
|
->pluck('buyerProductName', 'buyerProductName')
|
||||||
->toArray();
|
->toArray();
|
||||||
@ -89,7 +126,22 @@ public function form(Schema $form): Schema
|
|||||||
->placeholder('Válasszon megnevezést...'),
|
->placeholder('Válasszon megnevezést...'),
|
||||||
Select::make('producer')
|
Select::make('producer')
|
||||||
->label('Gyártó :')
|
->label('Gyártó :')
|
||||||
->options(Producer::orderBy('name')->pluck('name', 'id'))
|
->options(function (Get $get) {
|
||||||
|
$supplierIds = $get('supplier') ?? [];
|
||||||
|
$productGroupIds = $get('productGroup') ?? [];
|
||||||
|
$query = Producer::query();
|
||||||
|
if (filled($supplierIds) || filled($productGroupIds)) {
|
||||||
|
$productQuery = Product::query();
|
||||||
|
if (filled($supplierIds)) {
|
||||||
|
$productQuery->whereIn('supplier_id', $supplierIds);
|
||||||
|
}
|
||||||
|
if (filled($productGroupIds)) {
|
||||||
|
$productQuery->whereIn('product_group_id', $productGroupIds);
|
||||||
|
}
|
||||||
|
$query->whereIn('id', $productQuery->whereNotNull('producer_id')->distinct()->pluck('producer_id'));
|
||||||
|
}
|
||||||
|
return $query->orderBy('name')->pluck('name', 'id');
|
||||||
|
})
|
||||||
->multiple()
|
->multiple()
|
||||||
->searchable()
|
->searchable()
|
||||||
->placeholder('Válasszon gyártót...'),
|
->placeholder('Válasszon gyártót...'),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user