✅ تم رفع الشعار بنجاح!';
} else {
$upload_message = '
❌ حدث خطأ أثناء رفع الملف.
';
}
} else {
$upload_message = '❌ يسمح فقط بملفات JPG, PNG, JPEG, WEBP.
';
}
} else {
$upload_message = '❌ الملف ليس صورة صالحة.
';
}
}
// حذف الشعار
if (isset($_GET['delete_logo'])) {
if (file_exists($logo_path)) {
unlink($logo_path);
$upload_message = '✅ تم حذف الشعار بنجاح!
';
}
}
// إحصائيات الجداول
$tables = [
'bookings' => ['name' => 'حجوزات الزيارات', 'icon' => 'fa-calendar-check'],
'maintenance_requests' => ['name' => 'طلبات الصيانة', 'icon' => 'fa-tools'],
'distributor_requests' => ['name' => 'طلبات الوكالة', 'icon' => 'fa-handshake'],
'contact_messages' => ['name' => 'رسائل الاتصال', 'icon' => 'fa-envelope'],
'newsletter_subscribers' => ['name' => 'المشتركين', 'icon' => 'fa-newspaper']
];
$stats = [];
foreach ($tables as $key => $info) {
$stats[$key] = $pdo->query("SELECT COUNT(*) FROM `$key`")->fetchColumn();
}
$total_messages = array_sum($stats);
// آخر 5 رسائل
$recent_bookings = $pdo->query("SELECT * FROM bookings ORDER BY id DESC LIMIT 5")->fetchAll();
$recent_maintenance = $pdo->query("SELECT * FROM maintenance_requests ORDER BY id DESC LIMIT 5")->fetchAll();
// معالجة عرض الجدول
$current_table = $_GET['table'] ?? '';
$search = $_GET['search'] ?? '';
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
$per_page = 20;
$offset = ($page - 1) * $per_page;
$table_data = null;
$table_columns = [];
$table_rows = [];
$total_pages = 0;
if ($current_table && isset($tables[$current_table])) {
$where = '';
$params = [];
if (!empty($search)) {
$columns = $pdo->query("SHOW COLUMNS FROM `$current_table`")->fetchAll();
$search_conditions = [];
foreach ($columns as $col) {
$search_conditions[] = "`{$col['Field']}` LIKE ?";
$params[] = "%$search%";
}
if (!empty($search_conditions)) {
$where = "WHERE " . implode(" OR ", $search_conditions);
}
}
$count_query = "SELECT COUNT(*) FROM `$current_table` $where";
$count_stmt = $pdo->prepare($count_query);
$count_stmt->execute($params);
$total_rows = $count_stmt->fetchColumn();
$total_pages = ceil($total_rows / $per_page);
$query = "SELECT * FROM `$current_table` $where ORDER BY id DESC LIMIT $per_page OFFSET $offset";
$stmt = $pdo->prepare($query);
$stmt->execute($params);
$table_rows = $stmt->fetchAll();
$table_columns = $pdo->query("SHOW COLUMNS FROM `$current_table`")->fetchAll();
}
// معالجة تحديث الحالة
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_status'])) {
$table = $_POST['table'];
$id = $_POST['id'];
$status = $_POST['status'];
$update = $pdo->prepare("UPDATE `$table` SET status = ? WHERE id = ?");
$update->execute([$status, $id]);
header("Location: dashboard.php?table=$table&updated=1");
exit;
}
?>
لوحة تحكم تواصل نت
✅ تم التحديث بنجاح
| الاسم | الجوال | المنطقة | التاريخ | الحالة |
|
|
|
|
|
| اسم العميل | الجوال | نوع العطل | التاريخ | الحالة |
|
|
|
|
|