<?php

namespace App\Reports\Sources\OrderServices;

class PopulateQuickColumns extends \App\Reports\Sources\PopulateAbstract
{

	public function populate() :void
	{

		// INITS ----------------------------------------------------------------------------------
		global $DBTRd_users, $DBTRd_offices, $DBTRd_departments, $DBTRd_customers, $DBTRd_corporates, $DBTRd_trusts;
		global $DBTRd_corporateSegments, $DBTRd_customerSegments, $DBTRd_contactPersons;
		global $DBTRd_stations, $DBTRd_autoProcessRules, $DBTRd_miceProjects, $DBTRd_docSeries;
		global $DBTRd_clientInvoiceCashings, $DBTRd_countries, $DBTRd_cities, $DBTRd_stations;
		global $DBTRd_activityDomains, $DBTRd_activityDomainCategories;

		$reportTable = $this->tableManager->getTableName();

		$activeColumns = array_keys( $this->columnsManager->getStdColumns() );

		$_LANG = \App\Loader_Lang::getInstance()->getGlobal();

		// SERVICE DATA ///////////////////////////////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateServiceDetails', 0);

		// update the service package fin name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("serv_packageServFinStatusName", "serv_packageServFinStatusCode", (Array)$_LANG['reservationServices']['statusFinName']);
		$reportCopyInfo->populate();

		// CORPORATE ACTIVITY DOMAIN / CATEGORY NAMES ///////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateCorporateActivityDomain', 0);
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_activityDomains, 'inv_corporateDomainName', 'inv_corporateDomainId', 'name');

		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateCorporateActivityDomainCategory', 0);
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_activityDomainCategories, 'inv_corporateDomainCategoryName', 'inv_corporateDomainCategoryId', 'name');

		// update the service cancel reason name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("serv_cancelReasonName", "serv_cancelReasonCode", (Array)$_LANG['serviceCancelReason']);
		$reportCopyInfo->populate();

		// update the service responsible user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'serv_userName', 'serv_userId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the service responsible user office name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_offices, 'serv_userOfficeName', 'serv_userOfficeId', 'name');

		// update the service responsible user department name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_departments, 'serv_userDeptName', 'serv_userDeptId', 'name');

		// update the service add user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'serv_addUserName', 'serv_addUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the service update user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'serv_updateUserName', 'serv_updateUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// service cost center name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("serv_agencyCostCenterName", "serv_agencyCostCenterCode", \App\Config\AgencyCostCenters::getInstance()->getListActive());
		$reportCopyInfo->populate();

		// update the AP rule name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_autoProcessRules, 'serv_autoProcessRuleName', 'serv_autoProcessRuleId', "name");

		// update the service status op name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("serv_statusOpName", "serv_statusOpCode", (Array)$_LANG['reservationServices']['statusOpName']);
		$reportCopyInfo->populate();

		// update the service status fin name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("serv_statusFinName", "serv_statusFinCode", (Array)$_LANG['reservationServices']['statusFinName']);
		$reportCopyInfo->populate();

		// ORDER DATA /////////////////////////////////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateOrderDetails', 0);

		// update the order add user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'ord_addUserName', 'ord_addUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the order update user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'ord_updateUserName', 'ord_updateUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the order contact person name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_contactPersons, 'ord_contactPersonName', 'ord_contactPersonId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the order mice project name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_miceProjects, 'ord_miceProjectName', 'ord_miceProjectId', 'name');

		// update the order responsible user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'ord_userName', 'ord_userId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the order reponsible department name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_departments, 'ord_deptName', 'ord_deptId', 'name');

		// update the order reponsible office name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_offices, 'ord_officeName', 'ord_officeId', 'name');

		// update the order type
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn('ord_typeName',  "ord_typeCode", \App\Config\OrderTypes::getInstance()->getAll());
		$reportCopyInfo->populate();

		// update the order flag
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn('ord_flagName',  "ord_flagCode", \App\Config\OrderFlags::getInstance()->getAll());
		$reportCopyInfo->populate();

		// update the order services type
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn('ord_servicesTypeName',  "ord_servicesTypeCode", \App\Config\OrderServicesTypes::getInstance()->getAll());
		$reportCopyInfo->populate();

		// update the order status op name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("ord_statusOpName", "ord_statusOpCode", (Array)$_LANG['reservations']['statusOpName']);
		$reportCopyInfo->populate();

		// update the order status fin name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("ord_statusFinName", "ord_statusFinCode", (Array)$_LANG['reservations']['statusFinName']);
		$reportCopyInfo->populate();

		// OFFER DATA /////////////////////////////////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateOfferDetails', 0);

		// update the offer add user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'off_addUserName', 'off_addUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the offer service name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("off_serviceName", "off_serviceCode", \App\Config\Services_Basic::getInstance()->getListLinearSimple());
		$reportCopyInfo->populate();

		// update offer type name
		if (in_array('off_typeName', $activeColumns)) {

			$langFromCfg = \App\Config\Services_OfferTypes::getInstance()->getAll();

			foreach ($langFromCfg as $serviceCode=>$offerTypeList) {
				$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
				$reportCopyInfo->addCaseStructureColumn("off_typeName",   "off_typeCode",   $offerTypeList);
				$reportCopyInfo->addFilter("rep.serv_serviceCode", "=", $serviceCode);
				$reportCopyInfo->populate();
			}
		}

		// INVOICE DATA ///////////////////////////////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateInvoiceDetails', 0);

		// update the invoice series code
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_docSeries, 'inv_seriesCode', 'inv_seriesId', 'code');

		// update the AP rule name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_autoProcessRules, 'inv_autoProcessRuleName', 'inv_autoProcessRuleId', "name");

		// update the invoice responsible user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'inv_respUserName', 'inv_respUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the invoice reponsible office name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_offices, 'inv_respOfficeName', 'inv_respOfficeId', 'name');

		// update the invoice add user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'inv_addUserName', 'inv_addUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the invoice issue user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'inv_issueUserName', 'inv_issueUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the last cashing doc id
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addStructureColumn("inv_lastCashingDocId", "(SELECT id FROM `".$DBTRd_clientInvoiceCashings."` WHERE rep.inv_id = idInvoice ORDER BY id DESC LIMIT 1)", "rep");
		$reportCopyInfo->populate();

		// update the last cashing doc number
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addStructureColumn("inv_lastCashingDocNumber", "(SELECT docNumber FROM `".$DBTRd_clientInvoiceCashings."` WHERE rep.inv_id = idInvoice ORDER BY id DESC LIMIT 1)", "rep");
		$reportCopyInfo->populate();

		// update the last cashing document type
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addStructureColumn("inv_lastCashingDocTypeCode", "(SELECT docType FROM `".$DBTRd_clientInvoiceCashings."` WHERE rep.inv_id = idInvoice ORDER BY id DESC LIMIT 1)", "rep");
		$reportCopyInfo->populate();

		// update the document doc type name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("inv_lastCashingDocTypeName", "inv_lastCashingDocTypeCode", \App\Config\CashingDocuments::getInstance()->getList());
		$reportCopyInfo->populate();

		// BALANCE DATA ///////////////////////////////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateBalanceDetails', 0);

		// update the balance responsible user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'bal_respUserName', 'bal_respUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the balance reponsible office name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_offices, 'bal_respOfficeName', 'bal_respOfficeId', 'name');

		// update the balance add user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'bal_addUserName', 'bal_addUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update the balance confirmation user name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_users, 'bal_confUserName', 'bal_confUserId', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)");

		// update balance type name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("bal_typeName",   "bal_typeCode",   (Array)$_LANG['invoiceBalance']['type']);
		$reportCopyInfo->populate();

		// update balance status name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn("bal_statusName", "bal_statusCode", (Array)$_LANG['invoiceBalance']['status']);
		$reportCopyInfo->populate();


		// ADD CUSTOMER / CORPORATE DATA //////////////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateClientDetails', 0);
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addJoinTable($DBTRd_corporates,        'corp',        'rep.inv_corporateId=corp.id', 'LEFT');
		$reportCopyInfo->addJoinTable($DBTRd_customers,         'cust',        'rep.inv_customerId=cust.id', 'LEFT');
		$reportCopyInfo->addJoinTable($DBTRd_trusts,            'trust',       'corp.idTrust=trust.id', 'LEFT');
		$reportCopyInfo->addJoinTable($DBTRd_corporateSegments, 'corpSeg',     'corp.idSegment=corpSeg.id', 'LEFT');
		$reportCopyInfo->addJoinTable($DBTRd_customerSegments,  'custSeg',     'cust.idSegment=custSeg.id', 'LEFT');
		$reportCopyInfo->addJoinTable($DBTRd_users, 			'kamUser',     'corp.idAccountManager=kamUser.id', 'LEFT');

		$cols = [
			'inv_corporateAlias'					=> 'corp.alias',
			'inv_corporateTrustId'					=> 'corp.idTrust',
			'inv_corporateTrustName'				=> 'trust.name',
			'inv_corporateSegmentId'				=> 'corp.idSegment',
			'inv_corporateSegmentName'				=> 'corpSeg.name',
			'inv_corporateKamId'					=> 'corp.idAccountManager',
			'inv_corporateProcessedRemarks'			=> 'corp.processedRemarks',

			'inv_customerSegmentId'					=> 'cust.idSegment',
			'inv_customerSegmentName'				=> 'custSeg.name',
			'inv_customerCountryCode'				=> 'cust.countryCode',
			'inv_customerCityId'					=> 'cust.cityId',
		];

		$reportCopyInfo->setStructureColumns($cols);
		$reportCopyInfo->addStructureColumn("inv_corporateCompanyName", "TRIM(CONCAT(corp.companyNameStd, ' ', corp.companySuffixStd))", "corp");
		$reportCopyInfo->addStructureColumn("inv_corporateKamName", 	"CONCAT(kamUser.lastName, ' ', kamUser.firstName)", "kamUser");
		$reportCopyInfo->addStructureColumn("inv_customerName", 		"CONCAT(cust.lastNameStd, ' ', cust.firstNameStd)", "cust");
		$reportCopyInfo->addStructureColumn("inv_clientId", 			"IF(rep.inv_corporateId, rep.inv_corporateId, rep.inv_customerId)", "rep");
		$reportCopyInfo->addStructureColumn("inv_clientName", 			"IF(rep.inv_corporateId, corp.alias, CONCAT(cust.lastNameStd, ' ', cust.firstNameStd))", "rep");
		$reportCopyInfo->addStructureColumn("inv_clientTypeCode", 		"IF(rep.inv_corporateId, corp.type, IF(rep.inv_customerId, 'DC', ''))", "corp");
		$reportCopyInfo->addStructureColumn("inv_clientCountryCode", 	"IF(rep.inv_corporateId, rep.inv_corporateSelOfficeCountryCode, cust.countryCode)", "cust");
		$reportCopyInfo->addStructureColumn("inv_clientCityId", 		"IF(rep.inv_corporateId, rep.inv_corporateSelOfficeCityId, cust.cityId)", "cust");

		$reportCopyInfo->populate();

		// update the invoice client type name
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addCaseStructureColumn('inv_clientTypeName',  "inv_clientTypeCode", (Array)$_LANG['generalData']['clientType']);
		$reportCopyInfo->populate();

		// ADD LEGAL ENTITY COUNTRY AND CITY NAMES ////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'countryAndCityCorporate', 0);

		// update invoice corporate country
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_countries, 'inv_corporateSelOfficeCountryName', 'inv_corporateSelOfficeCountryCode', 'nameStd', 'code');

		// update invoice corporate city
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_cities, 'inv_corporateSelOfficeCityName', 'inv_corporateSelOfficeCityId', "nameStd");

		// ADD INDIVIDUAL COUNTRY AND CITY NAMES /////////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'countryAndCityCustomer', 0);

		// update invoice customer country
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_countries, 'inv_customerCountryName', 'inv_customerCountryCode', 'nameStd', 'code');

		// update invoice customer city
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_cities, 'inv_customerCityName', 'inv_customerCityId', "nameStd");

		// ADD UNIFIED CLIENT COUNTRY AND CITY NAMES //////////////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'countryAndCityClient', 0);

		// update invoice client country
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_countries, 'inv_clientCountryName', 'inv_clientCountryCode', 'nameStd', 'code');

		// update invoice client city
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_cities, 'inv_clientCityName', 'inv_clientCityId', "nameStd");

		// ADD OFFER DEPARTURE CITY, COUNTRY & STATION DETAILS ////////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'departureLocationDetails', 0);
		// update offer departure country code and zone
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addJoinTable($DBTRd_countries,  'countries',   'rep.off_deptCountryCode=countries.code');
		$reportCopyInfo->setStructureColumns([
			'off_deptCountryName' => 	'countries.nameStd',
			'off_deptCountryZone' => 	'countries.zone',
		]);
		$reportCopyInfo->populate();

		// update offer departure city name, district and region
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addJoinTable($DBTRd_cities,     'cities',   	  'rep.off_deptCityId=cities.id');
		$reportCopyInfo->setStructureColumns([
			'off_deptCityName' => 		'cities.nameStd',
			'off_deptCityDistrict' => 	'cities.districtStd',
			'off_deptCityRegion' => 	'cities.regionStd',
		]);
		$reportCopyInfo->populate();

		// update offer departure station
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_stations, 'off_deptStationName', 'off_deptStationCode', 'nameStd', 'code');

		// ADD OFFER DESTINATION CITY, COUNTRY & STATION DETAILS //////////////////////////////////////////
		$this->reportGenerationStatusUpdate('extractMainDataFromDb', 'destinationLocationDetails', 0);
		// update offer destination country code and zone
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addJoinTable($DBTRd_countries,  'countries',   'rep.off_destCountryCode=countries.code');
		$reportCopyInfo->setStructureColumns([
			'off_destCountryName' => 	'countries.nameStd',
			'off_destCountryZone' => 	'countries.zone',
		]);
		$reportCopyInfo->populate();

		// update offer destination city name, district and region
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns);
		$reportCopyInfo->addJoinTable($DBTRd_cities,     'cities',   	  'rep.off_destCityId=cities.id');
		$reportCopyInfo->setStructureColumns([
			'off_destCityName' => 		'cities.nameStd',
			'off_destCityDistrict' => 	'cities.districtStd',
			'off_destCityRegion' => 	'cities.regionStd',
		]);
		$reportCopyInfo->populate();

		// update offer destination station
		$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns);
		$reportCopyInfo->populateSimple($DBTRd_stations, 'off_destStationName', 'off_destStationCode', 'nameStd', 'code');




	}

}

