@@ -111,12 +111,20 @@ class WorkflowNotices
|
||||
}
|
||||
$step = $request->steps->firstWhere('id', $notice->approval_step_id)
|
||||
?? $request->allSteps()->whereKey($notice->approval_step_id)->first();
|
||||
$event = $notice->event_kind ?? 'task';
|
||||
if ($event === 'escalation') {
|
||||
$deadline = app(RequisitionExpiry::class)->deadline($request);
|
||||
if ($deadline['state'] !== 'running' || $deadline['step_id'] !== $notice->approval_step_id
|
||||
|| ! collect(app(RequisitionExpiry::class)->escalationRecipients($request, $deadline['profile_ids']))->contains('id', $actor->id)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$outcome = $request->requester_id === $actor->id && $step !== null && in_array($step->decision, ['approved', 'rejected', 'expired'], true);
|
||||
if (! $outcome && (! $request->canDecide($actor) || $request->steps->firstWhere('decision', 'pending')?->id !== $notice->approval_step_id)) {
|
||||
if ($event !== 'escalation' && ! $outcome && (! $request->canDecide($actor) || $request->steps->firstWhere('decision', 'pending')?->id !== $notice->approval_step_id)) {
|
||||
continue;
|
||||
}
|
||||
$items[] = ['id' => $notice->id, 'reference' => $notice->reference, 'role' => $notice->role, 'role_label' => $step?->routing['name'] ?? null,
|
||||
'kind' => $outcome ? 'outcome' : 'task', 'outcome' => $outcome ? $step->decision : null, 'current_status' => $request->status,
|
||||
'kind' => $outcome ? 'outcome' : ($event === 'task' ? 'task' : $event), 'outcome' => $outcome ? $step->decision : null, 'current_status' => $request->status,
|
||||
'created_at' => $notice->created_at, 'read_at' => $notice->read_at, 'href' => '/requisicoes/'.$request->id.($outcome && $step->decision === 'expired' ? '/prazos' : '')];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user