<?php
namespace App\Controllers;

use App\Core\Controller;
use App\Core\Database;
use App\Middleware\RoleGuard;

class AdminSubmissionsController extends Controller
{
    public function index(): void
    {
        RoleGuard::allow(['super_admin']);

        $db = Database::getInstance();

        $submissions = $db->query("
            SELECT s.id,
                   COALESCE(s.title_en, s.title_ar) AS title,
                   s.status,
                   COALESCE(c.title_en, c.title_ar) AS conference
            FROM submissions s
            LEFT JOIN conferences c ON s.conference_id=c.id
            ORDER BY s.id DESC
        ")->fetchAll();

        ob_start();
        require BASE_PATH.'/app/views/admin/submissions/index.php';
        $content = ob_get_clean();

        require BASE_PATH.'/app/views/layouts/admin_layout.php';
    }
}
