<?php
namespace App\Controllers;

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

class ProductionController extends Controller
{
    private function validateContext()
    {
        if (!isset($_SESSION['org_id']) || !isset($_SESSION['conference_id'])) {
            die("Context not selected.");
        }
    }

    public function index()
    {
        $this->validateContext();
        $db = Database::getInstance();

        $stmt = $db->prepare("
            SELECT *
            FROM submissions
            WHERE org_id = ?
            AND conference_id = ?
            AND status = 'accepted'
        ");
        $stmt->execute([
            $_SESSION['org_id'],
            $_SESSION['conference_id']
        ]);

        $submissions = $stmt->fetchAll(\PDO::FETCH_ASSOC);

        ob_start();
        require BASE_PATH . '/app/views/admin/production/index.php';
        $content = ob_get_clean();
        require BASE_PATH . '/app/views/layouts/admin_layout.php';
    }
}
