Files
fewo-stommer/app/Filament/Resources/BookingTasks/Tables/BookingTasksTable.php
T
LarsandClaude Sonnet 5.5 a73b164ea1
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m36s
Zahlungsaufgaben, Freigabe-/Storno-Link, Vertragsvorlagen, Anreise-Mail
- Zahlungen werden nicht mehr automatisch angemahnt: faellige Anzahlung/Restzahlung werden Aufgaben
  (Zahlungen & Wuensche, Tages-/Wochenuebersicht); Mail nur per Klick; je Portal und Buchungstyp abschaltbar
- Freigabe-Link in der Eingangsbestaetigung, Storno-Link in der Buchungsbestaetigung; je Wohnung
  Wunsch / sofort / sofort bis Frist; Stornowuensche und Kosten bleiben Aufgabe des Gastgebers
- Vertragsvorlagen mit Versionen (je Angebot, Portal oder Wohnung waehlbar), benutzte Versionen gesperrt;
  Angebot und finaler Vertrag als unveraenderliche PDF mit SHA-256, Vertrag wird nie neu geschrieben
- Anreise-Mail je Wohnung einstellbar (Standard 3 Tage), neue Textfelder Schluessel/Parken/Ankunftstag

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 12:46:29 +01:00

81 lines
4.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Filament\Resources\BookingTasks\Tables;
use App\Actions\SendPaymentReminder;
use App\Enums\BookingTaskStatus;
use App\Exceptions\ReservationException;
use App\Filament\Resources\Bookings\BookingResource;
use App\Models\BookingTask;
use App\Support\Money;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Throwable;
class BookingTasksTable
{
public static function configure(Table $table): Table
{
return $table
->defaultSort('created_at', 'desc')
->description('Fällige Zahlungen und Wünsche von Gästen. Es wird nichts automatisch an Gäste gesendet: Bitte erst den Zahlungseingang prüfen, dann die Erinnerung per Klick senden oder die Aufgabe abhaken.')
->columns([
TextColumn::make('booking.reference')->label('Buchung')->weight('medium')->description(fn (BookingTask $record): string => $record->booking->guest?->full_name ?? ''),
TextColumn::make('kind')->label('Aufgabe')->badge(),
TextColumn::make('due_on')->label('Fällig seit')->date('d.m.Y')->placeholder('–'),
TextColumn::make('open')->label('Offen')->state(fn (BookingTask $record): string => Money::format($record->booking->openAmount())),
TextColumn::make('status')->label('Status')->badge()
->description(fn (BookingTask $record): ?string => $record->completed_by ? "{$record->completed_by}, {$record->completed_at?->format('d.m. H:i')}" : null),
TextColumn::make('note')->label('Hinweis')->wrap()->placeholder('–'),
])
->filters([
SelectFilter::make('status')->label('Status')->options(BookingTaskStatus::class)->default(BookingTaskStatus::Open->value),
])
->recordActions([
Action::make('booking')
->label('Buchung')
->icon(Heroicon::OutlinedArrowTopRightOnSquare)
->color('gray')
->url(fn (BookingTask $record): string => BookingResource::getUrl('view', ['record' => $record->booking])),
Action::make('send')
->label('Mail an Gast senden')
->icon(Heroicon::OutlinedEnvelope)
->requiresConfirmation()
->modalDescription('Haben Sie den Zahlungseingang geprüft? Der Gast erhält die Zahlungs-E-Mail sofort.')
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open && $record->kind->reminder() !== null)
->action(function (BookingTask $record, SendPaymentReminder $send): void {
try {
$send->handle($record, auth()->user()->name);
} catch (ReservationException $exception) {
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
return;
} catch (Throwable) {
Notification::make()->title('E-Mail konnte nicht gesendet werden')->body('Die Aufgabe bleibt offen.')->danger()->send();
return;
}
Notification::make()->title('E-Mail gesendet')->success()->send();
}),
Action::make('done')
->label('Erledigt')
->icon(Heroicon::OutlinedCheck)
->color('success')
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open)
->action(fn (BookingTask $record) => $record->complete(auth()->user()->name)),
Action::make('dismiss')
->label('Verwerfen')
->icon(Heroicon::OutlinedXMark)
->color('gray')
->requiresConfirmation()
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open)
->action(fn (BookingTask $record) => $record->update(['status' => BookingTaskStatus::Dismissed])),
]);
}
}