@extends('layouts.app')
@section('title', __('dashboard.stats_transactions_title'))
@section('page_heading', __('dashboard.stats_transactions_title'))
@section('styles')
@endsection
@section('content')
@include('dashboard.statistics.partials.nav')
@php
$salesCollection = collect($sales);
$depositsCollection = collect($reservationsDeposits);
$finalPaymentsCollection = collect($reservationsFinalPayments);
$salesTotal = $salesCollection->sum('final_total');
$depositsTotal = $depositsCollection->sum('deposit');
$finalPaymentsTotal = $finalPaymentsCollection->sum(fn ($reservation) => $reservation->price - $reservation->deposit);
$treasuryTotal = $salesTotal + $depositsTotal + $finalPaymentsTotal;
$operationsCount = $salesCollection->count() + $depositsCollection->count() + $finalPaymentsCollection->count();
$paymentSummary = [];
foreach ($salesCollection as $sale) {
$method = __('dashboard.' . ($sale->payment_method ?: 'none'));
$paymentSummary[$method] = ($paymentSummary[$method] ?? 0) + $sale->final_total;
}
foreach ($depositsCollection as $reservation) {
$method = __('dashboard.' . ($reservation->payment_method ?: 'none'));
$paymentSummary[$method] = ($paymentSummary[$method] ?? 0) + $reservation->deposit;
}
foreach ($finalPaymentsCollection as $reservation) {
$method = __('dashboard.' . ($reservation->final_payment_method ?: 'none'));
$paymentSummary[$method] = ($paymentSummary[$method] ?? 0) + ($reservation->price - $reservation->deposit);
}
arsort($paymentSummary);
$maxPayment = $paymentSummary ? max(array_values($paymentSummary)) : 1;
$dateValue = request()->filled('start_date') || request()->filled('end_date')
? request('date')
: request('date', $startDate->format('Y-m-d'));
$selectedAdmin = $admins->firstWhere('id', $adminId);
$periodLabel = $startDate->format('Y-m-d') . ' - ' . $endDate->format('Y-m-d');
@endphp
@foreach([
['fa-solid fa-vault', '#eff6ff', '#2563eb', number_format($treasuryTotal, 2), 'إجمالي الخزينة', $periodLabel],
['fa-solid fa-cart-shopping', '#f0fdf4', '#16a34a', number_format($salesTotal, 2), 'تحصيلات المبيعات', $salesCollection->count() . ' عملية'],
['fa-solid fa-coins', '#fffbeb', '#d97706', number_format($depositsTotal + $finalPaymentsTotal, 2), 'تحصيلات الحجوزات', ($depositsCollection->count() + $finalPaymentsCollection->count()) . ' عملية'],
['fa-solid fa-receipt', '#faf5ff', '#7c3aed', number_format($operationsCount), 'عدد العمليات', 'مبيعات + حجوزات'],
] as [$icon, $bg, $color, $value, $label, $meta])
{{ $value }}
{{ $label }}
{{ $meta }}
@endforeach
ملخص طرق الدفع
@forelse($paymentSummary as $method => $amount)
{{ $method }}
{{ number_format($amount, 2) }}
@empty
لا توجد بيانات
@endforelse
قراءة سريعة
@foreach([
['عمليات البيع', $salesCollection->count() . ' عملية'],
['عربون الحجوزات', number_format($depositsTotal, 2)],
['الدفعات النهائية للحجوزات', number_format($finalPaymentsTotal, 2)],
['المستخدم المحدد', $selectedAdmin?->name ?? 'كل المستخدمين'],
] as [$label, $value])
{{ $label }}
{{ $value }}
@endforeach
@if($transactionType === 'all' || $transactionType === 'sales')
عمليات البيع
{{ $salesCollection->count() }}
{{ number_format($salesTotal, 2) }}
@if($salesCollection->isEmpty())
لا توجد بيانات مبيعات
@else
| {{ __('dashboard.Date') }} |
{{ __('dashboard.Sale ID') }} |
{{ __('dashboard.Total') }} |
{{ __('dashboard.Payment Method') }} |
{{ __('dashboard.Reference') }} |
{{ __('dashboard.Created By') }} |
@foreach($salesCollection as $sale)
| {{ $sale->created_at->format('Y-m-d') }} |
#{{ $sale->id }} |
{{ number_format($sale->final_total, 2) }} |
{{ __('dashboard.' . ($sale->payment_method ?: 'none')) }} |
{{ $sale->payment_reference ?? '-' }} |
{{ $sale->creator?->name ?? '-' }} |
@endforeach
@endif
@endif
@if($transactionType === 'all' || $transactionType === 'reservations')
عربون الحجوزات
{{ $depositsCollection->count() }}
{{ number_format($depositsTotal, 2) }}
@if($depositsCollection->isEmpty())
لا توجد بيانات عربون
@else
| {{ __('dashboard.Date') }} |
{{ __('dashboard.Reservation ID') }} |
{{ __('dashboard.Deposit') }} |
{{ __('dashboard.Payment Method') }} |
{{ __('dashboard.Reference') }} |
{{ __('dashboard.Created By') }} |
@foreach($depositsCollection as $reservation)
| {{ $reservation->created_at->format('Y-m-d') }} |
#{{ $reservation->id }} |
{{ number_format($reservation->deposit, 2) }} |
{{ __('dashboard.' . ($reservation->payment_method ?: 'none')) }} |
{{ $reservation->payment_reference ?? '-' }} |
{{ $reservation->creator?->name ?? '-' }} |
@endforeach
@endif
الدفعات النهائية للحجوزات
{{ $finalPaymentsCollection->count() }}
{{ number_format($finalPaymentsTotal, 2) }}
@if($finalPaymentsCollection->isEmpty())
لا توجد دفعات نهائية
@else
| {{ __('dashboard.Date') }} |
{{ __('dashboard.Reservation ID') }} |
{{ __('dashboard.Remaining Amount') }} |
{{ __('dashboard.Payment Method') }} |
{{ __('dashboard.Reference') }} |
{{ __('dashboard.Created By') }} |
{{ __('dashboard.Delivered By') }} |
{{ __('dashboard.Finished By') }} |
@foreach($finalPaymentsCollection as $reservation)
| {{ $reservation->actual_delivered_date->format('Y-m-d') }} |
#{{ $reservation->id }} |
{{ number_format($reservation->price - $reservation->deposit, 2) }} |
{{ __('dashboard.' . ($reservation->final_payment_method ?: 'none')) }} |
{{ $reservation->final_payment_reference ?? '-' }} |
{{ $reservation->creator?->name ?? '-' }} |
{{ $reservation->deliverer?->name ?? '-' }} |
{{ $reservation->finisher?->name ?? '-' }} |
@endforeach
@endif
@endif
@endsection
@section('scripts')
@endsection