@props([ 'requests' => collect(), 'title' => 'Documents', 'emptyMessage' => 'No documents found.', 'statusFilterMap' => [], 'statusResolver' => null, 'viewerRouteView' => null, 'showCreateRequestLink' => false, 'showUnreadFilter' => true, 'highlightAnyOverdue' => false, 'rowHighlightResolver' => null, ]) @php $documentRequests = collect($requests); $statusOptions = array_keys($statusFilterMap ?? []); $documentTypeOptions = $documentRequests ->map(function ($request) { $label = trim((string) ($request->document_type_label ?? '')); if ($label === '') { $label = trim((string) ($request->document_type ?? '')); } return $label !== '' ? $label : __('N/A'); }) ->unique() ->sort() ->values(); $resolveDashboardStatus = $statusResolver instanceof \Closure ? $statusResolver : fn ($request) => [ 'label' => ucfirst((string) ($request->status ?? 'pending')), 'badge' => 'bg-secondary-subtle text-secondary', 'title' => ucfirst((string) ($request->status ?? 'pending')), ]; @endphp

{{ __($title) }}

{{ __('UHS Code') }} {{ __('Registry Document Number') }} {{ __('Finished Number') }} {{ __('Requested Date') }} {{ __('Document Name') }} {{ __('Document Type') }} {{ __('From') }} {{ __('Document ID') }} {{ __('Last Updated') }} {{ __('Current Holder') }} {{ __('Status') }} {{ __('Action') }} @forelse($documentRequests as $request) @php $rawFromLabel = trim((string) ($request->submitter_label ?? '')); $fromLabel = $rawFromLabel !== '' ? __($rawFromLabel) : __('N/A'); $dashboardStatus = $resolveDashboardStatus($request); $statusLabel = $dashboardStatus['label'] ?? ucfirst((string) ($request->status ?? 'pending')); $statusTitle = $dashboardStatus['title'] ?? $statusLabel; $documentTypeLabel = trim((string) ($request->document_type_label ?? '')); if ($documentTypeLabel === '') { $documentTypeLabel = trim((string) ($request->document_type ?? '')); } if ($documentTypeLabel === '') { $documentTypeLabel = __('N/A'); } $statusKey = \Illuminate\Support\Str::slug((string) $statusLabel); $baseViewerStatus = \App\Support\WorkflowPermission::dashboardStatus( $request, (string) optional(auth()->user())->role, (int) (auth()->id() ?? 0) ); $isDashboardOverdue = \App\Support\WorkflowPermission::isDashboardOverdue($request); $isOverdueReview = $isDashboardOverdue && ( $highlightAnyOverdue || in_array( (string) ($baseViewerStatus['label'] ?? ''), ['Needs Your Review', 'Need Your Decision'], true ) ); $documentTypeKey = md5(mb_strtolower((string) $documentTypeLabel)); $hasUnreadUpdate = (bool) ($request->dashboard_has_unread_update ?? false); $needsActionStatusLabels = [ 'Needs Your Review', 'Need Your Decision', 'Sent Back to You', 'Sent Back to My Organization', 'Returned Back', ]; $showNewUpdateBadge = $hasUnreadUpdate && in_array((string) $statusLabel, $needsActionStatusLabels, true); if ($rowHighlightResolver instanceof \Closure) { $resolvedRowHighlight = $rowHighlightResolver($request); if (is_array($resolvedRowHighlight)) { $isOverdueReview = (bool) ($resolvedRowHighlight['overdue'] ?? false); $showNewUpdateBadge = (bool) ($resolvedRowHighlight['unread'] ?? false); } } // The model resolves one authoritative holder from the // assigned user and current workflow-step configuration. $resolvedCurrentHolderLabel = trim((string) data_get($request, 'current_holder_label')); $currentHolderLabel = $resolvedCurrentHolderLabel !== '' ? $resolvedCurrentHolderLabel : __('N/A'); $finishedDocumentNumber = trim((string) (data_get($request, 'finished_document_number') ?? '')); $routeParams = ['id' => $request->id]; if (filled($viewerRouteView)) { $routeParams['view'] = $viewerRouteView; } $viewerUrl = route('document-viewer.show', $routeParams); @endphp {{ trim((string) ($request->uhs_code ?? '')) !== '' ? $request->uhs_code : __('N/A') }} {{ trim((string) ($request->registry_document_number ?? '')) !== '' ? $request->registry_document_number : '' }} {{ $finishedDocumentNumber }} {{ \App\Support\DateFormatter::localized($request->created_at, 'd F, Y h:i A') }} {{ $request->document_name }} {{ $documentTypeLabel }} {{ $fromLabel }} {{ trim((string) ($request->document_code ?? '')) !== '' ? $request->document_code : __('N/A') }} {{ \App\Support\DateFormatter::localized($request->updated_at, 'd F, Y h:i A') }} {{ $currentHolderLabel }} @if($isOverdueReview) @endif @if($showNewUpdateBadge) {{ __('New') }} @endif {{ __('View') }} @empty {{ __($emptyMessage) }} @if($showCreateRequestLink) {{ __('Create your first request') }} @endif @endforelse
@once @endonce @once @endonce @include('components.dashboard-filter-summary-script')