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