<?php
 namespace App\Reports\Sources\UsersAccess; class PopulateInitialImport extends \App\Reports\Sources\PopulateAbstract { public function populate() :void { global $DBTUsers, $DBTUsersAccess, $DBTUsersProfilesAccess; $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($DBTUsers, 'user'); $reportCopyInfo->addJoinTable($DBTUsersAccess, 'access', 'access.idUser = user.id'); $cols = [ 'idUser' => 'user.id', 'firstName' => 'user.firstName', 'lastName' => 'user.lastName', 'userProcessedRemarks' => 'user.processedRemarks', 'idOffice' => 'user.idOffice', 'idDepartment' => 'user.idDepartment', 'idProfile' => 'user.idUsersAccessProfile', 'idSection' => 'access.idSection', 'type' => 'access.type', 'optionValue' => 'access.optionValue', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->addStructureColumn("id", "CONCAT(user.id, '|', access.idSection)", "access"); $reportCopyInfo->setActiveColumns($activeColumns); if ($stdFilters['users']) { $reportCopyInfo->addFilter('user.id', 'IN', $stdFilters['users']); } $reportCopyInfo->addFilter('user.idUsersAccessProfile', '=', 0); $reportCopyInfo->addFilter('user.deleted', '=', 0); $reportCopyInfo->populate(); $reportCopyInfo = new \App\Reports\Db\ManageRecords\Insert($reportTable); $reportCopyInfo->setMainTable($DBTUsers, 'user'); $reportCopyInfo->addJoinTable($DBTUsersProfilesAccess, 'profile', 'profile.idProfile = user.idUsersAccessProfile'); $cols = [ 'idUser' => 'user.id', 'firstName' => 'user.firstName', 'lastName' => 'user.lastName', 'userProcessedRemarks' => 'user.processedRemarks', 'idOffice' => 'user.idOffice', 'idDepartment' => 'user.idDepartment', 'idProfile' => 'user.idUsersAccessProfile', 'idSection' => 'profile.idSection', 'type' => 'profile.type', 'optionValue' => 'profile.optionValue', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->addStructureColumn("id", "CONCAT(user.id, '|', profile.idSection)", "profile"); $reportCopyInfo->setActiveColumns($activeColumns); if ($stdFilters['users']) { $reportCopyInfo->addFilter('user.id', 'IN', $stdFilters['users']); } $reportCopyInfo->addFilter('user.idUsersAccessProfile', '>', 0); $reportCopyInfo->addFilter('user.deleted', '=', 0); $reportCopyInfo->populate(); } } 