Merge pull request #22865 from demeritcowboy/contributionview
[civicrm-core.git] / CRM / Contribute / DAO / Premium.php
CommitLineData
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/Contribute/Premium.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:a458d7c03a26386d799d9d69db691051)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Premium entity.
f41f0342 14 */
e501603b 15class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.4';
d31fb4e3 18 const COMPONENT = 'CiviContribute';
c3fc2621 19
e501603b 20 /**
f41f0342 21 * Static instance to hold the table name.
e501603b
TO
22 *
23 * @var string
24 */
fa45b5b9 25 public static $_tableName = 'civicrm_premiums';
c3fc2621 26
e501603b 27 /**
f41f0342 28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 29 *
c3fc2621 30 * @var bool
e501603b 31 */
fa45b5b9 32 public static $_log = TRUE;
c3fc2621 33
e501603b 34 /**
28979d65
CW
35 * @var int|string|null
36 * (SQL type: int unsigned)
37 * Note that values will be retrieved from the database as a string.
e501603b
TO
38 */
39 public $id;
c3fc2621 40
e501603b
TO
41 /**
42 * Joins these premium settings to another object. Always civicrm_contribution_page for now.
43 *
44 * @var string
28979d65
CW
45 * (SQL type: varchar(64))
46 * Note that values will be retrieved from the database as a string.
e501603b
TO
47 */
48 public $entity_table;
c3fc2621 49
e501603b 50 /**
28979d65
CW
51 * @var int|string
52 * (SQL type: int unsigned)
53 * Note that values will be retrieved from the database as a string.
e501603b
TO
54 */
55 public $entity_id;
c3fc2621 56
e501603b
TO
57 /**
58 * Is the Premiums feature enabled for this page?
59 *
28979d65
CW
60 * @var bool|string
61 * (SQL type: tinyint)
62 * Note that values will be retrieved from the database as a string.
e501603b
TO
63 */
64 public $premiums_active;
c3fc2621 65
e501603b
TO
66 /**
67 * Title for Premiums section.
68 *
28979d65
CW
69 * @var string|null
70 * (SQL type: varchar(255))
71 * Note that values will be retrieved from the database as a string.
e501603b
TO
72 */
73 public $premiums_intro_title;
c3fc2621 74
e501603b
TO
75 /**
76 * Displayed in <div> at top of Premiums section of page. Text and HTML allowed.
77 *
28979d65
CW
78 * @var string|null
79 * (SQL type: text)
80 * Note that values will be retrieved from the database as a string.
e501603b
TO
81 */
82 public $premiums_intro_text;
c3fc2621 83
e501603b
TO
84 /**
85 * This email address is included in receipts if it is populated and a premium has been selected.
86 *
28979d65
CW
87 * @var string|null
88 * (SQL type: varchar(100))
89 * Note that values will be retrieved from the database as a string.
e501603b
TO
90 */
91 public $premiums_contact_email;
c3fc2621 92
e501603b
TO
93 /**
94 * This phone number is included in receipts if it is populated and a premium has been selected.
95 *
28979d65
CW
96 * @var string|null
97 * (SQL type: varchar(50))
98 * Note that values will be retrieved from the database as a string.
e501603b
TO
99 */
100 public $premiums_contact_phone;
c3fc2621 101
e501603b
TO
102 /**
103 * Boolean. Should we automatically display minimum contribution amount text after the premium descriptions.
104 *
28979d65
CW
105 * @var bool|string
106 * (SQL type: tinyint)
107 * Note that values will be retrieved from the database as a string.
e501603b
TO
108 */
109 public $premiums_display_min_contribution;
c3fc2621 110
e501603b
TO
111 /**
112 * Label displayed for No Thank-you option in premiums block (e.g. No thank you)
113 *
28979d65
CW
114 * @var string|null
115 * (SQL type: varchar(255))
116 * Note that values will be retrieved from the database as a string.
e501603b
TO
117 */
118 public $premiums_nothankyou_label;
c3fc2621 119
e501603b 120 /**
28979d65
CW
121 * @var int|string|null
122 * (SQL type: int unsigned)
123 * Note that values will be retrieved from the database as a string.
e501603b
TO
124 */
125 public $premiums_nothankyou_position;
c3fc2621 126
e501603b 127 /**
f41f0342 128 * Class constructor.
e501603b 129 */
c3fc2621 130 public function __construct() {
e501603b
TO
131 $this->__table = 'civicrm_premiums';
132 parent::__construct();
133 }
c3fc2621 134
449c4e6b
CW
135 /**
136 * Returns localized title of this entity.
7b66c3b5
AH
137 *
138 * @param bool $plural
139 * Whether to return the plural version of the title.
449c4e6b 140 */
7b66c3b5
AH
141 public static function getEntityTitle($plural = FALSE) {
142 return $plural ? ts('Premiums') : ts('Premium');
449c4e6b
CW
143 }
144
e501603b 145 /**
f41f0342 146 * Returns foreign keys and entity references.
e501603b
TO
147 *
148 * @return array
149 * [CRM_Core_Reference_Interface]
150 */
c3fc2621 151 public static function getReferenceColumns() {
346aaaba 152 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 153 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 154 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
346aaaba 155 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 156 }
346aaaba 157 return Civi::$statics[__CLASS__]['links'];
e501603b 158 }
c3fc2621 159
e501603b
TO
160 /**
161 * Returns all the column names of this table
162 *
163 * @return array
164 */
c3fc2621 165 public static function &fields() {
346aaaba 166 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
167 Civi::$statics[__CLASS__]['fields'] = [
168 'id' => [
e501603b
TO
169 'name' => 'id',
170 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
171 'title' => ts('Premium ID'),
172 'required' => TRUE,
a36434b9 173 'where' => 'civicrm_premiums.id',
522a26c9 174 'table_name' => 'civicrm_premiums',
175 'entity' => 'Premium',
176 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 177 'localizable' => 0,
2cbbebe8
A
178 'html' => [
179 'type' => 'Number',
180 ],
1fe423d6 181 'readonly' => TRUE,
a9d0587b 182 'add' => '1.4',
c3fc2621
CW
183 ],
184 'entity_table' => [
e501603b
TO
185 'name' => 'entity_table',
186 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 187 'title' => ts('Premium Entity'),
215b423e 188 'description' => ts('Joins these premium settings to another object. Always civicrm_contribution_page for now.'),
c3fc2621 189 'required' => TRUE,
e501603b
TO
190 'maxlength' => 64,
191 'size' => CRM_Utils_Type::BIG,
a36434b9 192 'where' => 'civicrm_premiums.entity_table',
522a26c9 193 'table_name' => 'civicrm_premiums',
194 'entity' => 'Premium',
195 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 196 'localizable' => 0,
a9d0587b 197 'add' => '1.4',
c3fc2621
CW
198 ],
199 'entity_id' => [
e501603b
TO
200 'name' => 'entity_id',
201 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
202 'title' => ts('Premium entity ID'),
203 'required' => TRUE,
a36434b9 204 'where' => 'civicrm_premiums.entity_id',
522a26c9 205 'table_name' => 'civicrm_premiums',
206 'entity' => 'Premium',
207 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 208 'localizable' => 0,
a9d0587b 209 'add' => '1.4',
c3fc2621
CW
210 ],
211 'premiums_active' => [
e501603b
TO
212 'name' => 'premiums_active',
213 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 214 'title' => ts('Is Premium Active?'),
215b423e 215 'description' => ts('Is the Premiums feature enabled for this page?'),
c3fc2621 216 'required' => TRUE,
a36434b9 217 'where' => 'civicrm_premiums.premiums_active',
45a83e42 218 'default' => '0',
522a26c9 219 'table_name' => 'civicrm_premiums',
220 'entity' => 'Premium',
221 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 222 'localizable' => 0,
a9d0587b 223 'add' => '1.4',
c3fc2621
CW
224 ],
225 'premiums_intro_title' => [
e501603b
TO
226 'name' => 'premiums_intro_title',
227 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 228 'title' => ts('Title for Premiums section'),
215b423e 229 'description' => ts('Title for Premiums section.'),
e501603b
TO
230 'maxlength' => 255,
231 'size' => CRM_Utils_Type::HUGE,
a36434b9 232 'where' => 'civicrm_premiums.premiums_intro_title',
522a26c9 233 'table_name' => 'civicrm_premiums',
234 'entity' => 'Premium',
235 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 236 'localizable' => 1,
a9d0587b 237 'add' => '1.4',
c3fc2621
CW
238 ],
239 'premiums_intro_text' => [
e501603b
TO
240 'name' => 'premiums_intro_text',
241 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 242 'title' => ts('Premium Introductory Text'),
215b423e 243 'description' => ts('Displayed in <div> at top of Premiums section of page. Text and HTML allowed.'),
a36434b9 244 'where' => 'civicrm_premiums.premiums_intro_text',
522a26c9 245 'table_name' => 'civicrm_premiums',
246 'entity' => 'Premium',
247 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 248 'localizable' => 1,
a9d0587b 249 'add' => '1.4',
c3fc2621
CW
250 ],
251 'premiums_contact_email' => [
e501603b
TO
252 'name' => 'premiums_contact_email',
253 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 254 'title' => ts('Premium Contact Email'),
215b423e 255 'description' => ts('This email address is included in receipts if it is populated and a premium has been selected.'),
e501603b
TO
256 'maxlength' => 100,
257 'size' => CRM_Utils_Type::HUGE,
a36434b9 258 'where' => 'civicrm_premiums.premiums_contact_email',
522a26c9 259 'table_name' => 'civicrm_premiums',
260 'entity' => 'Premium',
261 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 262 'localizable' => 0,
a9d0587b 263 'add' => '1.4',
c3fc2621
CW
264 ],
265 'premiums_contact_phone' => [
e501603b
TO
266 'name' => 'premiums_contact_phone',
267 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 268 'title' => ts('Premiums Contact Phone'),
215b423e 269 'description' => ts('This phone number is included in receipts if it is populated and a premium has been selected.'),
e501603b
TO
270 'maxlength' => 50,
271 'size' => CRM_Utils_Type::BIG,
a36434b9 272 'where' => 'civicrm_premiums.premiums_contact_phone',
522a26c9 273 'table_name' => 'civicrm_premiums',
274 'entity' => 'Premium',
275 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 276 'localizable' => 0,
a9d0587b 277 'add' => '1.4',
c3fc2621
CW
278 ],
279 'premiums_display_min_contribution' => [
e501603b
TO
280 'name' => 'premiums_display_min_contribution',
281 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 282 'title' => ts('Display Minimum Contribution?'),
215b423e 283 'description' => ts('Boolean. Should we automatically display minimum contribution amount text after the premium descriptions.'),
c3fc2621 284 'required' => TRUE,
a36434b9 285 'where' => 'civicrm_premiums.premiums_display_min_contribution',
522a26c9 286 'table_name' => 'civicrm_premiums',
287 'entity' => 'Premium',
288 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 289 'localizable' => 0,
a9d0587b 290 'add' => '1.4',
c3fc2621
CW
291 ],
292 'premiums_nothankyou_label' => [
e501603b
TO
293 'name' => 'premiums_nothankyou_label',
294 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 295 'title' => ts('No Thank-you Text'),
215b423e 296 'description' => ts('Label displayed for No Thank-you option in premiums block (e.g. No thank you)'),
e501603b
TO
297 'maxlength' => 255,
298 'size' => CRM_Utils_Type::HUGE,
a36434b9 299 'where' => 'civicrm_premiums.premiums_nothankyou_label',
522a26c9 300 'table_name' => 'civicrm_premiums',
301 'entity' => 'Premium',
302 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 303 'localizable' => 1,
a9d0587b 304 'add' => '4.3',
c3fc2621
CW
305 ],
306 'premiums_nothankyou_position' => [
e501603b
TO
307 'name' => 'premiums_nothankyou_position',
308 'type' => CRM_Utils_Type::T_INT,
c3fc2621 309 'title' => ts('No Thank-you Position'),
a36434b9 310 'where' => 'civicrm_premiums.premiums_nothankyou_position',
e501603b 311 'default' => '1',
522a26c9 312 'table_name' => 'civicrm_premiums',
313 'entity' => 'Premium',
314 'bao' => 'CRM_Contribute_BAO_Premium',
6a7e5e5d 315 'localizable' => 0,
a9d0587b 316 'add' => '4.3',
c3fc2621
CW
317 ],
318 ];
346aaaba 319 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 320 }
346aaaba 321 return Civi::$statics[__CLASS__]['fields'];
e501603b 322 }
c3fc2621 323
e501603b 324 /**
bd8e0b14 325 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
326 *
327 * @return array
bd8e0b14 328 * Array(string $name => string $uniqueName).
e501603b 329 */
c3fc2621 330 public static function &fieldKeys() {
bd8e0b14
TO
331 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
332 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 333 }
bd8e0b14 334 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 335 }
c3fc2621 336
e501603b
TO
337 /**
338 * Returns the names of this table
339 *
340 * @return string
341 */
c3fc2621 342 public static function getTableName() {
e501603b
TO
343 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
344 }
c3fc2621 345
e501603b
TO
346 /**
347 * Returns if this table needs to be logged
348 *
c3fc2621 349 * @return bool
e501603b 350 */
c3fc2621 351 public function getLog() {
e501603b
TO
352 return self::$_log;
353 }
c3fc2621 354
e501603b
TO
355 /**
356 * Returns the list of fields that can be imported
357 *
358 * @param bool $prefix
359 *
360 * @return array
361 */
c3fc2621
CW
362 public static function &import($prefix = FALSE) {
363 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'premiums', $prefix, []);
60808919 364 return $r;
e501603b 365 }
c3fc2621 366
e501603b
TO
367 /**
368 * Returns the list of fields that can be exported
369 *
370 * @param bool $prefix
371 *
372 * @return array
373 */
c3fc2621
CW
374 public static function &export($prefix = FALSE) {
375 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'premiums', $prefix, []);
60808919 376 return $r;
e501603b 377 }
c3fc2621 378
e7a6b91a
AS
379 /**
380 * Returns the list of indices
c3fc2621
CW
381 *
382 * @param bool $localize
383 *
384 * @return array
e7a6b91a
AS
385 */
386 public static function indices($localize = TRUE) {
c3fc2621 387 $indices = [];
e7a6b91a
AS
388 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
389 }
c3fc2621 390
e501603b 391}