<?php
namespace App\Form\Input; class Autocomplete_Data_User extends \Engine\Form\Input\Autocomplete_Data_GeneralAbstract { protected function getPageResultsBulk() :array { $searchWords = preg_split("/[\s,]+/", $this->searchString); $usersListObj = new \App\EntityList\Users(); $usersListObj->applyUserRestriction(false); $usersListObj->setColumns(['user.lastName', 'user.firstName', 'user.idOffice', 'user.idDepartment']); $usersListObj->setColumn("CONCAT(lastName, ' ',firstName)", 'name'); if ($this->filters['idOffice']) { $usersListObj->setFilter('user.idOffice', '=', $this->filters['idOffice']); } foreach ($searchWords as $word) { $usersListObj->setCustomFilter('user.lastName LIKE ? OR user.firstName LIKE ?', ["{$word}%", "{$word}%"]); } $usersListObj->setOrderBy('user.lastName', 'ASC'); $usersListObj->setOrderBy('user.firstName', 'ASC'); $usersListObj->setLimit($this->offset, $this->resultsCountPage); return $this->executeSqlEntityList($usersListObj); } protected function getPageResultsFormatted(Array $pageResults) { $list = []; foreach($pageResults as $row) { $extra = \Entity\Office::select($row['idOffice'])->name; $extra .= ' ('.\Entity\Department::select($row['idDepartment'])->name.')'; $list[] = $this->getCleanItem($row['id'], $row['name'], $extra); } return $list; } }