@extends('layouts.app')
@section('title', __('dashboard.Loyalty Points'))
@section('page_heading', __('dashboard.Loyalty Points'))
@section('content')
@php
$earnedPoints = $transactions->where('points_amount', '>', 0)->sum('points_amount');
$spentPoints = abs($transactions->where('points_amount', '<', 0)->sum('points_amount'));
$activeCustomers = $transactions->pluck('user_id')->unique()->count();
$typeBadge = [
'earned' => ['#f0fdf4','#16a34a'],
'spent' => ['#fef2f2','#dc2626'],
'expired' => ['#fffbeb','#d97706'],
'adjustment' => ['#eff6ff','#2563eb'],
];
@endphp
{{-- KPIs --}}
@foreach([
['fa-solid fa-circle-arrow-up', '#f0fdf4','#16a34a', number_format($earnedPoints), 'النقاط المكتسبة'],
['fa-solid fa-circle-arrow-down','#fef2f2','#dc2626', number_format($spentPoints), 'النقاط المصروفة'],
['fa-solid fa-users', '#eff6ff','#2563eb', number_format($activeCustomers), 'عملاء نشطون'],
['fa-solid fa-list-check', '#fffbeb','#d97706', number_format($transactions->total()), 'إجمالي الحركات'],
] as [$icon,$bg,$color,$val,$lbl])
@endforeach
{{-- Shell --}}
{{ __('dashboard.Loyalty Point Transactions') }}
{{ number_format($transactions->total()) }}
@if($transactions->isEmpty())
@include('layouts.partials.index-empty-state', ['icon'=>'fa-solid fa-clock-rotate-left','title'=>__('dashboard.No transactions found'),'message'=>''])
@else
@foreach([__('dashboard.Customer'),__('dashboard.Points'),__('dashboard.Type'),__('dashboard.Reference'),'الصلاحية',__('dashboard.Description')] as $h)
| {{ $h }} |
@endforeach
{{ __('dashboard.Date') }} |
@foreach($transactions as $tx)
@php [$bg,$color] = $typeBadge[$tx->transaction_type] ?? ['#eff6ff','#2563eb']; @endphp
{{ mb_substr($tx->user->name,0,1) }}
|
{{ $tx->points_amount > 0 ? '+' : '' }}{{ number_format($tx->points_amount) }}
|
{{ __("dashboard.loyalty_type_{$tx->transaction_type}") }}
|
@if($tx->reference_type === 'Sale')
بيع #{{ $tx->reference_id }}
@elseif($tx->reference_type === 'Reservation')
حجز #{{ $tx->reference_id }}
@elseif($tx->reference_type === \App\Models\LoyaltyCard::class)
كرت: {{ $tx->loyaltyCard?->code ?? ('#'.$tx->reference_id) }}
@else
—
@endif
|
@if($tx->expires_at)
{{ $tx->expires_at->format('Y-m-d') }}
@else
بدون انتهاء
@endif
|
{{ $tx->description }}
@if($tx->loyaltyCardBatch)
دفعة: {{ $tx->loyaltyCardBatch->title }}
@endif
|
{{ $tx->created_at->format('Y-m-d H:i') }}
|
@endforeach
{{ $transactions->links() }}
@endif
@endsection