<?php
namespace Modules\Bsp\Settlement; class ModelGenerateReportBspOperationalStatus extends ModelGenerateReportAbstract { protected function getBspIterator(\App\Mvc\View\Listing\Members\Params $listingParams) { $listingParams = new \App\Mvc\View\Listing\Members\Params(__CLASS__); $listingParams->setFilters([ 'ticketDate' => [ 'start' => null, 'end' => null, ], ]); $sqlIterator = parent::getBspIterator($listingParams); $sqlIterator->appendCondition("bspSettlement.operationalStatus != ''"); return $sqlIterator; } public function generate($outputFile) { $sqlIterator = $this->getBspIterator($this->listingParams); $rowFormatter = new \ModulesAbstract\PluginReports\Report\Model\Iterator\MapResultsIterator(); $rowFormatter->setSource($sqlIterator); $_LANG = \App\Loader_Lang::getInstance()->getGlobal(); $rowTemplate = [ 'key' => '', 'settlementOperationalStatus' => '', 'settlementOperationalDateTime' => '', 'settlementOperationalUserId' => '', ]; $rowFormatter->setPreReturnCallback(function($rowFields) use ($rowTemplate) { $ret = $rowTemplate; $ret['key'] = $rowFields['id']; $ret['settlementOperationalStatus'] = $rowFields['operationalStatus']; $ret['settlementOperationalDateTime'] = $rowFields['operationalDateTime']; $ret['settlementOperationalUserId'] = $rowFields['operationalUser']; return $ret; }); $xlsObj = new \App\Utils\CSV\Writer\BufferedWriter(); $xlsObj->appendHeaderRow(array_keys($rowTemplate)); $xlsObj->fromArray($rowFormatter->asIterator()); $xlsObj->save($outputFile); return $this; } } 