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