<?php

namespace ModulesGarden\Servers\ProxmoxVps\App\UI\Admin\Product\Sections;


use ModulesGarden\Servers\ProxmoxVps\Core\Lang\Lang;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AdminArea;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Select;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Switcher;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Sections\BoxSection;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Sections\HalfPageSection;
use function ModulesGarden\Servers\ProxmoxVps\Core\Helper\sl;

class MainSection extends BoxSection implements AdminArea
{
    protected $id = 'mainSection';
    protected $name = 'mainSection';
    protected $title = 'mainSection';

    /**
     * @var HalfPageSection
     */
    private $leftSection;
    /**
     * @var HalfPageSection
     */
    private $rightSection;

    public function initContent()
    {
        $this->leftSection = new HalfPageSection('leftSection');

        $this->rightSection = new HalfPageSection('rightSection');

        $this->addSection($this->leftSection)
            ->addSection($this->rightSection);
        $this->initFields();
    }

    private function initFields()
    {
        /**
         * @var Lang $lang
         */
        $lang = sl("lang");
        //Virtualization
        $field = new Select('customconfigoption[virtualization]');
        $field->setDefaultValue('qemu');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Default Node
        $field = new Select('customconfigoption[defaultNode]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Check Available Resources
        $field = new Switcher('customconfigoption[checkResources]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //resetUsageFirstDayOfMonth
        $field = new Switcher('customconfigoption[resetUsageFirstDayOfMonth]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
    }

}
