Please ensure '.$source_file.' exists in the same directory.
'); } // Get content $json_data = file_get_contents($source_file); $data = json_decode($json_data, true); if (!$data) { die('Error decoding JSON data.'); } $drivers = $data['data']; $last_updated = $data['last_updated'] ?? date('Y-m-d H:i:s'); // ============================================================ // 2. DATA PROCESSING (Logic Layer) // ============================================================ $processed_drivers = []; $stats = [ 'total' => 0, 'elite' => 0, // +50 hours 'stable' => 0, // +20 hours 'experimental' => 0, // +5 hours 'inactive' => 0 ]; foreach ($drivers as $driver) { // Parse Active Time String (e.g., "293 ساعة و 48 دقيقة") $timeStr = $driver['active_time'] ?? "0 ساعة و 0 دقيقة"; preg_match('/(\d+)\s*ساعة/', $timeStr, $hoursMatch); preg_match('/(\d+)\s*دقيقة/', $timeStr, $minsMatch); $hours = isset($hoursMatch[1]) ? (int)$hoursMatch[1] : 0; $mins = isset($minsMatch[1]) ? (int)$minsMatch[1] : 0; $totalMinutes = ($hours * 60) + $mins; // Categorize Driver $category = 'inactive'; $catLabel = 'خامل'; $catClass = 'cat-inactive'; if ($totalMinutes >= 3000) { // 50 hours $category = 'elite'; $catLabel = 'نخبة'; $catClass = 'cat-elite'; $stats['elite']++; } elseif ($totalMinutes >= 1200) { // 20 hours $category = 'stable'; $catLabel = 'مستقر'; $catClass = 'cat-stable'; $stats['stable']++; } elseif ($totalMinutes >= 300) { // 5 hours $category = 'experimental'; $catLabel = 'تجريبي'; $catClass = 'cat-experimental'; $stats['experimental']++; } else { $stats['inactive']++; } $driver['total_minutes'] = $totalMinutes; $driver['category_label'] = $catLabel; $driver['category_class'] = $catClass; $processed_drivers[] = $driver; } $stats['total'] = count($processed_drivers); // Sort by Active Time (High to Low) usort($processed_drivers, function($a, $b) { return $b['total_minutes'] <=> $a['total_minutes']; }); ?>| # | اسم السائق | رقم الهاتف | ساعات النشاط | الحالة | تاريخ الانضمام | ملاحظات إدارية |
|---|---|---|---|---|---|---|