<?php
namespace App\Controllers;

require_once BASE_PATH . '/app/helpers/permissions.php';

use App\Core\Controller;
use App\Core\Database;

class SuperAdminMonitoringController extends Controller
{
    public function index()
    {
        RoleGuard::allow(['superadmin']);

        $db = Database::getInstance();

        $stats = [
            'active_orgs' => $db->query("SELECT COUNT(*) FROM organizations WHERE is_active=1")->fetchColumn(),
            'active_confs' => $db->query("SELECT COUNT(*) FROM conferences WHERE is_active=1")->fetchColumn(),
            'pending_reviews' => $db->query("SELECT COUNT(*) FROM reviews WHERE is_submitted=0")->fetchColumn(),
            'decision_stage' => $db->query("SELECT COUNT(*) FROM conferences WHERE status='decision'")->fetchColumn(),
            'system_jobs_failed' => $db->query("SELECT COUNT(*) FROM system_jobs WHERE status='failed'")->fetchColumn()
        ];

        $this->view('superadmin/monitoring', compact('stats'));
    }
}
