<?php
 namespace Modules\TaskManagement\Tasks; 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\Tasks(); $listObj->setColumns(['taskDate', 'status', 'statusReason', 'description', 'idCategory', 'idDepartment', 'idOffice', 'idResponsibleUser', 'idAssignorUser', 'free', 'priority', 'deadline', 'estimatedFinishTime', 'estimatedDuration', 'pivot', 'idPivot', 'idOperationType', 'comments', 'addTime']); if ($filters['taskDate']['start']) { $listObj->setFilter('taskDate', '>=', $filters['taskDate']['start']); } if ($filters['taskDate']['end']) { $listObj->setFilter('taskDate', '<=', $filters['taskDate']['end']); } if ($filters['deadline']['start']) { $listObj->setFilter('DATE_FORMAT( FROM_UNIXTIME( deadline ), "%Y-%m-%d")', '>=', $filters['deadline']['start']); } if ($filters['deadline']['end']) { $listObj->setFilter('DATE_FORMAT( FROM_UNIXTIME( deadline ), "%Y-%m-%d")', '<=', $filters['deadline']['end']); } if ($filters['idCategory']) { $listObj->setFilter('idCategory', '=', $filters['idCategory']); } if ($filters['priority'] && $filters['priority']!='all') { $listObj->setFilter('priority', '=', $filters['priority']); } if ($filters['idDepartment']['id']) { $listObj->setFilter('idDepartment', '=', $filters['idDepartment']['id']); } if ($filters['idOffice']['id']) { $listObj->setFilter('idOffice', '=', $filters['idOffice']['id']); } if ($filters['idAssignorUser']['id']) { $listObj->setFilter('idAssignorUser', '=', $filters['idAssignorUser']['id']); } if ($filters['idResponsibleUser']['id']) { $listObj->setFilter('idResponsibleUser', '=', $filters['idResponsibleUser']['id']); } if ($filters['idAddUser']['id']) { $listObj->setFilter('idAddUser', '=', $filters['idAddUser']['id']); } if ($filters['text']) { $listObj->setCustomFilter('description LIKE ?', ["%{$filters['text']}%"]); } if ($filters['free']) { $listObj->setFilter('free', '=', ($filters['free']=='yes'?1:0)); } if (is_array($filters['status']) && $filters['status']) { $listObj->setFilter('status', 'IN', array_values($filters['status'])); } if ($filters['pivot']) { $listObj->setFilter('pivot', '=', $filters['pivot']); } if ($filters['idPivot']) { $listObj->setFilter('idPivot', '=', $filters['idPivot']); } if ($filters['idTask']) { $listObj->setFilter('id', '=', $filters['idTask']); } $listObj = $this->entityList_inheritListingParams($listingParams, $listObj); $this->recordsList = $listObj->exportRecords(); $this->totalRecordsCount = $listObj->getRecordsCount(); } } 