<?php
namespace Modules\RemoteData\InfoBox;

class View_MiceProject extends \App\Mvc\View_RemoteDataInfoBoxEntityAbstract
{
	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\View_RemoteDataInfoBoxEntityAbstract::getEntityRemoteDetails()
	 */
	protected function getEntityRemoteDetails(\App\Entity\SelectAbstract $entity)
	{
		// the output object
		$output = \Engine\RemoteData\InfoBox\Container_Main::create(sprintf($this->lang['miceProject']['title'], $entity->name))
			->setShortTitle($entity->name)
			->setId(sprintf("%s.%s", __CLASS__, $entity->getId()));


		// BASIC INFO -----------------------------------------------------------------------------
		$cont1 = \Engine\RemoteData\InfoBox\Container_Simple::create($this->lang['general']['titles']['general']);
		$output->addContainer($cont1);

		$cont1->addField( \Engine\RemoteData\InfoBox\Field_String::create($this->lang['general']['fields']['id'], $entity->getId()) );
		$cont1->addField( \Engine\RemoteData\InfoBox\Field_String::create($this->lang['general']['fields']['name'], $entity->name) );
		$cont1->addField( \Engine\RemoteData\InfoBox\Field_String::create($this->lang['general']['fields']['code'], $entity->code) );
		$cont1->addField( \Engine\RemoteData\InfoBox\Field_Boolean::create($this->lang['miceProject']['fields']['closed'], (Bool)$entity->closed) );


		$cont2 = \Engine\RemoteData\InfoBox\Container_Simple::create($this->lang['miceProject']['titles']['reservationList'])->setHidden(true);
		$output->addContainer($cont2);
		foreach ($entity->idOrders as $idOrder) {
			$cont2->addField( \App\RemoteData\InfoBox\Field_EntityInfoBox::create(null, \Entity\Order::select($idOrder)->convertedId)->setEntity('order', $idOrder) );
		}

		// MISC DETAILS ---------------------------------------------------------------------------
		$cont4 = \Engine\RemoteData\InfoBox\Container_Simple::create($this->lang['general']['titles']['misc'])->setHidden(true);
		$output->addContainer($cont4);

		$cont4->addField( \Engine\RemoteData\InfoBox\Field_MultiLine::create($this->lang['general']['fields']['comments'], $entity->comments) );
		$cont4->addField( \Engine\RemoteData\InfoBox\Field_Remarks::create($this->lang['general']['fields']['remarks'], $entity->remarks) );

		// PROCESSED REMARKS
		$cRmk = \Engine\RemoteData\InfoBox\Container_ProcessedRemarks::create($this->lang['general']['fields']['processedRemarks'])->setHidden(true);
		$cRmk->addRemarkFields('miceProject', $entity->processedRemarks);
		$output->addContainer($cRmk);


		// ADD/EDIT DETAILS -----------------------------------------------------------------------
		$cont5 = \Engine\RemoteData\InfoBox\Container_Simple::create($this->lang['general']['titles']['updates'])->setHidden(true);
		$output->addContainer($cont5);

		$cont5->addField( \App\RemoteData\InfoBox\Field_EntityInfoBox::create($this->lang['general']['fields']['addUser'],\Entity\User::select($entity->idAddUser)->name)->setEntity('user', $entity->idAddUser) );
		$cont5->addField( \Engine\RemoteData\InfoBox\Field_DateTime::create($this->lang['general']['fields']['addTime'], \Engine\DateTime::createFromIsoDatetime($entity->addTime)) );
		$cont5->addField( \App\RemoteData\InfoBox\Field_EntityInfoBox::create($this->lang['general']['fields']['updateUser'],\Entity\User::select($entity->idUpdateUser)->name)->setEntity('user', $entity->idUpdateUser) );
		$cont5->addField( \Engine\RemoteData\InfoBox\Field_DateTime::create($this->lang['general']['fields']['updateTime'], \Engine\DateTime::createFromIsoDatetime($entity->lastUpdateTime)) );
		if ($entity->updatesCount) {
			$cont5->addField( \Engine\RemoteData\InfoBox\Field_String::create($this->lang['general']['fields']['updatesCount'], $entity->updatesCount) );
		}

		return $output;

	}
}