<?php

namespace ModulesGarden\HostingQuotaNotifications\App\UI\TicketTemplates\Forms\EditSubPages;

use ModulesGarden\HostingQuotaNotifications\App\Helper\Models\Admin;
use ModulesGarden\HostingQuotaNotifications\App\UI\Validators\NotEmptyWithTrim;
use ModulesGarden\HostingQuotaNotifications\App\UI\Validators\TicketTemplateExist;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\Forms\Fields;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\Forms\Sections;
use \ModulesGarden\HostingQuotaNotifications\App\Libs\TicketTemplates\Manage;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\Forms\Fields\Text;
use \ModulesGarden\HostingQuotaNotifications\Core\UI\Widget\Forms\Fields\Select;
use \ModulesGarden\HostingQuotaNotifications\App\Helper\Models\TicketDepartment;

/**
 * Description of ConfigurationForm
 *
 * @author Artur Pilch <artur.pi@modulesgarden.com>
 */
class ConfigurationForm
{
    private $section;

    public function __construct($section = false)
    {
        $this->section = new Sections\BaseSection();
        $this->section->setId('configurationSection');
    }

    public function initFields()
    {
//        echo '<pre>';
//        print_r(Admin::getAdminsAsKeyIdNameValue());
//        die;
        $field = (new Text('name'))->addValidator(new NotEmptyWithTrim())->addValidator(new TicketTemplateExist());
        $this->section->addField($field);

        $field = new Select('department_id');
        $field->notEmpty();
        $field->setAvalibleValues(TicketDepartment::getDepartmentsIDkeyNAMEvalue());
        $this->section->addField($field);


        $field = new Select('admin_id');
        $field->notEmpty();
        $field->setAvalibleValues(Admin::getAdminsAsKeyIdNameValue());
        $this->section->addField($field);

        return $this->section;
    }
}
