@include('Partials.sidebar')
@include('Partials.header')

{{ $user->name }}

{{ $user->role === 'broker' ? 'Broker' : 'Buyer' }} · Joined {{ $user->created_at->format('d M Y') }}

@foreach(['success','error'] as $t) @if(session($t))
{{ session($t) }}
@endif @endforeach
{{-- ── Left column ── --}}
{{-- ── Bookings ── --}}
Bookings ({{ $bookings->count() }})
@forelse($bookings as $booking) @php $bsColors = ['confirmed'=>'#22c55e','pending'=>'#f59e0b','cancelled'=>'#ef4444']; $bsColor = $bsColors[$booking->booking_status] ?? '#94a3b8'; $milestones = $booking->milestones ?? collect(); $totalAmt = $milestones->sum('amount'); $paidAmt = $milestones->where('status','paid')->sum('amount'); $balanceAmt = $totalAmt - $paidAmt; $pct = $totalAmt > 0 ? round(($paidAmt / $totalAmt) * 100) : 0; @endphp
{{-- Booking header --}}
Unit {{ $booking->plot_number }} {{ $booking->plot_type }} · #{{ $booking->id }}
Booked {{ $booking->created_at->format('d M Y') }} @if($booking->paymentPlan) · Plan: {{ $booking->paymentPlan->name }} @endif
{{ ucfirst($booking->booking_status) }} View
{{-- Amount summary --}}
@foreach([ ['Price', '₹'.number_format($booking->price ?? 0, 0), '#1e293b'], ['Down Payment', '₹'.number_format($booking->down_payment_amount ?? 0, 0), '#c9a96e'], ['Total', '₹'.number_format($booking->total_amount ?? $booking->price ?? 0, 0), '#3b82f6'], ] as [$lbl, $val, $col])
{{ $lbl }}
{{ $val }}
@endforeach
{{-- ── Milestone schedule ── --}} @if($milestones->isNotEmpty())
Payment Schedule
₹{{ number_format($paidAmt, 0) }} paid · ₹{{ number_format($balanceAmt, 0) }} balance
{{-- Progress bar --}}
@foreach($milestones as $m) @php $isOverdue = $m->status === 'pending' && $m->due_date && $m->due_date->isPast(); $mStatus = $m->status === 'paid' ? 'paid' : ($m->status === 'waived' ? 'waived' : ($isOverdue ? 'overdue' : 'pending')); $mColor = match($mStatus) { 'paid'=>'#22c55e','overdue'=>'#ef4444','waived'=>'#94a3b8', default=>'#f59e0b' }; @endphp
{{ $m->label }} @if($m->percentage) ({{ $m->percentage }}%) @endif @if($m->due_date && $mStatus !== 'paid' && $mStatus !== 'waived') · Due {{ $m->due_date->format('d M Y') }} @if($isOverdue) ⚠ Overdue@endif @endif @if($m->paid_at) · Paid {{ $m->paid_at->format('d M Y') }} @endif
₹{{ number_format($m->amount, 0) }}
{{ $mStatus }}
@endforeach
@elseif($booking->booking_status === 'confirmed' && $booking->paymentPlan)
Milestones not yet generated for this booking. Generate →
@endif
@empty
No bookings yet
@endforelse
{{-- ── Payment Transactions ── --}}
Payment Transactions ({{ $transactions->count() }})
@php $statusColors = ['success'=>'#22c55e','failed'=>'#ef4444','pending'=>'#f59e0b','refunded'=>'#94a3b8']; $gwIcons = ['razorpay'=>'💳','stripe'=>'💎','phonepe'=>'📱','cash'=>'💵','manual'=>'🏦']; $currency = \App\Models\Setting::get('currency_symbol', '₹'); @endphp @forelse($transactions as $txn) @php $txnColor = $statusColors[$txn->status] ?? '#94a3b8'; @endphp
{{ $gwIcons[strtolower($txn->gateway)] ?? '🏦' }}
{{ ucfirst($txn->gateway) }} {{ $txn->status }}
@if($txn->booking)Unit {{ $txn->booking->plot_number }} ·@endif {{ $txn->paid_at ? $txn->paid_at->format('d M Y, H:i') : $txn->created_at->format('d M Y') }} @if($txn->notes) · {{ Str::limit($txn->notes, 50) }} @endif
@if($txn->gateway_payment_id || $txn->gateway_order_id)
{{ Str::limit($txn->gateway_payment_id ?? $txn->gateway_order_id, 40) }}
@endif
{{ $currency }} {{ number_format($txn->amount, 0) }}
View →
@empty
No payment transactions
@endforelse
{{-- ── Right column ── --}}
{{-- Profile card --}}
Profile
{{ strtoupper(substr($user->name, 0, 1)) }}
{{ $user->name }}
{{ $user->email }}
{{ ucfirst($user->status ?? 'active') }}
@if($user->role === 'broker') @endif
Phone {{ ($user->country_code ?? '') . ($user->phone ?? '—') }}
Role {{ $user->role }}
Company {{ $user->broker_company ?? '—' }}
Commission {{ $user->commission_rate ?? 0 }}%
Joined {{ $user->created_at->format('d M Y') }}
Total Bookings {{ $bookings->count() }}
{{-- Stats --}} @php $confirmedCount = $bookings->where('booking_status','confirmed')->count(); $pendingCount = $bookings->where('booking_status','pending')->count(); $totalPaid = $transactions->where('status','success')->sum('amount'); $currency = \App\Models\Setting::get('currency_symbol', '₹'); @endphp
Summary
@foreach([ ['Confirmed Bookings', $confirmedCount, '#22c55e'], ['Pending Bookings', $pendingCount, '#f59e0b'], ['Total Paid', $currency . ' ' . number_format($totalPaid, 0), '#c9a96e'], ['Transactions', $transactions->count(), '#3b82f6'], ] as [$lbl, $val, $col])
{{ $lbl }} {{ $val }}
@endforeach
{{-- ── Broker Commission Summary ── --}} @if($user->role === 'broker' && $bookings->isNotEmpty()) @php $commPending = $bookings->where('commission_status','pending')->sum('commission_amount'); $commApproved = $bookings->where('commission_status','approved')->sum('commission_amount'); $commPaid = $bookings->where('commission_status','paid')->sum('commission_amount'); $commRejected = $bookings->where('commission_status','rejected')->sum('commission_amount'); $commTotal = $bookings->whereNotNull('commission_amount')->sum('commission_amount'); $currency = \App\Models\Setting::get('currency_symbol', '₹'); @endphp
Commission Summary
{{ $user->commission_rate ?? 0 }}% rate
{{-- Progress bar: paid vs total --}} @if($commTotal > 0) @php $commPct = round(($commPaid / $commTotal) * 100); @endphp
Paid out {{ $commPct }}%
@endif @foreach([ ['Total Commission', $commTotal, '#1e293b', 'fa-calculator'], ['Pending Approval', $commPending, '#f59e0b', 'fa-hourglass-half'], ['Approved', $commApproved, '#3b82f6', 'fa-check-circle'], ['Paid Out', $commPaid, '#22c55e', 'fa-money-bill-wave'], ['Rejected', $commRejected, '#ef4444', 'fa-times-circle'], ] as [$lbl, $val, $col, $icon]) @if($val > 0 || $lbl === 'Total Commission')
{{ $lbl }}
{{ $currency }} {{ number_format($val, 0) }}
@endif @endforeach {{-- Per-booking breakdown --}} @php $brokerBookings = $bookings->whereNotNull('commission_amount')->where('commission_amount', '>', 0); @endphp @if($brokerBookings->isNotEmpty())
Per Booking
@foreach($brokerBookings as $b) @php $csColors = [ 'pending' => '#f59e0b', 'approved' => '#3b82f6', 'paid' => '#22c55e', 'rejected' => '#ef4444', ]; $csColor = $csColors[$b->commission_status] ?? '#94a3b8'; $csLabel = ucfirst($b->commission_status ?? 'pending'); @endphp
Unit {{ $b->plot_number }}
Client: {{ $b->client_name ?: ($b->name ?? '—') }} @if($b->commission_paid_at) · Paid {{ $b->commission_paid_at->format('d M Y') }} @endif
{{ $currency }} {{ number_format($b->commission_amount, 0) }}
{{ $csLabel }}
@endforeach @endif
@endif {{-- Actions --}}
Actions
@csrf
Back to {{ $user->role === 'broker' ? 'Brokers' : 'Users' }}
@include('Partials.footer')