Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
- Buchung erfassen: Buchungsweg Portal (Referenz, Portalpreis, ohne Kontaktdaten), Prozess bestaetigen/Vertrag sofort/nur erfassen - Buchungsakte: Kontaktdaten eintragen (automatisch oder manuell weiter), Gast um Kontaktdaten bitten, Status von Hand aendern, Archivieren - Liste: Filter Kanal, Anreisezeitraum, Kontaktdaten fehlen; Spalten ausblendbar; Archiv - Klaerung: verstaendlichere Texte, eigenstaendige Belegung mit Kanal gilt als geklaert (Gitea #4) - Akte per Button aus Liste und Belegungsplan erreichbar - Menue: Gruppen Verwaltung (Tagesgeschaeft) und Einrichtung (Konfiguration), einfache Ansicht auf 8 Punkte Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
94 lines
4.5 KiB
PHP
94 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\CancellationPolicies;
|
|
|
|
use App\Filament\Concerns\FollowsAdminMode;
|
|
use App\Filament\Forms\Components\EuroInput;
|
|
use App\Filament\Resources\CancellationPolicies\Pages\CreateCancellationPolicy;
|
|
use App\Filament\Resources\CancellationPolicies\Pages\EditCancellationPolicy;
|
|
use App\Filament\Resources\CancellationPolicies\Pages\ListCancellationPolicies;
|
|
use App\Models\CancellationPolicy;
|
|
use BackedEnum;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\Repeater;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Components\Text;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Support\HtmlString;
|
|
use UnitEnum;
|
|
|
|
/**
|
|
* Cancellation rules: stepped percentages by days before arrival. Assigned to contract templates.
|
|
*/
|
|
class CancellationPolicyResource extends Resource
|
|
{
|
|
use FollowsAdminMode;
|
|
|
|
protected static ?string $model = CancellationPolicy::class;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedReceiptPercent;
|
|
|
|
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
|
|
|
protected static ?string $modelLabel = 'Stornoregel';
|
|
|
|
protected static ?string $pluralModelLabel = 'Stornoregeln';
|
|
|
|
protected static ?int $navigationSort = 3;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
TextInput::make('name')->label('Name')->required()->maxLength(120)->helperText('z. B. „Direktbuchung“ oder „FeWo-direkt“.'),
|
|
Select::make('base')
|
|
->label('Berechnungsgrundlage')
|
|
->options([CancellationPolicy::BASE_RENT => 'Mietpreis (ohne Endreinigung, Service und Kurtaxe)', CancellationPolicy::BASE_TOTAL => 'Gesamtpreis'])
|
|
->default(CancellationPolicy::BASE_RENT)
|
|
->required(),
|
|
Repeater::make('tiers')
|
|
->label('Stufen')
|
|
->helperText('Jede Stufe gilt, wenn bis zur Anreise mindestens so viele Tage bleiben. Beispiel: ab 60 Tagen 0 %, ab 30 Tagen 50 %, ab 0 Tagen 100 %. Die letzte Stufe (0 Tage) gilt für alles danach.')
|
|
->schema([
|
|
TextInput::make('min_days')->label('Ab Tagen vor Anreise')->integer()->minValue(0)->required(),
|
|
TextInput::make('percent')->label('Entschädigung')->integer()->minValue(0)->maxValue(100)->suffix('%')->required(),
|
|
])
|
|
->columns(2)
|
|
->default([['min_days' => 60, 'percent' => 0], ['min_days' => 30, 'percent' => 50], ['min_days' => 0, 'percent' => 100]])
|
|
->minItems(1)
|
|
->required()
|
|
->columnSpanFull(),
|
|
EuroInput::make('replacement_fee')->label('Gebühr bei Ersatzmieter (optional)'),
|
|
Text::make(fn (?CancellationPolicy $record): HtmlString => new HtmlString($record ? '<strong>So steht es im Vertrag ({{ storno_regel }}):</strong><ul style="margin-top:.4rem">'.collect(CancellationPolicy::describe($record->snapshot()))->map(fn (string $line): string => '<li>'.e($line).'</li>')->implode('').'</ul>' : ''))->columnSpanFull(),
|
|
Textarea::make('notes')->label('Interne Notiz')->rows(2)->columnSpanFull(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->defaultSort('name')
|
|
->columns([
|
|
TextColumn::make('name')->label('Regel')->weight('medium')->searchable(),
|
|
TextColumn::make('base')->label('Grundlage')->formatStateUsing(fn (string $state): string => $state === CancellationPolicy::BASE_TOTAL ? 'Gesamtpreis' : 'Mietpreis'),
|
|
TextColumn::make('steps')->label('Stufen')->state(fn (CancellationPolicy $record): string => collect(CancellationPolicy::normalise((array) $record->tiers))->map(fn (array $tier): string => 'ab '.$tier['min_days'].' T: '.$tier['percent'].' %')->implode(' · ')),
|
|
])
|
|
->recordActions([EditAction::make(), DeleteAction::make()]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListCancellationPolicies::route('/'),
|
|
'create' => CreateCancellationPolicy::route('/create'),
|
|
'edit' => EditCancellationPolicy::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|