<?php
declare(strict_types=1);

namespace App\Controllers;

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

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

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

final class AdminChairsController 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 ch.*
          FROM chairs ch
          JOIN conferences c ON c.id=ch.conference_id
          WHERE c.org_id=:org_id
          ORDER BY ch.id DESC
          LIMIT 300
        ";
        $st=$db->prepare($sql);
        $st->execute([':org_id'=>$orgId]);
        $rows=$st->fetchAll()?:[];

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