Files
fewo-stommer/app/Process/WorkList.php
LarsandClaude Opus 5.5 40d20cb7d1 Pakete 7 und 9: Auskunft und Buchungswunsch, Aufenthalt und Abschluss (Zwischenstand)
- Haltefrist 0: unverbindliche Auskunft mit signiertem Link "Buchung anfragen",
  erneute Prüfung unter Sperre, automatische oder manuelle Bestätigung, Absage
  bei vergebenem Zeitraum, Ablauf unbeantworteter Auskünfte
- Aufenthalt: Anreisedaten, Aufgaben je Wohnung, gebuchte Leistungen,
  Abweichungen und Folgeaufgaben als Aufgaben am Vorgang
- Abschluss getrennt: Aufenthalt abgeschlossen / kaufmännisch abgeschlossen,
  Nachläufer (Forderung, Auszahlung) bleiben sichtbar
- Zahlungsstatus nur aus Geld auf unserem Konto; Altbestand per Vorschau-Befehl
- Verlauf weist Testzustellungen als solche aus
- Abnahmetests T16-T25, T23 über isolierten SMTP-Empfänger

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 08:29:19 +01:00

91 lines
4.4 KiB
PHP
Raw Permalink 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\Process;
use App\Enums\ActivityState;
use App\Enums\BookingStatus;
use App\Enums\ChannelTaskAction;
use App\Filament\Resources\Bookings\BookingResource;
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
use App\Filament\Resources\InboxMessages\InboxMessageResource;
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
use App\Models\BlockedPeriod;
use App\Models\Booking;
use App\Models\ChannelTask;
use App\Models\InboxMessage;
/**
* "Zu erledigen": everything the landlord has to do, in one list – the next step of every open case, portals to block
* or release, calendar entries nobody knows yet and system notices that need a decision. Each entry names the thing in
* plain words and leads to the one place where it is done.
*/
class WorkList
{
/**
* @return list<array{title: string, detail: ?string, url: string, button: string, tone: string, sort: string}>
*/
public static function items(): array
{
$items = [];
$cases = Booking::query()
->with(['guest', 'property', 'payments', 'importChannel', 'originChannel'])
->whereNull('archived_at')
->whereNotIn('status', [BookingStatus::Declined, BookingStatus::Expired])
// Closed stays and cancellations only with open tasks: follow-ups (money, damage) stay visible (package 9).
->where(fn ($query) => $query->whereNotIn('status', [BookingStatus::Cancelled, BookingStatus::Completed])->orWhereHas('tasks', fn ($tasks) => $tasks->where('status', 'open')))
->get();
foreach ($cases as $case) {
$next = CaseActivities::next($case);
if ($next === null) {
continue;
}
$items[] = [
'title' => $next->label,
'detail' => $case->guestName().' · '.$case->arrival->format('d.m.').'–'.$case->departure->format('d.m.Y').' · '.$case->property->name.($next->detail ? ' · '.$next->detail : ''),
'url' => BookingResource::getUrl('view', ['record' => $case]),
'button' => 'Vorgang öffnen',
'tone' => $next->state === ActivityState::Problem ? 'danger' : 'warning',
'sort' => ($next->state === ActivityState::Problem ? '0' : '1').$case->arrival->format('Ymd'),
];
}
foreach (ChannelTask::query()->open()->with('channel.property')->orderBy('starts_on')->get() as $task) {
$items[] = [
'title' => ($task->action === ChannelTaskAction::Block ? 'In '.$task->channel?->name.' sperren' : 'In '.$task->channel?->name.' wieder freigeben'),
'detail' => $task->period().' · '.$task->channel?->property?->name.' · '.$task->reason,
'url' => ChannelTaskResource::getUrl(),
'button' => 'Erledigen',
'tone' => 'danger',
'sort' => '0'.$task->starts_on->format('Ymd'),
];
}
foreach (BlockedPeriod::query()->unclear()->with(['channel', 'property'])->whereDate('ends_on', '>=', today())->orderBy('starts_on')->get() as $occupation) {
$items[] = [
'title' => 'Belegung von '.($occupation->channel?->name ?? 'einem Portal').' klären',
'detail' => 'Für den Zeitraum '.$occupation->starts_on->format('d.m.').'–'.$occupation->ends_on->format('d.m.Y').' wurde eine Belegung von '.($occupation->channel?->name ?? 'einem Portal').' gemeldet. Bitte klären Sie, um welche Art von Belegung es sich handelt. · '.$occupation->property?->name,
'url' => PortalOccupationResource::getUrl('view', ['record' => $occupation]),
'button' => 'Klären',
'tone' => 'warning',
'sort' => '1'.$occupation->starts_on->format('Ymd'),
];
}
foreach (InboxMessage::query()->whereNull('read_at')->latest()->get() as $message) {
$items[] = [
'title' => $message->subject,
'detail' => str($message->body)->limit(160)->toString(),
'url' => $message->action_url ?: InboxMessageResource::getUrl(),
'button' => 'Ansehen',
'tone' => 'info',
'sort' => '2'.$message->created_at?->format('YmdHis'),
];
}
usort($items, fn (array $a, array $b): int => strcmp($a['sort'], $b['sort']));
return $items;
}
}