<?php

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

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

class ConfigurationSection extends BoxSection implements AdminArea
{
    protected $id = 'lxcConfigurationSection';
    protected $name = 'lxcConfigurationSection';
    protected $title = 'lxcConfigurationSection';
    /**
     * @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()
    {
        //OS Architecture Type
        $field = new Select('customconfigoption[arch]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Console Type
        $field = new Select('customconfigoption[cmode]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Console
        $field = new Switcher('customconfigoption[console]');
        $field->setDescription('tip');
        $field->setDefaultValue("on");
        $this->rightSection->addField($field);
        //OS Type
        $field = new Select('customconfigoption[ostype]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Start At Boot
        $field = new Switcher('customconfigoption[onboot]');
        $this->rightSection->addField($field);
        //Add The VM To The Specific Pool
        $field = new  Select('customconfigoption[pool]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Protection
        $field = new Switcher('customconfigoption[protection]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Container Notes
        $field = new Textarea('customconfigoption[description]');
        $field->setDescription('tip');
        $field->setDefaultValue("Client: {\$client_name}  (ID: {\$client_id})\nEmail: {\$client_email}\nService ID: {\$service_id}\nHostname: {\$service_domain}\nMain IP: {\$service_dedicated_ip}\n{if \$service_assigned_ips}IP address allocation: {\$service_assigned_ips}\n{/if}\nProduct:  {\$product_name} (ID: {\$product_id})");
        $this->leftSection->addField($field);
        //Startup
        $field = new Text('customconfigoption[startup]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Amount of tty For The VM
        $field = new Text('customconfigoption[tty]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Unprivileged
        $field = new Switcher('customconfigoption[unprivileged]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //SSH Key Pairs
        $field = new Switcher('customconfigoption[sshKeyPairs]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //Delete Private Key
        $field = new Switcher('customconfigoption[sshDeletePrivateKey]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //Start after created
        $field = new Switcher('customconfigoption[start]');
        $field->setDescription('tip');
        $this->leftSection->addField($field);
        //featureKeyctl
        $field = new Switcher('customconfigoption[featureKeyctl]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //featureNesting
        $field = new Switcher('customconfigoption[featureNesting]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //featureNfs
        $field = new Switcher('customconfigoption[featureNfs]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //featureCifs
        $field = new Switcher('customconfigoption[featureCifs]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //featureFuse
        $field = new Switcher('customconfigoption[featureFuse]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);
        //featureMknod
        $field = new Switcher('customconfigoption[featureMknod]');
        $field->setDescription('tip');
        $this->rightSection->addField($field);

    }

}
