@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)
@endforeach
@endif
{{-- KPIs --}}
إجمالي المبيعات
{{ number_format($totalSales, 0) }} ج.م
@if($prev)
@php $growth = $prev['totalSales'] > 0 ? round(($totalSales-$prev['totalSales'])/$prev['totalSales']*100, 1) : 0; @endphp
{{ $growth > 0 ? '+' : '' }}{{ $growth }}% vs الفترة السابقة
السابق: {{ number_format($prev['totalSales'], 0) }}
@else
{{ $invoiceCount }} فاتورة
@endif
المُحصَّل
{{ number_format($totalPaid, 0) }} ج.م
معدل التحصيل {{ $collectionRate }}%
المتبقي
{{ number_format($totalRemaining, 0) }} ج.م
@if($totalRemaining > 0)
يحتاج متابعة
@else
لا مديونيات
@endif
مبيعات نقطة البيع
{{ number_format($posSales, 0) }} ج.م
متوسط الفاتورة: {{ number_format($avgInvoice, 0) }}
{{-- Charts --}}
@forelse($byCustomer as $i => $c)
#{{ $i + 1 }}
{{ $c['customer'] }}
{{ $c['count'] }} فاتورة
{{ number_format($c['total'], 0) }}
@empty
لا توجد بيانات
@endforelse
{{-- Comparison Table --}}
@if($prev)
| المؤشر |
الفترة الحالية |
الفترة السابقة |
الفرق |
% التغير |
@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
| {{ $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 }}%
|
@endforeach
@endif
{{-- Full Invoices Table --}}
| الرقم | التاريخ | العميل | الفرع |
الإجمالي | المدفوع | المتبقي | الحالة |
@foreach($invoices as $inv)
| {{ $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 }} |
@endforeach
| الإجمالي: |
{{ number_format($totalSales, 2) }} |
{{ number_format($totalPaid, 2) }} |
{{ number_format($totalRemaining, 2) }} |
|
@endsection
@push('scripts')
@endpush