'y'); protected $_urlParseFields = array('description', 'contactDetails'); protected $_fileFields = array('photo'); public function getAutocompleteSubmitterName($term) { $select = $this->_db->select(); $select->from($this->_getPair('User'), User\AbstractObj::getAutocompleteColumns()); $select->joinLeft($this->_getPair('Company', 'c'), '`c`.`id` = `User`.`companyId`', []); $select->where('`User`.`bought` = "y"'); $select->where('`User`.`nickname` LIKE ? OR `User`.`lastName` LIKE ?', '%' . $term . '%'); $select->limit(10); return $this->_db->fetchAll($select); } public function getListSelect() { if (null === $this->_select) { parent::getListSelect(); $this->_select->join( $this->_getPair('ClassifiedType'), '`Classified`.`type` = `ClassifiedType`.`id`', array('typeTitle' => 'title') ); } return $this->_select; } protected function _getFromDbSelect($primaryKey) { $select = $this->_db->select(); $select->from($this->_getPair(), $this->_getFromDbColumns()); $select->join( $this->_getPair('ClassifiedType'), '`Classified`.`type` = `ClassifiedType`.`id`', array('typeTitle' => 'title') ); $select->where($this->_getTable()->prepareWhere((array)$primaryKey, $this->_getTableAlias())); return $select; } /** * @param string|null $value allowed values: 'y', null * @return int Return count updated rows * @throws Qs_Exception */ public function setBought($value = 'y') { if (!in_array($value, array('y', null))) { throw new Qs_Exception('Incorrect "bought" value.'); } if (!$this->getPrimaryKey()) { throw new Qs_Exception('Primary key is not defined.'); } return $this->_getTable()->updateByKey(array('bought' => $value), $this->getPrimaryKey()); } protected function initFromFormDateRange(array &$data) { if (!empty($data['id'])) { return $this; } if (empty($data['startDate'])) { $data['startDate'] = date('Y-m-d'); } if (empty($data['expirationDate'])) { $data['expirationDate'] = $this->calculateExpirationDate($data['startDate']); } return $this; } public function calculateExpirationDate($startDate = null) { if (empty($startDate)) { $startDate = date('Y-m-d'); } $days = (int) App_Settings_Obj::get('classifiedDays'); $expirationDate = date('Y-m-d', strtotime($startDate . " +" . $days . " day")); return $expirationDate; } }