_objectData = $data; } function getObjectData($field = false) { if (false === $field) { return $this->_objectData; } if (array_key_exists($field, $this->_objectData)) { return $this->_objectData[$field]; } return null; } function isUnique($field, $value) { $sql = "SELECT COUNT(*) FROM {$this->tableNameDB} WHERE {$field} = ".$this->db->quote($value); if ($this->id) { $sql .= ' AND id != '.$this->db->quote($this->id); } return !(bool)$this->db->queryOne($sql) ; } function setFilter($filter) { if (isset($filter['query'])) { $this->_filterQuery = (string) $filter['query']; unset($filter['query']); } $this->_filter = $filter; } function addFilter($filter) { if (isset($filter['query'])) { $this->_filterQuery = (string) $filter['query']; unset($filter['query']); } $this->_filter = array_merge($this->_filter, $filter); } function getFitler($field = false) { if (false === $field) { return $this->_filter; } if (array_key_exists($field, $this->_filter)) { return $this->_filter[$field]; } return null; } function _getWhat4Grid($opt = array()) { $sql = parent::_getWhat4Grid($opt); $sql .= ", DATEDIFF(CURRENT_DATE(), `{$this->tableName}`.`date_due`) AS `overdue`"; return $sql; } function _filterSql() { require_once('class/DB/DBObj/Filter.php'); $sql = DBObj_Filter::perseQr($this->db, $this->_filterFields, $this->_filterQuery); if (false === $sql) { $sql = ''; } $sql .= $this->_getWhereFilter($this->_filter); return (empty($sql) ? false : $sql); } protected function _getWhereFilter($filter) { $sql = ''; foreach ($filter as $field => $value) { if (empty($value)) { continue; } switch ($field) { case 'id_location': $sql .= " AND `{$this->tableName}`.`{$field}` = " . $this->db->quote($value, 'integer'); break; case 'id_member': $sql .= " AND `Member`.`id` = " . $this->db->quote($value, 'integer'); break; case 'paid': $sql .= " AND `{$this->tableName}`.`{$field}` = " . $this->db->quote($value, 'text'); break; case 'number': if (is_string($value)) { $value = split('[, ]', $value); } $value = array_filter($value, 'intval'); if (empty($value)) { continue; } $sql .= " AND `{$this->tableName}`.`{$field}` IN(" . implode(', ', $value) . ')'; break; default: break; } } return $sql; } function initFromForm(&$form) { $files = $this->initFilesFromForm($form); $data = $form->exportValues(); if (($id_object = $this->getObjectData('id'))) { $data[$this->_objectReferenceField] = $id_object; } $data = $this->initDateFromForm($form, $data); $this->arrayParseUrl2Tag($data); $this->initFromArray($data, $files); return true; } function _getWhereDeleted() { $sql = ''; if (DB_OBJ_DEL_METHOD_LOGICAL == $this->delMethod) { $sql = ' AND `' . $this->tableName . '`.`deleted` = \'n\''; } return $sql; } function getFromDB($id, $field = false) { $id = intval($id); $sql = "SELECT {$this->tableName}.* FROM {$this->tableNameDB} AS {$this->tableName} WHERE {$this->tableName}.id = $id"; $res = $this->db->queryRow($sql); if ($res && $field === false) { if ($res['paid'] == 'y' && $res['id_transaction']) { $res['transaction'] = $this->getMemberTransactionById($res['id_transaction']); } } $this->arrayParseTag2Url(&$res); return $this->getSubElem($res, $field); } function delete() { $this->_files = array(); if (is_array($this->fileFields) && !empty($this->fileFields)) { foreach ($this->fileFields as $elementName) { $this->_files[$elementName] = array('del' => 1); } } parent::delete(); } }