@extends('layouts.app') @section('title', 'Exit Process — ' . ($exit->employee?->first_name ?? '') . ' ' . ($exit->employee?->last_name ?? '')) @section('breadcrumbs') @endsection @section('content')
{{-- Header --}}

{{ $exit->employee?->first_name }} {{ $exit->employee?->last_name }} — {{ $exit->exit_type_label }}

{{ $exit->employee?->employee_code }} · {{ $exit->employee?->department?->name ?? '' }} · Initiated {{ $exit->initiated_date->format('d M Y') }}

{{ $exit->status_label }} @if(auth()->user()->role === 'company_admin' && $exit->status !== 'completed') @endif
{{-- Summary Cards --}}
Last Working Day
{{ $exit->last_working_date?->format('d M Y') ?? 'TBD' }}
@if($exit->days_remaining > 0)
{{ $exit->days_remaining }} days remaining
@endif
Notice Period
{{ $exit->notice_period_days }} days
Checklist Progress
{{ $exit->checklist_progress }}%
Settlement
@if($exit->final_settlement_amount)
OMR {{ number_format($exit->final_settlement_amount, 3) }}
@if($exit->settlement_approved_at)
Approved
@else
Pending approval
@endif @else
Not calculated
@endif
{{-- Tabs --}}
{{-- Checklist Tab --}}

Exit Checklist

{{ $exit->checklistItems->where('status', 'completed')->count() }}/{{ $exit->checklistItems->where('status', '!=', 'not_applicable')->count() }} completed
@foreach($exit->checklistItems as $item)
@if($item->status === 'completed') @elseif($item->status === 'not_applicable') @else
@endif

{{ $item->item_name }}

{{ $item->status_label }}
@if($item->item_description)

{{ $item->item_description }}

@endif @if($item->completed_at)

Completed by {{ $item->completedByUser?->name ?? 'Unknown' }} on {{ $item->completed_at->format('d M Y H:i') }}

@endif @if($item->notes)

{{ $item->notes }}

@endif {{-- Quick update form --}} @if(auth()->user()->role === 'company_admin' && $exit->status !== 'completed')
@csrf @method('PATCH')
@endif
@endforeach
{{-- Settlement Tab --}}
@if(auth()->user()->role === 'company_admin' && !$exit->settlement_breakdown && $exit->status !== 'completed')
@csrf
@endif @if($settlement)

Final Settlement Breakdown

@if($exit->settlement_approved_at) Approved by {{ $exit->settlementApprover?->name ?? '' }} @endif
@php $breakdown = $settlement['breakdown'] ?? ($settlement instanceof array ? $settlement['breakdown'] : []); @endphp {{-- Earnings --}}

Earnings

@foreach($breakdown as $key => $item) @if(($item['type'] ?? '') === 'earning')
{{ $item['label'] }} OMR {{ number_format($item['amount'], 3) }}
@endif @endforeach
Total Earnings OMR {{ number_format($settlement['total_earnings'] ?? 0, 3) }}
{{-- Deductions --}} @if(collect($breakdown)->where('type', 'deduction')->count() > 0)

Deductions

@foreach($breakdown as $key => $item) @if(($item['type'] ?? '') === 'deduction')
{{ $item['label'] }} - OMR {{ number_format($item['amount'], 3) }}
@endif @endforeach
Total Deductions OMR {{ number_format($settlement['total_deductions'] ?? 0, 3) }}
@endif {{-- Net --}}
Net Final Settlement OMR {{ number_format($settlement['net_settlement'] ?? $exit->final_settlement_amount ?? 0, 3) }}
@if(auth()->user()->role === 'company_admin' && !$exit->settlement_approved_at && $exit->final_settlement_amount)
@csrf
@endif
@endif
{{-- Visa Tab --}}

Visa Cancellation & Repatriation

{{-- Visa Status --}}
@if(auth()->user()->role === 'company_admin' && $exit->status !== 'completed')
@csrf @method('PATCH')
@else {{ $exit->visa_status_label }} @endif
{{-- Visa Timeline --}}

Progress

@foreach(['not_started' => 'Not Started', 'initiated' => 'Initiated', 'submitted' => 'Submitted', 'cancelled' => 'Cancelled'] as $step => $label) @php $stepOrder = array_search($step, array_keys($visaStatuses)); $currentOrder = array_search($exit->visa_cancellation_status ?? 'not_started', array_keys($visaStatuses)); $isComplete = $stepOrder <= $currentOrder; $isCurrent = $stepOrder === $currentOrder; @endphp
@if($isComplete && !$isCurrent) @else {{ $stepOrder + 1 }} @endif

{{ $label }}

@if(!$loop->last)
@endif @endforeach
{{-- Repatriation --}}

Repatriation Date

{{ $exit->repatriation_date?->format('d M Y') ?? 'Not set' }}

{{-- Details Tab --}}

Exit Details

Exit Type

{{ $exit->exit_type_label }}

Initiated By

{{ $exit->initiator?->name ?? '—' }}

Initiated Date

{{ $exit->initiated_date->format('d M Y') }}

Last Working Date

{{ $exit->last_working_date?->format('d M Y') ?? 'TBD' }}

Reason

{{ $exit->exit_reason ?? 'Not specified' }}

Exit Interview Notes

{{ $exit->exit_interview_notes ?? 'No notes recorded' }}

{{-- Status Change Modal --}}
@endsection