API/DAO Metadata - Retain versioning metadata for possible usage in runtime+tooling
[civicrm-core.git] / CRM / Core / DAO / Discount.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Discount.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:b240911ddcf71cc294fe02614887711c)
10 */
11
12 /**
13 * Database access object for the Discount entity.
14 */
15 class CRM_Core_DAO_Discount extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_discount';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = TRUE;
30
31 /**
32 * primary key
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * physical tablename for entity being joined to discount, e.g. civicrm_event
40 *
41 * @var string
42 */
43 public $entity_table;
44
45 /**
46 * FK to entity table specified in entity_table column.
47 *
48 * @var int
49 */
50 public $entity_id;
51
52 /**
53 * FK to civicrm_price_set
54 *
55 * @var int
56 */
57 public $price_set_id;
58
59 /**
60 * Date when discount starts.
61 *
62 * @var date
63 */
64 public $start_date;
65
66 /**
67 * Date when discount ends.
68 *
69 * @var date
70 */
71 public $end_date;
72
73 /**
74 * Class constructor.
75 */
76 public function __construct() {
77 $this->__table = 'civicrm_discount';
78 parent::__construct();
79 }
80
81 /**
82 * Returns localized title of this entity.
83 */
84 public static function getEntityTitle() {
85 return ts('Discounts');
86 }
87
88 /**
89 * Returns foreign keys and entity references.
90 *
91 * @return array
92 * [CRM_Core_Reference_Interface]
93 */
94 public static function getReferenceColumns() {
95 if (!isset(Civi::$statics[__CLASS__]['links'])) {
96 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id');
98 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
99 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
100 }
101 return Civi::$statics[__CLASS__]['links'];
102 }
103
104 /**
105 * Returns all the column names of this table
106 *
107 * @return array
108 */
109 public static function &fields() {
110 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
111 Civi::$statics[__CLASS__]['fields'] = [
112 'id' => [
113 'name' => 'id',
114 'type' => CRM_Utils_Type::T_INT,
115 'title' => ts('Discount ID'),
116 'description' => ts('primary key'),
117 'required' => TRUE,
118 'where' => 'civicrm_discount.id',
119 'table_name' => 'civicrm_discount',
120 'entity' => 'Discount',
121 'bao' => 'CRM_Core_BAO_Discount',
122 'localizable' => 0,
123 'add' => '2.1',
124 ],
125 'entity_table' => [
126 'name' => 'entity_table',
127 'type' => CRM_Utils_Type::T_STRING,
128 'title' => ts('Entity Table'),
129 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
130 'maxlength' => 64,
131 'size' => CRM_Utils_Type::BIG,
132 'where' => 'civicrm_discount.entity_table',
133 'table_name' => 'civicrm_discount',
134 'entity' => 'Discount',
135 'bao' => 'CRM_Core_BAO_Discount',
136 'localizable' => 0,
137 'add' => '2.1',
138 ],
139 'entity_id' => [
140 'name' => 'entity_id',
141 'type' => CRM_Utils_Type::T_INT,
142 'title' => ts('Entity ID'),
143 'description' => ts('FK to entity table specified in entity_table column.'),
144 'required' => TRUE,
145 'where' => 'civicrm_discount.entity_id',
146 'table_name' => 'civicrm_discount',
147 'entity' => 'Discount',
148 'bao' => 'CRM_Core_BAO_Discount',
149 'localizable' => 0,
150 'add' => '2.1',
151 ],
152 'participant_discount_name' => [
153 'name' => 'price_set_id',
154 'type' => CRM_Utils_Type::T_INT,
155 'title' => ts('Discount Name'),
156 'description' => ts('FK to civicrm_price_set'),
157 'required' => TRUE,
158 'where' => 'civicrm_discount.price_set_id',
159 'export' => TRUE,
160 'table_name' => 'civicrm_discount',
161 'entity' => 'Discount',
162 'bao' => 'CRM_Core_BAO_Discount',
163 'localizable' => 0,
164 'FKClassName' => 'CRM_Price_DAO_PriceSet',
165 'pseudoconstant' => [
166 'table' => 'civicrm_price_set',
167 'keyColumn' => 'id',
168 'labelColumn' => 'title',
169 ],
170 'add' => '4.3',
171 ],
172 'start_date' => [
173 'name' => 'start_date',
174 'type' => CRM_Utils_Type::T_DATE,
175 'title' => ts('Discount Start Date'),
176 'description' => ts('Date when discount starts.'),
177 'where' => 'civicrm_discount.start_date',
178 'table_name' => 'civicrm_discount',
179 'entity' => 'Discount',
180 'bao' => 'CRM_Core_BAO_Discount',
181 'localizable' => 0,
182 'add' => '2.1',
183 ],
184 'end_date' => [
185 'name' => 'end_date',
186 'type' => CRM_Utils_Type::T_DATE,
187 'title' => ts('Discount End Date'),
188 'description' => ts('Date when discount ends.'),
189 'where' => 'civicrm_discount.end_date',
190 'table_name' => 'civicrm_discount',
191 'entity' => 'Discount',
192 'bao' => 'CRM_Core_BAO_Discount',
193 'localizable' => 0,
194 'add' => '2.1',
195 ],
196 ];
197 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
198 }
199 return Civi::$statics[__CLASS__]['fields'];
200 }
201
202 /**
203 * Return a mapping from field-name to the corresponding key (as used in fields()).
204 *
205 * @return array
206 * Array(string $name => string $uniqueName).
207 */
208 public static function &fieldKeys() {
209 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
210 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
211 }
212 return Civi::$statics[__CLASS__]['fieldKeys'];
213 }
214
215 /**
216 * Returns the names of this table
217 *
218 * @return string
219 */
220 public static function getTableName() {
221 return self::$_tableName;
222 }
223
224 /**
225 * Returns if this table needs to be logged
226 *
227 * @return bool
228 */
229 public function getLog() {
230 return self::$_log;
231 }
232
233 /**
234 * Returns the list of fields that can be imported
235 *
236 * @param bool $prefix
237 *
238 * @return array
239 */
240 public static function &import($prefix = FALSE) {
241 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'discount', $prefix, []);
242 return $r;
243 }
244
245 /**
246 * Returns the list of fields that can be exported
247 *
248 * @param bool $prefix
249 *
250 * @return array
251 */
252 public static function &export($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'discount', $prefix, []);
254 return $r;
255 }
256
257 /**
258 * Returns the list of indices
259 *
260 * @param bool $localize
261 *
262 * @return array
263 */
264 public static function indices($localize = TRUE) {
265 $indices = [
266 'index_entity' => [
267 'name' => 'index_entity',
268 'field' => [
269 0 => 'entity_table',
270 1 => 'entity_id',
271 ],
272 'localizable' => FALSE,
273 'sig' => 'civicrm_discount::0::entity_table::entity_id',
274 ],
275 'index_entity_option_id' => [
276 'name' => 'index_entity_option_id',
277 'field' => [
278 0 => 'entity_table',
279 1 => 'entity_id',
280 2 => 'price_set_id',
281 ],
282 'localizable' => FALSE,
283 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id',
284 ],
285 ];
286 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
287 }
288
289 }