@if($instances->count() > 0)
| # |
Reference |
Workflow |
Initiated By |
Initiated Date |
Approval Status |
Document Status |
Current Step |
Expiry Date |
Actions |
@foreach($instances as $index => $instance)
@php
$documentStatus = 'N/A';
$document = null;
if ($instance->record_type === 'DOCUMENT') {
$document = \App\Models\Document::where('document_id', $instance->record_id)->first();
} elseif ($instance->record_type === 'sop') {
$document = \App\Models\Document::where('source_id', $instance->record_id)
->where('source_type', 'sop')
->first();
}
if ($document) {
$documentStatus = $document->document_status;
}
// Map Document Status to Bootstrap 4 badge colors
$docStatusColor = match($documentStatus) {
'Approved' => 'success',
'Under Review' => 'warning',
'Draft' => 'secondary',
'Rejected' => 'danger',
'Archived' => 'dark',
'Request_Changes' => 'info',
default => 'secondary'
};
// Map Workflow Status to Bootstrap 4 badge colors
$workflowStatusColor = match($instance->status) {
'PENDING' => 'warning',
'IN_PROGRESS' => 'info',
'APPROVED' => 'success',
'REJECTED' => 'danger',
'CANCELLED' => 'secondary',
default => 'dark'
};
// Helper for Badge Text Contrast (Fix for White text on Yellow/Orange)
$workflowBadgeClass = in_array($instance->status, ['PENDING', 'IN_PROGRESS']) ? 'text-dark' : 'text-white';
@endphp
| {{ $instances->firstItem() + $index }} |
{{ $instance->reference_code ?? $instance->record_number ?? 'N/A' }}
|
@if($instance->workflow)
{{ $instance->workflow->name }}
@else
N/A
@endif
|
{{ $instance->initiator->name ?? 'System' }}
|
{{ $instance->initiated_at?->format('d M Y H:i') ?? 'N/A' }}
|
{{ ucfirst(str_replace('_', ' ', $instance->status)) }}
|
{{ $documentStatus }}
|
@if($instance->current_step)
Step {{ $instance->current_step }}
@else
N/A
@endif
|
@if($instance->expiry_date)
@if($instance->expiry_date < now())
{{ $instance->expiry_date->format('d M Y') }} (Expired)
@else
{{ $instance->expiry_date->format('d M Y') }}
@endif
@else
N/A
@endif
|
@if($instance->status === 'PENDING' || $instance->status === 'IN_PROGRESS')
@endif
|
@endforeach
Showing {{ $instances->firstItem() }} to {{ $instances->lastItem() }} of {{ $instances->total() }} instances
{{ $instances->appends(request()->query())->links('pagination::bootstrap-4') }}
@else
No approval instances found.
@endif