5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Member/MembershipType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ebffd1b4dde86196cd988e43adcd6ad8)
13 * Database access object for the MembershipType entity.
15 class CRM_Member_DAO_MembershipType
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.5';
18 const COMPONENT
= 'CiviMember';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_membership_type';
28 * Field to show when displaying a record.
32 public static $_labelField = 'name';
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 public static $_log = TRUE;
44 * @var int|string|null
45 * (SQL type: int unsigned)
46 * Note that values will be retrieved from the database as a string.
51 * Which Domain is this match entry for
54 * (SQL type: int unsigned)
55 * Note that values will be retrieved from the database as a string.
60 * Name of Membership Type
63 * (SQL type: varchar(128))
64 * Note that values will be retrieved from the database as a string.
69 * Description of Membership Type
72 * (SQL type: varchar(255))
73 * Note that values will be retrieved from the database as a string.
78 * Owner organization for this membership type. FK to Contact ID
81 * (SQL type: int unsigned)
82 * Note that values will be retrieved from the database as a string.
84 public $member_of_contact_id;
87 * If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id
90 * (SQL type: int unsigned)
91 * Note that values will be retrieved from the database as a string.
93 public $financial_type_id;
96 * Minimum fee for this membership (0 for free/complimentary memberships).
98 * @var float|string|null
99 * (SQL type: decimal(18,9))
100 * Note that values will be retrieved from the database as a string.
105 * Unit in which membership period is expressed.
108 * (SQL type: varchar(8))
109 * Note that values will be retrieved from the database as a string.
111 public $duration_unit;
114 * Number of duration units in membership period (e.g. 1 year, 12 months).
116 * @var int|string|null
118 * Note that values will be retrieved from the database as a string.
120 public $duration_interval;
123 * Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.
126 * (SQL type: varchar(8))
127 * Note that values will be retrieved from the database as a string.
132 * For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.
134 * @var int|string|null
136 * Note that values will be retrieved from the database as a string.
138 public $fixed_period_start_day;
141 * For fixed period memberships, signups after this day (mmdd) rollover to next period.
143 * @var int|string|null
145 * Note that values will be retrieved from the database as a string.
147 public $fixed_period_rollover_day;
150 * FK to Relationship Type ID
153 * (SQL type: varchar(64))
154 * Note that values will be retrieved from the database as a string.
156 public $relationship_type_id;
160 * (SQL type: varchar(128))
161 * Note that values will be retrieved from the database as a string.
163 public $relationship_direction;
166 * Maximum number of related memberships.
168 * @var int|string|null
170 * Note that values will be retrieved from the database as a string.
176 * (SQL type: varchar(64))
177 * Note that values will be retrieved from the database as a string.
182 * @var int|string|null
184 * Note that values will be retrieved from the database as a string.
189 * Receipt Text for membership signup
192 * (SQL type: varchar(255))
193 * Note that values will be retrieved from the database as a string.
195 public $receipt_text_signup;
198 * Receipt Text for membership renewal
201 * (SQL type: varchar(255))
202 * Note that values will be retrieved from the database as a string.
204 public $receipt_text_renewal;
207 * 0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;
209 * @var int|string|null
210 * (SQL type: tinyint)
211 * Note that values will be retrieved from the database as a string.
216 * Is this membership_type enabled
218 * @var bool|string|null
219 * (SQL type: tinyint)
220 * Note that values will be retrieved from the database as a string.
227 public function __construct() {
228 $this->__table
= 'civicrm_membership_type';
229 parent
::__construct();
233 * Returns localized title of this entity.
235 * @param bool $plural
236 * Whether to return the plural version of the title.
238 public static function getEntityTitle($plural = FALSE) {
239 return $plural ?
ts('Membership Types') : ts('Membership Type');
243 * Returns foreign keys and entity references.
246 * [CRM_Core_Reference_Interface]
248 public static function getReferenceColumns() {
249 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
250 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
251 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'domain_id', 'civicrm_domain', 'id');
252 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'member_of_contact_id', 'civicrm_contact', 'id');
253 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
254 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
256 return Civi
::$statics[__CLASS__
]['links'];
260 * Returns all the column names of this table
264 public static function &fields() {
265 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
266 Civi
::$statics[__CLASS__
]['fields'] = [
269 'type' => CRM_Utils_Type
::T_INT
,
270 'title' => ts('Membership Type ID'),
271 'description' => ts('Membership ID'),
273 'where' => 'civicrm_membership_type.id',
274 'table_name' => 'civicrm_membership_type',
275 'entity' => 'MembershipType',
276 'bao' => 'CRM_Member_BAO_MembershipType',
285 'name' => 'domain_id',
286 'type' => CRM_Utils_Type
::T_INT
,
287 'title' => ts('Domain ID'),
288 'description' => ts('Which Domain is this match entry for'),
290 'where' => 'civicrm_membership_type.domain_id',
291 'table_name' => 'civicrm_membership_type',
292 'entity' => 'MembershipType',
293 'bao' => 'CRM_Member_BAO_MembershipType',
295 'FKClassName' => 'CRM_Core_DAO_Domain',
297 'label' => ts("Domain"),
299 'pseudoconstant' => [
300 'table' => 'civicrm_domain',
302 'labelColumn' => 'name',
306 'membership_type' => [
308 'type' => CRM_Utils_Type
::T_STRING
,
309 'title' => ts('Membership Type'),
310 'description' => ts('Name of Membership Type'),
313 'size' => CRM_Utils_Type
::HUGE
,
315 'where' => 'civicrm_membership_type.name',
317 'table_name' => 'civicrm_membership_type',
318 'entity' => 'MembershipType',
319 'bao' => 'CRM_Member_BAO_MembershipType',
323 'label' => ts("Name"),
328 'name' => 'description',
329 'type' => CRM_Utils_Type
::T_STRING
,
330 'title' => ts('Description'),
331 'description' => ts('Description of Membership Type'),
333 'size' => CRM_Utils_Type
::HUGE
,
334 'where' => 'civicrm_membership_type.description',
335 'table_name' => 'civicrm_membership_type',
336 'entity' => 'MembershipType',
337 'bao' => 'CRM_Member_BAO_MembershipType',
340 'type' => 'TextArea',
341 'label' => ts("Description"),
345 'member_of_contact_id' => [
346 'name' => 'member_of_contact_id',
347 'type' => CRM_Utils_Type
::T_INT
,
348 'title' => ts('Organization ID'),
349 'description' => ts('Owner organization for this membership type. FK to Contact ID'),
351 'where' => 'civicrm_membership_type.member_of_contact_id',
352 'table_name' => 'civicrm_membership_type',
353 'entity' => 'MembershipType',
354 'bao' => 'CRM_Member_BAO_MembershipType',
356 'FKClassName' => 'CRM_Contact_DAO_Contact',
358 'label' => ts("Organization"),
362 'financial_type_id' => [
363 'name' => 'financial_type_id',
364 'type' => CRM_Utils_Type
::T_INT
,
365 'title' => ts('Financial Type ID'),
366 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
368 'where' => 'civicrm_membership_type.financial_type_id',
369 'table_name' => 'civicrm_membership_type',
370 'entity' => 'MembershipType',
371 'bao' => 'CRM_Member_BAO_MembershipType',
373 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
375 'label' => ts("Financial Type"),
377 'pseudoconstant' => [
378 'table' => 'civicrm_financial_type',
380 'labelColumn' => 'name',
385 'name' => 'minimum_fee',
386 'type' => CRM_Utils_Type
::T_MONEY
,
387 'title' => ts('Minimum Fee'),
388 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'),
393 'where' => 'civicrm_membership_type.minimum_fee',
395 'table_name' => 'civicrm_membership_type',
396 'entity' => 'MembershipType',
397 'bao' => 'CRM_Member_BAO_MembershipType',
401 'label' => ts("Minimum Fee"),
406 'name' => 'duration_unit',
407 'type' => CRM_Utils_Type
::T_STRING
,
408 'title' => ts('Membership Type Duration Unit'),
409 'description' => ts('Unit in which membership period is expressed.'),
412 'size' => CRM_Utils_Type
::EIGHT
,
413 'where' => 'civicrm_membership_type.duration_unit',
414 'table_name' => 'civicrm_membership_type',
415 'entity' => 'MembershipType',
416 'bao' => 'CRM_Member_BAO_MembershipType',
421 'pseudoconstant' => [
422 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
426 'duration_interval' => [
427 'name' => 'duration_interval',
428 'type' => CRM_Utils_Type
::T_INT
,
429 'title' => ts('Membership Type Duration Interval'),
430 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
431 'where' => 'civicrm_membership_type.duration_interval',
432 'table_name' => 'civicrm_membership_type',
433 'entity' => 'MembershipType',
434 'bao' => 'CRM_Member_BAO_MembershipType',
442 'name' => 'period_type',
443 'type' => CRM_Utils_Type
::T_STRING
,
444 'title' => ts('Membership Type Plan'),
445 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
448 'size' => CRM_Utils_Type
::EIGHT
,
449 'where' => 'civicrm_membership_type.period_type',
450 'table_name' => 'civicrm_membership_type',
451 'entity' => 'MembershipType',
452 'bao' => 'CRM_Member_BAO_MembershipType',
457 'pseudoconstant' => [
458 'callback' => 'CRM_Core_SelectValues::periodType',
462 'fixed_period_start_day' => [
463 'name' => 'fixed_period_start_day',
464 'type' => CRM_Utils_Type
::T_INT
,
465 'title' => ts('Fixed Period Start Day'),
466 '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.'),
467 'where' => 'civicrm_membership_type.fixed_period_start_day',
468 'table_name' => 'civicrm_membership_type',
469 'entity' => 'MembershipType',
470 'bao' => 'CRM_Member_BAO_MembershipType',
474 'fixed_period_rollover_day' => [
475 'name' => 'fixed_period_rollover_day',
476 'type' => CRM_Utils_Type
::T_INT
,
477 'title' => ts('Fixed Period Rollover Day'),
478 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
479 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
480 'table_name' => 'civicrm_membership_type',
481 'entity' => 'MembershipType',
482 'bao' => 'CRM_Member_BAO_MembershipType',
486 'relationship_type_id' => [
487 'name' => 'relationship_type_id',
488 'type' => CRM_Utils_Type
::T_STRING
,
489 'title' => ts('Membership Type Relationship'),
490 'description' => ts('FK to Relationship Type ID'),
492 'size' => CRM_Utils_Type
::BIG
,
493 'where' => 'civicrm_membership_type.relationship_type_id',
494 'table_name' => 'civicrm_membership_type',
495 'entity' => 'MembershipType',
496 'bao' => 'CRM_Member_BAO_MembershipType',
498 'serialize' => self
::SERIALIZE_SEPARATOR_TRIMMED
,
501 'relationship_direction' => [
502 'name' => 'relationship_direction',
503 'type' => CRM_Utils_Type
::T_STRING
,
504 'title' => ts('Relationship Direction'),
506 'size' => CRM_Utils_Type
::HUGE
,
507 'where' => 'civicrm_membership_type.relationship_direction',
508 'table_name' => 'civicrm_membership_type',
509 'entity' => 'MembershipType',
510 'bao' => 'CRM_Member_BAO_MembershipType',
512 'serialize' => self
::SERIALIZE_SEPARATOR_TRIMMED
,
514 'label' => ts("Relationship Direction"),
519 'name' => 'max_related',
520 'type' => CRM_Utils_Type
::T_INT
,
521 'title' => ts('Max Related Members for Type'),
522 'description' => ts('Maximum number of related memberships.'),
523 'where' => 'civicrm_membership_type.max_related',
524 'table_name' => 'civicrm_membership_type',
525 'entity' => 'MembershipType',
526 'bao' => 'CRM_Member_BAO_MembershipType',
530 'label' => ts("Max Related"),
535 'name' => 'visibility',
536 'type' => CRM_Utils_Type
::T_STRING
,
537 'title' => ts('Visible'),
539 'size' => CRM_Utils_Type
::BIG
,
540 'where' => 'civicrm_membership_type.visibility',
541 'table_name' => 'civicrm_membership_type',
542 'entity' => 'MembershipType',
543 'bao' => 'CRM_Member_BAO_MembershipType',
548 'pseudoconstant' => [
549 'callback' => 'CRM_Core_SelectValues::memberVisibility',
555 'type' => CRM_Utils_Type
::T_INT
,
556 'title' => ts('Order'),
557 'where' => 'civicrm_membership_type.weight',
558 'table_name' => 'civicrm_membership_type',
559 'entity' => 'MembershipType',
560 'bao' => 'CRM_Member_BAO_MembershipType',
567 'receipt_text_signup' => [
568 'name' => 'receipt_text_signup',
569 'type' => CRM_Utils_Type
::T_STRING
,
570 'title' => ts('Membership Type Receipt Text'),
571 'description' => ts('Receipt Text for membership signup'),
573 'size' => CRM_Utils_Type
::HUGE
,
574 'where' => 'civicrm_membership_type.receipt_text_signup',
575 'table_name' => 'civicrm_membership_type',
576 'entity' => 'MembershipType',
577 'bao' => 'CRM_Member_BAO_MembershipType',
580 'type' => 'TextArea',
584 'receipt_text_renewal' => [
585 'name' => 'receipt_text_renewal',
586 'type' => CRM_Utils_Type
::T_STRING
,
587 'title' => ts('Membership Type Renewal Text'),
588 'description' => ts('Receipt Text for membership renewal'),
590 'size' => CRM_Utils_Type
::HUGE
,
591 'where' => 'civicrm_membership_type.receipt_text_renewal',
592 'table_name' => 'civicrm_membership_type',
593 'entity' => 'MembershipType',
594 'bao' => 'CRM_Member_BAO_MembershipType',
597 'type' => 'TextArea',
602 'name' => 'auto_renew',
603 'type' => CRM_Utils_Type
::T_INT
,
604 'title' => ts('Auto Renew'),
605 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
606 'where' => 'civicrm_membership_type.auto_renew',
608 'table_name' => 'civicrm_membership_type',
609 'entity' => 'MembershipType',
610 'bao' => 'CRM_Member_BAO_MembershipType',
614 'label' => ts("Auto-Renew"),
616 'pseudoconstant' => [
617 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
622 'name' => 'is_active',
623 'type' => CRM_Utils_Type
::T_BOOLEAN
,
624 'title' => ts('Is Active'),
625 'description' => ts('Is this membership_type enabled'),
626 'where' => 'civicrm_membership_type.is_active',
628 'table_name' => 'civicrm_membership_type',
629 'entity' => 'MembershipType',
630 'bao' => 'CRM_Member_BAO_MembershipType',
633 'type' => 'CheckBox',
634 'label' => ts("Enabled?"),
639 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
641 return Civi
::$statics[__CLASS__
]['fields'];
645 * Return a mapping from field-name to the corresponding key (as used in fields()).
648 * Array(string $name => string $uniqueName).
650 public static function &fieldKeys() {
651 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
652 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
654 return Civi
::$statics[__CLASS__
]['fieldKeys'];
658 * Returns the names of this table
662 public static function getTableName() {
663 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
667 * Returns if this table needs to be logged
671 public function getLog() {
676 * Returns the list of fields that can be imported
678 * @param bool $prefix
682 public static function &import($prefix = FALSE) {
683 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership_type', $prefix, []);
688 * Returns the list of fields that can be exported
690 * @param bool $prefix
694 public static function &export($prefix = FALSE) {
695 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership_type', $prefix, []);
700 * Returns the list of indices
702 * @param bool $localize
706 public static function indices($localize = TRUE) {
708 'index_relationship_type_id' => [
709 'name' => 'index_relationship_type_id',
711 0 => 'relationship_type_id',
713 'localizable' => FALSE,
714 'sig' => 'civicrm_membership_type::0::relationship_type_id',
717 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;