`;
+ }).join('');
+}
+
+function openGameCredits(slug) {
+ // Switch to Games section and open the credit modal for this platform
+ showSec('games');
+ // Wait for games to load then find and click the matching game's edit button
+ const tryOpen = () => {
+ const games = window._gamesData || [];
+ const g = games.find(x => x.slug === slug);
+ if (g) { editGame(g.id); setTimeout(() => openCreditModal(), 150); }
+ };
+ if ((window._gamesData||[]).length) { tryOpen(); }
+ else { loadGames().then(() => tryOpen()); }
}
// âââ SECTION NAV âââââââââââââââââââââââââââââââââââââââââââ
diff --git a/api/admin.php b/api/admin.php
index 33369df..ff126c4 100644
--- a/api/admin.php
+++ b/api/admin.php
@@ -68,6 +68,23 @@ switch ($action) {
}
break;
+ // âââ PLATFORM STATS ââââââââââââââââââââââââââââââââââââââ
+ case 'platform_stats':
+ if (!$isAdmin) { echo json_encode(['success'=>false,'error'=>'Forbidden']); exit; }
+ $rows = db()->query("
+ SELECT p.id, p.name, p.slug, p.color,
+ COALESCE(SUM(CASE WHEN pc.type='debit' THEN -pc.credits_purchased ELSE pc.credits_purchased END),0) AS credits_balance,
+ (SELECT COUNT(*) FROM token_purchases tp WHERE tp.platform_id=p.slug AND tp.status='completed') AS purchases,
+ (SELECT COUNT(*) FROM cashout_requests cr WHERE cr.platform_id=p.slug AND cr.status IN ('sent','approved')) AS cashouts
+ FROM platforms p
+ LEFT JOIN platform_credits pc ON pc.platform_id=p.id
+ WHERE p.is_deleted=0 AND p.is_active=1
+ GROUP BY p.id, p.name, p.slug, p.color
+ ORDER BY p.sort_order, p.id
+ ")->fetchAll();
+ echo json_encode(['success'=>true,'platforms'=>$rows]);
+ break;
+
// âââ PURCHASES ââââââââââââââââââââââââââââââââââââââââââââ
case 'purchases':
$status = $_GET['status'] ?? 'pending';