<?php

namespace KupShop\UserBundle\Admin\Actions;

use KupShop\AdminBundle\Admin\Actions\AbstractAction;
use KupShop\AdminBundle\Admin\Actions\ActionResult;
use KupShop\AdminBundle\Admin\Actions\IAction;

class PrintUserLabelAction extends AbstractAction implements IAction
{
    #[\Override]
    public function getTypes(): array
    {
        return ['users'];
    }

    #[\Override]
    public function getName(): string
    {
        return 'Vytisknout štítek uživatele';
    }

    #[\Override]
    public function getVars(): array
    {
        return [
            'userId' => $this->getId(),
        ];
    }

    #[\Override]
    public function execute(&$data, array $config, string $type): ActionResult
    {
        if (!$this->getId()) {
            echo 'Není zadáno uživatelské ID!';
            exit;
        }

        $smarty = createSmarty(true, true);
        $smarty->assign([
            'user' => \User::createFromId($this->getId()),
        ]);
        $smarty->display('window/userPrintLabel.tpl');

        exit;
    }

    #[\Override]
    public function getDialogHrefAttributes()
    {
        return 'data-modal-hide-buttons="true"';
    }
}
