<?php

namespace Container\MenuTop;

use Helpers\Additional\Additional;
use Helpers\Outil\Roles;
use Modules\GlobalApplication\Repository\LicenceOxalys;
use Psr\Container\ContainerInterface;
use Skeleton\Router;

class PilotageAchat extends AbsMenuTop
{
    
    use \Traits\Menu\Droit;
    
    protected string $pack;
    protected Additional $additional;

    /**
     * __construct
     *
     * @param  Additional $additional
     * @return void
     */
    public function __construct(Additional $additional)
    {
        $this->pack = 'PilotageAchats';
        $this->additional = $additional;
    }

    /**
     * @return array<mixed>
     */
    public function getListeAction(router $router, ContainerInterface $contenaire, \PDO $pdo)
    {
        /** @var \Helpers\Trad\ITrad */
        $trad = $contenaire->get(\Helpers\Trad\ITrad::class);

        $menu = [];
        
        if ((new LicenceOxalys($pdo))->dOAActive()) {
            if (roles::droitsUtilisateur($pdo, 'DOA_DON_CM')
                || roles::droitsUtilisateur($pdo, 'DOA_DOA_SV')
                || roles::droitsUtilisateur($pdo, 'DOA_DOA_CM')
                || Roles::droitsUtilisateur($pdo, 'DOA_OPE_CM')
                || roles::droitsUtilisateur($pdo, 'DOA_DOA_TT')
                || Roles::droitsUtilisateur($pdo, 'DOA_OPE')
                || $this->getAll()
            ) {
                $menu[] = [
                    'id'            => 'menuTopProjetsAchats',
                    'pathLogin'     => 'projetAchat',
                    'path'          => $router->generateUri('ProjetAchat.GestionProjetAchat.tableauBord'),
                    'libelle'       => $trad->t('Projets Achats'),
                    'menuActive'    => 'ProjetAchat'
                ];
            }
        }

        return $menu;
    }
}
