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:9fd7f864fc6d70c8a1fad482ded120ff)
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;
49 * Which Domain is this match entry for
56 * Name of Membership Type
63 * Description of Membership Type
70 * Owner organization for this membership type. FK to Contact ID
74 public $member_of_contact_id;
77 * If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id
81 public $financial_type_id;
84 * Minimum fee for this membership (0 for free/complimentary memberships).
91 * Unit in which membership period is expressed.
95 public $duration_unit;
98 * Number of duration units in membership period (e.g. 1 year, 12 months).
102 public $duration_interval;
105 * Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.
112 * For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.
116 public $fixed_period_start_day;
119 * For fixed period memberships, signups after this day (mmdd) rollover to next period.
123 public $fixed_period_rollover_day;
126 * FK to Relationship Type ID
130 public $relationship_type_id;
135 public $relationship_direction;
138 * Maximum number of related memberships.
155 * Receipt Text for membership signup
159 public $receipt_text_signup;
162 * Receipt Text for membership renewal
166 public $receipt_text_renewal;
169 * 0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;
176 * Is this membership_type enabled
185 public function __construct() {
186 $this->__table
= 'civicrm_membership_type';
187 parent
::__construct();
191 * Returns localized title of this entity.
193 * @param bool $plural
194 * Whether to return the plural version of the title.
196 public static function getEntityTitle($plural = FALSE) {
197 return $plural ?
ts('Membership Types') : ts('Membership Type');
201 * Returns foreign keys and entity references.
204 * [CRM_Core_Reference_Interface]
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']);
214 return Civi
::$statics[__CLASS__
]['links'];
218 * Returns all the column names of this table
222 public static function &fields() {
223 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
224 Civi
::$statics[__CLASS__
]['fields'] = [
227 'type' => CRM_Utils_Type
::T_INT
,
228 'title' => ts('Membership Type ID'),
229 'description' => ts('Membership ID'),
231 'where' => 'civicrm_membership_type.id',
232 'table_name' => 'civicrm_membership_type',
233 'entity' => 'MembershipType',
234 'bao' => 'CRM_Member_BAO_MembershipType',
242 'name' => 'domain_id',
243 'type' => CRM_Utils_Type
::T_INT
,
244 'title' => ts('Domain ID'),
245 'description' => ts('Which Domain is this match entry for'),
247 'where' => 'civicrm_membership_type.domain_id',
248 'table_name' => 'civicrm_membership_type',
249 'entity' => 'MembershipType',
250 'bao' => 'CRM_Member_BAO_MembershipType',
252 'FKClassName' => 'CRM_Core_DAO_Domain',
254 'label' => ts("Domain"),
256 'pseudoconstant' => [
257 'table' => 'civicrm_domain',
259 'labelColumn' => 'name',
263 'membership_type' => [
265 'type' => CRM_Utils_Type
::T_STRING
,
266 'title' => ts('Membership Type'),
267 'description' => ts('Name of Membership Type'),
270 'size' => CRM_Utils_Type
::HUGE
,
272 'where' => 'civicrm_membership_type.name',
274 'table_name' => 'civicrm_membership_type',
275 'entity' => 'MembershipType',
276 'bao' => 'CRM_Member_BAO_MembershipType',
280 'label' => ts("Name"),
285 'name' => 'description',
286 'type' => CRM_Utils_Type
::T_STRING
,
287 'title' => ts('Description'),
288 'description' => ts('Description of Membership Type'),
290 'size' => CRM_Utils_Type
::HUGE
,
291 'where' => 'civicrm_membership_type.description',
292 'table_name' => 'civicrm_membership_type',
293 'entity' => 'MembershipType',
294 'bao' => 'CRM_Member_BAO_MembershipType',
297 'type' => 'TextArea',
298 'label' => ts("Description"),
302 'member_of_contact_id' => [
303 'name' => 'member_of_contact_id',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('Organization ID'),
306 'description' => ts('Owner organization for this membership type. FK to Contact ID'),
308 'where' => 'civicrm_membership_type.member_of_contact_id',
309 'table_name' => 'civicrm_membership_type',
310 'entity' => 'MembershipType',
311 'bao' => 'CRM_Member_BAO_MembershipType',
313 'FKClassName' => 'CRM_Contact_DAO_Contact',
315 'label' => ts("Organization"),
319 'financial_type_id' => [
320 'name' => 'financial_type_id',
321 'type' => CRM_Utils_Type
::T_INT
,
322 'title' => ts('Financial Type ID'),
323 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
325 'where' => 'civicrm_membership_type.financial_type_id',
326 'table_name' => 'civicrm_membership_type',
327 'entity' => 'MembershipType',
328 'bao' => 'CRM_Member_BAO_MembershipType',
330 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
332 'label' => ts("Financial Type"),
334 'pseudoconstant' => [
335 'table' => 'civicrm_financial_type',
337 'labelColumn' => 'name',
342 'name' => 'minimum_fee',
343 'type' => CRM_Utils_Type
::T_MONEY
,
344 'title' => ts('Minimum Fee'),
345 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'),
350 'where' => 'civicrm_membership_type.minimum_fee',
352 'table_name' => 'civicrm_membership_type',
353 'entity' => 'MembershipType',
354 'bao' => 'CRM_Member_BAO_MembershipType',
358 'label' => ts("Minimum Fee"),
363 'name' => 'duration_unit',
364 'type' => CRM_Utils_Type
::T_STRING
,
365 'title' => ts('Membership Type Duration Unit'),
366 'description' => ts('Unit in which membership period is expressed.'),
368 'size' => CRM_Utils_Type
::EIGHT
,
369 'where' => 'civicrm_membership_type.duration_unit',
370 'table_name' => 'civicrm_membership_type',
371 'entity' => 'MembershipType',
372 'bao' => 'CRM_Member_BAO_MembershipType',
377 'pseudoconstant' => [
378 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
382 'duration_interval' => [
383 'name' => 'duration_interval',
384 'type' => CRM_Utils_Type
::T_INT
,
385 'title' => ts('Membership Type Duration Interval'),
386 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
387 'where' => 'civicrm_membership_type.duration_interval',
388 'table_name' => 'civicrm_membership_type',
389 'entity' => 'MembershipType',
390 'bao' => 'CRM_Member_BAO_MembershipType',
398 'name' => 'period_type',
399 'type' => CRM_Utils_Type
::T_STRING
,
400 'title' => ts('Membership Type Plan'),
401 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
404 'size' => CRM_Utils_Type
::EIGHT
,
405 'where' => 'civicrm_membership_type.period_type',
406 'table_name' => 'civicrm_membership_type',
407 'entity' => 'MembershipType',
408 'bao' => 'CRM_Member_BAO_MembershipType',
413 'pseudoconstant' => [
414 'callback' => 'CRM_Core_SelectValues::periodType',
418 'fixed_period_start_day' => [
419 'name' => 'fixed_period_start_day',
420 'type' => CRM_Utils_Type
::T_INT
,
421 'title' => ts('Fixed Period Start Day'),
422 '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.'),
423 'where' => 'civicrm_membership_type.fixed_period_start_day',
424 'table_name' => 'civicrm_membership_type',
425 'entity' => 'MembershipType',
426 'bao' => 'CRM_Member_BAO_MembershipType',
430 'fixed_period_rollover_day' => [
431 'name' => 'fixed_period_rollover_day',
432 'type' => CRM_Utils_Type
::T_INT
,
433 'title' => ts('Fixed Period Rollover Day'),
434 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
435 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
436 'table_name' => 'civicrm_membership_type',
437 'entity' => 'MembershipType',
438 'bao' => 'CRM_Member_BAO_MembershipType',
442 'relationship_type_id' => [
443 'name' => 'relationship_type_id',
444 'type' => CRM_Utils_Type
::T_STRING
,
445 'title' => ts('Membership Type Relationship'),
446 'description' => ts('FK to Relationship Type ID'),
448 'size' => CRM_Utils_Type
::BIG
,
449 'where' => 'civicrm_membership_type.relationship_type_id',
450 'table_name' => 'civicrm_membership_type',
451 'entity' => 'MembershipType',
452 'bao' => 'CRM_Member_BAO_MembershipType',
454 'serialize' => self
::SERIALIZE_SEPARATOR_TRIMMED
,
457 'relationship_direction' => [
458 'name' => 'relationship_direction',
459 'type' => CRM_Utils_Type
::T_STRING
,
460 'title' => ts('Relationship Direction'),
462 'size' => CRM_Utils_Type
::HUGE
,
463 'where' => 'civicrm_membership_type.relationship_direction',
464 'table_name' => 'civicrm_membership_type',
465 'entity' => 'MembershipType',
466 'bao' => 'CRM_Member_BAO_MembershipType',
468 'serialize' => self
::SERIALIZE_SEPARATOR_TRIMMED
,
470 'label' => ts("Relationship Direction"),
475 'name' => 'max_related',
476 'type' => CRM_Utils_Type
::T_INT
,
477 'title' => ts('Max Related Members for Type'),
478 'description' => ts('Maximum number of related memberships.'),
479 'where' => 'civicrm_membership_type.max_related',
480 'table_name' => 'civicrm_membership_type',
481 'entity' => 'MembershipType',
482 'bao' => 'CRM_Member_BAO_MembershipType',
486 'label' => ts("Max Related"),
491 'name' => 'visibility',
492 'type' => CRM_Utils_Type
::T_STRING
,
493 'title' => ts('Visible'),
495 'size' => CRM_Utils_Type
::BIG
,
496 'where' => 'civicrm_membership_type.visibility',
497 'table_name' => 'civicrm_membership_type',
498 'entity' => 'MembershipType',
499 'bao' => 'CRM_Member_BAO_MembershipType',
504 'pseudoconstant' => [
505 'callback' => 'CRM_Core_SelectValues::memberVisibility',
511 'type' => CRM_Utils_Type
::T_INT
,
512 'title' => ts('Order'),
513 'where' => 'civicrm_membership_type.weight',
514 'table_name' => 'civicrm_membership_type',
515 'entity' => 'MembershipType',
516 'bao' => 'CRM_Member_BAO_MembershipType',
523 'receipt_text_signup' => [
524 'name' => 'receipt_text_signup',
525 'type' => CRM_Utils_Type
::T_STRING
,
526 'title' => ts('Membership Type Receipt Text'),
527 'description' => ts('Receipt Text for membership signup'),
529 'size' => CRM_Utils_Type
::HUGE
,
530 'where' => 'civicrm_membership_type.receipt_text_signup',
531 'table_name' => 'civicrm_membership_type',
532 'entity' => 'MembershipType',
533 'bao' => 'CRM_Member_BAO_MembershipType',
536 'type' => 'TextArea',
540 'receipt_text_renewal' => [
541 'name' => 'receipt_text_renewal',
542 'type' => CRM_Utils_Type
::T_STRING
,
543 'title' => ts('Membership Type Renewal Text'),
544 'description' => ts('Receipt Text for membership renewal'),
546 'size' => CRM_Utils_Type
::HUGE
,
547 'where' => 'civicrm_membership_type.receipt_text_renewal',
548 'table_name' => 'civicrm_membership_type',
549 'entity' => 'MembershipType',
550 'bao' => 'CRM_Member_BAO_MembershipType',
553 'type' => 'TextArea',
558 'name' => 'auto_renew',
559 'type' => CRM_Utils_Type
::T_BOOLEAN
,
560 'title' => ts('Auto Renew'),
561 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
562 'where' => 'civicrm_membership_type.auto_renew',
564 'table_name' => 'civicrm_membership_type',
565 'entity' => 'MembershipType',
566 'bao' => 'CRM_Member_BAO_MembershipType',
570 'label' => ts("Auto-Renew"),
572 'pseudoconstant' => [
573 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
578 'name' => 'is_active',
579 'type' => CRM_Utils_Type
::T_BOOLEAN
,
580 'title' => ts('Is Active'),
581 'description' => ts('Is this membership_type enabled'),
582 'where' => 'civicrm_membership_type.is_active',
584 'table_name' => 'civicrm_membership_type',
585 'entity' => 'MembershipType',
586 'bao' => 'CRM_Member_BAO_MembershipType',
589 'type' => 'CheckBox',
590 'label' => ts("Enabled?"),
595 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
597 return Civi
::$statics[__CLASS__
]['fields'];
601 * Return a mapping from field-name to the corresponding key (as used in fields()).
604 * Array(string $name => string $uniqueName).
606 public static function &fieldKeys() {
607 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
608 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
610 return Civi
::$statics[__CLASS__
]['fieldKeys'];
614 * Returns the names of this table
618 public static function getTableName() {
619 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
623 * Returns if this table needs to be logged
627 public function getLog() {
632 * Returns the list of fields that can be imported
634 * @param bool $prefix
638 public static function &import($prefix = FALSE) {
639 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership_type', $prefix, []);
644 * Returns the list of fields that can be exported
646 * @param bool $prefix
650 public static function &export($prefix = FALSE) {
651 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership_type', $prefix, []);
656 * Returns the list of indices
658 * @param bool $localize
662 public static function indices($localize = TRUE) {
664 'index_relationship_type_id' => [
665 'name' => 'index_relationship_type_id',
667 0 => 'relationship_type_id',
669 'localizable' => FALSE,
670 'sig' => 'civicrm_membership_type::0::relationship_type_id',
673 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;