<?php

namespace KupShop\ElninoBundle\Admin\Tabs;

use KupShop\AdminBundle\Admin\WindowTab;

class ElninoCategorySettings extends WindowTab
{
    protected $title = 'flapElninoCategory';

    protected $template = 'window/sections.elnino.tpl';

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

    public function getVars($smarty_tpl_vars)
    {
        $vars = parent::getVars($smarty_tpl_vars);

        $vars['section']['list_models'] = $this->selectSQL('sections', ['id' => $this->getID()], ['list_models'])->fetchColumn();

        return $vars;
    }

    public function handleUpdate()
    {
        if (getVal('Submit')) {
            $data = $this->getData();
            if (!empty($data['list_models'])) {
                $this->updateSQL('sections', ['list_models' => $data['list_models']], ['id' => $this->getID()]);
            }
        }
    }
}
