<?php
declare(strict_types=1);

namespace App\Controllers;

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

abstract class _TenantLiteBase extends Controller
{
    protected function gate(): array
    {
        require_admin_or_chair();
        require_org_context();

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

        $st = $db->prepare("SELECT id,title_en,title_ar,is_active FROM conferences WHERE org_id=:o ORDER BY id DESC");
        $st->execute([':o'=>$orgId]);
        $confs = $st->fetchAll() ?: [];

        return [$db,$orgId,$confs];
    }

    protected function litePage(string $titleAr, string $titleEn, string $noteAr, string $noteEn): void
    {
        $lang = current_lang();
        [$db,$orgId,$confs] = $this->gate();

        $this->view('admin/tenant_lite/index', [
            'title_ar'=>$titleAr,
            'title_en'=>$titleEn,
            'note_ar'=>$noteAr,
            'note_en'=>$noteEn,
            'org_id'=>$orgId,
            'confs'=>$confs,
        ]);
    }
}
