<?php

namespace App\Form\Input;

/**
 * Class used by the Tamara & IBank plugins for now
 * @author Lucian
 */
class ServicesAssociations extends \Engine\Form\Input\GeneralAssociations
{
	public function __construct($label=null, $name=null, $value=null, $possibleValues=null)
	{
		parent::__construct($label, $name, $value);

		$servicesListAssoc = [];
		foreach(\App\Config\Services_Basic::getInstance()->getListGrouped() as $c1=>$serviceDet1) {
			// this is a service
			if ($serviceDet1['type']=='service') {
				$servicesListAssoc[$c1] = $serviceDet1['name'];
			}
			// this is a group
			else {
				foreach($serviceDet1['list'] as $c2=>$serviceDet2) {
					$servicesListAssoc[$c2] = $serviceDet2['name'];
				}
			}
		}
		$this->setAssociationsList($servicesListAssoc);
	}
}
