Add "labelField" metadata to entities
[civicrm-core.git] / CRM / Member / DAO / MembershipType.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Member/MembershipType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:fc8f5dc27b9a33132464da9c006ec85d)
10 */
11
12 /**
13 * Database access object for the MembershipType entity.
14 */
15 class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
18 const COMPONENT = 'CiviMember';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_membership_type';
26
27 /**
28 * Field to show when displaying a record.
29 *
30 * @var string
31 */
32 public static $_labelField = 'name';
33
34 /**
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 *
37 * @var bool
38 */
39 public static $_log = TRUE;
40
41 /**
42 * Membership Id
43 *
44 * @var int
45 */
46 public $id;
47
48 /**
49 * Which Domain is this match entry for
50 *
51 * @var int
52 */
53 public $domain_id;
54
55 /**
56 * Name of Membership Type
57 *
58 * @var string
59 */
60 public $name;
61
62 /**
63 * Description of Membership Type
64 *
65 * @var string
66 */
67 public $description;
68
69 /**
70 * Owner organization for this membership type. FK to Contact ID
71 *
72 * @var int
73 */
74 public $member_of_contact_id;
75
76 /**
77 * If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id
78 *
79 * @var int
80 */
81 public $financial_type_id;
82
83 /**
84 * Minimum fee for this membership (0 for free/complimentary memberships).
85 *
86 * @var float
87 */
88 public $minimum_fee;
89
90 /**
91 * Unit in which membership period is expressed.
92 *
93 * @var string
94 */
95 public $duration_unit;
96
97 /**
98 * Number of duration units in membership period (e.g. 1 year, 12 months).
99 *
100 * @var int
101 */
102 public $duration_interval;
103
104 /**
105 * Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.
106 *
107 * @var string
108 */
109 public $period_type;
110
111 /**
112 * For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.
113 *
114 * @var int
115 */
116 public $fixed_period_start_day;
117
118 /**
119 * For fixed period memberships, signups after this day (mmdd) rollover to next period.
120 *
121 * @var int
122 */
123 public $fixed_period_rollover_day;
124
125 /**
126 * FK to Relationship Type ID
127 *
128 * @var string
129 */
130 public $relationship_type_id;
131
132 /**
133 * @var string
134 */
135 public $relationship_direction;
136
137 /**
138 * Maximum number of related memberships.
139 *
140 * @var int
141 */
142 public $max_related;
143
144 /**
145 * @var string
146 */
147 public $visibility;
148
149 /**
150 * @var int
151 */
152 public $weight;
153
154 /**
155 * Receipt Text for membership signup
156 *
157 * @var string
158 */
159 public $receipt_text_signup;
160
161 /**
162 * Receipt Text for membership renewal
163 *
164 * @var string
165 */
166 public $receipt_text_renewal;
167
168 /**
169 * 0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;
170 *
171 * @var bool
172 */
173 public $auto_renew;
174
175 /**
176 * Is this membership_type enabled
177 *
178 * @var bool
179 */
180 public $is_active;
181
182 /**
183 * Class constructor.
184 */
185 public function __construct() {
186 $this->__table = 'civicrm_membership_type';
187 parent::__construct();
188 }
189
190 /**
191 * Returns localized title of this entity.
192 *
193 * @param bool $plural
194 * Whether to return the plural version of the title.
195 */
196 public static function getEntityTitle($plural = FALSE) {
197 return $plural ? ts('Membership Types') : ts('Membership Type');
198 }
199
200 /**
201 * Returns foreign keys and entity references.
202 *
203 * @return array
204 * [CRM_Core_Reference_Interface]
205 */
206 public static function getReferenceColumns() {
207 if (!isset(Civi::$statics[__CLASS__]['links'])) {
208 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
209 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
210 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'member_of_contact_id', 'civicrm_contact', 'id');
211 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
212 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
213 }
214 return Civi::$statics[__CLASS__]['links'];
215 }
216
217 /**
218 * Returns all the column names of this table
219 *
220 * @return array
221 */
222 public static function &fields() {
223 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
224 Civi::$statics[__CLASS__]['fields'] = [
225 'id' => [
226 'name' => 'id',
227 'type' => CRM_Utils_Type::T_INT,
228 'title' => ts('Membership Type ID'),
229 'description' => ts('Membership Id'),
230 'required' => TRUE,
231 'where' => 'civicrm_membership_type.id',
232 'table_name' => 'civicrm_membership_type',
233 'entity' => 'MembershipType',
234 'bao' => 'CRM_Member_BAO_MembershipType',
235 'localizable' => 0,
236 'add' => '1.5',
237 ],
238 'domain_id' => [
239 'name' => 'domain_id',
240 'type' => CRM_Utils_Type::T_INT,
241 'title' => ts('Membership Type Domain'),
242 'description' => ts('Which Domain is this match entry for'),
243 'required' => TRUE,
244 'where' => 'civicrm_membership_type.domain_id',
245 'table_name' => 'civicrm_membership_type',
246 'entity' => 'MembershipType',
247 'bao' => 'CRM_Member_BAO_MembershipType',
248 'localizable' => 0,
249 'FKClassName' => 'CRM_Core_DAO_Domain',
250 'pseudoconstant' => [
251 'table' => 'civicrm_domain',
252 'keyColumn' => 'id',
253 'labelColumn' => 'name',
254 ],
255 'add' => '3.0',
256 ],
257 'membership_type' => [
258 'name' => 'name',
259 'type' => CRM_Utils_Type::T_STRING,
260 'title' => ts('Membership Type'),
261 'description' => ts('Name of Membership Type'),
262 'required' => TRUE,
263 'maxlength' => 128,
264 'size' => CRM_Utils_Type::HUGE,
265 'import' => TRUE,
266 'where' => 'civicrm_membership_type.name',
267 'export' => TRUE,
268 'table_name' => 'civicrm_membership_type',
269 'entity' => 'MembershipType',
270 'bao' => 'CRM_Member_BAO_MembershipType',
271 'localizable' => 1,
272 'html' => [
273 'type' => 'Text',
274 'label' => ts("Name"),
275 ],
276 'add' => '1.5',
277 ],
278 'description' => [
279 'name' => 'description',
280 'type' => CRM_Utils_Type::T_STRING,
281 'title' => ts('Membership Type Description'),
282 'description' => ts('Description of Membership Type'),
283 'maxlength' => 255,
284 'size' => CRM_Utils_Type::HUGE,
285 'where' => 'civicrm_membership_type.description',
286 'table_name' => 'civicrm_membership_type',
287 'entity' => 'MembershipType',
288 'bao' => 'CRM_Member_BAO_MembershipType',
289 'localizable' => 1,
290 'html' => [
291 'type' => 'TextArea',
292 'label' => ts("Description"),
293 ],
294 'add' => '1.5',
295 ],
296 'member_of_contact_id' => [
297 'name' => 'member_of_contact_id',
298 'type' => CRM_Utils_Type::T_INT,
299 'title' => ts('Membership Type Organization'),
300 'description' => ts('Owner organization for this membership type. FK to Contact ID'),
301 'required' => TRUE,
302 'where' => 'civicrm_membership_type.member_of_contact_id',
303 'table_name' => 'civicrm_membership_type',
304 'entity' => 'MembershipType',
305 'bao' => 'CRM_Member_BAO_MembershipType',
306 'localizable' => 0,
307 'FKClassName' => 'CRM_Contact_DAO_Contact',
308 'add' => '1.5',
309 ],
310 'financial_type_id' => [
311 'name' => 'financial_type_id',
312 'type' => CRM_Utils_Type::T_INT,
313 'title' => ts('Membership Financial Type'),
314 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
315 'required' => TRUE,
316 'where' => 'civicrm_membership_type.financial_type_id',
317 'table_name' => 'civicrm_membership_type',
318 'entity' => 'MembershipType',
319 'bao' => 'CRM_Member_BAO_MembershipType',
320 'localizable' => 0,
321 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
322 'pseudoconstant' => [
323 'table' => 'civicrm_financial_type',
324 'keyColumn' => 'id',
325 'labelColumn' => 'name',
326 ],
327 'add' => '4.3',
328 ],
329 'minimum_fee' => [
330 'name' => 'minimum_fee',
331 'type' => CRM_Utils_Type::T_MONEY,
332 'title' => ts('Membership Type Minimum Fee'),
333 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'),
334 'precision' => [
335 18,
336 9,
337 ],
338 'where' => 'civicrm_membership_type.minimum_fee',
339 'default' => '0',
340 'table_name' => 'civicrm_membership_type',
341 'entity' => 'MembershipType',
342 'bao' => 'CRM_Member_BAO_MembershipType',
343 'localizable' => 0,
344 'html' => [
345 'type' => 'Text',
346 'label' => ts("Minimum Fee"),
347 ],
348 'add' => '1.5',
349 ],
350 'duration_unit' => [
351 'name' => 'duration_unit',
352 'type' => CRM_Utils_Type::T_STRING,
353 'title' => ts('Membership Type Duration Unit'),
354 'description' => ts('Unit in which membership period is expressed.'),
355 'maxlength' => 8,
356 'size' => CRM_Utils_Type::EIGHT,
357 'where' => 'civicrm_membership_type.duration_unit',
358 'table_name' => 'civicrm_membership_type',
359 'entity' => 'MembershipType',
360 'bao' => 'CRM_Member_BAO_MembershipType',
361 'localizable' => 0,
362 'html' => [
363 'type' => 'Select',
364 ],
365 'pseudoconstant' => [
366 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
367 ],
368 'add' => '1.5',
369 ],
370 'duration_interval' => [
371 'name' => 'duration_interval',
372 'type' => CRM_Utils_Type::T_INT,
373 'title' => ts('Membership Type Duration Interval'),
374 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
375 'where' => 'civicrm_membership_type.duration_interval',
376 'table_name' => 'civicrm_membership_type',
377 'entity' => 'MembershipType',
378 'bao' => 'CRM_Member_BAO_MembershipType',
379 'localizable' => 0,
380 'html' => [
381 'type' => 'Text',
382 ],
383 'add' => '1.5',
384 ],
385 'period_type' => [
386 'name' => 'period_type',
387 'type' => CRM_Utils_Type::T_STRING,
388 'title' => ts('Membership Type Plan'),
389 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
390 'required' => TRUE,
391 'maxlength' => 8,
392 'size' => CRM_Utils_Type::EIGHT,
393 'where' => 'civicrm_membership_type.period_type',
394 'table_name' => 'civicrm_membership_type',
395 'entity' => 'MembershipType',
396 'bao' => 'CRM_Member_BAO_MembershipType',
397 'localizable' => 0,
398 'html' => [
399 'type' => 'Select',
400 ],
401 'pseudoconstant' => [
402 'callback' => 'CRM_Core_SelectValues::periodType',
403 ],
404 'add' => '1.5',
405 ],
406 'fixed_period_start_day' => [
407 'name' => 'fixed_period_start_day',
408 'type' => CRM_Utils_Type::T_INT,
409 'title' => ts('Fixed Period Start Day'),
410 'description' => ts('For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.'),
411 'where' => 'civicrm_membership_type.fixed_period_start_day',
412 'table_name' => 'civicrm_membership_type',
413 'entity' => 'MembershipType',
414 'bao' => 'CRM_Member_BAO_MembershipType',
415 'localizable' => 0,
416 'add' => '1.5',
417 ],
418 'fixed_period_rollover_day' => [
419 'name' => 'fixed_period_rollover_day',
420 'type' => CRM_Utils_Type::T_INT,
421 'title' => ts('Fixed Period Rollover Day'),
422 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
423 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
424 'table_name' => 'civicrm_membership_type',
425 'entity' => 'MembershipType',
426 'bao' => 'CRM_Member_BAO_MembershipType',
427 'localizable' => 0,
428 'add' => '1.5',
429 ],
430 'relationship_type_id' => [
431 'name' => 'relationship_type_id',
432 'type' => CRM_Utils_Type::T_STRING,
433 'title' => ts('Membership Type Relationship'),
434 'description' => ts('FK to Relationship Type ID'),
435 'maxlength' => 64,
436 'size' => CRM_Utils_Type::BIG,
437 'where' => 'civicrm_membership_type.relationship_type_id',
438 'table_name' => 'civicrm_membership_type',
439 'entity' => 'MembershipType',
440 'bao' => 'CRM_Member_BAO_MembershipType',
441 'localizable' => 0,
442 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
443 'add' => '1.5',
444 ],
445 'relationship_direction' => [
446 'name' => 'relationship_direction',
447 'type' => CRM_Utils_Type::T_STRING,
448 'title' => ts('Relationship Direction'),
449 'maxlength' => 128,
450 'size' => CRM_Utils_Type::HUGE,
451 'where' => 'civicrm_membership_type.relationship_direction',
452 'table_name' => 'civicrm_membership_type',
453 'entity' => 'MembershipType',
454 'bao' => 'CRM_Member_BAO_MembershipType',
455 'localizable' => 0,
456 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
457 'add' => '1.7',
458 ],
459 'max_related' => [
460 'name' => 'max_related',
461 'type' => CRM_Utils_Type::T_INT,
462 'title' => ts('Max Related Members for Type'),
463 'description' => ts('Maximum number of related memberships.'),
464 'where' => 'civicrm_membership_type.max_related',
465 'table_name' => 'civicrm_membership_type',
466 'entity' => 'MembershipType',
467 'bao' => 'CRM_Member_BAO_MembershipType',
468 'localizable' => 0,
469 'html' => [
470 'type' => 'Text',
471 'label' => ts("Max Related"),
472 ],
473 'add' => '4.3',
474 ],
475 'visibility' => [
476 'name' => 'visibility',
477 'type' => CRM_Utils_Type::T_STRING,
478 'title' => ts('Visible'),
479 'maxlength' => 64,
480 'size' => CRM_Utils_Type::BIG,
481 'where' => 'civicrm_membership_type.visibility',
482 'table_name' => 'civicrm_membership_type',
483 'entity' => 'MembershipType',
484 'bao' => 'CRM_Member_BAO_MembershipType',
485 'localizable' => 0,
486 'html' => [
487 'type' => 'Select',
488 ],
489 'pseudoconstant' => [
490 'callback' => 'CRM_Core_SelectValues::memberVisibility',
491 ],
492 'add' => '1.5',
493 ],
494 'weight' => [
495 'name' => 'weight',
496 'type' => CRM_Utils_Type::T_INT,
497 'title' => ts('Order'),
498 'where' => 'civicrm_membership_type.weight',
499 'table_name' => 'civicrm_membership_type',
500 'entity' => 'MembershipType',
501 'bao' => 'CRM_Member_BAO_MembershipType',
502 'localizable' => 0,
503 'html' => [
504 'type' => 'Text',
505 ],
506 'add' => '1.5',
507 ],
508 'receipt_text_signup' => [
509 'name' => 'receipt_text_signup',
510 'type' => CRM_Utils_Type::T_STRING,
511 'title' => ts('Membership Type Receipt Text'),
512 'description' => ts('Receipt Text for membership signup'),
513 'maxlength' => 255,
514 'size' => CRM_Utils_Type::HUGE,
515 'where' => 'civicrm_membership_type.receipt_text_signup',
516 'table_name' => 'civicrm_membership_type',
517 'entity' => 'MembershipType',
518 'bao' => 'CRM_Member_BAO_MembershipType',
519 'localizable' => 0,
520 'html' => [
521 'type' => 'TextArea',
522 ],
523 'add' => '2.0',
524 ],
525 'receipt_text_renewal' => [
526 'name' => 'receipt_text_renewal',
527 'type' => CRM_Utils_Type::T_STRING,
528 'title' => ts('Membership Type Renewal Text'),
529 'description' => ts('Receipt Text for membership renewal'),
530 'maxlength' => 255,
531 'size' => CRM_Utils_Type::HUGE,
532 'where' => 'civicrm_membership_type.receipt_text_renewal',
533 'table_name' => 'civicrm_membership_type',
534 'entity' => 'MembershipType',
535 'bao' => 'CRM_Member_BAO_MembershipType',
536 'localizable' => 0,
537 'html' => [
538 'type' => 'TextArea',
539 ],
540 'add' => '2.0',
541 ],
542 'auto_renew' => [
543 'name' => 'auto_renew',
544 'type' => CRM_Utils_Type::T_BOOLEAN,
545 'title' => ts('Auto Renew'),
546 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
547 'where' => 'civicrm_membership_type.auto_renew',
548 'default' => '0',
549 'table_name' => 'civicrm_membership_type',
550 'entity' => 'MembershipType',
551 'bao' => 'CRM_Member_BAO_MembershipType',
552 'localizable' => 0,
553 'html' => [
554 'type' => 'Radio',
555 ],
556 'pseudoconstant' => [
557 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
558 ],
559 'add' => '3.3',
560 ],
561 'is_active' => [
562 'name' => 'is_active',
563 'type' => CRM_Utils_Type::T_BOOLEAN,
564 'title' => ts('Is Active'),
565 'description' => ts('Is this membership_type enabled'),
566 'where' => 'civicrm_membership_type.is_active',
567 'default' => '1',
568 'table_name' => 'civicrm_membership_type',
569 'entity' => 'MembershipType',
570 'bao' => 'CRM_Member_BAO_MembershipType',
571 'localizable' => 0,
572 'html' => [
573 'type' => 'CheckBox',
574 'label' => ts("Enabled?"),
575 ],
576 'add' => '1.5',
577 ],
578 ];
579 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
580 }
581 return Civi::$statics[__CLASS__]['fields'];
582 }
583
584 /**
585 * Return a mapping from field-name to the corresponding key (as used in fields()).
586 *
587 * @return array
588 * Array(string $name => string $uniqueName).
589 */
590 public static function &fieldKeys() {
591 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
592 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
593 }
594 return Civi::$statics[__CLASS__]['fieldKeys'];
595 }
596
597 /**
598 * Returns the names of this table
599 *
600 * @return string
601 */
602 public static function getTableName() {
603 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
604 }
605
606 /**
607 * Returns if this table needs to be logged
608 *
609 * @return bool
610 */
611 public function getLog() {
612 return self::$_log;
613 }
614
615 /**
616 * Returns the list of fields that can be imported
617 *
618 * @param bool $prefix
619 *
620 * @return array
621 */
622 public static function &import($prefix = FALSE) {
623 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_type', $prefix, []);
624 return $r;
625 }
626
627 /**
628 * Returns the list of fields that can be exported
629 *
630 * @param bool $prefix
631 *
632 * @return array
633 */
634 public static function &export($prefix = FALSE) {
635 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_type', $prefix, []);
636 return $r;
637 }
638
639 /**
640 * Returns the list of indices
641 *
642 * @param bool $localize
643 *
644 * @return array
645 */
646 public static function indices($localize = TRUE) {
647 $indices = [
648 'index_relationship_type_id' => [
649 'name' => 'index_relationship_type_id',
650 'field' => [
651 0 => 'relationship_type_id',
652 ],
653 'localizable' => FALSE,
654 'sig' => 'civicrm_membership_type::0::relationship_type_id',
655 ],
656 ];
657 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
658 }
659
660 }