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 | |
7b66c3b5 | 9 | * (GenCodeChecksum:5fbe08bc556f5b913860a55c6d0cedc4) |
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, |
a9d0587b | 128 | 'add' => '2.1', |
c3fc2621 CW |
129 | ], |
130 | 'entity_table' => [ | |
e501603b TO |
131 | 'name' => 'entity_table', |
132 | 'type' => CRM_Utils_Type::T_STRING, | |
c3fc2621 | 133 | 'title' => ts('Entity Table'), |
215b423e | 134 | 'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'), |
e501603b TO |
135 | 'maxlength' => 64, |
136 | 'size' => CRM_Utils_Type::BIG, | |
a36434b9 | 137 | 'where' => 'civicrm_discount.entity_table', |
522a26c9 | 138 | 'table_name' => 'civicrm_discount', |
139 | 'entity' => 'Discount', | |
140 | 'bao' => 'CRM_Core_BAO_Discount', | |
6a7e5e5d | 141 | 'localizable' => 0, |
a9d0587b | 142 | 'add' => '2.1', |
c3fc2621 CW |
143 | ], |
144 | 'entity_id' => [ | |
e501603b TO |
145 | 'name' => 'entity_id', |
146 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 147 | 'title' => ts('Entity ID'), |
215b423e | 148 | 'description' => ts('FK to entity table specified in entity_table column.'), |
c3fc2621 | 149 | 'required' => TRUE, |
a36434b9 | 150 | 'where' => 'civicrm_discount.entity_id', |
522a26c9 | 151 | 'table_name' => 'civicrm_discount', |
152 | 'entity' => 'Discount', | |
153 | 'bao' => 'CRM_Core_BAO_Discount', | |
6a7e5e5d | 154 | 'localizable' => 0, |
a9d0587b | 155 | 'add' => '2.1', |
c3fc2621 CW |
156 | ], |
157 | 'participant_discount_name' => [ | |
e501603b TO |
158 | 'name' => 'price_set_id', |
159 | 'type' => CRM_Utils_Type::T_INT, | |
c3fc2621 | 160 | 'title' => ts('Discount Name'), |
215b423e | 161 | 'description' => ts('FK to civicrm_price_set'), |
c3fc2621 | 162 | 'required' => TRUE, |
e501603b | 163 | 'where' => 'civicrm_discount.price_set_id', |
a36434b9 | 164 | 'export' => TRUE, |
522a26c9 | 165 | 'table_name' => 'civicrm_discount', |
166 | 'entity' => 'Discount', | |
167 | 'bao' => 'CRM_Core_BAO_Discount', | |
6a7e5e5d | 168 | 'localizable' => 0, |
e501603b | 169 | 'FKClassName' => 'CRM_Price_DAO_PriceSet', |
f65a7e43 PN |
170 | 'pseudoconstant' => [ |
171 | 'table' => 'civicrm_price_set', | |
172 | 'keyColumn' => 'id', | |
173 | 'labelColumn' => 'title', | |
174 | ], | |
a9d0587b | 175 | 'add' => '4.3', |
c3fc2621 CW |
176 | ], |
177 | 'start_date' => [ | |
e501603b TO |
178 | 'name' => 'start_date', |
179 | 'type' => CRM_Utils_Type::T_DATE, | |
c3fc2621 | 180 | 'title' => ts('Discount Start Date'), |
215b423e | 181 | 'description' => ts('Date when discount starts.'), |
a36434b9 | 182 | 'where' => 'civicrm_discount.start_date', |
522a26c9 | 183 | 'table_name' => 'civicrm_discount', |
184 | 'entity' => 'Discount', | |
185 | 'bao' => 'CRM_Core_BAO_Discount', | |
6a7e5e5d | 186 | 'localizable' => 0, |
a9d0587b | 187 | 'add' => '2.1', |
c3fc2621 CW |
188 | ], |
189 | 'end_date' => [ | |
e501603b TO |
190 | 'name' => 'end_date', |
191 | 'type' => CRM_Utils_Type::T_DATE, | |
c3fc2621 | 192 | 'title' => ts('Discount End Date'), |
215b423e | 193 | 'description' => ts('Date when discount ends.'), |
a36434b9 | 194 | 'where' => 'civicrm_discount.end_date', |
522a26c9 | 195 | 'table_name' => 'civicrm_discount', |
196 | 'entity' => 'Discount', | |
197 | 'bao' => 'CRM_Core_BAO_Discount', | |
6a7e5e5d | 198 | 'localizable' => 0, |
a9d0587b | 199 | 'add' => '2.1', |
c3fc2621 CW |
200 | ], |
201 | ]; | |
346aaaba | 202 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
e501603b | 203 | } |
346aaaba | 204 | return Civi::$statics[__CLASS__]['fields']; |
e501603b | 205 | } |
c3fc2621 | 206 | |
e501603b | 207 | /** |
bd8e0b14 | 208 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
e501603b TO |
209 | * |
210 | * @return array | |
bd8e0b14 | 211 | * Array(string $name => string $uniqueName). |
e501603b | 212 | */ |
c3fc2621 | 213 | public static function &fieldKeys() { |
bd8e0b14 TO |
214 | if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) { |
215 | Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields())); | |
e501603b | 216 | } |
bd8e0b14 | 217 | return Civi::$statics[__CLASS__]['fieldKeys']; |
e501603b | 218 | } |
c3fc2621 | 219 | |
e501603b TO |
220 | /** |
221 | * Returns the names of this table | |
222 | * | |
223 | * @return string | |
224 | */ | |
c3fc2621 | 225 | public static function getTableName() { |
e501603b TO |
226 | return self::$_tableName; |
227 | } | |
c3fc2621 | 228 | |
e501603b TO |
229 | /** |
230 | * Returns if this table needs to be logged | |
231 | * | |
c3fc2621 | 232 | * @return bool |
e501603b | 233 | */ |
c3fc2621 | 234 | public function getLog() { |
e501603b TO |
235 | return self::$_log; |
236 | } | |
c3fc2621 | 237 | |
e501603b TO |
238 | /** |
239 | * Returns the list of fields that can be imported | |
240 | * | |
241 | * @param bool $prefix | |
242 | * | |
243 | * @return array | |
244 | */ | |
c3fc2621 CW |
245 | public static function &import($prefix = FALSE) { |
246 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'discount', $prefix, []); | |
60808919 | 247 | return $r; |
e501603b | 248 | } |
c3fc2621 | 249 | |
e501603b TO |
250 | /** |
251 | * Returns the list of fields that can be exported | |
252 | * | |
253 | * @param bool $prefix | |
254 | * | |
255 | * @return array | |
256 | */ | |
c3fc2621 CW |
257 | public static function &export($prefix = FALSE) { |
258 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'discount', $prefix, []); | |
60808919 | 259 | return $r; |
e501603b | 260 | } |
c3fc2621 | 261 | |
e7a6b91a AS |
262 | /** |
263 | * Returns the list of indices | |
c3fc2621 CW |
264 | * |
265 | * @param bool $localize | |
266 | * | |
267 | * @return array | |
e7a6b91a AS |
268 | */ |
269 | public static function indices($localize = TRUE) { | |
c3fc2621 CW |
270 | $indices = [ |
271 | 'index_entity' => [ | |
e7a6b91a | 272 | 'name' => 'index_entity', |
c3fc2621 | 273 | 'field' => [ |
e7a6b91a AS |
274 | 0 => 'entity_table', |
275 | 1 => 'entity_id', | |
c3fc2621 CW |
276 | ], |
277 | 'localizable' => FALSE, | |
e7a6b91a | 278 | 'sig' => 'civicrm_discount::0::entity_table::entity_id', |
c3fc2621 CW |
279 | ], |
280 | 'index_entity_option_id' => [ | |
e7a6b91a | 281 | 'name' => 'index_entity_option_id', |
c3fc2621 | 282 | 'field' => [ |
e7a6b91a AS |
283 | 0 => 'entity_table', |
284 | 1 => 'entity_id', | |
285 | 2 => 'price_set_id', | |
c3fc2621 CW |
286 | ], |
287 | 'localizable' => FALSE, | |
e7a6b91a | 288 | 'sig' => 'civicrm_discount::0::entity_table::entity_id::price_set_id', |
c3fc2621 CW |
289 | ], |
290 | ]; | |
e7a6b91a AS |
291 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
292 | } | |
c3fc2621 | 293 | |
e501603b | 294 | } |