<?php
namespace ThurData\Servers\KerioEmail\App\UI\Admin\ProductConfiguration\Pages\Sections;
use ThurData\Servers\KerioEmail\App\Enums\Size;
use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Fields\ExtendedInputField;
use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\BoxSectionExtended;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Switcher;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\BoxSection;
use ThurData\Servers\KerioEmail\Core\UI\Interfaces\AdminArea;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\HalfPageSection;

/**
 *
 * Created by PhpStorm.
 * User: ThurData
 * Date: 28.08.19
 * Time: 09:15
 * Class KerioSettingsSection
 */
class KerioSettings extends BoxSectionExtended implements AdminArea
{
    protected $id       = 'kerioSettings';
    protected $name     = 'kerioSettings';
    protected $title    = 'kerioSettings';

    public function initContent()
    {
        $this
            ->addSection($this->getLeftSection())
            ->addSection($this->getRightSection());

    }

    /**
     * @description left section
     * @return HalfPageSection
     */
    public function getLeftSection()
    {
        $leftSection = new HalfPageSection('leftSide');

        $field = new ExtendedInputField('acc_limit');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $leftSection->addField($field);

        $field = new ExtendedInputField('acc_base');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $leftSection->addField($field);

        $field = new ExtendedInputField('alias_limit');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $leftSection->addField($field);

        $loginLink = new Text('login_link');
        $loginLink->setDescription('description');
        $leftSection->addField($loginLink);

        $field = new Switcher('outlook_connector');
        $field->setDescription('description');
        $leftSection->addField($field);

        $spf = new Text('spf_string');
        $spf->setDescription('description');
        $leftSection->addField($spf);

        return $leftSection;
    }

    /**
     * @description right section
     * @return HalfPageSection
     */
    public function getRightSection()
    {
        $right = new HalfPageSection('rightSide');

        $field = new ExtendedInputField('acc_size');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $right->addField($field);

        $field = new ExtendedInputField('domain_alias_limit');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $right->addField($field);

        $field = new ExtendedInputField('dist_list_limit');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $right->addField($field);

        $field = new ExtendedInputField('domainMaxSize');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $right->addField($field);

        $field = new ExtendedInputField('domainBaseSize');
        $field->setFieldType(ExtendedInputField::TYPE_NUMBER);
        $field->addHtmlAttribute('min', Size::UNLIMITED);
        $field->setDescription('description');
        $right->addField($field);

        $dmarc = new Text('dmarc_string');
        $dmarc->setDescription('description');
        $right->addField($dmarc);

        return $right;
    }
}