@extends('layouts.app') @section('title', 'Leave Request Details') @section('content') @php $flow = []; // Step 0: Applied (always green - starting point) $flow[] = ['level' => 0, 'role' => 'Applied', 'is_applied' => true]; $flow[] = ['level' => 1, 'role' => 'Training Officer', 'is_applied' => false]; if ($leaveRequest->student_type === 'hostel') { $flow[] = ['level' => 2, 'role' => 'Warden', 'is_applied' => false]; $flow[] = ['level' => 3, 'role' => 'Asst. Director', 'is_applied' => false]; } else { $flow[] = ['level' => 2, 'role' => 'Asst. Director', 'is_applied' => false]; } $totalSteps = count($flow); $currentLvl = $leaveRequest->current_level; $globalStatus = $leaveRequest->status; if ($globalStatus === 'approved') { $doneLevels = $totalSteps - 1; // all approval steps done (excluding applied) } elseif ($globalStatus === 'rejected') { $doneLevels = max(0, $currentLvl - 1); } else { $doneLevels = max(0, $currentLvl - 1); } // Add 1 to account for the "Applied" step which is always done $doneLevels += 1; @endphp
{{-- ── Top row ── --}}

Leave Request Details

Applied on: {{ $leaveRequest->created_at->format('d M Y, h:i A') }}

Back to History
{{-- ── Main card ── --}}
{{-- Section: Overview --}}
Request Overview
{{-- Student Type --}}
Student Type
{{ ucfirst($leaveRequest->student_type ?? '—') }}
{{-- Leave Type --}}
Leave Type
{{ $leaveRequest->leave_type_label ?? '—' }}
{{-- Status --}}
Status
@php $st = $leaveRequest->status; @endphp {{ ucfirst($st) }}
{{-- From Date --}}
From Date
{{ $leaveRequest->from_date->format('d M Y') }}
{{-- To Date --}}
To Date
{{ $leaveRequest->to_date ? $leaveRequest->to_date->format('d M Y') : '—' }}
{{-- Days --}}
Total Days
{{ $leaveRequest->number_of_days }} day(s)
{{-- /grid --}}
{{-- ══════════ STEPPER ══════════ --}}
Approval Progress
@php /* Width of fill: fraction of (totalSteps-1) segments completed */ if ($totalSteps <= 1) { $fillPct = 0; } elseif ($globalStatus === 'approved') { $fillPct = 100; } else { $fillPct = round(($doneLevels / ($totalSteps - 1)) * 100); if ($fillPct > 100) $fillPct = 100; } @endphp
@foreach ($flow as $step) @php $lvl = $step['level']; $isApplied = $step['is_applied']; if ($isApplied) { // Applied step is always green/done $cc = 'lrd-circle-applied'; $rc = 'lrd-srole-applied'; $sc = 'lrd-ss-applied'; $stxt = 'Submitted'; $log = null; } else { $log = $leaveRequest->approvalLogs->where('level', $lvl)->first(); if ($log && $log->decision === 'approved') { $cc = 'lrd-circle-done'; $rc = 'lrd-srole-done'; $sc = 'lrd-ss-done'; $stxt = 'Approved'; } elseif ($log && $log->decision === 'rejected') { $cc = 'lrd-circle-rejected'; $rc = ''; $sc = 'lrd-ss-rejected'; $stxt = 'Rejected'; } elseif ($currentLvl == $lvl && !in_array($globalStatus, ['approved','rejected'])) { $cc = 'lrd-circle-active'; $rc = 'lrd-srole-active'; $sc = 'lrd-ss-active'; $stxt = 'In Review'; } else { $cc = ''; $rc = ''; $sc = 'lrd-ss-pending'; $stxt = 'Pending'; } } @endphp
@if($cc === 'lrd-circle-applied') @elseif($cc === 'lrd-circle-done') @elseif($cc === 'lrd-circle-rejected') @elseif($cc === 'lrd-circle-active') @else {{ $lvl }} @endif

{{ $step['role'] }}

{{ $stxt }}

@if($isApplied)

{{ $leaveRequest->created_at->format('d M Y') }}

@elseif($log && $log->approved_at)

{{ $log->approved_at->format('d M Y') }}

@endif
@endforeach

{{-- Reason --}}
Leave Reason
{{ $leaveRequest->leave_reason }}

{{-- Attachment --}}
Attachment
@if($leaveRequest->attachment) @php $attachmentUrl = asset('storage/' . $leaveRequest->attachment); $extension = strtolower(pathinfo($leaveRequest->attachment, PATHINFO_EXTENSION)); $fileName = basename($leaveRequest->attachment); @endphp
Download Attachment
@else
No attachment uploaded
@endif
{{-- Approval History --}}
Approval History
@if ($leaveRequest->approvalLogs->count() > 0) @foreach ($leaveRequest->approvalLogs as $log) @php $words = explode(' ', trim($log->approver->name)); $initials = strtoupper(substr($words[0],0,1) . (isset($words[1]) ? substr($words[1],0,1) : '')); $avRej = $log->decision === 'rejected' ? 'lrd-av-rej' : ''; @endphp
{{ $initials }}

{{ $log->approver->name }}

{{ $log->levelName }}

{{ ucfirst($log->decision) }}

{{ $log->approved_at->format('d M Y, h:i A') }}

@if($log->remarks)
Remarks: {{ $log->remarks }}
@endif
@endforeach @else
No approvals yet — your request is pending review.
@endif
{{-- /card-body --}}
{{-- /card --}}
{{-- /wrap --}} {{-- ══════════ ATTACHMENT PREVIEW MODAL ══════════ --}}

Attachment Preview

@if($leaveRequest->attachment) Download @endif
{{-- Content injected by JS --}}
@endsection