<?php

namespace Modules\Commande\Rules;

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

class AjaxGestionCommande
{
    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
    {
        if (Roles::droitsUtilisateur($this->pdo, 'HA_CA_VIS')) {
            return true;
        }
        return false;
    }

    public function suppresionCommande(): bool
    {
        if (Roles::droitsUtilisateur($this->pdo, 'HA_CA_SUP')) {
            return true;
        }

        return false;
    }

    public function devaliderCommande(): bool
    {
        if (Roles::droitsUtilisateur($this->pdo, 'HA_CA_DEV')) {
            return true;
        }

        return false;
    }
    public function popupAnnulerCommande(): bool
    {
        if (Roles::droitsUtilisateur($this->pdo, 'HA_CA_ANN')) {
            return true;
        }

        return false;
    }
}
