<?php
 refreshReportStatus('extractMainDataFromDb', 'runningMainSQL', 0); $reportCopyInfo = new \App\Reports\Db\ManageRecords\Insert($reportTable); $reportCopyInfo->setMainTable($DBTRd_suppliers, 'supp'); $reportCopyInfo->addJoinTable($DBTRd_users, 'addUser', 'supp.idAddUser=addUser.id', 'LEFT'); $cols = [ 'supp_id' => 'supp.id', 'supp_alias' => 'supp.alias', 'supp_companyPrefix' => 'supp.companyPrefix', 'supp_companyName' => 'supp.companyName', 'supp_companySuffix' => 'supp.companySuffix', 'supp_comments' => 'supp.comments', 'supp_remarks' => 'supp.remarks', 'supp_processedRemarks' => 'supp.processedRemarks', 'supp_locked' => 'supp.locked', 'supp_lockedComments' => 'supp.lockedComments', 'supp_iataCode' => 'supp.iataCode', 'supp_tktCode' => 'supp.tktCode', 'trust_id' => 'supp.idTrust', 'supp_address' => 'supp.address', 'supp_deliveryAddress' => 'supp.deliveryAddress', 'supp_countryCode' => 'supp.countryCode', 'supp_cityId' => 'supp.cityId', 'supp_zipCode' => 'supp.zipCode', 'supp_telephone' => 'supp.telephone', 'supp_fax' => 'supp.fax', 'supp_email' => 'supp.email', 'supp_website' => 'supp.website', 'supp_regNo' => 'supp.regNo', 'supp_fiscalCode' => 'supp.fiscalCode', 'supp_accountingNumber' => 'supp.accountingNumber', 'supp_vatRegistered' => 'supp.vatRegistered', 'supp_vatCertificateNumber' => 'supp.vatCertificateNumber', 'realSupp_id' => 'supp.idRealSupplier', 'supp_addTime' => 'supp.addTime', 'supp_idAddUser' => 'supp.idAddUser', 'supp_addOfficeId' => 'addUser.idOffice', 'supp_lastUpdateTime' => 'supp.lastUpdateTime', 'supp_idUpdateUser' => 'supp.idUpdateUser', 'supp_updatesCount' => 'supp.updatesCount', ]; $reportCopyInfo->setStructureColumns($cols); $reportCopyInfo->addStructureColumn("supp_companyFull", "TRIM(CONCAT(supp.companyPrefix, ' ', supp.companyName, ' ', supp.companySuffix))"); $reportCopyInfo->addStructureColumn("supp_duplicated", "IF(supp.idRealSupplier, 1, 0)"); $reportCopyInfo->addStructureColumn("supp_addUserName", "CONCAT(addUser.lastName, ' ', addUser.firstName)", 'addUser'); $reportCopyInfo->setActiveColumns($availableTableColumns); if ($reportFilters['addDate']['startDate']) { $reportCopyInfo->addFilter('supp.addTime', '>=', $reportFilters['addDate']['startDate']." 00:00:00"); } if ($reportFilters['addDate']['endDate']) { $reportCopyInfo->addFilter('supp.addTime', '<=', $reportFilters['addDate']['endDate']." 23:59:59"); } if ($reportFilters['supplierGroups']) { if ($reportExtraFilters['suppliersInGroups']) { $reportCopyInfo->addFilter('supp.id', 'IN', $reportExtraFilters['suppliersInGroups']); } else { $reportCopyInfo->addCustomFilter("0"); } } $reportCopyInfo->addFilter('supp.deleted', '=', 0); $reportCopyInfo->populate(); 