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