<?php

namespace ThurData\Servers\KerioEmail\App\UI\Client\Setting\Sections;

use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Info;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Switcher;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;

/**
 *
 * Created by PhpStorm.
 * User: ThurData
 * Date: 12.11.19
 * Time: 13:52
 * Class EditAdditionalSection
 */
class EditAdditionalSection extends FreeFieldsSection
{
    protected $id   = 'editAdditionalSection';
    protected $name = 'editAdditionalSection';

    use FormExtendedTrait;

    public function initContent()
    {
        $domain = $this->getWhmcsParamByKey('domain');
        $maildomain = $this->getRequestValue('actionElementId');
        if($domain == $maildomain) {
            $dkimsigenabled = new Switcher('dkimsigenabled');
            $this->addField($dkimsigenabled);
            $tfaenabled = new Switcher('tfaenabled');
            $this->addField($tfaenabled);
            $chatenabled = new Switcher('chatenabled');
            $this->addField($chatenabled);
            $this->addField(new Hidden('domainid'));
        } else {
            $infoalias = new Info('infoaliasdomain');
            $infoalias->setId('infoaliasdomain');
            $infoalias->setName('infoaliasdomain');
            $infoalias->setTitle($maildomain);
            $infoalias->setDescription('infoaliasmessage');
            $this->addField($infoalias);
        }
    }

}