<?php
declare(strict_types=1);

namespace App\Controllers;

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

final class AdminReviewAssignmentsController extends Controller
{
    public function index(): void
    {
        require_admin_area();
        
        $orgId = (int) current_org_id();
require_org_context();

        $db=Database::getInstance();
        $orgId=(int)current_org_id();

        $sql="
          SELECT ra.*, s.conference_id, s.title_en, s.title_ar,
                 u.email AS reviewer_email
          FROM review_assignments ra
          JOIN submissions s ON s.id=ra.submission_id
          JOIN conferences c ON c.id=s.conference_id
          LEFT JOIN users u ON u.id=ra.reviewer_id
          WHERE c.org_id=:org_id
          ORDER BY ra.id DESC
          LIMIT 400
        ";
        $st=$db->prepare($sql);
        $st->execute([':org_id'=>$orgId]);
        $rows=$st->fetchAll()?:[];

        $this->view('admin/review_assignments/index',['rows'=>$rows,'q'=>'']);
    }
}
