<?php

namespace Modules\Consultation\Rules;

use Entity\Model\AoEntet;
use Psr\Http\Message\ServerRequestInterface;

class ChoixFournisseur
{
    /** @var ServerRequestInterface $request */
    protected ServerRequestInterface $request;

    /** @var \PDO $pdo */
    protected \PDO $pdo;

    /** @var string|mixed $currentUser */
    protected $currentUser;

    /** @var AoEntet $consultationEntity */
    protected AoEntet $consultationEntity;

    /** @var array<mixed> $droits */
    protected array $droits;

    /**
     * @param ServerRequestInterface $request
     * @param \PDO $pdo
     */
    public function __construct(ServerRequestInterface $request, \PDO $pdo)
    {
        $this->request              = $request;
        $this->pdo                  = $pdo;
        $this->currentUser          = $_SESSION['Session_Login'];
        $this->consultationEntity   = new AoEntet($pdo);
    }

    /**
     * @return bool
     */
    public function choixFrs(): bool
    {
        $idAO   = $this->request->getAttribute('idAO');
        $consultation = $this->consultationEntity->find($idAO, [], [], $this->pdo::FETCH_ASSOC);

        if ($consultation['RFI_Q'] === 'Q') {
            return true;
        }

        return false;
    }
    
    /**
     * @return bool
     */
    public function choixFrsWithOutLigne(): bool
    {
        $idAO   = $this->request->getAttribute('idAO');
        $consultation = $this->consultationEntity->find($idAO, [], [], $this->pdo::FETCH_ASSOC);

        if ($consultation['RFI_Q'] !== 'Q') {
            return true;
        }

        return false;
    }
}
