@extends('admin.layouts.app') @section('title', '#' . $client->id . ' - ' . $client->full_name) @section('content') {{-- Info Bar --}}
{{ __('admin.clients.status') }}: {{ ucfirst($client->status->value) }}
{{ __('admin.clients.credit_balance') }}: {{ money_fmt($client->credit) }} @if(auth('admin')->user()?->hasPermission('manage_invoices')){{ __('admin.clients.credit_manage') }}@endif
{{ __('admin.clients.tax_exempt') }}: {{ $client->tax_exempt ? 'Yes' : 'No' }}
{{-- Stats Row --}}
{{ $serviceCount }}
{{ __('admin.clients.services') }}
{{ $domainCount }}
{{ __('admin.clients.domains') }}
{{ $invoiceCount }}
{{ __('admin.clients.invoices') }}
{{ $ticketCount }}
{{ __('admin.clients.tickets') }}
{{ money_fmt($unpaidInvoices) }}
{{ __('admin.clients.unpaid') }}
{{-- Tab Navigation --}} @php $tabs = ['summary'=>__('admin.clients.tab_summary'),'services'=>__('admin.clients.tab_services'),'domains'=>__('admin.clients.tab_domains'),'invoices'=>__('admin.clients.tab_invoices'),'tickets'=>__('admin.clients.tab_tickets'),'notes'=>__('admin.clients.tab_notes'),'log'=>__('admin.clients.tab_log')]; @endphp
@foreach($tabs as $key => $label) {{ $label }} @endforeach
{{-- Tab Content --}} @if($tab === 'summary')
{{-- Column 1 --}}
{{-- Client information and billing identity in one place. The trade title, tax office, tax or national number and address sit together, copyable in one click. A gap is pointed out here, before the invoice is written, not while. --}} @php $identityType = $client->client_type; $identityGaps = $client->missingBillingIdentity(); $copyLines = [$client->full_name]; if ($identityType) { $copyLines[] = __('admin.clients.billing_type').': '.__('admin.clients.billing_type_'.($identityType === 'company' ? 'company' : 'individual')); } if ($identityType === 'company') { $copyLines[] = __('admin.clients.company').': '.($client->company_name ?: ''); $copyLines[] = __('admin.clients.billing_tax_office').': '.($client->tax_office ?: ''); $copyLines[] = __('common.form.tax_id').': '.($client->tax_id ?: ''); } if ($identityType === 'individual') { $copyLines[] = __('admin.clients.billing_national_id').': '.($client->national_id ?: ''); } $copyLines[] = trim(($client->address1 ?: '').' '.($client->city ?: '').' '.($client->postcode ?: '').' '.($client->country ?: '')); $copyLines[] = $client->full_phone; $copyLines[] = $client->email; $copyText = implode("\n", array_filter($copyLines)); @endphp
{{ __('admin.clients.client_information') }}
@if($identityGaps)
{{ __('admin.clients.billing_missing', ['fields' => implode(', ', \App\Support\BillingIdentity::labels($identityGaps))]) }}
@endif @if($identityType === 'company') @endif @if($identityType === 'individual') @endif
{{ __('admin.clients.name') }}{{ $client->full_name }}
{{ __('admin.clients.billing_type') }}{{ $identityType ? __('admin.clients.billing_type_'.($identityType === 'company' ? 'company' : 'individual')) : '-' }}
{{ __('admin.clients.company') }}{{ $client->company_name ?: '-' }}
{{ __('admin.clients.billing_tax_office') }}{{ $client->tax_office ?: '-' }}
{{ __('common.form.tax_id') }}{{ $client->tax_id ?: '-' }}
{{ __('admin.clients.billing_national_id') }}{{ $client->national_id ?: '-' }}
{{ __('admin.clients.email') }}{{ $client->email }}
{{ __('common.form.billing_email') }}@if($client->billing_email){{ $client->billing_email }}@else - @endif
{{ __('admin.clients.phone') }}{{ $client->full_phone ?: '-' }}
{{ __('admin.clients.address') }}{{ $client->address1 ?: '-' }}@if($client->city)
{{ $client->city }}{{ $client->state ? ', '.$client->state : '' }} {{ $client->postcode }}@endif
{{ __('admin.clients.country') }}{{ $client->country ?: '-' }}
{{ __('admin.clients.registered') }}{{ $client->created_at->format(date_fmt()) }}
{{-- If the copy button is refused clipboard access the text is selectable above anyway; the button is a convenience. --}} {{ __('admin.clients.edit_client') }}
@if($customFields->isNotEmpty())
{{ __('admin.clients.custom_fields') }}
@foreach($customFields as $field) @endforeach
{{ $field->field_name }}{{ $field->values->first()?->value ?: '-' }}
@endif
{{-- Column 2 --}}
{{ __('admin.clients.billing_summary') }}
@php $paid = isset($invoiceSummary) ? ($invoiceSummary['paid'] ?? 0) : 0; $unpaid = isset($invoiceSummary) ? ($invoiceSummary['unpaid'] ?? 0) : 0; $ovrd = isset($invoiceSummary) ? ($invoiceSummary['overdue'] ?? 0) : 0; $total = isset($invoiceSummary) ? ($invoiceSummary['total'] ?? 0) : 0; @endphp
{{ __('admin.clients.paid_invoices') }}{{ $paid }}
{{ __('admin.clients.unpaid_invoices') }}{{ $unpaid }}
{{ __('admin.clients.overdue_invoices') }}{{ $ovrd }}
{{ __('admin.clients.total_invoices') }}{{ $invoiceCount }}
{{ __('admin.clients.credit_balance') }}{{ money_fmt($client->credit) }}
{{ __('admin.clients.other_info') }}
@php($consent = \App\Models\MarketingConsent::where('client_id', $client->id)->first())
{{ __('admin.clients.status') }}{{ ucfirst($client->status->value) }}
{{ __('admin.clients.tax_exempt') }}{{ $client->tax_exempt ? 'Yes' : 'No' }}
{{ __('admin.clients.created') }}{{ $client->created_at->format(date_fmt()) }}
{{ __('admin.clients.marketing_consent') }}@if($consent?->email_opt_in){{ __('admin.clients.marketing_yes', ['date' => $consent->consented_at?->format(date_fmt()) ?? '-', 'source' => $consent->source]) }}@elseif($consent){{ __('admin.clients.marketing_withdrawn', ['date' => $consent->withdrawn_at?->format(date_fmt()) ?? '-']) }}@else{{ __('admin.clients.marketing_no') }}@endif
{{ __('admin.clients.last_login') }}{{ $client->users->max('last_login')?->diffForHumans() ?? __('admin.clients.never') }}
{{-- Column 3 --}}
{{ __('admin.clients.admin_notes') }}
@csrf
@forelse(($notes ?? collect())->take(3) as $note)

