@extends('layouts.dashboard') @section('title', 'الأجهزة والمستخدمين') @php // Country code to Arabic name mapping $countryNames = [ 'SA' => 'السعودية', 'AE' => 'الإمارات', 'KW' => 'الكويت', 'QA' => 'قطر', 'BH' => 'البحرين', 'OM' => 'عمان', 'EG' => 'مصر', 'JO' => 'الأردن', 'LB' => 'لبنان', 'SY' => 'سوريا', 'IQ' => 'العراق', 'YE' => 'اليمن', 'PS' => 'فلسطين', 'SD' => 'السودان', 'LY' => 'ليبيا', 'TN' => 'تونس', 'DZ' => 'الجزائر', 'MA' => 'المغرب', 'US' => 'أمريكا', 'GB' => 'بريطانيا', 'CA' => 'كندا', 'AU' => 'أستراليا', 'DE' => 'ألمانيا', 'FR' => 'فرنسا', 'TR' => 'تركيا', 'IN' => 'الهند', 'PK' => 'باكستان', 'MY' => 'ماليزيا', 'ID' => 'إندونيسيا', ]; function getCountryName($code, $countryNames) { if (!$code) return null; $code = strtoupper($code); return $countryNames[$code] ?? $code; } @endphp @section('styles') @endsection @section('content')
{{ number_format($stats['total_devices']) }}
إجمالي الأجهزة
{{ number_format($stats['total_users']) }}
المستخدمين المسجلين
{{ number_format($stats['ios_devices']) }}
أجهزة iOS
{{ number_format($stats['android_devices']) }}
أجهزة Android
{{ number_format($stats['donated_devices']) }}
متبرعين
{{ number_format($stats['total_donations'], 0) }}
إجمالي التبرعات (ر.س)

قائمة الأجهزة

@forelse($devices as $device) @empty @endforelse
معرف الجهاز الجمعية المنصة المستخدم الهاتف الموقع التبرعات آخر نشاط
{{ substr($device->device_id, 0, 12) }}... {{ $charityNames[$device->charity_id] ?? $device->charity_id }} @if($device->platform === 'ios') iOS @else Android @endif @if($device->user_id) {{ $device->user_id }} @else زائر @endif @if($device->phone) {{ $device->phone }} @else - @endif @if($device->country || $device->city)
@if($device->city) {{ $device->city }} @if($device->country) - {{ getCountryName($device->country, $countryNames) }}@endif @else {{ getCountryName($device->country, $countryNames) }} @endif
@else غير محدد @endif
@if($device->donation_count > 0)
{{ $device->donation_count }} تبرعات {{ number_format($device->total_donations, 0) }} ر.س
@else لم يتبرع @endif
{{ $device->last_active_at ? $device->last_active_at->diffForHumans() : '-' }}

لا توجد أجهزة مسجلة

سيظهر هنا الأجهزة عند تسجيلها من التطبيق

@if($devices->hasPages()) @endif

خريطة مواقع الأجهزة

@php $devicesWithCoords = \App\Models\Device::whereNotNull('latitude') ->whereNotNull('longitude') ->when($selectedCharity !== 'all', fn($q) => $q->where('charity_id', $selectedCharity)) ->get(); @endphp @if($devicesWithCoords->count() > 0)
{{ $devicesWithCoords->count() }}
جهاز على الخريطة
{{ $devicesWithCoords->where('platform', 'ios')->count() }}
iOS
{{ $devicesWithCoords->where('platform', 'android')->count() }}
Android
@php $mapData = $devicesWithCoords->map(function($d) use ($charityNames) { return [ 'lat' => $d->latitude, 'lng' => $d->longitude, 'platform' => $d->platform, 'city' => $d->city, 'country' => $d->country, 'charity' => $charityNames[$d->charity_id] ?? $d->charity_id, 'user_id' => $d->user_id, 'donation_count' => $d->donation_count, 'total_donations' => $d->total_donations, ]; })->values(); @endphp @else

لا توجد بيانات موقع

لم يتم استلام إحداثيات GPS من الأجهزة بعد. سيتم عرض مواقع الأجهزة على الخريطة عندما يرسل التطبيق بيانات الموقع (latitude/longitude).

@endif
@if(!empty($locations['countries']))

توزيع المستخدمين حسب الدولة

@foreach($locations['countries'] as $country => $count)
{{ $country }} {{ $count }}
@endforeach
@endif @endsection @section('scripts') @endsection