add new featurs like realtime 2026-5-10-15
This commit is contained in:
@@ -9,8 +9,6 @@ if ($role !== 'super_admin' && $role !== 'admin') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// جلب سجل العمليات
|
|
||||||
// ملاحظة: يتطلب وجود جدول admin_audit_log
|
|
||||||
$stmt = $con->prepare("
|
$stmt = $con->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
l.id, l.admin_id, e.name as admin_name, l.action, l.table_name, l.record_id, l.details, l.created_at
|
l.id, l.admin_id, e.name as admin_name, l.action, l.table_name, l.record_id, l.details, l.created_at
|
||||||
@@ -20,13 +18,12 @@ try {
|
|||||||
LIMIT 100
|
LIMIT 100
|
||||||
");
|
");
|
||||||
|
|
||||||
// سأقوم بإضافة فحص لوجود الجدول لتجنب الخطأ إذا لم يكن موجوداً بعد
|
|
||||||
$tableExists = $con->query("SHOW TABLES LIKE 'admin_audit_log'")->rowCount() > 0;
|
$tableExists = $con->query("SHOW TABLES LIKE 'admin_audit_log'")->rowCount() > 0;
|
||||||
|
|
||||||
if (!$tableExists) {
|
if (!$tableExists) {
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
'message' => 'Audit log table not found. Please create it using the provided SQL.',
|
'message' => 'Audit log table not found.',
|
||||||
'data' => []
|
'data' => []
|
||||||
]);
|
]);
|
||||||
exit;
|
exit;
|
||||||
@@ -35,11 +32,15 @@ try {
|
|||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$logs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$logs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
echo json_encode([
|
// تسجيل عدد السجلات في ملف لوج للفحص
|
||||||
'status' => 'success',
|
$count = count($logs);
|
||||||
'data' => $logs
|
file_put_contents(__DIR__ . '/fetch_debug.txt', "[" . date('Y-m-d H:i:s') . "] Fetching Logs. Count: $count. User: $user_id\n", FILE_APPEND);
|
||||||
]);
|
|
||||||
|
// توحيد الاستجابة مع دالة jsonSuccess الموجودة في helpers.php
|
||||||
|
// والتي تضع البيانات داخل مفتاح message
|
||||||
|
jsonSuccess($logs);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
file_put_contents(__DIR__ . '/fetch_debug.txt', "Error: " . $e->getMessage() . "\n", FILE_APPEND);
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
|
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user