getData('idSchool'); } public function initFromForm(array $data) { $data['userId'] = App_User_Auth::getInstance()->getData('id'); $data['schoolId'] = App_User_Auth::getInstance()->getData('idSchool'); $data['addedIdx'] = $this->_prepareDueIdx(date('m'), date('d')); return parent::initFromForm($data); } public function getReportsByUserId($userId) { $select = $this->_db->select(); $select->from($this->_getPair('User'), array()); $select->join($this->_getPair('UserReport'), 'UserReport.schoolId = User.idSchool', array('id', 'file')); $select->where('User.id = ?', $userId, Qs_Db::INT_TYPE); return $this->_db->fetchPairs($select); } protected function _getFromColumns() { $columns = parent::_getFromColumns(); $columns['status'] = $this->_getStatusExpr($this->getSchoolId()); return $columns; } protected function _prepareList(&$list) { if ($list) { $schoolReports = null; $schoolReports = $this->_getReportsBySchool(App_User_Auth::getInstance()->getData('idSchool')); foreach ($list as &$row) { if ($schoolReports && isset($schoolReports[$row['id']])) { $row['reports'] = $schoolReports[$row['id']]; } } } return parent::_prepareList($list); } public function getListSelect($options = array()) { if (null == $this->_select) { $this->_select = $this->_db->select(); $this->_select->from($this->_getPair('Report'), array( '*', 'status' => $this->_getStatusExpr(App_User_Auth::getInstance()->getData('idSchool')) )); $this->_prepareListOptions($options); if (!empty($this->_filterFields) && array_key_exists('query', $this->_filter)) { Qs_Db_Filter::where($this->_select, $this->_filterFields, $this->_filter['query']); } if (!empty($this->_filter['reportsStatus'])) { $this->_select->having('status = ?', $this->_filter['reportsStatus']); } } return $this->_select; } }