<?php
 namespace App\Reports\Sources\Corporates; class PopulateQuickColumns extends \App\Reports\Sources\PopulateAbstract { public function populate() :void { global $DBTRd_corporates, $DBTRd_trusts, $DBTRd_corporateSegments, $DBTRd_users, $DBTRd_offices; global $DBTRd_activityDomains, $DBTRd_activityDomainCategories, $DBTCorporateCreditLimitDetails, $DBTRd_corporateContracts; $reportTable = $this->tableManager->getTableName(); $activeColumns = array_keys( $this->columnsManager->getStdColumns() ); $this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateCorporateDetails', 0); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_corporateSegments, 'corp_segmentName', 'corp_idSegment', 'name'); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_users, 'corp_accountManagerName', 'corp_idAccountManager', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)"); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_users, 'corp_collectionRespName', 'corp_idCollectionResp', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)"); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_users, 'corp_invoiceRespName', 'corp_idInvoiceResp', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)"); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_trusts, 'trust_name', 'trust_id', 'name'); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_activityDomains, 'domain_name', 'domain_id', 'name'); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_activityDomainCategories, 'domainCategory_name', 'domainCategory_id', 'name'); $this->reportGenerationStatusUpdate('extractMainDataFromDb', 'updateCorporateDetails', 50); $reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns); $reportCopyInfo->addJoinTable($DBTRd_corporates, 'realCorp', 'rep.realCorp_id=realCorp.id', 'LEFT'); $cols = [ 'realCorp_alias' => 'realCorp.alias', 'realCorp_companyNameStd' => 'realCorp.companyNameStd', 'realCorp_companyNameLoc' => 'realCorp.companyNameLoc', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->populate(); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_offices, 'corp_addOfficeName', 'corp_addOfficeId', "name"); $reportCopyInfo = new \App\Reports\Db\ManageRecords\UpdateSimple($reportTable, $activeColumns); $reportCopyInfo->populateSimple($DBTRd_users, 'corp_updateUserName', 'corp_idUpdateUser', "CONCAT(joinTable.lastName, ' ', joinTable.firstName)"); $reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns); $reportCopyInfo->addJoinTable($DBTCorporateCreditLimitDetails, 'creditLimits', 'rep.corp_id=creditLimits.idCorporate', 'LEFT'); $reportCopyInfo->addStructureColumn("corp_creditLimitContactIds", "IF(LENGTH(creditLimits.idContactPersons), REPLACE(TRIM(BOTH '|' FROM creditLimits.idContactPersons), '|', ', '),'')", "creditLimits"); $reportCopyInfo->populate(); $reportCopyInfo = new \App\Reports\Db\ManageRecords\Update($reportTable, 'rep', $activeColumns); $reportCopyInfo->addStructureColumn('corp_hasContract', '(SELECT 1 FROM `'.$DBTRd_corporateContracts.'` WHERE rep.corp_id = idCorporate AND deleted=0 LIMIT 1)', 'rep'); $reportCopyInfo->populate(); } } 