<?php

namespace Modules\Commande\Rules;

use Entity\Model\CaEntet;
use Helpers\Outil\Roles;
use Psr\Http\Message\ServerRequestInterface;

class AjaxModificationCommande
{
    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
    {
        $idCommande = $this->request->getAttribute('idCommande');
        Roles::droitsUtilisateur($this->pdo, 'HA_CA_MVI');

        $caEntet = new CaEntet($this->pdo);
        $infoCde = $caEntet->find($idCommande);

        if (Roles::droitsUtilisateur($this->pdo, 'HA_CA_CMV') ||(Roles::droitsUtilisateur($this->pdo, 'HA_CA_MVI') && $infoCde['ACH'] == $_SESSION["Session_Login"])) {
            return true;
        }
        return false;
    }


    /**
     * @return bool
     */
    public function ajaxValueContactFrs(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueAdresseFrs(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueContactCentre(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueLivraison(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueAdresseLiv(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueContactTransitaire(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueAdresseFrsLiv(): bool
    {
        return true;
    }

    /**
     * @return bool
     */
    public function ajaxValueContactExport(): bool
    {
        return true;
    }
}
