<?php

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

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;

class MiscellaneousSection extends BoxSection implements AdminArea
{
    protected $id = 'miscellaneousSection';
    protected $name = 'miscellaneousSection';
    protected $title = 'miscellaneousSection';
    /**
     * @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()
    {
        //Backup VM Before Reinstallation
        $field = new Switcher('customconfigoption[backupVmBeforeReinstall]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Reboot VM After Changing Package
        $field = new Switcher('customconfigoption[rebootVmAfterChangePackage]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Delete Backups After Termination
        $field = new Switcher('customconfigoption[deleteBackups]');
        $field->setDescription('tip');
        $field->setDefaultValue("on");
        $this->leftSection->addField($field);
        //Use Server Nameservers
        $field = new Switcher('customconfigoption[serverNameservers]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Suspension Action
        $field = new Select('customconfigoption[suspensionAction]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Bandwidth Overage
        $field = new Switcher('customconfigoption[suspendOnBandwidthOverage]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
    }

}
