@extends('admin.layouts.master') @section('title', $customer->name_ar) @section('page_title', $customer->name_ar . ' (' . $customer->code . ')') @section('breadcrumbs') @endsection @section('content') {{-- Header card --}}

{{ $customer->name_ar }} @if($customer->name_en){{ $customer->name_en }}@endif

@php $clsMap = ['vip' => 'warning', 'regular' => 'success', 'new' => 'info']; @endphp {{ $customer->classification }} {{ $customer->type === 'company' ? 'شركة' : 'فرد' }} {{ $customer->status }} @if($customer->phone) {{ $customer->phone }}@endif @if($customer->whatsapp) {{ $customer->whatsapp }}@endif @if($customer->email) {{ $customer->email }}@endif
@can('customers.edit') {{ __('admin.edit') }} @endcan @can('customers.delete') @endcan
{{-- INFO --}}
الكود{{ $customer->code }}
المندوب{{ $customer->salesperson?->name ?? '—' }}
المحافظة{{ $customer->governorate ?? '—' }}
المدينة{{ $customer->city ?? '—' }}
العنوان{{ $customer->address ?? '—' }}
Landmark{{ $customer->landmark ?? '—' }}
@if($customer->type === 'company') @endif
السجل التجاري{{ $customer->commercial_register ?? '—' }}
البطاقة الضريبية{{ $customer->tax_card ?? '—' }}
الشخص المسؤول{{ $customer->contact_person ?? '—' }} {{ $customer->contact_phone ? '— '.$customer->contact_phone : '' }}
الرصيد الافتتاحي{{ format_money($customer->opening_balance) }}
حد الائتمان{{ format_money($customer->credit_limit) }}
مدة الائتمان{{ $customer->credit_days }} يوم
أنشئ في{{ $customer->created_at?->format('Y-m-d H:i') }}
@if($customer->notes)
ملاحظات: {!! nl2br(e($customer->notes)) !!}
@endif
{{-- ADDRESSES --}}
العناوين الإضافية
@can('customers.edit') @endcan
@if($customer->addresses->isEmpty())

لا توجد عناوين إضافية بعد.

@else @foreach($customer->addresses as $a) @endforeach
التسميةالشخصالهاتفالمدينةالعنوان افتراضي{{ __('admin.actions') }}
{{ $a->label }} {{ $a->contact_name ?? '—' }} {{ $a->contact_phone ?? '—' }} {{ $a->city ?? '—' }} {{ \Illuminate\Support\Str::limit($a->address, 80) }} {!! $a->is_default ? '' : '—' !!} @can('customers.edit') @endcan
@endif
{{-- FOLLOW-UPS --}}
المتابعات والملاحظات
@can('customers.edit') @endcan
@if($customer->followUps->isEmpty())

لا توجد متابعات بعد.

@else
@foreach($customer->followUps as $f) @php $iconMap = ['call' => 'phone', 'visit' => 'walking', 'email' => 'envelope', 'whatsapp' => 'comment', 'sms' => 'sms', 'meeting' => 'users', 'other' => 'circle']; $colorMap = ['pending' => 'warning', 'completed' => 'success', 'cancelled' => 'secondary']; @endphp
{{ $f->subject }} {{ $f->status }} {{ $f->followup_date?->format('Y-m-d H:i') }} @if($f->next_followup_date) متابعة في {{ $f->next_followup_date?->format('Y-m-d') }} @endif
@if($f->notes)
{!! nl2br(e($f->notes)) !!}
@endif
@endforeach
@endif
{{-- QUOTATIONS --}}
عروض الأسعار
@can('quotations.create') عرض سعر جديد @endcan
@if($customer->quotations->isEmpty())

لا توجد عروض أسعار.

@else @foreach($customer->quotations as $q) @endforeach
الرقمالتاريخالصلاحية الإجماليالحالة{{ __('admin.actions') }}
{{ $q->number }} {{ $q->quotation_date?->format('Y-m-d') }} {{ $q->expiry_date?->format('Y-m-d') }} {{ number_format((float) $q->total, 2) }} {{ $q->currency_code }} {{ $q->status }}
@endif
{{-- SALES ORDERS --}}
أوامر البيع
@can('sales_orders.create') أمر بيع جديد @endcan
@if($customer->salesOrders->isEmpty())

لا توجد أوامر بيع.

