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

class UserSection extends BoxSection implements AdminArea
{
    protected $id = 'userSection';
    protected $name = 'userSection';
    protected $title = 'userSection';
    /**
     * @var HalfPageSection
     */
    private $leftSection;
    /**
     * @var HalfPageSection
     */
    private $rightSection;

    public function initContent()
    {
        $this->leftSection  = new HalfPageSection('leftSectionsdf');
        $this->rightSection = new HalfPageSection('rightSectionsdf');
        $this->addSection($this->leftSection)
            ->addSection($this->rightSection);
        $this->initFields();
    }

    private function initFields()
    {
        //One User Per VPS
        $field = new Switcher('customconfigoption[oneUserPerVps]');
        $field->setDescription('tip');
        $field->setDefaultValue("on");
        $this->leftSection->addField($field);
        //Username Prefix
        $field = new Text('customconfigoption[userPrefix]');
        $field->setDescription('tip');
        $field->setDefaultValue('proxmoxVPS_{$serviceid}');
        $this->rightSection->addField($field);
        //Realm
        $field = new Select('customconfigoption[realm]');
        $field->setDescription('tip');
        $field->setDefaultValue('pve');
        $this->leftSection->addField($field);
        //Comment
        $field = new Textarea('customconfigoption[userComment]');
        $field->setDescription('tip');
        $field->setDefaultValue('User from module ProxmoxVPS for WHMCS');
        $this->rightSection->addField($field);
        //Role
        $field = new Select('customconfigoption[userRole]');
        $field->setDescription('tip');
        $field->setDefaultValue('PVEVMUser');
        $this->leftSection->addField($field);
    }

}
