<?php
refreshReportStatus('extractMainDataFromDb', 'updateContactDetails', 0);

// update the title name
$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $availableTableColumns);
$reportCopyInfo->addCaseStructureColumn("contact_titleName", "contact_titleCode", (Array)$_LANG['generalData']['personTitles']);
$reportCopyInfo->populate();

// update the office name
$reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $availableTableColumns);
$reportCopyInfo->populateSimple($DBTRd_offices, 'contact_addOfficeName', 'contact_addOfficeId', "name");

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

refreshReportStatus('extractMainDataFromDb', 'updateSupplierDetails', 0);

// update the supplier info
$reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $availableTableColumns);
$reportCopyInfo->addJoinTable($DBTRd_suppliers,       'supp',        'rep.supp_id=supp.id', 	'LEFT');

$cols = [
	'supp_alias'			=> 'supp.alias',
	'supp_companyName'		=> 'supp.companyName',
	'supp_companyPrefix'	=> 'supp.companyPrefix',
	'supp_companySuffix'	=> 'supp.companySuffix',
];
$reportCopyInfo->setStructureColumns($cols);
$reportCopyInfo->addStructureColumn("supp_companyFull", 		"TRIM(CONCAT(supp.companyName, ' ', supp.companySuffix))", "supp");
$reportCopyInfo->populate();

