-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
63 lines (54 loc) · 1.97 KB
/
Copy pathsettings.php
File metadata and controls
63 lines (54 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
// تضمين إعدادات الجلسة
require_once __DIR__ . '/config/session.php';
require_once __DIR__ . '/config/database.php';
require_once __DIR__ . '/config/config.php';
require_once __DIR__ . '/models/Database.php';
require_once __DIR__ . '/controllers/AuthController.php';
require_once __DIR__ . '/models/Notification.php';
// التحقق من تسجيل الدخول
$authController = new AuthController();
if(!$authController->isLoggedIn()) {
header('Location: index.php');
exit();
}
$user = $authController->getCurrentUser();
// إنشاء كائن الإشعارات
$database = new Database();
$conn = $database->getConnection();
$notificationModel = new Notification($conn);
// الحصول على إعدادات الإشعارات
$notificationSettings = $notificationModel->getNotificationSettings($_SESSION['user_id']);
if (!$notificationSettings) {
$notificationSettings = [
'task_created' => 1,
'task_updated' => 1,
'task_deleted' => 1,
'task_due' => 1,
'email_notifications' => 1,
'browser_notifications' => 1,
'in_app_notifications' => 1,
'sound_notifications' => 1
];
}
$notificationLogs = $notificationModel->getNotificationLogs($_SESSION['user_id'], 20);
if (!$notificationLogs) {
$notificationLogs = [];
}
// الحصول على إحصائيات المستخدم
$stmt = $conn->prepare("
SELECT
COUNT(*) as total_tasks,
SUM(CASE WHEN status = 'Completed' THEN 1 ELSE 0 END) as completed_tasks,
SUM(CASE WHEN status = 'Pending' THEN 1 ELSE 0 END) as pending_tasks
FROM tasks
WHERE user_id = ?
");
$stmt->execute([$_SESSION['user_id']]);
$userStats = $stmt->fetch();
// إضافة الإحصائيات إلى كائن المستخدم
$user->total_tasks = $userStats['total_tasks'] ?? 0;
$user->completed_tasks = $userStats['completed_tasks'] ?? 0;
$user->pending_tasks = $userStats['pending_tasks'] ?? 0;
include 'views/settings/settings.php';
?>