<?php

namespace App\ReportsData\EntityFields;

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

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

	/**
	 * {@inheritDoc}
	 * @see \App\ReportsData\EntityFields\GeneralAbstract::getCustomValues()
	 */
	protected function getCustomValues($fieldName)
	{
		switch ($fieldName) {
			case 'fullName':
				$this->values[$fieldName] = trim($this->values['firstName'].' '.$this->values['lastName']);
				return $this->values[$fieldName];

			case 'corporate':
				return new Corporate($this->values['idCorporate']);
			case 'corporateOffice':
				return new CorporateOffice($this->values['idCorporateOffice']);
			case 'supplier':
				return new Supplier($this->values['idSupplier']);

			case 'addUser':
				return new User($this->values['idAddUser']);
			case 'updateUser':
				return new User($this->values['idUpdateUser']);

			default:
				return parent::getCustomValues($fieldName);
		}

	}

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