- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
124 lines
6.8 KiB
PHP
124 lines
6.8 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Resources\Bookings\Schemas;
|
||
|
||
use App\Filament\Forms\Components\EuroInput;
|
||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||
use App\Models\Channel;
|
||
use App\Models\Property;
|
||
use App\Support\CurrentProperty;
|
||
use Filament\Forms\Components\DatePicker;
|
||
use Filament\Forms\Components\Radio;
|
||
use Filament\Forms\Components\Select;
|
||
use Filament\Forms\Components\Textarea;
|
||
use Filament\Forms\Components\TextInput;
|
||
use Filament\Forms\Components\Toggle;
|
||
use Filament\Schemas\Components\Section;
|
||
use Filament\Schemas\Components\Text;
|
||
use Filament\Schemas\Components\Utilities\Get;
|
||
use Filament\Schemas\Schema;
|
||
use Illuminate\Support\HtmlString;
|
||
|
||
/**
|
||
* "Neu": one entry for everything that arrives outside the website. The first question is what it is – a request,
|
||
* a booking already binding on a portal, or own use / a block – and only the fields that matter for that answer follow.
|
||
* Nothing has to be invented: unknown guest data, number of guests or portal price stay empty.
|
||
*/
|
||
class BookingForm
|
||
{
|
||
public const INQUIRY = 'inquiry';
|
||
|
||
public const EXTERNAL = 'external';
|
||
|
||
public const OWN_USE = 'own_use';
|
||
|
||
public static function configure(Schema $schema): Schema
|
||
{
|
||
$is = fn (string $kind): \Closure => fn (Get $get): bool => $get('kind') === $kind;
|
||
$isCase = fn (Get $get): bool => in_array($get('kind'), [self::INQUIRY, self::EXTERNAL], true);
|
||
|
||
return $schema
|
||
->components([
|
||
Section::make('Was möchten Sie eintragen?')
|
||
->schema([
|
||
Radio::make('kind')
|
||
->hiddenLabel()
|
||
->options([
|
||
self::INQUIRY => 'Eine Anfrage – per Telefon, E-Mail oder Nachricht über ein Portal',
|
||
self::EXTERNAL => 'Eine Buchung, die bei einem Portal schon fest gebucht ist',
|
||
self::OWN_USE => 'Eigene Nutzung oder eine Sperre (z. B. Wartung)',
|
||
])
|
||
->default(self::INQUIRY)
|
||
->required()
|
||
->live(),
|
||
Text::make(new HtmlString('Eigene Nutzung und Sperren tragen Sie bis auf Weiteres unter <a class="underline" href="'.e(BlockedPeriodResource::getUrl()).'">Sperrzeiten</a> ein.'))
|
||
->visible($is(self::OWN_USE)),
|
||
]),
|
||
Section::make('Zeitraum')
|
||
->columns(2)
|
||
->visible($isCase)
|
||
->schema([
|
||
Select::make('property_id')
|
||
->label('Wohnung')
|
||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||
->required()
|
||
->live(),
|
||
TextInput::make('guests')
|
||
->label('Personen')
|
||
->integer()
|
||
->minValue(1)
|
||
->helperText(fn (Get $get): ?string => $get('kind') === self::EXTERNAL ? 'Leer lassen, wenn nicht bekannt.' : null)
|
||
->required($is(self::INQUIRY)),
|
||
DatePicker::make('arrival')->label('Anreise')->required(),
|
||
DatePicker::make('departure')->label('Abreise')->after('arrival')->required(),
|
||
]),
|
||
Section::make('Portal')
|
||
->columns(2)
|
||
->visible($isCase)
|
||
->schema([
|
||
Select::make('channel_id')
|
||
->label(fn (Get $get): string => $get('kind') === self::EXTERNAL ? 'Gebucht über' : 'Über ein Portal (optional)')
|
||
->placeholder('Direkt – kein Portal')
|
||
->options(fn (Get $get): array => Channel::query()->where('property_id', $get('property_id'))->orderBy('name')->pluck('name', 'id')->all())
|
||
->required($is(self::EXTERNAL)),
|
||
TextInput::make('portal_reference')->label('Buchungsnummer im Portal')->maxLength(100)->visible($is(self::EXTERNAL)),
|
||
EuroInput::make('portal_total')
|
||
->label('Gesamtpreis laut Portal')
|
||
->helperText('Der Betrag, den der Gast beim Portal gebucht hat. Leer lassen, wenn noch nicht bekannt – er wird nicht geschätzt.')
|
||
->visible($is(self::EXTERNAL)),
|
||
]),
|
||
Section::make('Gast')
|
||
->description('Nur eintragen, was bekannt ist. Fehlendes wird später ergänzt; das System erinnert daran.')
|
||
->columns(2)
|
||
->visible($isCase)
|
||
->schema([
|
||
TextInput::make('first_name')->label('Vorname')->required($is(self::INQUIRY))->maxLength(255),
|
||
TextInput::make('last_name')->label('Nachname')->required($is(self::INQUIRY))->maxLength(255),
|
||
TextInput::make('email')->label('E-Mail')->email()->maxLength(255),
|
||
TextInput::make('phone')->label('Telefon')->tel()->maxLength(50),
|
||
TextInput::make('street')->label('Straße')->maxLength(255),
|
||
TextInput::make('postal_code')->label('PLZ')->maxLength(20),
|
||
TextInput::make('city')->label('Ort')->maxLength(255),
|
||
Toggle::make('guest_confirmed')->label('Der Gast hat die Buchung bereits per E-Mail bestätigt')->visible($is(self::EXTERNAL)),
|
||
]),
|
||
Section::make('Wie geht es weiter?')
|
||
->visible($is(self::INQUIRY))
|
||
->schema([
|
||
Toggle::make('confirm_immediately')
|
||
->label('Die Buchung ist mit dem Gast schon fest vereinbart – gleich verbindlich eintragen')
|
||
->helperText('Aus: Das System bereitet das Angebot vor; je nach Einstellung geht es automatisch hinaus oder wartet auf Ihre Freigabe.')
|
||
->default(false),
|
||
Toggle::make('send_mails')->label('Dem Gast E-Mails senden (Eingangsbestätigung bzw. Buchungsbestätigung)')->default(true),
|
||
TextInput::make('promo_code')->label('Aktionscode')->maxLength(50),
|
||
]),
|
||
Section::make('Notiz')
|
||
->visible($isCase)
|
||
->collapsed()
|
||
->schema([
|
||
Textarea::make('internal_notes')->hiddenLabel()->placeholder('Interne Notiz (nur für Sie sichtbar)'),
|
||
]),
|
||
]);
|
||
}
|
||
}
|