<?php

namespace Modules\Commande\Rules;

use Helpers\Ariane\Ariane;
use Helpers\Outil\Roles;
use Psr\Http\Message\ServerRequestInterface;

class Main
{
    protected ServerRequestInterface $request;
    protected \PDO $pdo;
        
    /**
     * __construct
     *
     * @param  ServerRequestInterface $request
     * @return void
     */
    public function __construct(ServerRequestInterface  $request, \PDO $pdo)
    {
        $this->request  = $request;
        $this->pdo      = $pdo;
    }
    
    /**
     * init
     *
     * @return bool
     */
    public function init() : bool
    {
        $droit['HA_CA_VIS'] = Roles::droitsUtilisateur($this->pdo, 'HA_CA_VIS');
        $droit['HA_CA_CMV'] = Roles::droitsUtilisateur($this->pdo, 'HA_CA_CMV');
        
        if ($droit['HA_CA_VIS'] || $droit['HA_CA_CMV'] || ($_SESSION['SIG_CDE'] || $_SESSION['DA_CreatModif'])) {
            return true;
        }
        return false;
    }
}
