<?php
namespace ModulesAbstract\PluginReports\Report\Model\Gatherer; class OrderServicesWithFakeInvoices extends OrderServices { public function getAcceptedFilters() { return [ 'ticketDate', 'corporatesAndSegmentsAndGroups', 'userAndOffice', ]; } protected function objectInitialize() { $listObj = new \App\EntityList\OrderServices(); $listObj->setColumns([ 'serv.id' => 'idOrderService', 'serv.passengersTicketsDate' => 'ticketDate', ]); $listObj->setFilter('res.date', 'BETWEEN', [ \Engine\DateTime::createFromIsoDate($this->filters['ticketDate']['start'])->sub(new \DateInterval('P6M'))->formatDateIso(), \Engine\DateTime::createFromIsoDate($this->filters['ticketDate']['end'])->add(new \DateInterval('P6M'))->formatDateIso(), ]); $listObj->setFilter('serv.cancelReason', '=', ''); $listObj->setFilter('serv.statusOp', '=', 'OK'); if ($this->filters['userAndOffice']['type'] == 'user') { if ($this->filters['userAndOffice']['entityId']) { $listObj->setFilter('serv.idUser', '=', $this->filters['userAndOffice']['entityId']); } } elseif ($this->filters['userAndOffice']['type'] == 'office') { if ($this->filters['userAndOffice']['entityId']) { $listObj->setFilter('serv.idOffice', '=', $this->filters['userAndOffice']['entityId']); } } if (in_array($this->filters['corporatesAndSegmentsAndGroups']['type'], ['segment', 'groups']) && !$this->filters['corporatesAndSegmentsAndGroups']['corporateIds']) { $this->orderServicesIterator = new \ADORecordSet_empty(); return; } if (in_array($this->filters['corporatesAndSegmentsAndGroups']['type'], ['all', 'corporate', 'segment', 'groups'])) { if ($this->filters['corporatesAndSegmentsAndGroups']['corporateIds']) { $listObj->setFilter('res.idCorporateOwner', 'IN', $this->filters['corporatesAndSegmentsAndGroups']['corporateIds']); } else { $listObj->setFilter('res.idCorporateOwner', '!=', 0); } } else { throw new \Exception(sprintf("%s type is invalid", __METHOD__)); } $listObj->setFilter('off.offerWorkTotal', '=', 0); $listObj->setOrderBy('ticketDate', 'ASC'); $listObj->setOrderBy('idOrderService', 'ASC'); $listObj->applyUserRestriction(false); $this->orderServicesIterator = $listObj->getExecution(); } }