_loggedInUser, $field, $default); } /** * @param null|array $loggedInUser */ public function setLoggedInUser($loggedInUser) { $this->_loggedInUser = $loggedInUser; } public function getListSelect() { if (null === $this->_select) { $this->_select = parent::getListSelect(); $this->_select->reset(Zend_Db_Select::COLUMNS); $this->_select->columns(['nickname', 'lastName', 'jobTitle']); //join by company $this->_select->where('`User`.`companyId` = ?', $this->_loggedInUser['companyId'], Qs_Db::INT_TYPE); //attendee $this->_select->join( $this->_getPair('EventAttendee'), '`EventAttendee`.`userId` = `User`.`id`', ['id', 'ceus', 'certificate', 'status'] ); //event $this->_select->join( $this->_getPair('Event'), '`Event`.`id` = `EventAttendee`.`eventId`', ['eventName' => 'title', 'startDate', 'endDate'] ); $this->_select->where('`EventAttendee`.`status` = ?', EventAttendeeEntity::STATUS_ATTENDED); $this->_select->where('`EventAttendee`.`bought` = "y"'); $this->_select->joinLeft( $this->_getPair('Cart'), '`EventAttendee`.`cartId` = `Cart`.`id` AND `Cart`.`userId` = `User`.`id`', ['createdBy' => 'IF(`Cart`.`userId` = ' . $this->_db->quote($this->getLoggedInUser('id'), Qs_Db::INT_TYPE) . ', "me", "other")'] ); $this->_select->joinLeft( $this->_getPair('Transaction'), '`Transaction`.`id` = `Cart`.`transactionId` AND `Transaction`.`enabled` = "y"', ['orderId' => 'Transaction.id'] ); } return $this->_select; } protected function _filter(Zend_Db_Select $select) { if (!empty($this->_filter['eventType'])) { $select->where('`Event`.`type` = ?', $this->_filter['eventType']); unset($this->_filter['eventType']); } if (!empty($this->_filter['timePeriod'])) { $select->where( '`startDate` >= DATE_SUB(NOW(), INTERVAL ? YEAR)', $this->_filter['timePeriod'], Qs_Db::INT_TYPE ); $select->where( '`endDate` <= DATE_ADD(NOW(), INTERVAL ? YEAR)', $this->_filter['timePeriod'], Qs_Db::INT_TYPE ); unset($this->_filter['timePeriod']); } //filter by event subtype if (!empty($this->_filter['eventSubtype'])) { $select->where('`Event`.`subtype` = ?', $this->_filter['eventSubtype']); } if (!empty($this->_filter['individualStatus'])) { $select->where('`User`.`status` = ?', $this->_filter['individualStatus']); unset($this->_filter['individualStatus']); } parent::_filter($select); return $this; } }