<?php
 namespace App\Reports\Sources\CorporateContactPersons; class PopulateInitialImport extends \App\Reports\Sources\PopulateAbstract { public function populate() :void { global $DBTRd_contactPersons, $DBTRd_users, $DBTRd_corporates; $reportTable = $this->tableManager->getTableName(); $activeColumns = array_keys( $this->columnsManager->getStdColumns() ); $stdFilters = $this->filtersManager->getStdFilters(); $this->reportGenerationStatusUpdate('extractMainDataFromDb', 'runningMainSQL', 0); $reportCopyInfo = new \App\Reports\Db\ManageRecords\Insert($reportTable); $reportCopyInfo->setMainTable($DBTRd_contactPersons, 'contact'); $reportCopyInfo->addJoinTable($DBTRd_corporates, 'corp', 'corp.id=contact.idCorporate', 'LEFT'); $reportCopyInfo->addJoinTable($DBTRd_users, 'addUser', 'contact.idAddUser=addUser.id', 'LEFT'); $cols = [ 'contact_id' => 'contact.id', 'contact_titleCode' => 'contact.title', 'contact_firstName' => 'contact.firstName', 'contact_lastName' => 'contact.lastName', 'contact_department' => 'contact.department', 'contact_job' => 'contact.job', 'contact_role' => 'contact.role', 'contact_comments' => 'contact.comments', 'contact_remarks' => 'contact.remarks', 'contact_processedRemarks' => 'contact.processedRemarks', 'contact_birthday' => 'contact.birthday', 'contact_email' => 'contact.email', 'contact_telephone' => 'contact.telephone', 'contact_telephoneMobile' => 'contact.telephoneMobile', 'contact_fax' => 'contact.fax', 'contact_addTime' => 'contact.addTime', 'contact_idAddUser' => 'contact.idAddUser', 'contact_addOfficeId' => 'addUser.idOffice', 'contact_lastUpdateTime' => 'contact.lastUpdateTime', 'contact_idUpdateUser' => 'contact.idUpdateUser', 'contact_updatesCount' => 'contact.updatesCount', 'corp_idOriginal' => 'contact.idCorporate', 'corp_idOffice' => 'contact.idCorporateOffice', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->addStructureColumn("corp_id", "IF(corp.idRealCorporate, corp.idRealCorporate, corp.id)", "corp"); $reportCopyInfo->addStructureColumn("corp_duplicated", "IF(corp.idRealCorporate, 1, 0)", "corp"); $reportCopyInfo->addStructureColumn("contact_addUserName", "CONCAT(addUser.lastName, ' ', addUser.firstName)", 'addUser'); $reportCopyInfo->setActiveColumns($activeColumns); $reportCopyInfo->addFilter('contact.type', '=', 'corporate'); $reportCopyInfo->addFilter('contact.deleted', '=', '0'); if ($stdFilters['addDate']['start']) { $reportCopyInfo->addFilter('contact.addTime', '>=', $stdFilters['addDate']['start']." 00:00:00"); } if ($stdFilters['addDate']['end']) { $reportCopyInfo->addFilter('contact.addTime', '<=', $stdFilters['addDate']['end']." 23:59:59"); } if ($stdFilters['idAddUsers']) { $reportCopyInfo->addFilter('contact.idAddUser' , 'IN', $stdFilters['idAddUsers']); } if ($stdFilters['idAddOffices']) { $reportCopyInfo->addFilter('addUser.idOffice' , 'IN', $stdFilters['idAddOffices']); } if ($stdFilters['idCorporates']) { $reportCopyInfo->addFilter('contact.idCorporate', 'IN', $this->filtersManager->getDuplicateEntitiesGroup('idCorporates')); } $reportCopyInfo->populate(); } } 