@extends('layout')@section('c')@php
$role=auth()->user()->role; $cid=$c->id; $fd=$role=='frontdesk'; $u=url('/');
$req=$stages->where('required',1); $doneN=$req->filter(fn($s)=>isset($done[$s->id]))->count(); $pct=$req->count()?round($doneN*100/$req->count()):0;
$first=optional($stages->first(fn($s)=>!isset($done[$s->id])))->id ?? $stages->first()->id;
$pending=$req->filter(fn($s)=>!isset($done[$s->id]))->pluck('name');
@endphp
{{ $c->full_name }} {{ $c->status }}
{{ $c->job_title ?: 'No job set' }} · {{ $employer->name ?? 'No employer' }} · {{ $c->sponsorship=='self'?'Self sponsored':'Agency sponsored' }} · Passport {{ $c->passport_no ?: '—' }} · {{ $c->phone }}
@foreach(['passport_expiry'=>'Passport','medical_expiry'=>'Medical','visa_expiry'=>'Visa'] as $f=>$l)@if(($c->$f ?? '')){{ $l }} expires {{ ($c->$f ?? '') }} @endif @endforeach
Progress: {{ $doneN }} of {{ $req->count() }} required stages{{ $pct }}%
@if($pending->count() && $c->status!='employed')
Still needed before employment: {{ $pending->implode(', ') }}@endif
@if(!$fd)
@foreach($stages as $s)@php $names=array_values(array_filter(array_map('trim',explode(',',$s->docs??'')))); $have=($docs[$s->id]??collect())->keyBy('name'); $hn=count(array_intersect($names,$have->keys()->all())); $sx=$exp[$s->id]??collect(); @endphp
@endforeach
@if(!$fd)@endif
@foreach($stages as $s)@php $d=$done[$s->id]??null; $names=array_values(array_filter(array_map('trim',explode(',',$s->docs??'')))); $have=($docs[$s->id]??collect())->keyBy('name'); $sx=$exp[$s->id]??collect(); $co=$sx->where('paid_by','agency')->sum('amount'); $ca=$sx->where('paid_by','candidate')->sum('amount'); @endphp
{{ $s->position }}. {{ $s->name }} {{ $s->required?'':'(optional)' }}
{{ $d->status??'pending' }}@if($d&&$d->reason): {{ $d->reason }}@endif
@if(!$fd)
Expense at this step:
@if($sx->count())
Company paid {{ number_format($co,2) }}@if($ca)
Candidate paid {{ number_format($ca,2) }}@endif
@foreach($sx as $t)- {{ $t->date }} — {{ $t->category }}: {{ number_format($t->amount,2) }} ({{ $t->paid_by=='agency'?'company':$t->paid_by }}) {{ $t->note }} 🧾 voucher
@endforeach
@else
No expense recorded@endif
@if(!$d)
@endif
@if($role=='admin' && !$d)
@endif
@if($role=='admin' && $d)
@endif@endif
@endforeach
@if(!$fd)
Commission {{ number_format($c->commission,2) }} payable by {{ $c->commission_payer }} · received {{ number_format($received,2) }} · balance {{ number_format($c->commission-$received,2) }}
| Date | Type | Category | Paid by | Stage | Amount |
@foreach($tx as $t)| {{ $t->date }} | {{ $t->type }} | {{ $t->category }} | {{ $t->paid_by }} | {{ optional($stages->firstWhere('id',$t->stage_id))->name }} | {{ number_format($t->amount,2) }} 🧾 |
@endforeach
@endif
@endsection