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