@php use App\Support\Hr\HrPerformanceLendingRoutes; use App\Support\Navigation\WorkspaceEmbed; $summary = $officerWorkspace['summary'] ?? []; $registerService = app(\App\Services\LoanBook\ClientIntelligenceRegisterService::class); $registerHomeRoute = $registerHomeRoute ?? HrPerformanceLendingRoutes::registerRoute(); $activeState = $officerWorkspace['state'] ?? null; $employeeId = (int) ($officerWorkspace['employee_id'] ?? 0); $baseParams = collect(request()->except('page', 'state')) ->merge($registerService->filterQueryParams([ 'type' => 'officer', 'employee_id' => $employeeId > 0 ? $employeeId : null, ])) ->all(); $officers = ($clientIntelligence ?? [])['officer_highlights'] ?? []; $fmtOfficer = function (?array $row): string { if (! $row) { return '—'; } return ($row['officer_name'] ?? '—').' · '.number_format((float) ($row['metric_value'] ?? 0), ($row['metric_label'] ?? '') === 'PAR30 %' ? 1 : 0).' '.strtolower((string) ($row['metric_label'] ?? '')); }; @endphp
@include('loan.clients.partials.intelligence-workspace-header', [ 'headerTitle' => $summary['officer_name'] ?? 'Officer', 'bulkSmsUrl' => $officerWorkspace['bulk_sms_url'] ?? route('loan.bulksms.compose'), 'showExport' => $registerHomeRoute === 'loan.clients.index', ])
@include('loan.clients.partials.intelligence-scope-switcher', [ 'mode' => 'officer', 'compact' => true, 'selectedOfficerId' => $employeeId, ])

Total Clients

{{ number_format((int) ($summary['total_clients'] ?? 0)) }}

Active Loans

{{ number_format((int) ($summary['active_loans'] ?? 0)) }}

Active Clients

{{ number_format((int) ($summary['active_clients'] ?? 0)) }}

Dormant

{{ number_format((int) ($summary['dormant_clients'] ?? 0)) }}

Arrears

{{ number_format((int) ($summary['arrears_clients'] ?? 0)) }}

Watch List

{{ number_format((int) ($summary['watchlist_clients'] ?? 0)) }}

VIP

{{ number_format((int) ($summary['vip_clients'] ?? 0)) }}

Portfolio Balance

{{ number_format((float) ($summary['active_portfolio_balance'] ?? 0), 0) }}

Total Arrears

{{ number_format((float) ($summary['total_arrears'] ?? 0), 0) }}

PAR30

{{ number_format((float) ($summary['par30'] ?? 0), 1) }}%

Avg RES

@if (isset($summary['average_res'])) {{ number_format((float) $summary['average_res'], 1) }}% @else — @endif

High-Value Dormant

{{ number_format((int) ($summary['high_value_dormant'] ?? 0)) }}

Needs Follow-up

{{ number_format((int) ($summary['needs_followup'] ?? 0)) }}

Clients from the client register · PAR30, loans and portfolio from LoanBookPortfolioMetricsService (active book).

Segment: @foreach ([ null => 'All', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_ACTIVE => 'Active', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_DORMANT => 'Dormant', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_ARREARS => 'Arrears', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_WATCHLIST => 'Watch List', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_VIP => 'VIP', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_PERFORMING => 'Performing', \App\Services\LoanBook\ClientIntelligenceRegisterService::OFFICER_STATE_NEEDS_FOLLOWUP => 'Needs Follow-up', ] as $stateKey => $stateLabel) @php $isActive = ($stateKey === null && empty($activeState)) || $activeState === $stateKey; $linkParams = $baseParams; if ($stateKey !== null) { $linkParams['state'] = $stateKey; } @endphp {{ $stateLabel }} @endforeach
@if (! empty($officers))

Officer comparison (portfolio-wide)

@foreach ([ 'most_active' => 'Most active', 'most_dormant' => 'Most dormant (90+)', 'highest_par' => 'Highest PAR', 'best_res' => 'Best performing', ] as $key => $label) @php $row = $officers[$key] ?? null; @endphp
{{ $label }}
@if ($row && (int) ($row['officer_id'] ?? 0) > 0) {{ $fmtOfficer($row) }} @else {{ $fmtOfficer($row) }} @endif
@endforeach
@endif
@include('loan.clients.partials.intelligence-bulk-actions', [ 'bulkSmsUrl' => $officerWorkspace['bulk_sms_url'] ?? route('loan.bulksms.compose'), 'assignHint' => 'Select clients in the table below, then assign a loans officer or send bulk SMS.', ])