<?php

namespace ModulesGarden\Servers\OpenXchange\App\UI\Admin\ProductConfiguration\Helper;

use ModulesGarden\Servers\OpenXchange\App\Service\ConfigurableOptions\ConfigurableOptions;
use ModulesGarden\Servers\OpenXchange\App\Service\ConfigurableOptions\Helper\TypeConstans;
use ModulesGarden\Servers\OpenXchange\App\Service\ConfigurableOptions\Models\Option;
use ModulesGarden\Servers\OpenXchange\App\Service\ConfigurableOptions\Models\SubOption;

class ConfigurableOptionsBuilder
{

    public static function build(ConfigurableOptions $configurableOptions, $fieldsStatus = [])
    {
        foreach ($fieldsStatus as $key => $field)
        {
            if ($field == "on")
            {
                $configurableOptions->addOption(self::$key());
            }
        }
        return $configurableOptions;
    }

    public static function buildAll(ConfigurableOptions $configurableOptions)
    {
        $configurableOptions
                ->addOption(self::acc_limit())
                ->addOption(self::acc_limit_productivity())
                ->addOption(self::acc_limit_secure())
                ->addOption(self::acc_limit_productivity_secure())
                ->addOption(self::acc_limit_guard())
                ->addOption(self::acc_limit_ai())
                ->addOption(self::alias_limit())
                ->addOption(self::forwarding_alias_limit())
                ->addOption(self::max_quota())
                ->addOption(self::allow_to_change_password());

        return $configurableOptions;
    }

    private static function acc_limit()
    {
        $option  = new Option('acc_limit', 'Email Accounts For Selected Product', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Account'));
        return $option;
    }

    private static function acc_limit_productivity()
    {
        $option  = new Option('acc_limit_productivity', 'Email Accounts Limit Productivity', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Account (Productivity)'));
        return $option;
    }

    private static function acc_limit_secure()
    {
        $option  = new Option('acc_limit_secure', 'Email Accounts Limit Secure', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Account (Secure)'));
        return $option;
    }

    private static function acc_limit_productivity_secure()
    {
        $option  = new Option('acc_limit_productivity_secure', 'Email Accounts Limit Productivity-Secure', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Account (Productivity-Secure)'));
        return $option;
    }
    
    private static function acc_limit_guard()
    {
        $option  = new Option('acc_limit_guard', 'Email Accounts Limit Guard', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Account (Guard)'));
        return $option;
    }
    
    private static function acc_limit_ai()
    {
        $option  = new Option('acc_limit_ai', 'Email Accounts Limit AI', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Account (AI)'));
        return $option;
    }

    private static function alias_limit()
    {
        $option  = new Option('alias_limit', 'Email Aliases Limit', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Email Alias'));
        return $option;
    }

    private static function forwarding_alias_limit()
    {
        $option  = new Option('forwarding_alias_limit', 'Forwarding Aliases Limit', TypeConstans::QUANTITY);
        $option->addSubOption(new SubOption('1', 'Forwarding Alias'));
        return $option;
    }

    private static function max_quota()
    {
        $option  = new Option('max_quota', 'Pool Quota (overall Quota for all Mailboxes)', TypeConstans::DROPDOWN);
        $option->addSubOption(new SubOption('1000', '1000 MB'));
        return $option;
    }
    
     private static function allow_to_change_password()
    {
        $option  = new Option('allow_to_change_password', 'Allow To Change Password', TypeConstans::CHECKBOX);
        $option->addSubOption(new SubOption('1', 'Yes'));
        return $option;
    }
}
