<?php


namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Admin\Product\Sections;


use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\BoxSection;
use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\HalfPageSection;

class TwiceColumnSection extends BoxSection
{

    /**
     * @var HalfPageSection
     */
    protected $leftSection;
    /**
     * @var HalfPageSection
     */
    protected $rightSection;

    public function initContent()
    {
        $this->leftSection  = new HalfPageSection('leftSection');
        $this->rightSection = new HalfPageSection('rightSection');

        $this->addSection($this->leftSection)
            ->addSection($this->rightSection);
        $this->initFields();
    }

    protected function initFields()
    {

    }

    public function addField($field){
        $total = count($this->leftSection->getFields()) + count($this->rightSection->getFields());
        if($total % 2 == 0){
            $this->leftSection->addField($field);
        }else{
            $this->rightSection->addField($field);
        }
        return $this;
    }
}