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\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -53,19 +54,47 @@ public function form(Schema $form): Schema
|
||||
->options(Supplier::orderBy('name')->pluck('name', 'id'))
|
||||
->multiple()
|
||||
->searchable()
|
||||
->live()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('productGroup', []);
|
||||
$set('product', []);
|
||||
$set('hooreycaName', []);
|
||||
$set('producer', []);
|
||||
})
|
||||
->placeholder('Válasszon beszállítót...'),
|
||||
Select::make('productGroup')
|
||||
->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()
|
||||
->searchable()
|
||||
->live()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('product', []);
|
||||
$set('hooreycaName', []);
|
||||
$set('producer', []);
|
||||
})
|
||||
->placeholder('Válasszon termékcsoportot...'),
|
||||
Select::make('product')
|
||||
->label('Termék:')
|
||||
->multiple()
|
||||
->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}%");
|
||||
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();
|
||||
})
|
||||
->getOptionLabelsUsing(fn (array $values): array => Product::whereIn('name', $values)
|
||||
@ -74,10 +103,18 @@ public function form(Schema $form): Schema
|
||||
->placeholder('Válasszon terméket...'),
|
||||
Select::make('hooreycaName')
|
||||
->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',''));");
|
||||
$options = Product::orderBy('buyerProductName')
|
||||
->where('buyerProductName', '!=', '')
|
||||
$query = Product::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')
|
||||
->pluck('buyerProductName', 'buyerProductName')
|
||||
->toArray();
|
||||
@ -89,7 +126,22 @@ public function form(Schema $form): Schema
|
||||
->placeholder('Válasszon megnevezést...'),
|
||||
Select::make('producer')
|
||||
->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()
|
||||
->searchable()
|
||||
->placeholder('Válasszon gyártót...'),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user