<?php

namespace Modules\Tables\MenuContextuel;

use Helpers\Outil\MenuContextuel;
use Helpers\Outil\Roles;
use Helpers\Trad\ITrad;
use Skeleton\Router;

class CentresContextuel extends MenuContextuel
{
    /**
     * @var array<mixed> droit
     */
    public $droit;

    public function __construct(\PDO $pdo, Router $router, ITrad $trad)
    {
        parent::__construct($pdo, $router, $trad);

        $this->droit    = [
            'HA_CTR_CM'     => Roles::droitsUtilisateur($pdo, 'HA_CTR_CM'),
        ];
    }

    /**
     * @param array<mixed> $doc
     * @return array<mixed>
     */
    public function generate($doc, bool $popup = false)
    {
        $menuContextuel = [];

        if ($this->droit['HA_CTR_CM']) {
            $menuContextuel['listeSecondaire'][] = [
                'libelle'   => $this->trad->t('Modifier'),
                'lien'      => $popup? '':$this->router->generateUri('Tables.Centre.Create', ['mode' => 'form', 'idTable' => $doc['CODE_CTR']]),
                'lienJs'    => $popup? $this->ajaxDynamiqueTab(
                    $this->router->generateUri('Tables.Centre.Create', ['mode' => 'ajax', 'idTable' => $doc['CODE_CTR']]),
                    $this->trad->t('Modification centre')
                ):'',
            ];
        }

        /*$menuContextuel['listeSecondaire'][] = [
            'libelle'   => $this->trad->t('Supprimer'),
            'lien'      => '',
        ];*/
        
        return $menuContextuel;
    }
}
