diff --git a/admin/index.php b/admin/index.php
index 619bc4b..b1394d8 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -18,7 +18,7 @@ ob_start();
总用户数
-
= number_format($total_users) ?>
+
= number_format($total_users) ?>
@@ -29,7 +29,7 @@ ob_start();
总充值 (USDT)
-
= number_format($total_recharge, 2) ?>
+
= number_format($total_recharge, 2) ?>
@@ -40,7 +40,7 @@ ob_start();
总提现 (USDT)
-
= number_format($total_withdrawal, 2) ?>
+
= number_format($total_withdrawal, 2) ?>
@@ -51,7 +51,7 @@ ob_start();
待办事项
-
= $pending_finance + $pending_kyc ?>
+
= $pending_finance + $pending_kyc ?>
diff --git a/admin/layout.php b/admin/layout.php
index 11a46cb..b079364 100644
--- a/admin/layout.php
+++ b/admin/layout.php
@@ -337,16 +337,37 @@ function renderAdminPage($content, $title = '后台管理') {
utterance.lang = 'zh-CN';
window.speechSynthesis.speak(utterance);
}
+ // Also try native notification
+ if (Notification.permission === "granted") {
+ new Notification("新消息提醒", { body: text, icon: '/assets/images/logo.png' });
+ }
+ }
+
+ // Request notification permission
+ if (Notification.permission !== "granted" && Notification.permission !== "denied") {
+ Notification.requestPermission();
}
function checkNotifications() {
const currentPage = window.location.pathname;
- fetch('../api/admin_notifications.php')
+ const isDashboard = currentPage.includes('index.php') || currentPage.endsWith('/admin/');
+ const url = isDashboard ? '../api/admin_notifications.php?stats=1' : '../api/admin_notifications.php';
+
+ fetch(url)
.then(r => r.json())
.then(data => {
if (data.success) {
const counts = data.counts;
+ // Update dashboard stats if available
+ if (data.stats) {
+ const s = data.stats;
+ if (document.getElementById('stat-total-users')) document.getElementById('stat-total-users').innerText = parseInt(s.total_users).toLocaleString();
+ if (document.getElementById('stat-total-recharge')) document.getElementById('stat-total-recharge').innerText = parseFloat(s.total_recharge).toLocaleString(undefined, {minimumFractionDigits: 2});
+ if (document.getElementById('stat-total-withdrawal')) document.getElementById('stat-total-withdrawal').innerText = parseFloat(s.total_withdrawal).toLocaleString(undefined, {minimumFractionDigits: 2});
+ if (document.getElementById('stat-pending-tasks')) document.getElementById('stat-pending-tasks').innerText = s.pending_tasks;
+ }
+
// Auto-clear current page types
if (currentPage.includes('finance.php')) {
fetch('../api/admin_notifications.php?action=clear&type=finance');
@@ -455,6 +476,27 @@ function renderAdminPage($content, $title = '后台管理') {
if (lastSoundTotal !== -1 && soundTotal > lastSoundTotal) {
speak("你有新的消息,请注意查收");
+ // Show a Toast notification
+ if (window.Swal) {
+ Swal.fire({
+ title: '新提醒',
+ text: '您有新的充提申请或客服消息',
+ icon: 'info',
+ toast: true,
+ position: 'top-end',
+ showConfirmButton: false,
+ timer: 5000,
+ timerProgressBar: true,
+ didOpen: (toast) => {
+ toast.addEventListener('mouseenter', Swal.stopTimer)
+ toast.addEventListener('mouseleave', Swal.resumeTimer)
+ toast.onclick = () => {
+ if (counts.recharge > 0 || counts.withdrawal > 0) location.href = 'finance.php';
+ else if (counts.messages > 0) location.href = 'customer_service.php';
+ };
+ }
+ });
+ }
}
lastTotal = total;
lastSoundTotal = soundTotal;
diff --git a/api/admin_notifications.php b/api/admin_notifications.php
index cb380a9..1d3d675 100644
--- a/api/admin_notifications.php
+++ b/api/admin_notifications.php
@@ -66,6 +66,15 @@ if ($admin['is_agent']) {
$total = $pending_recharge + $pending_withdrawal + $pending_kyc + $active_binary + $active_spot + $active_contract + $new_messages;
$sound_trigger_count = $total; // Trigger sound for any pending action
+// Add dashboard stats if requested
+$stats = [];
+if (isset($_GET['stats'])) {
+ $stats['total_users'] = getCount($db, "SELECT COUNT(*) FROM users", []);
+ $stats['total_recharge'] = (float)getCount($db, "SELECT SUM(amount) FROM finance_requests WHERE type='recharge' AND status='3'", []) ?: 0;
+ $stats['total_withdrawal'] = (float)getCount($db, "SELECT SUM(amount) FROM finance_requests WHERE type='withdrawal' AND status='3'", []) ?: 0;
+ $stats['pending_tasks'] = $pending_recharge + $pending_withdrawal + $pending_kyc;
+}
+
echo json_encode([
'success' => true,
'counts' => [
@@ -79,5 +88,6 @@ echo json_encode([
'users' => $new_registrations,
'total' => $total,
'sound_total' => $sound_trigger_count
- ]
+ ],
+ 'stats' => $stats
]);
diff --git a/db/config.php b/db/config.php
index b627add..399e44b 100644
--- a/db/config.php
+++ b/db/config.php
@@ -1,6 +1,7 @@
-