<?php

namespace KupShop\BalikonosBundle\Admin\Tabs;

use KupShop\AdminBundle\Admin\WindowTab;
use KupShop\BalikonosBundle\Balikonos;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;

class BalikonosSettingsWindowTab extends WindowTab
{
    protected $title = 'flapBalikonosSettings';

    protected $template = 'window/settings.balikonos.tpl';

    public static function getTypes()
    {
        return [
            'settings' => 1,
        ];
    }

    public static function isAllowed()
    {
        return findModule(\Modules::BALIKONOS, 'provider') !== 'balikobot';
    }

    public function getVars($smarty_tpl_vars)
    {
        $data['delivery_type'] = \Delivery::getAll(false);
        $balikonos = ServiceContainer::getService(Balikonos::class);
        $data['balikonos']['client_id'] = $balikonos->getClientId();
        $balikonos->setTestMode();
        $data['balikonos']['client_id_test'] = $balikonos->getClientId();
        unset($balikonos);

        return $data;
    }
}
