Files
fewo-stommer/app/Process/WorkList.php
T
LarsandClaude Opus 5.5 ac9d20b812 Ein Eingang fuer alle Kanaele (Paket 4, Prozessarchitektur v0.10)
Portalbuchungen und -anfragen aus Kalender und Mail werden ueber PortalIntake
zum Vorgang (nur bei sicherer Erkennung), Dubletten ueber Buchungsnummer,
gleiches Portal mit gleichen Naechten und Spiegelung; Unsicheres wird geklaert.
Portalstorno und -aenderung als Aufgabe am Vorgang ohne stille Stornierung.
Schalter je Kanal (Aus als Standard, Beobachten, Anlegen, Anlegen + weiter),
Eingangsprotokoll, Bestandsuebernahme mit Vorschau/Bericht/Ruecknahme,
Sperrnachweis in drei Stufen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 20:53:35 +01:00

90 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\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, BookingStatus::Completed])
->where(fn ($query) => $query->whereNot('status', BookingStatus::Cancelled)->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;
}
}