@php $attention = (array) ($approvalWorkspace['attention'] ?? []); $items = (array) ($attention['items'] ?? []); $allApproved = (bool) ($attention['all_approved'] ?? false); $approvedCount = (int) ($attention['approved_count'] ?? 0); $requiredCount = (int) ($attention['required_count'] ?? 0); $deskLabel = trim((string) ($attention['desk_label'] ?? data_get($approvalWorkspace, 'attention_desk.label', ''))); $deskIsFirst = (bool) ($attention['desk_is_first'] ?? data_get($approvalWorkspace, 'attention_desk.is_first', true)); $requiresConfirmation = (bool) ($attention['requires_confirmation'] ?? data_get($approvalWorkspace, 'attention_desk.requires_confirmation', true)); $canAct = ($canActOnWorkflow ?? false) && ! ($approveBlockedByAppraisal ?? false); $canConfirm = $canAct && $requiresConfirmation; $approveUrl = route('loan.book.applications.approval.attention.approve', $application); $rejectUrl = route('loan.book.applications.approval.attention.reject', $application); $pendingKeys = []; foreach ($items as $item) { $children = (array) ($item['children'] ?? []); if ($children !== []) { foreach ($children as $child) { $childStatus = (string) ($child['status'] ?? 'pending'); $childKey = (string) ($child['key'] ?? ''); if ($childKey !== '' && ! in_array($childStatus, ['approved', 'rejected'], true)) { $pendingKeys[] = $childKey; } } continue; } $status = (string) ($item['status'] ?? 'pending'); $key = (string) ($item['key'] ?? ''); if ($key !== '' && ! in_array($status, ['approved', 'rejected'], true)) { $pendingKeys[] = $key; } } @endphp @if ($items !== [])

@if ($canConfirm) Confirm each row on this desk{{ $deskLabel !== '' ? ' ('.$deskLabel.')' : '' }}, even if a prior desk already signed them off. @elseif ($canAct) Prior desks already confirmed these items. Your work is to approve the application below. @elseif ($canSubmitForApproval ?? false) Preview for approvers — submit the application below to start the review chain. @elseif ($approvalCreditComplete ?? false) Credit approval is complete. Review items below are historical. @else Waiting for the current desk approver to review these items. @endif

@if ($canConfirm) Confirm each row on this desk before you approve. @elseif ($canAct) Prior desks confirmed these items. Approve below. @elseif ($canSubmitForApproval ?? false) Submit below — approvers will sign off each item on their desk. @elseif ($approvalCreditComplete ?? false) Credit approval complete. @else Pending review by the current approver. @endif

{{ $approvedCount }} of {{ $requiredCount }} confirmed @if ($deskLabel !== '' && $canConfirm) on {{ $deskLabel }} @endif
Processing your review action…
@if ($canConfirm && ! $deskIsFirst)

A prior desk already signed these items. Confirm each row on this desk before you can approve.

@elseif ($canAct && ! $canConfirm)

Review items were confirmed on earlier desks. You only need to approve the application.

@endif @if (($canSubmitForApproval ?? false) && ! $canAct)

@if ($awaitingLoanOfficerResubmit ?? false) Review items stay pending until you resubmit for approval below. Unit Manager and later desks confirm each row when the file reaches them — you do not tick these boxes on the loan officer desk. @else Review items stay pending until you Submit for approval below. Later desks (Unit Manager and after) check each row when the file reaches them. @endif

@elseif ( ! ($canSubmitForApproval ?? false) && ! $canAct && ! ($approvalCreditComplete ?? false) && ! (($approvalRequest ?? null)?->isOpen() ?? false) )

Waiting for the loan officer to submit this file for approval. You will be able to review these items when the file reaches your desk.

@endif @if ($canConfirm && $pendingKeys !== [])
@csrf
@csrf @foreach ($pendingKeys as $pendingKey) @endforeach
@endif @foreach ($items as $item) @php $status = (string) ($item['status'] ?? 'pending'); $key = (string) ($item['key'] ?? ''); $isApproved = $status === 'approved'; $isRejected = $status === 'rejected'; $children = (array) ($item['children'] ?? []); $pendingChildKeys = collect($children) ->filter(fn ($child) => ! in_array((string) ($child['status'] ?? 'pending'), ['approved', 'rejected'], true)) ->pluck('key') ->filter() ->values() ->all(); @endphp
$isApproved, 'loan-approval-attention__row--rejected' => $isRejected, 'loan-approval-attention__row--selected' => false, ]) :class="{ 'loan-approval-attention__row--selected': selected.includes(@js($key)), 'loan-approval-attention__row--busy': isBusy(@js($key)) || isBusy('reject-{{ md5($key) }}') }">
@if ($isApproved) ✓ @elseif ($isRejected) ✕ @elseif ($canConfirm && $children === []) @else @endif

{{ $item['label'] ?? 'Attention' }}

{{ $item['summary'] ?? '' }}

@if (! empty($item['detail']))

{{ $item['detail'] }}

@endif @if (! empty($item['review_lines']))
    @foreach ((array) $item['review_lines'] as $reviewLine)
  • {{ $reviewLine }}
  • @endforeach
@endif @if (($item['key'] ?? '') === 'guarantor') @include('loan.book.applications.partials.approval-attention-guarantor-otp', ['item' => $item]) @endif
@if ($canConfirm && ! $isApproved && ! $isRejected && $children === [])
@csrf
@csrf

Reject {{ strtolower($item['label'] ?? 'item') }}

{{ $item['reject_hint'] ?? 'Send back for correction.' }}

@endif
@if ($children !== [])
@foreach ($children as $child) @php $childStatus = (string) ($child['status'] ?? 'pending'); $childKey = (string) ($child['key'] ?? ''); $childLoanId = (int) ($child['loan_id'] ?? 0); $childApproved = $childStatus === 'approved'; $childRejected = $childStatus === 'rejected'; $hasPastLoanDetail = ($child['installment_rows'] ?? []) !== [] || trim((string) ($child['review'] ?? '')) !== ''; @endphp
@if ($childApproved) ✓ @elseif ($childRejected) ✕ @elseif ($canConfirm) @endif
@if ($hasPastLoanDetail) @else @endif

{{ $child['label'] ?? 'Past loan' }}

@if (! empty($child['headline']))

{{ $child['headline'] }}

@endif @if (! empty($child['metrics']))

{{ $child['metrics'] }}

@elseif (! empty($child['summary']))

{{ $child['summary'] }}

@endif @if (trim((string) ($child['review'] ?? '')) !== '')

{{ \Illuminate\Support\Str::limit(trim((string) $child['review']), 120) }}

@endif
@if ($canConfirm && ! $childApproved && ! $childRejected)
@csrf
@csrf

Reject past loan review

@endif
@if ($hasPastLoanDetail)
@include('loan.book.applications.partials.approval-attention-past-loan-detail', ['child' => $child])
@endif
@endforeach
@endif
@endforeach @if ($canConfirm && ! $allApproved)

Approve every attention above before you record the final workflow decision below.

@endif
@endif