Merge pull request #23875 from alexymik/patch-3
[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:ebffd1b4dde86196cd988e43adcd6ad8)
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|string|null
45 * (SQL type: int unsigned)
46 * Note that values will be retrieved from the database as a string.
47 */
48 public $id;
49
50 /**
51 * Which Domain is this match entry for
52 *
53 * @var int|string
54 * (SQL type: int unsigned)
55 * Note that values will be retrieved from the database as a string.
56 */
57 public $domain_id;
58
59 /**
60 * Name of Membership Type
61 *
62 * @var string
63 * (SQL type: varchar(128))
64 * Note that values will be retrieved from the database as a string.
65 */
66 public $name;
67
68 /**
69 * Description of Membership Type
70 *
71 * @var string|null
72 * (SQL type: varchar(255))
73 * Note that values will be retrieved from the database as a string.
74 */
75 public $description;
76
77 /**
78 * Owner organization for this membership type. FK to Contact ID
79 *
80 * @var int|string
81 * (SQL type: int unsigned)
82 * Note that values will be retrieved from the database as a string.
83 */
84 public $member_of_contact_id;
85
86 /**
87 * If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id
88 *
89 * @var int|string
90 * (SQL type: int unsigned)
91 * Note that values will be retrieved from the database as a string.
92 */
93 public $financial_type_id;
94
95 /**
96 * Minimum fee for this membership (0 for free/complimentary memberships).
97 *
98 * @var float|string|null
99 * (SQL type: decimal(18,9))
100 * Note that values will be retrieved from the database as a string.
101 */
102 public $minimum_fee;
103
104 /**
105 * Unit in which membership period is expressed.
106 *
107 * @var string
108 * (SQL type: varchar(8))
109 * Note that values will be retrieved from the database as a string.
110 */
111 public $duration_unit;
112
113 /**
114 * Number of duration units in membership period (e.g. 1 year, 12 months).
115 *
116 * @var int|string|null
117 * (SQL type: int)
118 * Note that values will be retrieved from the database as a string.
119 */
120 public $duration_interval;
121
122 /**
123 * Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.
124 *
125 * @var string
126 * (SQL type: varchar(8))
127 * Note that values will be retrieved from the database as a string.
128 */
129 public $period_type;
130
131 /**
132 * For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.
133 *
134 * @var int|string|null
135 * (SQL type: int)
136 * Note that values will be retrieved from the database as a string.
137 */
138 public $fixed_period_start_day;
139
140 /**
141 * For fixed period memberships, signups after this day (mmdd) rollover to next period.
142 *
143 * @var int|string|null
144 * (SQL type: int)
145 * Note that values will be retrieved from the database as a string.
146 */
147 public $fixed_period_rollover_day;
148
149 /**
150 * FK to Relationship Type ID
151 *
152 * @var string|null
153 * (SQL type: varchar(64))
154 * Note that values will be retrieved from the database as a string.
155 */
156 public $relationship_type_id;
157
158 /**
159 * @var string|null
160 * (SQL type: varchar(128))
161 * Note that values will be retrieved from the database as a string.
162 */
163 public $relationship_direction;
164
165 /**
166 * Maximum number of related memberships.
167 *
168 * @var int|string|null
169 * (SQL type: int)
170 * Note that values will be retrieved from the database as a string.
171 */
172 public $max_related;
173
174 /**
175 * @var string|null
176 * (SQL type: varchar(64))
177 * Note that values will be retrieved from the database as a string.
178 */
179 public $visibility;
180
181 /**
182 * @var int|string|null
183 * (SQL type: int)
184 * Note that values will be retrieved from the database as a string.
185 */
186 public $weight;
187
188 /**
189 * Receipt Text for membership signup
190 *
191 * @var string|null
192 * (SQL type: varchar(255))
193 * Note that values will be retrieved from the database as a string.
194 */
195 public $receipt_text_signup;
196
197 /**
198 * Receipt Text for membership renewal
199 *
200 * @var string|null
201 * (SQL type: varchar(255))
202 * Note that values will be retrieved from the database as a string.
203 */
204 public $receipt_text_renewal;
205
206 /**
207 * 0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;
208 *
209 * @var int|string|null
210 * (SQL type: tinyint)
211 * Note that values will be retrieved from the database as a string.
212 */
213 public $auto_renew;
214
215 /**
216 * Is this membership_type enabled
217 *
218 * @var bool|string|null
219 * (SQL type: tinyint)
220 * Note that values will be retrieved from the database as a string.
221 */
222 public $is_active;
223
224 /**
225 * Class constructor.
226 */
227 public function __construct() {
228 $this->__table = 'civicrm_membership_type';
229 parent::__construct();
230 }
231
232 /**
233 * Returns localized title of this entity.
234 *
235 * @param bool $plural
236 * Whether to return the plural version of the title.
237 */
238 public static function getEntityTitle($plural = FALSE) {
239 return $plural ? ts('Membership Types') : ts('Membership Type');
240 }
241
242 /**
243 * Returns foreign keys and entity references.
244 *
245 * @return array
246 * [CRM_Core_Reference_Interface]
247 */
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']);
255 }
256 return Civi::$statics[__CLASS__]['links'];
257 }
258
259 /**
260 * Returns all the column names of this table
261 *
262 * @return array
263 */
264 public static function &fields() {
265 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
266 Civi::$statics[__CLASS__]['fields'] = [
267 'id' => [
268 'name' => 'id',
269 'type' => CRM_Utils_Type::T_INT,
270 'title' => ts('Membership Type ID'),
271 'description' => ts('Membership ID'),
272 'required' => TRUE,
273 'where' => 'civicrm_membership_type.id',
274 'table_name' => 'civicrm_membership_type',
275 'entity' => 'MembershipType',
276 'bao' => 'CRM_Member_BAO_MembershipType',
277 'localizable' => 0,
278 'html' => [
279 'type' => 'Number',
280 ],
281 'readonly' => TRUE,
282 'add' => '1.5',
283 ],
284 'domain_id' => [
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'),
289 'required' => TRUE,
290 'where' => 'civicrm_membership_type.domain_id',
291 'table_name' => 'civicrm_membership_type',
292 'entity' => 'MembershipType',
293 'bao' => 'CRM_Member_BAO_MembershipType',
294 'localizable' => 0,
295 'FKClassName' => 'CRM_Core_DAO_Domain',
296 'html' => [
297 'label' => ts("Domain"),
298 ],
299 'pseudoconstant' => [
300 'table' => 'civicrm_domain',
301 'keyColumn' => 'id',
302 'labelColumn' => 'name',
303 ],
304 'add' => '3.0',
305 ],
306 'membership_type' => [
307 'name' => 'name',
308 'type' => CRM_Utils_Type::T_STRING,
309 'title' => ts('Membership Type'),
310 'description' => ts('Name of Membership Type'),
311 'required' => TRUE,
312 'maxlength' => 128,
313 'size' => CRM_Utils_Type::HUGE,
314 'import' => TRUE,
315 'where' => 'civicrm_membership_type.name',
316 'export' => TRUE,
317 'table_name' => 'civicrm_membership_type',
318 'entity' => 'MembershipType',
319 'bao' => 'CRM_Member_BAO_MembershipType',
320 'localizable' => 1,
321 'html' => [
322 'type' => 'Text',
323 'label' => ts("Name"),
324 ],
325 'add' => '1.5',
326 ],
327 'description' => [
328 'name' => 'description',
329 'type' => CRM_Utils_Type::T_STRING,
330 'title' => ts('Description'),
331 'description' => ts('Description of Membership Type'),
332 'maxlength' => 255,
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',
338 'localizable' => 1,
339 'html' => [
340 'type' => 'TextArea',
341 'label' => ts("Description"),
342 ],
343 'add' => '1.5',
344 ],
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'),
350 'required' => TRUE,
351 'where' => 'civicrm_membership_type.member_of_contact_id',
352 'table_name' => 'civicrm_membership_type',
353 'entity' => 'MembershipType',
354 'bao' => 'CRM_Member_BAO_MembershipType',
355 'localizable' => 0,
356 'FKClassName' => 'CRM_Contact_DAO_Contact',
357 'html' => [
358 'label' => ts("Organization"),
359 ],
360 'add' => '1.5',
361 ],
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'),
367 'required' => TRUE,
368 'where' => 'civicrm_membership_type.financial_type_id',
369 'table_name' => 'civicrm_membership_type',
370 'entity' => 'MembershipType',
371 'bao' => 'CRM_Member_BAO_MembershipType',
372 'localizable' => 0,
373 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
374 'html' => [
375 'label' => ts("Financial Type"),
376 ],
377 'pseudoconstant' => [
378 'table' => 'civicrm_financial_type',
379 'keyColumn' => 'id',
380 'labelColumn' => 'name',
381 ],
382 'add' => '4.3',
383 ],
384 'minimum_fee' => [
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).'),
389 'precision' => [
390 18,
391 9,
392 ],
393 'where' => 'civicrm_membership_type.minimum_fee',
394 'default' => '0',
395 'table_name' => 'civicrm_membership_type',
396 'entity' => 'MembershipType',
397 'bao' => 'CRM_Member_BAO_MembershipType',
398 'localizable' => 0,
399 'html' => [
400 'type' => 'Text',
401 'label' => ts("Minimum Fee"),
402 ],
403 'add' => '1.5',
404 ],
405 'duration_unit' => [
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.'),
410 'required' => TRUE,
411 'maxlength' => 8,
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',
417 'localizable' => 0,
418 'html' => [
419 'type' => 'Select',
420 ],
421 'pseudoconstant' => [
422 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
423 ],
424 'add' => '1.5',
425 ],
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',
435 'localizable' => 0,
436 'html' => [
437 'type' => 'Text',
438 ],
439 'add' => '1.5',
440 ],
441 'period_type' => [
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.'),
446 'required' => TRUE,
447 'maxlength' => 8,
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',
453 'localizable' => 0,
454 'html' => [
455 'type' => 'Select',
456 ],
457 'pseudoconstant' => [
458 'callback' => 'CRM_Core_SelectValues::periodType',
459 ],
460 'add' => '1.5',
461 ],
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',
471 'localizable' => 0,
472 'add' => '1.5',
473 ],
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',
483 'localizable' => 0,
484 'add' => '1.5',
485 ],
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'),
491 'maxlength' => 64,
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',
497 'localizable' => 0,
498 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
499 'add' => '1.5',
500 ],
501 'relationship_direction' => [
502 'name' => 'relationship_direction',
503 'type' => CRM_Utils_Type::T_STRING,
504 'title' => ts('Relationship Direction'),
505 'maxlength' => 128,
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',
511 'localizable' => 0,
512 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
513 'html' => [
514 'label' => ts("Relationship Direction"),
515 ],
516 'add' => '1.7',
517 ],
518 'max_related' => [
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',
527 'localizable' => 0,
528 'html' => [
529 'type' => 'Text',
530 'label' => ts("Max Related"),
531 ],
532 'add' => '4.3',
533 ],
534 'visibility' => [
535 'name' => 'visibility',
536 'type' => CRM_Utils_Type::T_STRING,
537 'title' => ts('Visible'),
538 'maxlength' => 64,
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',
544 'localizable' => 0,
545 'html' => [
546 'type' => 'Select',
547 ],
548 'pseudoconstant' => [
549 'callback' => 'CRM_Core_SelectValues::memberVisibility',
550 ],
551 'add' => '1.5',
552 ],
553 'weight' => [
554 'name' => 'weight',
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',
561 'localizable' => 0,
562 'html' => [
563 'type' => 'Text',
564 ],
565 'add' => '1.5',
566 ],
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'),
572 'maxlength' => 255,
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',
578 'localizable' => 0,
579 'html' => [
580 'type' => 'TextArea',
581 ],
582 'add' => '2.0',
583 ],
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'),
589 'maxlength' => 255,
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',
595 'localizable' => 0,
596 'html' => [
597 'type' => 'TextArea',
598 ],
599 'add' => '2.0',
600 ],
601 'auto_renew' => [
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',
607 'default' => '0',
608 'table_name' => 'civicrm_membership_type',
609 'entity' => 'MembershipType',
610 'bao' => 'CRM_Member_BAO_MembershipType',
611 'localizable' => 0,
612 'html' => [
613 'type' => 'Radio',
614 'label' => ts("Auto-Renew"),
615 ],
616 'pseudoconstant' => [
617 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
618 ],
619 'add' => '3.3',
620 ],
621 'is_active' => [
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',
627 'default' => '1',
628 'table_name' => 'civicrm_membership_type',
629 'entity' => 'MembershipType',
630 'bao' => 'CRM_Member_BAO_MembershipType',
631 'localizable' => 0,
632 'html' => [
633 'type' => 'CheckBox',
634 'label' => ts("Enabled?"),
635 ],
636 'add' => '1.5',
637 ],
638 ];
639 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
640 }
641 return Civi::$statics[__CLASS__]['fields'];
642 }
643
644 /**
645 * Return a mapping from field-name to the corresponding key (as used in fields()).
646 *
647 * @return array
648 * Array(string $name => string $uniqueName).
649 */
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()));
653 }
654 return Civi::$statics[__CLASS__]['fieldKeys'];
655 }
656
657 /**
658 * Returns the names of this table
659 *
660 * @return string
661 */
662 public static function getTableName() {
663 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
664 }
665
666 /**
667 * Returns if this table needs to be logged
668 *
669 * @return bool
670 */
671 public function getLog() {
672 return self::$_log;
673 }
674
675 /**
676 * Returns the list of fields that can be imported
677 *
678 * @param bool $prefix
679 *
680 * @return array
681 */
682 public static function &import($prefix = FALSE) {
683 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_type', $prefix, []);
684 return $r;
685 }
686
687 /**
688 * Returns the list of fields that can be exported
689 *
690 * @param bool $prefix
691 *
692 * @return array
693 */
694 public static function &export($prefix = FALSE) {
695 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_type', $prefix, []);
696 return $r;
697 }
698
699 /**
700 * Returns the list of indices
701 *
702 * @param bool $localize
703 *
704 * @return array
705 */
706 public static function indices($localize = TRUE) {
707 $indices = [
708 'index_relationship_type_id' => [
709 'name' => 'index_relationship_type_id',
710 'field' => [
711 0 => 'relationship_type_id',
712 ],
713 'localizable' => FALSE,
714 'sig' => 'civicrm_membership_type::0::relationship_type_id',
715 ],
716 ];
717 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
718 }
719
720 }