Visuelle iCal-Regelengine mit Originaldaten und individuellen Exportfeldern integrieren
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m37s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m37s
This commit is contained in:
1 parent
c4ebccbbea
commit
e9db98701b
30 files changed
+1269
-15
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\BlockedPeriods;
|
||||
|
||||
use App\Actions\ResolveChannelOccupation;
|
||||
use App\Channels\ICal\ICalRuleEngine;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\BlockedPeriods\Pages\ManageBlockedPeriods;
|
||||
use App\Models\BlockedPeriod;
|
||||
@@ -16,6 +17,7 @@
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
@@ -93,6 +95,8 @@ public static function table(Table $table): Table
|
||||
TextColumn::make('originChannel.name')->label('Ursprungskanal')->placeholder('Unbekannt')->toggleable(),
|
||||
TextColumn::make('id')->label('Interne Sperr-ID')->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('external_uid')->label('Externe UID')->limit(30)->toggleable(),
|
||||
TextColumn::make('ical_event_type')->label('Erkannt als')->formatStateUsing(fn (?string $state): string => ICalRuleEngine::TYPES[$state] ?? 'Nicht erkannt')->badge(),
|
||||
TextColumn::make('guest_fragment')->label('Verfügbare Namensinformation')->state(fn (BlockedPeriod $record): ?string => $record->ical_interpretation['fields']['guest_full_name'] ?? $record->ical_interpretation['fields']['guest_first_name'] ?? null)->placeholder('Unbekannt')->toggleable(),
|
||||
TextColumn::make('occupation_state')->label('Belegungsführung')->state(fn (BlockedPeriod $record): string => $record->is_representation
|
||||
? ($record->linked_booking_id ? 'Darstellung von Buchung #'.$record->linked_booking_id : 'Darstellung von Sperre #'.$record->canonical_block_id)
|
||||
: ($record->export_approved ? 'Führende Belegung' : 'Intern gesperrt – Export erst klären'))->badge(),
|
||||
@@ -107,6 +111,12 @@ public static function table(Table $table): Table
|
||||
->query(fn (Builder $query): Builder => $query->whereDate('ends_on', '>=', today())),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('icalOriginal')->label('iCal-Original & Erkennung')->visible(fn (BlockedPeriod $record): bool => $record->ical_raw !== null)
|
||||
->modalSubmitAction(false)->modalCancelActionLabel('Schließen')->schema([
|
||||
TextEntry::make('recognized_rule')->label('Treffende Regel')->state(fn (BlockedPeriod $record): string => $record->ical_interpretation['rule'] ?? 'Keine'),
|
||||
TextEntry::make('recognized_representation')->label('Fachliche Einordnung')->state(fn (BlockedPeriod $record): string => ICalRuleEngine::REPRESENTATIONS[$record->ical_interpretation['representation'] ?? 'unspecified']),
|
||||
TextEntry::make('original')->label('Originalereignis (entfaltet)')->state(fn (BlockedPeriod $record): string => $record->ical_raw)->wrap()->extraAttributes(['style' => 'white-space:pre-wrap;overflow-wrap:anywhere']),
|
||||
]),
|
||||
Action::make('resolve')->label('Belegung zuordnen / klären')
|
||||
->visible(fn (BlockedPeriod $record): bool => in_array($record->source, ['channel', 'email'], true))
|
||||
->authorize(fn (BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
|
||||
@@ -122,8 +132,8 @@ public static function table(Table $table): Table
|
||||
->mapWithKeys(fn (Booking $booking): array => [$booking->id => 'Buchung '.$booking->reference])->all();
|
||||
}
|
||||
|
||||
return BlockedPeriod::query()->where('property_id', $record->property_id)->occupying()->whereKeyNot($record->id)->whereDate('starts_on', $record->starts_on)->whereDate('ends_on', $record->ends_on)->get()
|
||||
->mapWithKeys(fn (BlockedPeriod $block): array => [$block->id => '#'.$block->id.' · '.($block->reason ?? 'Sperre')])->all();
|
||||
return BlockedPeriod::query()->where('property_id', $record->property_id)->occupying()->whereKeyNot($record->id)->whereDate('starts_on', $record->starts_on)->whereDate('ends_on', $record->ends_on)->orderByDesc('leading_priority')->orderBy('id')->get()
|
||||
->mapWithKeys(fn (BlockedPeriod $block): array => [$block->id => '#'.$block->id.' · '.($block->reason ?? 'Sperre').($block->leading_priority ? ' · bevorzugter Führungskandidat' : '')])->all();
|
||||
}),
|
||||
Select::make('origin_channel_id')->label('Ursprünglicher Buchungskanal, sofern persönlich bekannt')
|
||||
->options(fn (BlockedPeriod $record): array => Channel::query()->where('property_id', $record->property_id)->pluck('name', 'id')->all())
|
||||
|
||||
Reference in new issue
Block a user