<?php
declare(strict_types=1);
namespace App\Controllers;
use App\Core\Auth;
use App\Core\Controller;
use App\Core\Permission;
use App\Services\ExecutiveSecurityService;
final class ExecutiveSecurityController extends Controller
{
    public function index(): void
    {
        Auth::requireLogin();
        Permission::require('soc.executive.view');
        $days=max(7,min(90,(int)($_GET['days']??30)));
        $this->view('security/executive_security',[
            'pageTitle'=>'Executive Security Center',
            'report'=>(new ExecutiveSecurityService())->dashboard($days),
        ]);
    }
    public function exportCsv(): void
    {
        Auth::requireLogin();
        Permission::require('soc.executive.export');
        $days=max(7,min(90,(int)($_GET['days']??30)));
        (new ExecutiveSecurityService())->exportCsv($days);
    }
    public function printReport(): void
    {
        Auth::requireLogin();
        Permission::require('soc.executive.export');
        $days=max(7,min(90,(int)($_GET['days']??30)));
        $this->view('security/executive_security_print',[
            'pageTitle'=>'Rapport exécutif de sécurité',
            'report'=>(new ExecutiveSecurityService())->dashboard($days),
        ]);
    }
}