{{ $note->note }}

{{ $note->created_at->timezone(display_tz())->format(datetime_fmt()) }}{{ $note->sticky ? ' — ' . __('admin.clients.pinned') : '' }}
@empty

{{ __('admin.clients.no_notes') }}

@endforelse
@elseif($tab === 'services')
{{ __('admin.clients.tab_services') }}
@if($services->isEmpty())
{{ __('admin.services.no_services') }}
@else @foreach($services as $service) @endforeach
{{ __('common.table.product') }}{{ __('common.table.domain') }}{{ __('common.table.billing_cycle') }}{{ __('common.table.amount') }}{{ __('admin.clients.next_due') }}{{ __('common.table.status') }}
{{ $service->product?->name ?? 'N/A' }} {{ $service->domain ?? '-' }} {{ $service->billing_cycle }} {{ money_fmt($service->amount) }} {{ $service->next_due_date?->format(date_fmt()) ?? '-' }} {{ ucfirst($service->status) }}
{{ $services->appends(['tab' => 'services'])->links() }}
@endif
@elseif($tab === 'domains')
{{ __('admin.clients.tab_domains') }}
@if($domains->isEmpty())
{{ __('admin.domains.no_domains') }}
@else @foreach($domains as $domain) @endforeach
{{ __('common.table.domain') }}{{ __('common.table.registrar') }}{{ __('admin.clients.registered') }}{{ __('admin.domains.expiry_date') }}{{ __('common.table.status') }}{{ __('common.table.actions') }}
{{ $domain->domain }} {{ $domain->registrar ?? '-' }} {{ $domain->registration_date?->format(date_fmt()) ?? '-' }} {{ $domain->expiry_date?->format(date_fmt()) ?? '-' }} {{ ucfirst($domain->status) }} {{ __('common.actions.view') }}
{{ $domains->appends(['tab' => 'domains'])->links() }}
@endif
@elseif($tab === 'invoices')
@if($invoices->isEmpty())
{{ __('admin.invoices.no_invoices') }}
@else @foreach($invoices as $inv) @endforeach
{{ __('common.table.invoice_num') }}{{ __('common.table.date') }}{{ __('common.table.due_date') }}{{ __('common.table.total') }}{{ __('common.table.status') }}
{{ $inv->invoice_num }} {{ $inv->date?->format(date_fmt()) ?? '-' }} {{ $inv->due_date?->format(date_fmt()) ?? '-' }} {{ money_fmt($inv->total) }} {{ invoice_status_label($inv->status) }}
{{ $invoices->appends(['tab' => 'invoices'])->links() }}
@endif
@elseif($tab === 'tickets')
@if($tickets->isEmpty())
{{ __('admin.tickets.no_tickets') }}
@else @foreach($tickets as $ticket) @endforeach
{{ __('common.table.id') }}{{ __('common.table.department') }}{{ __('common.table.subject') }}{{ __('common.table.priority') }}{{ __('common.table.last_reply') }}{{ __('common.table.status') }}
{{ $ticket->tid }} {{ $ticket->department->name ?? '-' }} {{ $ticket->title }} {{ ucfirst($ticket->priority) }} {{ $ticket->last_reply?->diffForHumans() ?? '-' }} {{ ucfirst($ticket->status) }}
{{ $tickets->appends(['tab' => 'tickets'])->links() }}
@endif
@elseif($tab === 'notes')
{{ __('admin.clients.add_note') }}
@csrf
@forelse($notes as $note)
{{ __('admin.clients.author') }} {{ $note->admin }} · {{ $note->created_at->timezone(display_tz())->format(datetime_fmt()) }} @if($note->sticky) · {{ __('admin.clients.pinned') }}@endif @if($note->edited_by)
{{ __('admin.clients.edited_by') }} {{ $note->edited_by }} · {{ $note->updated_at->timezone(display_tz())->format(datetime_fmt()) }}
@endif
@empty

{{ __('admin.clients.no_notes') }}

@endforelse @elseif($tab === 'log')
@if($logs->isEmpty())
{{ __('admin.clients.no_activity') }}
@else @foreach($logs as $log) @endforeach
{{ __('common.table.date') }}{{ __('admin.clients.admin') }}{{ __('admin.clients.action') }}{{ __('common.table.description') }}
{{ $log->created_at->timezone(display_tz())->format(datetime_fmt()) }} {{ $log->admin ?? '-' }} {{ $log->action ?? '-' }} {{ $log->description }}
{{ $logs->appends(['tab' => 'log'])->links() }}
@endif
@endif @push('scripts') @endpush @endsection