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:e989278865fbeabd9f3d6efc7271a2d1)
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',
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'),
248 'where' => 'civicrm_membership_type.domain_id',
249 'table_name' => 'civicrm_membership_type',
250 'entity' => 'MembershipType',
251 'bao' => 'CRM_Member_BAO_MembershipType',
253 'FKClassName' => 'CRM_Core_DAO_Domain',
255 'label' => ts("Domain"),
257 'pseudoconstant' => [
258 'table' => 'civicrm_domain',
260 'labelColumn' => 'name',
264 'membership_type' => [
266 'type' => CRM_Utils_Type
::T_STRING
,
267 'title' => ts('Membership Type'),
268 'description' => ts('Name of Membership Type'),
271 'size' => CRM_Utils_Type
::HUGE
,
273 'where' => 'civicrm_membership_type.name',
275 'table_name' => 'civicrm_membership_type',
276 'entity' => 'MembershipType',
277 'bao' => 'CRM_Member_BAO_MembershipType',
281 'label' => ts("Name"),
286 'name' => 'description',
287 'type' => CRM_Utils_Type
::T_STRING
,
288 'title' => ts('Description'),
289 'description' => ts('Description of Membership Type'),
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',
298 'type' => 'TextArea',
299 'label' => ts("Description"),
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'),
309 'where' => 'civicrm_membership_type.member_of_contact_id',
310 'table_name' => 'civicrm_membership_type',
311 'entity' => 'MembershipType',
312 'bao' => 'CRM_Member_BAO_MembershipType',
314 'FKClassName' => 'CRM_Contact_DAO_Contact',
316 'label' => ts("Organization"),
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'),
326 'where' => 'civicrm_membership_type.financial_type_id',
327 'table_name' => 'civicrm_membership_type',
328 'entity' => 'MembershipType',
329 'bao' => 'CRM_Member_BAO_MembershipType',
331 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
333 'label' => ts("Financial Type"),
335 'pseudoconstant' => [
336 'table' => 'civicrm_financial_type',
338 'labelColumn' => 'name',
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).'),
351 'where' => 'civicrm_membership_type.minimum_fee',
353 'table_name' => 'civicrm_membership_type',
354 'entity' => 'MembershipType',
355 'bao' => 'CRM_Member_BAO_MembershipType',
359 'label' => ts("Minimum Fee"),
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.'),
369 'size' => CRM_Utils_Type
::EIGHT
,
370 'where' => 'civicrm_membership_type.duration_unit',
371 'table_name' => 'civicrm_membership_type',
372 'entity' => 'MembershipType',
373 'bao' => 'CRM_Member_BAO_MembershipType',
378 'pseudoconstant' => [
379 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
383 'duration_interval' => [
384 'name' => 'duration_interval',
385 'type' => CRM_Utils_Type
::T_INT
,
386 'title' => ts('Membership Type Duration Interval'),
387 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
388 'where' => 'civicrm_membership_type.duration_interval',
389 'table_name' => 'civicrm_membership_type',
390 'entity' => 'MembershipType',
391 'bao' => 'CRM_Member_BAO_MembershipType',
399 'name' => 'period_type',
400 'type' => CRM_Utils_Type
::T_STRING
,
401 'title' => ts('Membership Type Plan'),
402 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
405 'size' => CRM_Utils_Type
::EIGHT
,
406 'where' => 'civicrm_membership_type.period_type',
407 'table_name' => 'civicrm_membership_type',
408 'entity' => 'MembershipType',
409 'bao' => 'CRM_Member_BAO_MembershipType',
414 'pseudoconstant' => [
415 'callback' => 'CRM_Core_SelectValues::periodType',
419 'fixed_period_start_day' => [
420 'name' => 'fixed_period_start_day',
421 'type' => CRM_Utils_Type
::T_INT
,
422 'title' => ts('Fixed Period Start Day'),
423 '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.'),
424 'where' => 'civicrm_membership_type.fixed_period_start_day',
425 'table_name' => 'civicrm_membership_type',
426 'entity' => 'MembershipType',
427 'bao' => 'CRM_Member_BAO_MembershipType',
431 'fixed_period_rollover_day' => [
432 'name' => 'fixed_period_rollover_day',
433 'type' => CRM_Utils_Type
::T_INT
,
434 'title' => ts('Fixed Period Rollover Day'),
435 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
436 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
437 'table_name' => 'civicrm_membership_type',
438 'entity' => 'MembershipType',
439 'bao' => 'CRM_Member_BAO_MembershipType',
443 'relationship_type_id' => [
444 'name' => 'relationship_type_id',
445 'type' => CRM_Utils_Type
::T_STRING
,
446 'title' => ts('Membership Type Relationship'),
447 'description' => ts('FK to Relationship Type ID'),
449 'size' => CRM_Utils_Type
::BIG
,
450 'where' => 'civicrm_membership_type.relationship_type_id',
451 'table_name' => 'civicrm_membership_type',
452 'entity' => 'MembershipType',
453 'bao' => 'CRM_Member_BAO_MembershipType',
455 'serialize' => self
::SERIALIZE_SEPARATOR_TRIMMED
,
458 'relationship_direction' => [
459 'name' => 'relationship_direction',
460 'type' => CRM_Utils_Type
::T_STRING
,
461 'title' => ts('Relationship Direction'),
463 'size' => CRM_Utils_Type
::HUGE
,
464 'where' => 'civicrm_membership_type.relationship_direction',
465 'table_name' => 'civicrm_membership_type',
466 'entity' => 'MembershipType',
467 'bao' => 'CRM_Member_BAO_MembershipType',
469 'serialize' => self
::SERIALIZE_SEPARATOR_TRIMMED
,
471 'label' => ts("Relationship Direction"),
476 'name' => 'max_related',
477 'type' => CRM_Utils_Type
::T_INT
,
478 'title' => ts('Max Related Members for Type'),
479 'description' => ts('Maximum number of related memberships.'),
480 'where' => 'civicrm_membership_type.max_related',
481 'table_name' => 'civicrm_membership_type',
482 'entity' => 'MembershipType',
483 'bao' => 'CRM_Member_BAO_MembershipType',
487 'label' => ts("Max Related"),
492 'name' => 'visibility',
493 'type' => CRM_Utils_Type
::T_STRING
,
494 'title' => ts('Visible'),
496 'size' => CRM_Utils_Type
::BIG
,
497 'where' => 'civicrm_membership_type.visibility',
498 'table_name' => 'civicrm_membership_type',
499 'entity' => 'MembershipType',
500 'bao' => 'CRM_Member_BAO_MembershipType',
505 'pseudoconstant' => [
506 'callback' => 'CRM_Core_SelectValues::memberVisibility',
512 'type' => CRM_Utils_Type
::T_INT
,
513 'title' => ts('Order'),
514 'where' => 'civicrm_membership_type.weight',
515 'table_name' => 'civicrm_membership_type',
516 'entity' => 'MembershipType',
517 'bao' => 'CRM_Member_BAO_MembershipType',
524 'receipt_text_signup' => [
525 'name' => 'receipt_text_signup',
526 'type' => CRM_Utils_Type
::T_STRING
,
527 'title' => ts('Membership Type Receipt Text'),
528 'description' => ts('Receipt Text for membership signup'),
530 'size' => CRM_Utils_Type
::HUGE
,
531 'where' => 'civicrm_membership_type.receipt_text_signup',
532 'table_name' => 'civicrm_membership_type',
533 'entity' => 'MembershipType',
534 'bao' => 'CRM_Member_BAO_MembershipType',
537 'type' => 'TextArea',
541 'receipt_text_renewal' => [
542 'name' => 'receipt_text_renewal',
543 'type' => CRM_Utils_Type
::T_STRING
,
544 'title' => ts('Membership Type Renewal Text'),
545 'description' => ts('Receipt Text for membership renewal'),
547 'size' => CRM_Utils_Type
::HUGE
,
548 'where' => 'civicrm_membership_type.receipt_text_renewal',
549 'table_name' => 'civicrm_membership_type',
550 'entity' => 'MembershipType',
551 'bao' => 'CRM_Member_BAO_MembershipType',
554 'type' => 'TextArea',
559 'name' => 'auto_renew',
560 'type' => CRM_Utils_Type
::T_BOOLEAN
,
561 'title' => ts('Auto Renew'),
562 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
563 'where' => 'civicrm_membership_type.auto_renew',
565 'table_name' => 'civicrm_membership_type',
566 'entity' => 'MembershipType',
567 'bao' => 'CRM_Member_BAO_MembershipType',
571 'label' => ts("Auto-Renew"),
573 'pseudoconstant' => [
574 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
579 'name' => 'is_active',
580 'type' => CRM_Utils_Type
::T_BOOLEAN
,
581 'title' => ts('Is Active'),
582 'description' => ts('Is this membership_type enabled'),
583 'where' => 'civicrm_membership_type.is_active',
585 'table_name' => 'civicrm_membership_type',
586 'entity' => 'MembershipType',
587 'bao' => 'CRM_Member_BAO_MembershipType',
590 'type' => 'CheckBox',
591 'label' => ts("Enabled?"),
596 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
598 return Civi
::$statics[__CLASS__
]['fields'];
602 * Return a mapping from field-name to the corresponding key (as used in fields()).
605 * Array(string $name => string $uniqueName).
607 public static function &fieldKeys() {
608 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
609 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
611 return Civi
::$statics[__CLASS__
]['fieldKeys'];
615 * Returns the names of this table
619 public static function getTableName() {
620 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
624 * Returns if this table needs to be logged
628 public function getLog() {
633 * Returns the list of fields that can be imported
635 * @param bool $prefix
639 public static function &import($prefix = FALSE) {
640 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'membership_type', $prefix, []);
645 * Returns the list of fields that can be exported
647 * @param bool $prefix
651 public static function &export($prefix = FALSE) {
652 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'membership_type', $prefix, []);
657 * Returns the list of indices
659 * @param bool $localize
663 public static function indices($localize = TRUE) {
665 'index_relationship_type_id' => [
666 'name' => 'index_relationship_type_id',
668 0 => 'relationship_type_id',
670 'localizable' => FALSE,
671 'sig' => 'civicrm_membership_type::0::relationship_type_id',
674 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;