_getMembers($ids); foreach ($list as $index => &$item) { if (!empty($members[$item['id']])) { $item['members'] = $members[$item['id']]; } else { unset($list[$index]); } } unset($item); return parent::_prepareList($list); } protected function _prepareRow(array &$row) { $companies = Qs_Array::fetchCol($row['members'], 'company', Qs_Array::FETCH_UNIQUE); if (count($companies) == 1) { foreach ($row['members'] as &$member) { $member['company'] = ''; } } return parent::_prepareRow($row); } public function getListSelect() { if (null === $this->_select) { $this->_select = parent::getListSelect(); $this->_select->where('enabled = "y"'); } return $this->_select; } protected function _getMembers(array $leadershipGroupIds = array()) { if (!$leadershipGroupIds) { return []; } $select = $this->_db->select(); $select->from( $this->_getPair('User'), ['leadershipGroupId', 'id', 'alias', 'leadershipPhoto', 'linkedInUrl', 'firstName', 'lastName', 'leadershipPosition', 'fullName' => UserModel::getFullNameWithNicknameExpr()] ); $select->where('`User`.`leadershipGroupId` IN (?)', $leadershipGroupIds, Qs_Db::INT_TYPE); $select->where('`User`.`status` = ?', UserEntity::STATUS_ACTIVE); $select->joinLeft($this->_getPair('Company', 'c'), '`c`.`id` = `User`.`companyId`', ['company' => 'c.name']); $select->order('sorter'); return $this->_db->fetchAll($select, [], Qs_Db::FETCH_GROUP); } }