<?php
 namespace App\Reports\Sources\OrdersList; class PopulateInitialImport extends \App\Reports\Sources\PopulateAbstract { public function populate() :void { global $DBTRd_orders, $DBTRd_customers, $DBTRd_corporates, $DBTRd_corporateOffices; $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_orders, 'ord'); $reportCopyInfo->addJoinTable($DBTRd_customers, 'ownCust', 'ord.idCustomerOwner=ownCust.id', 'LEFT'); $reportCopyInfo->addJoinTable($DBTRd_corporates, 'ownCorp', 'ord.idCorporateOwner=ownCorp.id', 'LEFT'); $reportCopyInfo->addJoinTable($DBTRd_corporateOffices, 'ownCorpOffice', 'ord.idCorporateOwnerOffice=ownCorpOffice.id', 'LEFT'); $cols = [ 'ord_id' => 'ord.id', 'ord_convertedId' => 'ord.convertedId', 'ord_number' => 'ord.orderNumber', 'ord_code' => 'ord.orderCode', 'ord_idAutoProcessRule' => 'ord.idAutoProcessRule', 'ord_typeCode' => 'ord.orderType', 'ord_flagCode' => 'ord.flag', 'ord_servicesTypeCode' => 'ord.servicesType', 'ord_date' => 'ord.date', 'ord_startDate' => 'ord.startDate', 'ord_endDate' => 'ord.endDate', 'ord_ownerCustomerId' => 'ord.idCustomerOwner', 'ord_ownerCustomerProcessedRemarks' => 'ownCust.processedRemarks', 'ord_pax' => 'ord.pax', 'ord_ownerCorporateId' => 'ord.idCorporateOwner', 'ord_ownerCorporateAlias' => 'ownCorp.alias', 'ord_ownerCorporateProcessedRemarks' => 'ownCorp.processedRemarks', 'ord_ownerCorporateOfficeId' => 'ord.idCorporateOwnerOffice', 'ord_ownerCorporateOfficeName' => 'ownCorpOffice.name', 'ord_ownerCorporateOfficeCostCenter' => 'ord.corporateOwnerOfficeCostCenter', 'ord_contactPersonId' => 'ord.idContactPerson', 'ord_description' => 'ord.description', 'ord_comments' => 'ord.comments', 'ord_notes' => 'ord.notes', 'ord_statusOpCode' => 'ord.statusOp', 'ord_statusFinCode' => 'ord.statusFin', 'ord_miceProjectId' => 'ord.idMiceProject', 'ord_genDocsAssoc' => 'ord.genDocsAssoc', 'ord_addTime' => 'ord.addTime', 'ord_lastUpdateTime' => 'ord.lastUpdateTime', 'ord_updatesCount' => 'ord.updatesCount', 'ord_userId' => 'ord.idUser', 'ord_deptId' => 'ord.idDepartment', 'ord_officeId' => 'ord.idOffice', 'ord_addUserId' => 'ord.idAddUser', 'ord_updateUserId' => 'ord.idUpdateUser', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->addStructureColumn("ord_dateYM", "DATE_FORMAT(ord.date, '%Y-%m-01')", "ord"); $reportCopyInfo->addStructureColumn("ord_dateY", "YEAR(ord.date)", "ord"); $reportCopyInfo->addStructureColumn("ord_startDateYM", "DATE_FORMAT(ord.startDate, '%Y-%m-01')", "ord"); $reportCopyInfo->addStructureColumn("ord_startDateY", "YEAR(ord.startDate)", "ord"); $reportCopyInfo->addStructureColumn("ord_endDateYM", "DATE_FORMAT(ord.endDate, '%Y-%m-01')", "ord"); $reportCopyInfo->addStructureColumn("ord_endDateY", "YEAR(ord.endDate)", "ord"); $reportCopyInfo->addStructureColumn("ord_ownerCustomerName", "CONCAT(ownCust.lastNameStd, ' ', ownCust.firstNameStd)", "ownCust"); $reportCopyInfo->setActiveColumns($activeColumns); if ($stdFilters['orderDate']['start']) { $reportCopyInfo->addFilter('ord.date', '>=', $stdFilters['orderDate']['start']); } if ($stdFilters['orderDate']['end']) { $reportCopyInfo->addFilter('ord.date', '<=', $stdFilters['orderDate']['end']); } if ($stdFilters['orderStartDate']['start']) { $reportCopyInfo->addFilter('ord.startDate', '>=', $stdFilters['orderStartDate']['start']); } if ($stdFilters['orderStartDate']['end']) { $reportCopyInfo->addFilter('ord.startDate', '<=', $stdFilters['orderStartDate']['end']); } if ($stdFilters['orderEndDate']['start']) { $reportCopyInfo->addFilter('ord.endDate', '>=', $stdFilters['orderEndDate']['start']); } if ($stdFilters['orderEndDate']['end']) { $reportCopyInfo->addFilter('ord.endDate', '<=', $stdFilters['orderEndDate']['end']); } if ($stdFilters['idMiceProjects']) { $reportCopyInfo->addFilter('ord.idMiceProject', 'IN', $stdFilters['idMiceProjects']); } if ($stdFilters['orderStatusOp'] and count($stdFilters['orderStatusOp']) < 4) { $reportCopyInfo->addFilter('ord.statusOp', 'IN', $stdFilters['orderStatusOp']); } if ($stdFilters['orderStatusFin'] and count($stdFilters['orderStatusFin']) < 3) { $reportCopyInfo->addFilter('ord.statusFin', 'IN', $stdFilters['orderStatusFin']); } $reportCopyInfo->populate(); } } 