<?php

namespace Ecoyn\Setup\Steps\BasicData;

use Ecoyn\Setup\PackageConfig;
use QUI;
use QUI\Exception;
use QUI\Locale;

/**
 * Class Welcome
 */
class Bank extends QUI\InstallationWizard\AbstractInstallationWizardStep
{
    public function __construct($attributes = [])
    {
        parent::__construct($attributes);
        $this->addCSSFile(dirname(__FILE__) . '/Bank.css');
    }

    public function getTitle(?Locale $Locale = null): string
    {
        if ($Locale === null) {
            $Locale = QUI::getLocale();
        }

        return $Locale->get('ecoyn/core', 'setup.data.bank.title');
    }

    public function getDescription(?Locale $Locale = null): string
    {
        if ($Locale === null) {
            $Locale = QUI::getLocale();
        }

        return $Locale->get('ecoyn/core', 'setup.data.bank.description');
    }

    /**
     * @return string
     * @throws Exception
     */
    public function create(): string
    {
        $Engine = QUI::getTemplateManager()->getEngine();
        $Config = PackageConfig::get('quiqqer/erp');

        $Engine->assign([
            'urlImageDir' => URL_OPT_DIR . 'ecoyn/core/bin/setup/',
            'company_name' => $Config->get('company', 'name'),
            'company_bankBic' => $Config->get('company', 'bankBic'),
            'company_bankIban' => $Config->get('company', 'bankIban'),
        ]);

        return $Engine->fetch(dirname(__FILE__) . '/Bank.html');
    }
}
