<?php

namespace Modules\Consultation\Rules;

use Entity\Model\AoEntet;
use Entity\Model\Fourniss;
use Helpers\Outil\Roles;
use Helpers\Outil\Sql;
use Psr\Http\Message\ServerRequestInterface;

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

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

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

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

    /**
     * @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 questionnaire(): bool
    {
        $idAO = $this->request->getAttribute('idAO');
        $consultation = $this->consultationEntity->find($idAO, [], [], $this->pdo::FETCH_ASSOC);

        if (!Sql::boolSql($consultation['COMP_QUEST'])) {
            return false;
        }

        return true;
    }


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

    /**
     * @return bool
     */
    // @phpcs:ignore
    public function questionnaireContrib(): bool
    {
        return true;
    }
}
