<?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');
        $droit['HA_DA_CRE'] = Roles::droitsUtilisateur($this->pdo, 'HA_DA_CRE');
        
        if ($droit['HA_CA_VIS'] || $droit['HA_CA_CMV'] || $droit['HA_CA_LIS'] || ($_SESSION['SIG_CDE'] || $droit['HA_DA_CRE'])) {
            return true;
        }
        return false;
    }
}
