Merge pull request #21264 from civicrm/5.41
[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:9cb69957096aad15ee7d55a4efceb53e)
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 int
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 'html' => [
237 'type' => 'Number',
238 ],
239 'readonly' => TRUE,
240 'add' => '1.5',
241 ],
242 'domain_id' => [
243 'name' => 'domain_id',
244 'type' => CRM_Utils_Type::T_INT,
245 'title' => ts('Domain ID'),
246 'description' => ts('Which Domain is this match entry for'),
247 'required' => TRUE,
248 'where' => 'civicrm_membership_type.domain_id',
249 'table_name' => 'civicrm_membership_type',
250 'entity' => 'MembershipType',
251 'bao' => 'CRM_Member_BAO_MembershipType',
252 'localizable' => 0,
253 'FKClassName' => 'CRM_Core_DAO_Domain',
254 'html' => [
255 'label' => ts("Domain"),
256 ],
257 'pseudoconstant' => [
258 'table' => 'civicrm_domain',
259 'keyColumn' => 'id',
260 'labelColumn' => 'name',
261 ],
262 'add' => '3.0',
263 ],
264 'membership_type' => [
265 'name' => 'name',
266 'type' => CRM_Utils_Type::T_STRING,
267 'title' => ts('Membership Type'),
268 'description' => ts('Name of Membership Type'),
269 'required' => TRUE,
270 'maxlength' => 128,
271 'size' => CRM_Utils_Type::HUGE,
272 'import' => TRUE,
273 'where' => 'civicrm_membership_type.name',
274 'export' => TRUE,
275 'table_name' => 'civicrm_membership_type',
276 'entity' => 'MembershipType',
277 'bao' => 'CRM_Member_BAO_MembershipType',
278 'localizable' => 1,
279 'html' => [
280 'type' => 'Text',
281 'label' => ts("Name"),
282 ],
283 'add' => '1.5',
284 ],
285 'description' => [
286 'name' => 'description',
287 'type' => CRM_Utils_Type::T_STRING,
288 'title' => ts('Description'),
289 'description' => ts('Description of Membership Type'),
290 'maxlength' => 255,
291 'size' => CRM_Utils_Type::HUGE,
292 'where' => 'civicrm_membership_type.description',
293 'table_name' => 'civicrm_membership_type',
294 'entity' => 'MembershipType',
295 'bao' => 'CRM_Member_BAO_MembershipType',
296 'localizable' => 1,
297 'html' => [
298 'type' => 'TextArea',
299 'label' => ts("Description"),
300 ],
301 'add' => '1.5',
302 ],
303 'member_of_contact_id' => [
304 'name' => 'member_of_contact_id',
305 'type' => CRM_Utils_Type::T_INT,
306 'title' => ts('Organization ID'),
307 'description' => ts('Owner organization for this membership type. FK to Contact ID'),
308 'required' => TRUE,
309 'where' => 'civicrm_membership_type.member_of_contact_id',
310 'table_name' => 'civicrm_membership_type',
311 'entity' => 'MembershipType',
312 'bao' => 'CRM_Member_BAO_MembershipType',
313 'localizable' => 0,
314 'FKClassName' => 'CRM_Contact_DAO_Contact',
315 'html' => [
316 'label' => ts("Organization"),
317 ],
318 'add' => '1.5',
319 ],
320 'financial_type_id' => [
321 'name' => 'financial_type_id',
322 'type' => CRM_Utils_Type::T_INT,
323 'title' => ts('Financial Type ID'),
324 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
325 'required' => TRUE,
326 'where' => 'civicrm_membership_type.financial_type_id',
327 'table_name' => 'civicrm_membership_type',
328 'entity' => 'MembershipType',
329 'bao' => 'CRM_Member_BAO_MembershipType',
330 'localizable' => 0,
331 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
332 'html' => [
333 'label' => ts("Financial Type"),
334 ],
335 'pseudoconstant' => [
336 'table' => 'civicrm_financial_type',
337 'keyColumn' => 'id',
338 'labelColumn' => 'name',
339 ],
340 'add' => '4.3',
341 ],
342 'minimum_fee' => [
343 'name' => 'minimum_fee',
344 'type' => CRM_Utils_Type::T_MONEY,
345 'title' => ts('Minimum Fee'),
346 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'),
347 'precision' => [
348 18,
349 9,
350 ],
351 'where' => 'civicrm_membership_type.minimum_fee',
352 'default' => '0',
353 'table_name' => 'civicrm_membership_type',
354 'entity' => 'MembershipType',
355 'bao' => 'CRM_Member_BAO_MembershipType',
356 'localizable' => 0,
357 'html' => [
358 'type' => 'Text',
359 'label' => ts("Minimum Fee"),
360 ],
361 'add' => '1.5',
362 ],
363 'duration_unit' => [
364 'name' => 'duration_unit',
365 'type' => CRM_Utils_Type::T_STRING,
366 'title' => ts('Membership Type Duration Unit'),
367 'description' => ts('Unit in which membership period is expressed.'),
368 'required' => TRUE,
369 'maxlength' => 8,
370 'size' => CRM_Utils_Type::EIGHT,
371 'where' => 'civicrm_membership_type.duration_unit',
372 'table_name' => 'civicrm_membership_type',
373 'entity' => 'MembershipType',
374 'bao' => 'CRM_Member_BAO_MembershipType',
375 'localizable' => 0,
376 'html' => [
377 'type' => 'Select',
378 ],
379 'pseudoconstant' => [
380 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
381 ],
382 'add' => '1.5',
383 ],
384 'duration_interval' => [
385 'name' => 'duration_interval',
386 'type' => CRM_Utils_Type::T_INT,
387 'title' => ts('Membership Type Duration Interval'),
388 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
389 'where' => 'civicrm_membership_type.duration_interval',
390 'table_name' => 'civicrm_membership_type',
391 'entity' => 'MembershipType',
392 'bao' => 'CRM_Member_BAO_MembershipType',
393 'localizable' => 0,
394 'html' => [
395 'type' => 'Text',
396 ],
397 'add' => '1.5',
398 ],
399 'period_type' => [
400 'name' => 'period_type',
401 'type' => CRM_Utils_Type::T_STRING,
402 'title' => ts('Membership Type Plan'),
403 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
404 'required' => TRUE,
405 'maxlength' => 8,
406 'size' => CRM_Utils_Type::EIGHT,
407 'where' => 'civicrm_membership_type.period_type',
408 'table_name' => 'civicrm_membership_type',
409 'entity' => 'MembershipType',
410 'bao' => 'CRM_Member_BAO_MembershipType',
411 'localizable' => 0,
412 'html' => [
413 'type' => 'Select',
414 ],
415 'pseudoconstant' => [
416 'callback' => 'CRM_Core_SelectValues::periodType',
417 ],
418 'add' => '1.5',
419 ],
420 'fixed_period_start_day' => [
421 'name' => 'fixed_period_start_day',
422 'type' => CRM_Utils_Type::T_INT,
423 'title' => ts('Fixed Period Start Day'),
424 '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.'),
425 'where' => 'civicrm_membership_type.fixed_period_start_day',
426 'table_name' => 'civicrm_membership_type',
427 'entity' => 'MembershipType',
428 'bao' => 'CRM_Member_BAO_MembershipType',
429 'localizable' => 0,
430 'add' => '1.5',
431 ],
432 'fixed_period_rollover_day' => [
433 'name' => 'fixed_period_rollover_day',
434 'type' => CRM_Utils_Type::T_INT,
435 'title' => ts('Fixed Period Rollover Day'),
436 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
437 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
438 'table_name' => 'civicrm_membership_type',
439 'entity' => 'MembershipType',
440 'bao' => 'CRM_Member_BAO_MembershipType',
441 'localizable' => 0,
442 'add' => '1.5',
443 ],
444 'relationship_type_id' => [
445 'name' => 'relationship_type_id',
446 'type' => CRM_Utils_Type::T_STRING,
447 'title' => ts('Membership Type Relationship'),
448 'description' => ts('FK to Relationship Type ID'),
449 'maxlength' => 64,
450 'size' => CRM_Utils_Type::BIG,
451 'where' => 'civicrm_membership_type.relationship_type_id',
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.5',
458 ],
459 'relationship_direction' => [
460 'name' => 'relationship_direction',
461 'type' => CRM_Utils_Type::T_STRING,
462 'title' => ts('Relationship Direction'),
463 'maxlength' => 128,
464 'size' => CRM_Utils_Type::HUGE,
465 'where' => 'civicrm_membership_type.relationship_direction',
466 'table_name' => 'civicrm_membership_type',
467 'entity' => 'MembershipType',
468 'bao' => 'CRM_Member_BAO_MembershipType',
469 'localizable' => 0,
470 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
471 'html' => [
472 'label' => ts("Relationship Direction"),
473 ],
474 'add' => '1.7',
475 ],
476 'max_related' => [
477 'name' => 'max_related',
478 'type' => CRM_Utils_Type::T_INT,
479 'title' => ts('Max Related Members for Type'),
480 'description' => ts('Maximum number of related memberships.'),
481 'where' => 'civicrm_membership_type.max_related',
482 'table_name' => 'civicrm_membership_type',
483 'entity' => 'MembershipType',
484 'bao' => 'CRM_Member_BAO_MembershipType',
485 'localizable' => 0,
486 'html' => [
487 'type' => 'Text',
488 'label' => ts("Max Related"),
489 ],
490 'add' => '4.3',
491 ],
492 'visibility' => [
493 'name' => 'visibility',
494 'type' => CRM_Utils_Type::T_STRING,
495 'title' => ts('Visible'),
496 'maxlength' => 64,
497 'size' => CRM_Utils_Type::BIG,
498 'where' => 'civicrm_membership_type.visibility',
499 'table_name' => 'civicrm_membership_type',
500 'entity' => 'MembershipType',
501 'bao' => 'CRM_Member_BAO_MembershipType',
502 'localizable' => 0,
503 'html' => [
504 'type' => 'Select',
505 ],
506 'pseudoconstant' => [
507 'callback' => 'CRM_Core_SelectValues::memberVisibility',
508 ],
509 'add' => '1.5',
510 ],
511 'weight' => [
512 'name' => 'weight',
513 'type' => CRM_Utils_Type::T_INT,
514 'title' => ts('Order'),
515 'where' => 'civicrm_membership_type.weight',
516 'table_name' => 'civicrm_membership_type',
517 'entity' => 'MembershipType',
518 'bao' => 'CRM_Member_BAO_MembershipType',
519 'localizable' => 0,
520 'html' => [
521 'type' => 'Text',
522 ],
523 'add' => '1.5',
524 ],
525 'receipt_text_signup' => [
526 'name' => 'receipt_text_signup',
527 'type' => CRM_Utils_Type::T_STRING,
528 'title' => ts('Membership Type Receipt Text'),
529 'description' => ts('Receipt Text for membership signup'),
530 'maxlength' => 255,
531 'size' => CRM_Utils_Type::HUGE,
532 'where' => 'civicrm_membership_type.receipt_text_signup',
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 'receipt_text_renewal' => [
543 'name' => 'receipt_text_renewal',
544 'type' => CRM_Utils_Type::T_STRING,
545 'title' => ts('Membership Type Renewal Text'),
546 'description' => ts('Receipt Text for membership renewal'),
547 'maxlength' => 255,
548 'size' => CRM_Utils_Type::HUGE,
549 'where' => 'civicrm_membership_type.receipt_text_renewal',
550 'table_name' => 'civicrm_membership_type',
551 'entity' => 'MembershipType',
552 'bao' => 'CRM_Member_BAO_MembershipType',
553 'localizable' => 0,
554 'html' => [
555 'type' => 'TextArea',
556 ],
557 'add' => '2.0',
558 ],
559 'auto_renew' => [
560 'name' => 'auto_renew',
561 'type' => CRM_Utils_Type::T_INT,
562 'title' => ts('Auto Renew'),
563 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
564 'where' => 'civicrm_membership_type.auto_renew',
565 'default' => '0',
566 'table_name' => 'civicrm_membership_type',
567 'entity' => 'MembershipType',
568 'bao' => 'CRM_Member_BAO_MembershipType',
569 'localizable' => 0,
570 'html' => [
571 'type' => 'Radio',
572 'label' => ts("Auto-Renew"),
573 ],
574 'pseudoconstant' => [
575 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
576 ],
577 'add' => '3.3',
578 ],
579 'is_active' => [
580 'name' => 'is_active',
581 'type' => CRM_Utils_Type::T_BOOLEAN,
582 'title' => ts('Is Active'),
583 'description' => ts('Is this membership_type enabled'),
584 'where' => 'civicrm_membership_type.is_active',
585 'default' => '1',
586 'table_name' => 'civicrm_membership_type',
587 'entity' => 'MembershipType',
588 'bao' => 'CRM_Member_BAO_MembershipType',
589 'localizable' => 0,
590 'html' => [
591 'type' => 'CheckBox',
592 'label' => ts("Enabled?"),
593 ],
594 'add' => '1.5',
595 ],
596 ];
597 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
598 }
599 return Civi::$statics[__CLASS__]['fields'];
600 }
601
602 /**
603 * Return a mapping from field-name to the corresponding key (as used in fields()).
604 *
605 * @return array
606 * Array(string $name => string $uniqueName).
607 */
608 public static function &fieldKeys() {
609 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
610 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
611 }
612 return Civi::$statics[__CLASS__]['fieldKeys'];
613 }
614
615 /**
616 * Returns the names of this table
617 *
618 * @return string
619 */
620 public static function getTableName() {
621 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
622 }
623
624 /**
625 * Returns if this table needs to be logged
626 *
627 * @return bool
628 */
629 public function getLog() {
630 return self::$_log;
631 }
632
633 /**
634 * Returns the list of fields that can be imported
635 *
636 * @param bool $prefix
637 *
638 * @return array
639 */
640 public static function &import($prefix = FALSE) {
641 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_type', $prefix, []);
642 return $r;
643 }
644
645 /**
646 * Returns the list of fields that can be exported
647 *
648 * @param bool $prefix
649 *
650 * @return array
651 */
652 public static function &export($prefix = FALSE) {
653 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_type', $prefix, []);
654 return $r;
655 }
656
657 /**
658 * Returns the list of indices
659 *
660 * @param bool $localize
661 *
662 * @return array
663 */
664 public static function indices($localize = TRUE) {
665 $indices = [
666 'index_relationship_type_id' => [
667 'name' => 'index_relationship_type_id',
668 'field' => [
669 0 => 'relationship_type_id',
670 ],
671 'localizable' => FALSE,
672 'sig' => 'civicrm_membership_type::0::relationship_type_id',
673 ],
674 ];
675 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
676 }
677
678 }