ADD delivery calendar finish

This commit is contained in:
E98Developer 2026-04-24 18:09:57 +02:00
parent e31f33d9bf
commit 6b6738d1d5

View File

@ -17,6 +17,7 @@
use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Placeholder;
use Filament\Forms\Components\Toggle; use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Livewire\Attributes\On;
class DeliveryCalendarWidget extends FullCalendarWidget class DeliveryCalendarWidget extends FullCalendarWidget
{ {
@ -25,6 +26,10 @@ class DeliveryCalendarWidget extends FullCalendarWidget
*/ */
public Model | int | string | null $record = null; public Model | int | string | null $record = null;
public ?int $supplierId = null;
public ?int $profitCenterId = null;
/** /**
* Inaktív (nem választható) napok listája. * Inaktív (nem választható) napok listája.
* *
@ -34,6 +39,44 @@ class DeliveryCalendarWidget extends FullCalendarWidget
public function mount(): void public function mount(): void
{ {
$this->loadRecordFromFilter();
}
public function updatedSupplierId(): void
{
$this->loadRecordFromFilter();
$this->refreshRecords();
}
public function updatedProfitCenterId(): void
{
$this->loadRecordFromFilter();
$this->refreshRecords();
}
#[On('calendar-filter-changed')]
public function onFilterChanged(?int $supplierId, ?int $profitCenterId): void
{
$this->supplierId = $supplierId;
$this->profitCenterId = $profitCenterId;
$this->record = null;
$this->loadRecordFromFilter();
$this->refreshRecords();
}
protected function loadRecordFromFilter(): void
{
if ($this->record instanceof ProfitCenterSupplierSchedule) {
return;
}
if ($this->supplierId && $this->profitCenterId) {
$this->record = ProfitCenterSupplierSchedule::where('supplier_id', $this->supplierId)
->where('profit_center_id', $this->profitCenterId)
->first();
return;
}
if (!$this->record) { if (!$this->record) {
$this->record = ProfitCenterSupplierSchedule::first(); $this->record = ProfitCenterSupplierSchedule::first();
} }
@ -41,11 +84,12 @@ public function mount(): void
public function fetchEvents(array $info): array public function fetchEvents(array $info): array
{ {
if (!$this->record) { if (!($this->record instanceof ProfitCenterSupplierSchedule)) {
$this->record = ProfitCenterSupplierSchedule::first(); $this->loadRecordFromFilter();
} }
if (!$this->record) { if (!$this->record) {
$this->dispatch('calendar-events-done');
return $this->getDemoEvents($info); return $this->getDemoEvents($info);
} }
@ -127,6 +171,7 @@ public function fetchEvents(array $info): array
$current->addDay(); $current->addDay();
} }
$this->dispatch('calendar-events-done');
return $events; return $events;
} }