_getMembers(); $data['documents'] = $this->_getDocuments(); $data['nextMeeting'] = \App\Event\Obj::getNextMeetingData($this->_primaryKey); return parent::_addDependenciesFromDb($data); } public function getList() { $this->setSelectOptions(array('order' => 'sorter')); return parent::getList(); } protected function _getDocuments() { $select = $this->_db->select(); $select->from($this->_getPair('Document'), array('typeId', 'title', 'fileName')) ->where('`Document`.`committeeId` = ?', $this->_primaryKey, \Qs_Db::INT_TYPE) ->order('Document.added DESC'); return $this->_db->fetchAll($select, array(), \Qs_Db::FETCH_GROUP); } protected function _getMembers() { $select = $this->_db->select(); $select->from( $this->_getPair('User'), array('uc.roleId','firstName', 'lastName', 'email', 'phone', 'id', 'company') ) ->join($this->_getPair('UserCommittee', 'uc'), '`uc`.`userId` = `User`.`id`', array()) ->joinLeft($this->_getPair('UserGroup', 'group'), '`group`.`id` = `User`.`groupId`', array('title')) ->where('`uc`.`committeeId` = ?', $this->_primaryKey, \Qs_Db::INT_TYPE) ->order(array('User.lastName', 'User.firstName')); return $this->_db->fetchAll($select, array(), \Qs_Db::FETCH_GROUP); } public static function isMemberForAny() { $userId = \App_User_Auth::getInstance()->getData('id'); if (!$userId) { return false; } $select = \Qs_Db::getSelect(); $select->from(\Qs_Db::getPair('UserCommittee', 'uc'), 'userId') ->where('`uc`.`userId` = ?', $userId, \Qs_Db::INT_TYPE) ->limit(1); return (bool) \Qs_Db::getInstance()->fetchOne($select); } public function isLeadership($userId) { $select = $this->_db->select(); $select->from($this->_getPair('UserCommittee', 'uc'), 'userId') ->where('`userId` = ?', $userId, \Qs_Db::INT_TYPE) ->where('`committeeId` = ?', $this->_primaryKey, \Qs_Db::INT_TYPE) ->join( $this->_getPair('UserCommitteeRole', 'ucr'), '`uc`.`roleId` = `ucr`.`id` AND `ucr`.`leadership` = "y"', array() ) ->limit(1); return (bool) $this->_db->fetchOne($select); } public function isMember($userId) { $select = $this->_db->select(); $select->from($this->_getPair('UserCommittee', 'uc'), 'userId') ->where('`userId` = ?', $userId, \Qs_Db::INT_TYPE) ->where('`committeeId` = ?', $this->_primaryKey, \Qs_Db::INT_TYPE) ->limit(1); return (bool)$this->_db->fetchOne($select); } }