<?php

namespace App\ReportsData\EntityFields;

class CorporateOffice extends \App\ReportsData\EntityFields\GeneralAbstract
{

	/**
	 * Returns the table name that will store the current entity queue.
	 * @return string
	 */
	protected function getDbTableName()
	{
		global $DBTRd_corporateOffices;
		return $DBTRd_corporateOffices;
	}


	protected function getCustomValues($fieldName)
	{
		switch ($fieldName) {

			case 'corporate':
				return new Corporate($this->values['idCorporate']);
			case 'country':
				return new Country($this->values['countryCode']);
			case 'city':
				return new City($this->values['cityId']);
			case 'addUser':
				return new User($this->values['idAddUser']);
			case 'updateUser':
				return new User($this->values['idUpdateUser']);
			case 'costCentersList':
				return implode(', ', $this->values['costCenters']);
			default:
				return parent::getCustomValues($fieldName);
		}

	}

	protected function processDefaultValues()
	{
		$this->values['costCenters'] = ($this->values['costCenters'])?json_decode($this->values['costCenters']):[];
		$this->values['processedRemarks'] = ($this->values['processedRemarks'])?json_decode($this->values['processedRemarks'], true):[];
	}
}
