<?php
 namespace App\Reports\Sources\SupplierContactPersons; class PopulateInitialImport extends \App\Reports\Sources\PopulateAbstract { public function populate() :void { global $DBTRd_contactPersons, $DBTRd_users, $DBTRd_suppliers; $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_suppliers, 'supp', 'supp.id=contact.idSupplier'); $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', 'supp_idOriginal' => 'contact.idSupplier', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->addStructureColumn("supp_id", "IF(supp.idRealSupplier, supp.idRealSupplier, supp.id)", "supp"); $reportCopyInfo->addStructureColumn("supp_duplicated", "IF(supp.idRealSupplier, 1, 0)", "supp"); $reportCopyInfo->addStructureColumn("contact_addUserName", "CONCAT(addUser.lastName, ' ', addUser.firstName)", 'addUser'); $reportCopyInfo->setActiveColumns($activeColumns); $reportCopyInfo->addFilter('contact.type', '=', 'supplier'); $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']); } elseif ($stdFilters['idAddOffices']) { $reportCopyInfo->addFilter('addUser.idOffice' , 'IN', $stdFilters['idAddOffices']); } if ($stdFilters['idSuppliers']) { $reportCopyInfo->addFilter('contact.idSupplier', 'IN', $this->filtersManager->getDuplicateEntitiesGroup('idSuppliers')); } $reportCopyInfo->populate(); } } 