<?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\Fields\Text;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Sections\BoxSection;
use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Sections\HalfPageSection;

class BackupSection extends BoxSection implements AdminArea
{
    protected $id = 'backupSection';
    protected $name = 'backupSection';
    protected $title = 'backupSection';
    /**
     * @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()
    {
        //Storage
        $field = new Select('customconfigoption[backupStorage]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Backups Routing
        $field = new Switcher('customconfigoption[backupRouting]');
        $field->setDescription('tip');
        $field->setDefaultValue("on");
        $this->rightSection->addField($field);
        //Store The Backup For X Days
        $field = new Text('customconfigoption[backupStoreDays]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
    }

}
