<?php

namespace Modules\Stock\MenuContextuel;

use Helpers\Outil\MenuContextuel;
use Helpers\Trad\ITrad;
use Modules\Stock\Interface\MenuContextuelInterface;
use Modules\Stock\Trait\MenuContextuelTrait;
use PDO;
use Skeleton\Router;

class SiteStockContextuel extends MenuContextuel implements MenuContextuelInterface
{
    use MenuContextuelTrait;

    /**
     * @var array<string,mixed>
     */
    public array $droit = [];

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

    /**
     * @param array<string,string|int> $entity
     * @return array<string, array<int,array<string, mixed>>>
     */
    public function generate(array $entity): array
    {
        return [
            'listePrincipal' => [
                [
                    'icone' => 'icon-art-associated',
                    'libelle' => $this->trad->t('Articles'),
                    'lienJs' => 'voirStockLocal('.join(',', [json_encode($entity['SITE']), json_encode($entity['CODE_STE'])]).');'
                ],
                [
                    'icone' => 'documents_attaches',
                    'libelle' => $this->trad->t('Documents rattachés'),
                    'lien' => $this->router->generateUri('GlobalApplication.DocumentRattaches.document', ['MODULE' => 'SiteStock', 'id' => $entity['SITE']]),
                ]
            ],
        ];
    }
}
