@extends('layouts.crm') @section('title', ($isLeadsView ?? false) ? 'العملاء المحتملين — CRM — '.config('app.name') : 'جهات الاتصال — CRM — '.config('app.name')) @section('breadcrumb') الرئيسية إدارة العملاء @if($isLeadsView ?? false) العملاء المحتملين @else جهات الاتصال @endif @endsection @section('content') @php $crmAssigneeFilterOptions = $assignees->map(fn ($u) => ['value' => (string) $u->id, 'label' => $u->name])->values()->all(); $crmSourceFilterOptions = collect($sourceOptions ?? [])->map(fn ($s) => ['value' => (string) $s, 'label' => (string) $s])->values()->all(); $crmLeadPriorityOptions = [ ['value' => 'high', 'label' => 'عالية'], ['value' => 'medium', 'label' => 'متوسطة'], ['value' => 'low', 'label' => 'منخفضة'], ]; $crmStatusFilterOptions = [ ['value' => 'potential', 'label' => 'محتمل'], ['value' => 'interested', 'label' => 'مهتم'], ['value' => 'active', 'label' => 'نشط'], ['value' => 'not_interested', 'label' => 'غير مهتم'], ]; @endphp
@if($isLeadsView ?? false) {{-- شاشة العملاء المحتملين (محتوى رئيسي فقط — بدون تعديل السايدبار) --}}

العملاء المحتملين

عميل محتمل جديد
{{-- صف التصفية يبدأ مباشرة من محاذاة بطاقة الجدول (بدون صف عنوان مع أيقونة) --}}
@forelse($customers as $customer) @php $stage = $customer->crm_status ?? 'potential'; [$crmLabel, $crmClass] = match ($stage) { 'interested' => ['مهتم', 'bg-sky-50 text-sky-800 border border-sky-100'], 'active' => ['نشط', 'bg-emerald-50 text-emerald-800 border border-emerald-100'], 'not_interested' => ['غير مهتم', 'bg-red-50 text-red-800 border border-red-100'], default => ['محتمل', 'bg-violet-50 text-violet-900 border border-violet-100'], }; [$prioLabel, $prioClass] = match ($customer->lead_priority) { 'high' => ['عالية', 'bg-rose-50 text-rose-800 border border-rose-100'], 'medium' => ['متوسطة', 'bg-amber-50 text-amber-900 border border-amber-100'], 'low' => ['منخفضة', 'bg-teal-50 text-teal-800 border border-teal-100'], default => ['—', 'bg-gray-50 text-gray-500 border border-gray-100'], }; $rating = (int) ($customer->lead_rating ?? 0); $phoneDisp = $customer->phone ?: $customer->mobile; $waDigits = preg_replace('/\D+/', '', (string) ($phoneDisp ?? '')); $assignee = $customer->assignedUser; $assigneeInitials = ''; if ($assignee) { $parts = preg_split('/\s+/u', trim($assignee->name), -1, PREG_SPLIT_NO_EMPTY); foreach (array_slice($parts, 0, 2) as $p) { $assigneeInitials .= mb_substr($p, 0, 1); } $assigneeInitials = mb_strtoupper($assigneeInitials); } @endphp @empty @endforelse
رقم العميل الاسم الهاتف الحالة التسويقية الأولوية التقييم إجراءات
{{ $customer->lead_number ?: '—' }}
@if($assignee) {{ $assigneeInitials }} @endif {{ $customer->display_name }}
@if($phoneDisp)
{{ $phoneDisp }} @if($waDigits !== '') @endif
@else @endif
{{ $crmLabel }} {{ $prioLabel }}
لا توجد نتائج مطابقة للفلاتر.
@if($customers->hasPages())
{{ $customers->links() }}
@endif
@else @php $contactsStats = is_array($contactsStats ?? null) ? $contactsStats : ['total' => 0, 'leads' => 0, 'customers_active' => 0]; $sortCols = is_array($sortForView ?? null) ? $sortForView : ['sortColumn' => 'created_at', 'sortDirection' => 'desc']; $contactsSortColumn = $sortCols['sortColumn'] ?? 'created_at'; $contactsSortDirection = $sortCols['sortDirection'] ?? 'desc'; $contactsFilterBaseParams = collect(request()->except(['page'])) ->reject(fn ($v) => $v === null || $v === '') ->all(); $contactsSortNameDirection = (($contactsSortColumn === 'name' && $contactsSortDirection === 'asc') ? 'desc' : 'asc'); $contactsSortCreatedDirection = (($contactsSortColumn === 'created_at' && $contactsSortDirection === 'desc') ? 'asc' : 'desc'); @endphp {{-- جهات الاتصال — CRM --}}

جهات الاتصال

إجمالي جهات الاتصال

{{ number_format($contactsStats['total']) }}

العملاء المحتملين

{{ number_format($contactsStats['leads']) }}

العملاء

{{ number_format($contactsStats['customers_active']) }}

التصفية

@forelse($customers as $customer) @php $stage = $customer->crm_status ?? 'potential'; [$crmLabel, $crmClass] = match ($stage) { 'interested' => [\App\Models\Customer::labelForCrmStatus('interested'), 'bg-sky-50 text-sky-800 border border-sky-100'], 'active' => [\App\Models\Customer::labelForCrmStatus('active'), 'bg-emerald-50 text-emerald-800 border border-emerald-100'], 'not_interested' => [\App\Models\Customer::labelForCrmStatus('not_interested'), 'bg-red-50 text-red-800 border border-red-100'], default => [\App\Models\Customer::labelForCrmStatus('potential'), 'bg-violet-50 text-violet-900 border border-violet-100'], }; $phoneDisp = $customer->phone ?: $customer->mobile; $createdStr = optional($customer->created_at)?->timezone(config('app.timezone'))->format('Y/m/d H:i') ?? '—'; @endphp @empty @endforelse
@php $nameSortHref = route('crm.customers.index', array_merge($contactsFilterBaseParams, ['sort' => 'name', 'direction' => $contactsSortNameDirection])); @endphp الاسم النوع البريد الإلكتروني الحالة الهاتف @php $createdSortHref = route('crm.customers.index', array_merge($contactsFilterBaseParams, ['sort' => 'created_at', 'direction' => $contactsSortCreatedDirection])); @endphp تاريخ الإنشاء الإجراءات
{{ $customer->display_name }} @if($customer->code){{ $customer->code }}@endif {{ \App\Models\Customer::contactRecordTypeLabel($customer->company_name) }} @if($customer->email){{ $customer->email }}@else@endif {{ $crmLabel }} {{ $phoneDisp ?: '—' }} {{ $createdStr }}
لا توجد بيانات
@if($customers->hasPages())
{{ $customers->links() }}
@endif
@endif
@include('crm.partials.activity-modals') @endsection @push('scripts') @if($isLeadsView ?? false) @endif @unless($isLeadsView ?? false) @endunless @endpush