inquiry && ! $case->closed && $case->profile->awaitsPortalConfirmation(); } public function state(CaseContext $case): ?StepState { if (PortalConfirmation::evidence($case->booking) !== null) { return StepState::Done; } return PortalConfirmation::isOverdue($case->booking) ? StepState::Problem : StepState::Waiting; } public function activities(CaseContext $case): array { $evidence = PortalConfirmation::evidence($case->booking); $deadline = PortalConfirmation::deadline($case->booking); return [new Activity('portal_confirmation', 'Bestätigung des Portals abwarten', match (true) { $evidence !== null => ActivityState::Done, PortalConfirmation::isOverdue($case->booking) => ActivityState::Problem, default => ActivityState::Waiting, }, match (true) { $evidence !== null => $evidence['label'], PortalConfirmation::isOverdue($case->booking) => 'ausgeblieben seit '.$deadline->format('d.m.Y, H:i').' Uhr – bitte beim Portal prüfen; Unterlagen und Nachrichten warten weiter, bis Sie bestätigen oder von Hand senden', default => 'erwartet bis '.$deadline->format('d.m.Y, H:i').' Uhr – Unterlagen und Nachrichten warten; die Belegung ist gesichert', }, $evidence === null ? 'confirmPortal' : null)]; } /** Due when the time ran out without the mail: escalate once; or when the mail arrived and the escalation is still open. */ public function due(CaseContext $case): bool { $open = $this->openTask($case) !== null; $evidence = PortalConfirmation::evidence($case->booking) !== null; return ($evidence && $open) || (! $evidence && ! $open && PortalConfirmation::isOverdue($case->booking)); } public function blockers(CaseContext $case): array { return []; } public function run(CaseContext $case): StepResult { $task = $this->openTask($case); if (PortalConfirmation::evidence($case->booking) !== null) { $task?->complete(CaseLog::SYSTEM, 'Die Bestätigung des Portals liegt jetzt vor.'); return StepResult::ran(); } BookingTask::openOnce($case->booking, BookingTaskKind::PortalConfirmationMissing, 'portal-confirmation', [ 'due_on' => today(), 'note' => 'Die Bestätigungsmail des Portals ist bis '.PortalConfirmation::deadline($case->booking)->format('d.m.Y, H:i').' Uhr nicht eingegangen. Die Belegung ist gesichert. Bitte beim Portal prüfen und im Vorgang bestätigen – oder die Unterlagen von Hand senden.', ]); CaseLog::record($case->booking, 'task', 'Bestätigungsmail des Portals fehlt – Aufgabe angelegt', actor: CaseLog::SYSTEM); return StepResult::ran(); } public function isOutward(): bool { return false; } private function openTask(CaseContext $case): ?BookingTask { return BookingTask::query()->where('booking_id', $case->booking->id)->where('kind', BookingTaskKind::PortalConfirmationMissing)->where('status', BookingTaskStatus::Open)->first(); } }