<?php

namespace App\ReportsData\Populate\Entity;

class CorporateContact extends \App\ReportsData\Populate\GeneralAbstract
{
	/**
	 * Returns the table name that will store the current entity queue.
	 * @return string
	 */
	protected function getDbTableName()
	{
		global $DBTRd_corporateContacts;
		return $DBTRd_corporateContacts;
	}


	/**
	 * {@inheritDoc}
	 * @see \App\ReportsData\Populate\GeneralAbstract::getEntityFields()
	 */
	protected function getEntityFields()
	{

		// get current entity details
		$entity = \Entity\CorporateContact::select($this->id);

		// for non existing rows - return null
		if (!$entity->recordExists()) {
			return null;
		}

		// populate the entity details
		$return = [
			'id'				=> $this->id,
			'deleted'			=> $entity->deleted,
			'idCorporate'		=> $entity->idCorporate,
			'contactType'		=> $entity->contactType,
			'contactDatetime'	=> $entity->contactDatetime,
			'duration'			=> $entity->duration,
			'topics'			=> $entity->topics,
			'description'		=> $entity->description,
			'comments'			=> $entity->comments,
			'idContactPerson'	=> $entity->idContactPerson,
			'idUser'			=> $entity->idUser,
			'idAddUser'			=> $entity->idAddUser,
			'addTime'			=>\Engine\DateTime::createFromTimestamp($entity->addTime)->formatDatetimeIso(),
			'idUpdateUser'		=> $entity->idUpdateUser,
			'lastUpdateTime'	=> ($entity->lastUpdateTime ? \Engine\DateTime::createFromTimestamp($entity->lastUpdateTime)->formatDatetimeIso() : null),
			'updatesCount'		=> $entity->updatesCount,
		];

		return $return;
	}



}
