<?php

namespace App\ReportsData\Populate\Entity;

class SupplierProduct extends \App\ReportsData\Populate\GeneralAbstract
{

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


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

		// get current entity details
		$entity = \Entity\SupplierProduct::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,
			'serviceCode'			=> $entity->serviceCode,
			'category'				=> $entity->category,
			'productName'			=> $entity->productName,
			'chainCode'				=> $entity->chainCode,
			'localization'			=> $entity->localization,
			'address'				=> $entity->address,
			'zipCode'				=> $entity->zipCode,
			'departureCountryCode'	=> $entity->departureCountryCode,
			'departureCityId'		=> $entity->departureCityId,
			'destinationCountryCode'=> $entity->destinationCountryCode,
			'destinationCityId'		=> $entity->destinationCityId,
			'telephone'				=> $entity->telephone,
			'fax'					=> $entity->fax,
			'email'					=> $entity->email,
			'website'				=> $entity->website,
			'comments'				=> $entity->comments,
			'remarks'				=> $entity->remarks,
			'processedRemarks'		=> ( $entity->processedRemarks ? json_encode($entity->processedRemarks) : '' ),
			'idRealSupplierProduct'	=> $entity->idRealSupplierProduct,
			'addTime'				=> \Engine\DateTime::createFromTimestamp($entity->addTime)->formatDatetimeIso(),
			'idAddUser'				=> $entity->idAddUser,
			'lastUpdateTime'		=> ( $entity->lastUpdateTime ? \Engine\DateTime::createFromTimestamp($entity->lastUpdateTime)->formatDatetimeIso() : null ),
			'idUpdateUser'			=> $entity->idUpdateUser,
			'updatesCount'			=> $entity->updatesCount,
		];

		return $return;
	}

}
