@extends('layouts.app') @section('title', $customer->name) @section('content') @php $routePrefix = strtolower(auth()->user()->role->name); $canEdit = auth()->user()->hasPermissionName('customers.edit'); $canCreate = auth()->user()->hasPermissionName('customers.create'); $statusColors = [ 'Draft' => 'secondary', 'Sent' => 'info', 'Paid' => 'success', 'Partially Paid' => 'warning', 'Overdue' => 'danger', 'Cancelled' => 'dark', ]; $totalBilled = $customer->invoices->sum('total_amount'); $totalPaid = $customer->invoices->where('status', 'Paid')->sum('total_amount'); @endphp

{{ $customer->name }}

Customer profile and invoice history.
← Back @if($canEdit) Edit @endif @if($canCreate) New Invoice @endif
@if(session('success'))
{{ session('success') }}
@endif
{{-- Left: Invoice History --}}
{{-- Summary Stats --}}
Total Invoices
{{ $customer->invoices->count() }}
Total Billed
₹{{ number_format($totalBilled, 2) }}
Paid Invoices
{{ $customer->invoices->where('status', 'Paid')->count() }}
{{-- Invoice Table --}}
Invoice History
Last 10 invoices for this customer.
@if($customer->invoices->isEmpty())

No invoices yet for this customer.

@else
@foreach($customer->invoices as $invoice) @endforeach
Invoice No. Date Amount Status Action
{{ $invoice->invoice_number }} {{ $invoice->invoice_date->format('d M Y') }} ₹{{ number_format($invoice->total_amount, 2) }} {{ $invoice->status }}
@endif
{{-- Right: Contact Info --}}
Contact Details
Phone {{ $customer->phone }}
Email @if($customer->email) {{ $customer->email }} @else @endif
Address @if($customer->address) {{ $customer->address }} @else @endif
Customer Since {{ $customer->created_at->format('d M Y') }}
@if($canEdit) @endif
{{-- Billing Summary --}}
Billing Summary
Total Billed ₹{{ number_format($totalBilled, 2) }}
Paid Invoices {{ $customer->invoices->where('status', 'Paid')->count() }}
Pending / Overdue {{ $customer->invoices->whereIn('status', ['Sent', 'Overdue', 'Partially Paid'])->count() }}
Draft {{ $customer->invoices->where('status', 'Draft')->count() }}
@endsection