_reportId = $reportId; } public function getReportId() { return $this->_reportId; } protected function _prepareList(&$list) { if ($list) { $schoolReports = $this->_getReportsById($this->_reportId); foreach ($list as &$row) { if ($schoolReports && isset($schoolReports[$row['id']])) { $row['reports'] = $schoolReports[$row['id']]; } } } return parent::_prepareList($list); } protected function _getReportsById($reportId) { $select = $this->_db->select(); $select->from( $this->_getPair('UserReport'), array('schoolId', 'id', 'reportId', 'file', 'comments', 'rejected', 'rejectComment', 'rejectDate', 'added') ); $select->where('reportId = ?', $reportId); return $this->_db->fetchAll($select, null, PDO::FETCH_ASSOC | PDO::FETCH_GROUP); } public function getListSelect($options = array()) { if (null == $this->_select) { $this->_select = $this->_db->select(); $this->_select->from($this->_getPair('School'), array( '*', 'status' => $this->_getStatusExpr('School.id'), 'forcedStatus' => $this->_getForcedStatusExpr('School.id'), )); $this->_select->join( $this->_getPair('Report'), $this->_db->quoteInto('Report.id = ?', $this->getReportId(), Qs_Db::INT_TYPE), array() ); $filter = $this->_getCleanedFilter($this->_filter); Qs_Db::filter($this->_select, $filter, 'School'); } $this->_prepareListOptions($options); return $this->_select; } }