@extends('admin.layouts.master') @section('title', 'تقرير المبيعات') @section('page-header') @include('admin.reports._header', [ 'title' => 'تقرير المبيعات', 'subtitle' => 'تحليل شامل للمبيعات والتحصيل من '.$from.' إلى '.$to, 'icon' => 'ti-chart-bar', 'color' => 'primary', ]) @endsection @section('content') @include('admin.reports._filters', ['from'=>$from, 'to'=>$to, 'showCompare'=>true]) {{-- Insights --}} @if(!empty($insights))

الرؤى التحليلية الذكية

@foreach($insights as $insight)
{!! $insight['text'] !!}
@endforeach
@endif {{-- KPIs --}}
{{-- Charts --}}

اتجاه المبيعات اليومي

أعلى 10 عملاء

@forelse($byCustomer as $i => $c)
#{{ $i + 1 }}
{{ $c['customer'] }}
{{ $c['count'] }} فاتورة
{{ number_format($c['total'], 0) }}
@empty
لا توجد بيانات
@endforelse
{{-- Comparison Table --}} @if($prev)

مقارنة بالفترة السابقة ({{ $prev['from'] }} - {{ $prev['to'] }})

@php $rows = [ ['label'=>'إجمالي المبيعات', 'cur'=>$totalSales, 'prev'=>$prev['totalSales']], ['label'=>'المُحصَّل', 'cur'=>$totalPaid, 'prev'=>$prev['totalPaid']], ['label'=>'عدد الفواتير', 'cur'=>$invoiceCount, 'prev'=>$prev['invoiceCount'], 'int'=>true], ['label'=>'متوسط الفاتورة', 'cur'=>$avgInvoice, 'prev'=>$prev['avgInvoice']], ]; @endphp @foreach($rows as $r) @php $diff = $r['cur'] - $r['prev']; $pct = $r['prev'] > 0 ? round($diff / $r['prev'] * 100, 1) : ($r['cur'] > 0 ? 100 : 0); $cls = $diff > 0 ? 'cmp-up' : ($diff < 0 ? 'cmp-down' : 'cmp-flat'); @endphp @endforeach
المؤشر الفترة الحالية الفترة السابقة الفرق % التغير
{{ $r['label'] }} {{ number_format($r['cur'], $r['int'] ?? false ? 0 : 0) }} {{ number_format($r['prev'], $r['int'] ?? false ? 0 : 0) }} {{ $diff >= 0 ? '+' : '' }}{{ number_format($diff, 0) }} {{ $diff >= 0 ? '+' : '' }}{{ $pct }}%
@endif {{-- Full Invoices Table --}}

قائمة الفواتير التفصيلية ({{ $invoiceCount }})

@foreach($invoices as $inv) @endforeach
الرقمالتاريخالعميلالفرع الإجماليالمدفوعالمتبقيالحالة
{{ $inv->invoice_no }} {{ $inv->invoice_date->format('Y-m-d') }} {{ $inv->customer?->name ?? '-' }} {{ $inv->branch?->name ?? '-' }} {{ number_format($inv->total_amount, 2) }} {{ number_format($inv->paid_amount, 2) }} {{ number_format($inv->remaining_amount, 2) }} {{ $inv->status_label }}
الإجمالي: {{ number_format($totalSales, 2) }} {{ number_format($totalPaid, 2) }} {{ number_format($totalRemaining, 2) }}
@endsection @push('scripts') @endpush