<?php
 namespace App\AutoProcessRules; class ImportedDocIssue_RecordsList extends RecordsListAbstract { public function getRecords() { $ruleEnt = \Entity\AutoProcessRule::select($this->idRule); $importedDocsListObj = new \App\EntityList\ImportedDocuments(); $this->populateListObject($importedDocsListObj, $ruleEnt); $importedDocsListEx = $importedDocsListObj->exportRecords(); $recordsList = []; foreach($importedDocsListEx as $record) { $recordsList[] = $record['id']; } return $recordsList; } protected function populateListObject(\App\EntityList\ImportedDocuments $importedDocsListObj, \Entity\AutoProcessRule $ruleEnt) { $filters = $this->getFilters(); if ($filters['docCategory']) { $importedDocsListObj->setFilter('importedDocument.docCategory', '=', $filters['docCategory']); } $importedDocsListObj->setFilter('importedDocument.issueTime', 'IS NULL'); $importedDocsListObj->setFilter('importedDocument.systemStatus', '=', 'added'); $importedDocsListObj->setFilter('importedDocument.status', '!=', 'blocked'); if ($filters['docDate']) { $startDate = $filters['docDate']->getStartDate()->getActualDate(); if ($startDate) { $importedDocsListObj->setFilter('importedDocument.docDate', '>=', $startDate); } $endDate = $filters['docDate']->getEndDate()->getActualDate(); if ($endDate) { $importedDocsListObj->setFilter('importedDocument.docDate', '<=', $endDate); } } if ($filters['docAddDate']) { $startDate = $filters['docAddDate']->getStartDate()->getActualDate(); if ($startDate) { $importedDocsListObj->setFilter('importedDocument.addTime', '>=', $startDate.' 00:00:00'); } $endDate = $filters['docAddDate']->getEndDate()->getActualDate(); if ($endDate) { $importedDocsListObj->setFilter('importedDocument.addTime', '<=', $endDate.' 23:59:59'); } } if ($filters['docExternalSystems']) { $importedDocsListObj->setFilter('importedDocument.idExternalSystem', 'IN', $filters['docExternalSystems']); } if ($filters['docCurrencies']) { $importedDocsListObj->setFilter('importedDocument.docCurrency', 'IN', $filters['docCurrencies']); } if ($filters['docType']) { $importedDocsListObj->setFilter('importedDocument.docType', '=', $filters['docType']); } if ($filters['clientType'] == 'corporate') { if ($filters['corporates']) { $importedDocsListObj->setFilter('importedDocument.idCorporate', 'IN', $filters['corporates']); } else { $importedDocsListObj->setFilter('importedDocument.idCorporate', '!=', 0); } if ($filters['corporateGroups']) { $corporateGroupsHelper = new \App\ReportsData\Helpers\PartnerGroups\Corporate(); $corporateGroupsHelper->setGroupElementsLinear($filters['corporateGroups']); $idCorporatesList = $corporateGroupsHelper->getPartnerIdsList(); if ($idCorporatesList) { $importedDocsListObj->setFilter('importedDocument.idCorporate', 'IN', $idCorporatesList); } else { $importedDocsListObj->setCustomFilter('0'); } } } if ($filters['clientType'] == 'customer') { if ($filters['customers']) { $importedDocsListObj->setFilter('importedDocument.idCustomer', 'IN', $filters['customers']); } else { $importedDocsListObj->setFilter('importedDocument.idCustomer', '!=', 0); } } if ($filters['clientType'] == 'supplier') { if ($filters['suppliers']) { $importedDocsListObj->setFilter('importedDocument.idSupplier', 'IN', $filters['suppliers']); } else { $importedDocsListObj->setFilter('importedDocument.idSupplier', '!=', 0); } } $importedDocsListObj->setOrderBy('id', 'ASC'); if ($ruleEnt->recordsCountOnExecution) { $importedDocsListObj->setLimit($ruleEnt->recordsCountOnExecution); } } } 