@foreach($transaction->approval_sequence as $index => $step)
@php
$status = $step['status'] ?? 'F';
$isDone = $status === 'T';
$isCurrent = $index === $transaction->approval_index;
$isPending = !$isDone && !$isCurrent;
// Determine styling based on status
if ($isDone) {
$badgeClass = 'bg-success text-white';
$icon = '✅';
$statusText = 'Approved';
} elseif ($isCurrent) {
$badgeClass = 'bg-warning text-dark';
$icon = '⏳';
$statusText = 'Current Step';
} else {
$badgeClass = 'bg-secondary text-white';
$icon = '⏸️';
$statusText = 'Waiting';
}
@endphp
{{-- Debug information --}}
@if(config('app.debug'))
Debug: Index={{ $index }}, Status={{ $status }}, IsDone={{ $isDone ? 'true' : 'false' }}, IsCurrent={{ $isCurrent ? 'true' : 'false' }}, ApprovalIndex={{ $transaction->approval_index }}
@endif
{{ $icon }} {{ $step['name'] }}
{{ $statusText }}
@if($isCurrent)
← Your turn to approve
@endif
@if(!$loop->last)
@endif
@endforeach
@php
$totalSteps = count($transaction->approval_sequence);
$completedSteps = collect($transaction->approval_sequence)->where('status', 'T')->count();
$progressPercentage = $totalSteps > 0 ? ($completedSteps / $totalSteps) * 100 : 0;
@endphp
{{ $completedSteps }} of {{ $totalSteps }} steps completed
{{ number_format($progressPercentage, 1) }}% Complete