@else @foreach($customer->salesOrders as $o) @php $pmap = ['unpaid'=>'danger','partial'=>'warning','paid'=>'success']; @endphp @endforeach
الرقمالتاريخالتسليم المتوقع الإجماليالمدفوعالحالةالدفع {{ __('admin.actions') }}
{{ $o->number }} {{ $o->order_date?->format('Y-m-d') }} {{ $o->expected_delivery_date?->format('Y-m-d') ?? '—' }} {{ number_format((float) $o->total, 2) }} {{ $o->currency_code }} {{ number_format((float) $o->paid_amount, 2) }} {{ $o->status }} {{ $o->payment_status }}
@endif
{{-- INVOICES --}}
فواتير المبيعات
@can('invoices.create') فاتورة جديدة @endcan
@if(($invoices ?? collect())->isEmpty())

لا توجد فواتير.

@else @foreach($invoices as $inv) @endforeach
الرقمالتاريخالاستحقاق الإجماليالمدفوعالمتبقي الحالةالدفع
{{ $inv->number }} {{ $inv->invoice_date?->format('Y-m-d') }} {{ $inv->due_date?->format('Y-m-d') ?? '—' }} {{ number_format((float) $inv->total, 2) }} {{ number_format((float) $inv->paid_amount, 2) }} {{ number_format($inv->remaining_amount, 2) }} {{ $inv->status }} {{ $inv->payment_status }}
@endif
{{-- STATEMENT --}}
كشف الحساب
@can('reports.view') عرض كامل @endcan
@if(($statement['rows'] ?? collect())->isEmpty())

لا توجد حركات.

@else @foreach($statement['rows']->take(15) as $row) @endforeach
التاريخالمستندالمرجع مديندائن الرصيد
{{ $row['date'] }} {{ $row['document'] }} @if(! empty($row['href'])){{ $row['reference'] }} @else {{ $row['reference'] }} @endif {{ $row['debit'] > 0 ? number_format($row['debit'], 2) : '—' }} {{ $row['credit'] > 0 ? number_format($row['credit'], 2) : '—' }} {{ number_format($row['balance'], 2) }}
الرصيد الحالي {{ number_format($statement['totals']['debit'], 2) }} {{ number_format($statement['totals']['credit'], 2) }} {{ number_format($statement['totals']['balance'], 2) }}
@endif
أوامر التركيب
@can('installations.create') أمر تركيب جديد @endcan
@if(($installations ?? collect())->isEmpty())

لا توجد أوامر تركيب.

@else @foreach($installations as $ins) @endforeach
الرقمالموعدالفريقالحالةالتقييم
{{ $ins->number }} {{ $ins->scheduled_at?->format('Y-m-d H:i') }} {{ $ins->team?->name ?? '—' }} {{ $ins->status }} {!! $ins->customer_rating ? ''.str_repeat('★', $ins->customer_rating).str_repeat('☆', 5 - $ins->customer_rating).'' : '—' !!}
@endif
ضمانات العميل
@if(($warranties ?? collect())->isEmpty())

لا توجد ضمانات نشطة.

@else @foreach($warranties as $w) @php $days = (int) $w->days_remaining; $cls = $w->status !== 'active' ? 'secondary' : ($days <= 0 ? 'danger' : ($days <= 30 ? 'warning' : 'success')); $statusMap = ['active'=>'success','expired'=>'secondary','voided'=>'danger']; @endphp @endforeach
المنتجالفاتورةالكمية تاريخ البدءتاريخ الانتهاء أيام متبقيةالحالة
@if($w->product){{ $w->product->sku }} {{ $w->product->name_ar }}@endif @if($w->invoice){{ $w->invoice->number }}@endif {{ number_format((float) $w->quantity, 2) }} {{ $w->start_date?->format('Y-m-d') }} {{ $w->end_date?->format('Y-m-d') }} {!! $w->status === 'active' ? ''.$days.' يوم' : '—' !!} {{ $w->status }}
@endif
تذاكر الصيانة
@can('maintenance.create') تذكرة جديدة @endcan
@if(($tickets ?? collect())->isEmpty())

لا توجد تذاكر.

@else @foreach($tickets as $t) @endforeach
الرقمالتاريخالنوعالموضوعالحالة
{{ $t->number }} {{ $t->reported_at?->format('Y-m-d') }} {{ $t->type }} {{ $t->subject }} {{ $t->status }}
@endif
@include('admin.customers._address_modal', ['customer' => $customer]) @include('admin.customers._followup_modal', ['customer' => $customer, 'salespeople' => $salespeople]) @endsection @push('scripts') @include('admin._partials.crud_scripts') @endpush