getPositions($data['id']); $data['categories'] = $this->getCategories($data['id']); return parent::_addDependenciesFromDb($data); } private function getPositions($companyId) { $select = $this->_db->select(); $select->from($this->_getPair('User', 'u'), ['name' => UserModel::getFullNameWithNicknameExpr('u')]); $select->join($this->_getPair('CompanyUtilityStaff', 'cus'), '`cus`.`userId` = `u`.`id`', []); $select->where('`cus`.`companyId` = ?', $companyId, Qs_Db::INT_TYPE); $select->where('`u`.`status` = ?', UserEntity::STATUS_ACTIVE); $select->order('cus.sorter'); $select->join( $this->_getPair('PersonnelPosition', 'pp'), '`pp`.`id` = `cus`.`positionId`', ['position' => 'title'] ); return $this->_db->fetchAll($select); } private function getCategories($companyId) { $select = $this->_db->select(); $select->from($this->_getPair('UtilityCategory', 'uc'), ['title', 'symbol']); $select->join($this->_getPair('CompanyUtilityCategory', 'cuc'), '`cuc`.`utilityCategoryId` = `uc`.`id`', []); $select->where('`cuc`.`companyId` = ?', $companyId, Qs_Db::INT_TYPE); $select->order('uc.sorter'); return $this->_db->fetchAll($select); } }