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

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 28.08.19
 * Time: 09:15
 * Class ZimbraSettingsSection
 */
class ZimbraSettings extends BoxSectionExtended implements AdminArea
{
    protected $id       = 'zimbraSettings';
    protected $name     = 'zimbraSettings';
    protected $title    = 'zimbraSettings';

    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);

        $field = new Select('cos_name');
        $field->addHtmlAttribute('onChange','hiddeSections(event)');
        $field->setDescription('description');
        $leftSection->addField($field);

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

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

        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);

        return $right;
    }
}