<?php
declare(strict_types=1);

namespace App\Controllers;

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

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

final class ArchiveController extends Controller
{
    public function index(): void
    {
        require_login();
        $db = Database::getInstance();

        $st = $db->prepare("
          SELECT s.*,
                 c.title_en AS conf_title_en, c.title_ar AS conf_title_ar,
                 t.name_en AS track_name
          FROM submissions s
          LEFT JOIN conferences c ON c.id = s.conference_id
          LEFT JOIN tracks t ON t.id = s.track_id
          WHERE s.status IN ('accepted','published','archived')
          ORDER BY s.id DESC
          LIMIT 500
        ");
        $st->execute();
        $rows = $st->fetchAll();

        // reuse author table view quickly
        $this->view('author/index', ['rows'=>$rows]);
    }
}
