<?php
namespace Modules\Documents\DocumentsList; class Model extends \App\Mvc\Model_ListingAbstract { public function list_execute(\App\Mvc\View\Listing\Members\Params $listingParams) { $filters=$listingParams->getFilters(); $listObj = new \App\EntityList\Documents(); $listObj->setColumns(['pivot', 'idPivot', 'docType', 'docNumber', 'docDate', 'idTemplate', 'generation', 'docFile', 'emailSent', 'disableEmailSending' ]); $listObj->applyUserRestriction(true); if ($filters['docDate']) { $listObj->setFilter('docDate', '>=', $filters['docDate']['start']); $listObj->setFilter('docDate', '<=', $filters['docDate']['end']); } if ($filters['pivot']) { $listObj->setFilter('pivot', '=', $filters['pivot']); } if ($filters['docNumber']) { $listObj->setFilter('docNumber', '=', $filters['docNumber']); } if ($filters['idDoc']) { $listObj->setFilter('doc.id', '=', $filters['idDoc']); } if ($filters['idPivot']) { $listObj->setFilter('idPivot', '=', $filters['idPivot']); } if ($filters['docType']) { $listObj->setFilter('docType', '=', $filters['docType']); } if ($filters['generation']) { $listObj->setFilter('generation', '=', $filters['generation']); } if ($filters['docTemplate']) { $listObj->setFilter('idTemplate', '=', $filters['docTemplate']); } $listObj = $this->entityList_inheritListingParams($listingParams, $listObj); $documents = $listObj->exportRecords(); $documentsCount = $listObj->getRecordsCount(); $recordList = []; foreach ($documents as $doc) { $doc['fileSize'] = \Engine\File::formatBytes( \Entity\Document::select($doc['id'])->docFileSize ); $recordList[] = $doc; } $this->recordsList = $recordList; $this->totalRecordsCount = $documentsCount; } }