<?php

namespace Modules\GlobalApplication\MenuContextuel;

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

class HistoriqueMenuContextuel extends MenuContextuel
{
    public string $module;

    /**
     * @var array<mixed>
     */
    public $droit;

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

        $this->module = $module;
        $this->droit = [];
    }

    /**
     * @return array<mixed>
     */
    public function generate(string $id)
    {
        $menuContextuel = [];

        if ($this->module == 'FOU') {
            $menuContextuel['listeSecondaire'][] = [
                'libelle' => $this->trad->t('Commandes'),
                'lien' => $this->router->generateUri('Fournisseur.Commande.commande', ['id' => $id]),
                'lienJs' => '',
            ];

            $menuContextuel['listeSecondaire'][] = [
                'libelle' => $this->trad->t('Factures'),
                'lien' => $this->router->generateUri('Fournisseur.Facture.facture', ['id' => $id]),
                'lienJs' => '',
            ];

            $menuContextuel['listeSecondaire'][] = [
                'libelle' => $this->trad->t('Notations'),
                'lien' => $this->router->generateUri('Fournisseur.Notation.notation', ['id' => $id]),
                'lienJs' => '',
            ];

            $menuContextuel['listeSecondaire'][] = [
                'libelle' => $this->trad->t('Stats d\'incidents'),
                'lien' => '',
                'lienJs' => $this->ajaxPopup(
                    $this->router->generateUri('Fournisseur.popupHistorique.popupStatsIncident', ['id' => $id]),
                    $this->trad->t('Stats d\'incidents'),
                ),
            ];
        }

        $menuContextuel['listeSecondaire'][] = [
            'libelle' => $this->trad->t('Réponse AO'),
            'lien' => $this->router->generateUri('Fournisseur.ReponseAO.reponseAO', ['MODULE' => ($this->module=='FOU'? 'Fournisseur':$this->module), 'id' => $id]),
            'lienJs' => '',
        ];

        return $menuContextuel;
    }
}
