Merge pull request #18852 from eileenmcnaughton/aip
[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:db300e3a7f5ca29a1b6ca43e0885bcb5)
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
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_membership_type';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * Membership Id
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Which Domain is this match entry for
42 *
43 * @var int
44 */
45 public $domain_id;
46
47 /**
48 * Name of Membership Type
49 *
50 * @var string
51 */
52 public $name;
53
54 /**
55 * Description of Membership Type
56 *
57 * @var string
58 */
59 public $description;
60
61 /**
62 * Owner organization for this membership type. FK to Contact ID
63 *
64 * @var int
65 */
66 public $member_of_contact_id;
67
68 /**
69 * If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id
70 *
71 * @var int
72 */
73 public $financial_type_id;
74
75 /**
76 * Minimum fee for this membership (0 for free/complimentary memberships).
77 *
78 * @var float
79 */
80 public $minimum_fee;
81
82 /**
83 * Unit in which membership period is expressed.
84 *
85 * @var string
86 */
87 public $duration_unit;
88
89 /**
90 * Number of duration units in membership period (e.g. 1 year, 12 months).
91 *
92 * @var int
93 */
94 public $duration_interval;
95
96 /**
97 * Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.
98 *
99 * @var string
100 */
101 public $period_type;
102
103 /**
104 * For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.
105 *
106 * @var int
107 */
108 public $fixed_period_start_day;
109
110 /**
111 * For fixed period memberships, signups after this day (mmdd) rollover to next period.
112 *
113 * @var int
114 */
115 public $fixed_period_rollover_day;
116
117 /**
118 * FK to Relationship Type ID
119 *
120 * @var string
121 */
122 public $relationship_type_id;
123
124 /**
125 * @var string
126 */
127 public $relationship_direction;
128
129 /**
130 * Maximum number of related memberships.
131 *
132 * @var int
133 */
134 public $max_related;
135
136 /**
137 * @var string
138 */
139 public $visibility;
140
141 /**
142 * @var int
143 */
144 public $weight;
145
146 /**
147 * Receipt Text for membership signup
148 *
149 * @var string
150 */
151 public $receipt_text_signup;
152
153 /**
154 * Receipt Text for membership renewal
155 *
156 * @var string
157 */
158 public $receipt_text_renewal;
159
160 /**
161 * 0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;
162 *
163 * @var bool
164 */
165 public $auto_renew;
166
167 /**
168 * Is this membership_type enabled
169 *
170 * @var bool
171 */
172 public $is_active;
173
174 /**
175 * Class constructor.
176 */
177 public function __construct() {
178 $this->__table = 'civicrm_membership_type';
179 parent::__construct();
180 }
181
182 /**
183 * Returns localized title of this entity.
184 *
185 * @param bool $plural
186 * Whether to return the plural version of the title.
187 */
188 public static function getEntityTitle($plural = FALSE) {
189 return $plural ? ts('Membership Types') : ts('Membership Type');
190 }
191
192 /**
193 * Returns foreign keys and entity references.
194 *
195 * @return array
196 * [CRM_Core_Reference_Interface]
197 */
198 public static function getReferenceColumns() {
199 if (!isset(Civi::$statics[__CLASS__]['links'])) {
200 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
201 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
202 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'member_of_contact_id', 'civicrm_contact', 'id');
203 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
204 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
205 }
206 return Civi::$statics[__CLASS__]['links'];
207 }
208
209 /**
210 * Returns all the column names of this table
211 *
212 * @return array
213 */
214 public static function &fields() {
215 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
216 Civi::$statics[__CLASS__]['fields'] = [
217 'id' => [
218 'name' => 'id',
219 'type' => CRM_Utils_Type::T_INT,
220 'title' => ts('Membership Type ID'),
221 'description' => ts('Membership Id'),
222 'required' => TRUE,
223 'where' => 'civicrm_membership_type.id',
224 'table_name' => 'civicrm_membership_type',
225 'entity' => 'MembershipType',
226 'bao' => 'CRM_Member_BAO_MembershipType',
227 'localizable' => 0,
228 'add' => '1.5',
229 ],
230 'domain_id' => [
231 'name' => 'domain_id',
232 'type' => CRM_Utils_Type::T_INT,
233 'title' => ts('Membership Type Domain'),
234 'description' => ts('Which Domain is this match entry for'),
235 'required' => TRUE,
236 'where' => 'civicrm_membership_type.domain_id',
237 'table_name' => 'civicrm_membership_type',
238 'entity' => 'MembershipType',
239 'bao' => 'CRM_Member_BAO_MembershipType',
240 'localizable' => 0,
241 'FKClassName' => 'CRM_Core_DAO_Domain',
242 'pseudoconstant' => [
243 'table' => 'civicrm_domain',
244 'keyColumn' => 'id',
245 'labelColumn' => 'name',
246 ],
247 'add' => '3.0',
248 ],
249 'membership_type' => [
250 'name' => 'name',
251 'type' => CRM_Utils_Type::T_STRING,
252 'title' => ts('Membership Type'),
253 'description' => ts('Name of Membership Type'),
254 'required' => TRUE,
255 'maxlength' => 128,
256 'size' => CRM_Utils_Type::HUGE,
257 'import' => TRUE,
258 'where' => 'civicrm_membership_type.name',
259 'export' => TRUE,
260 'table_name' => 'civicrm_membership_type',
261 'entity' => 'MembershipType',
262 'bao' => 'CRM_Member_BAO_MembershipType',
263 'localizable' => 1,
264 'html' => [
265 'type' => 'Text',
266 'label' => ts("Name"),
267 ],
268 'add' => '1.5',
269 ],
270 'description' => [
271 'name' => 'description',
272 'type' => CRM_Utils_Type::T_STRING,
273 'title' => ts('Membership Type Description'),
274 'description' => ts('Description of Membership Type'),
275 'maxlength' => 255,
276 'size' => CRM_Utils_Type::HUGE,
277 'where' => 'civicrm_membership_type.description',
278 'table_name' => 'civicrm_membership_type',
279 'entity' => 'MembershipType',
280 'bao' => 'CRM_Member_BAO_MembershipType',
281 'localizable' => 1,
282 'html' => [
283 'type' => 'TextArea',
284 'label' => ts("Description"),
285 ],
286 'add' => '1.5',
287 ],
288 'member_of_contact_id' => [
289 'name' => 'member_of_contact_id',
290 'type' => CRM_Utils_Type::T_INT,
291 'title' => ts('Membership Type Organization'),
292 'description' => ts('Owner organization for this membership type. FK to Contact ID'),
293 'required' => TRUE,
294 'where' => 'civicrm_membership_type.member_of_contact_id',
295 'table_name' => 'civicrm_membership_type',
296 'entity' => 'MembershipType',
297 'bao' => 'CRM_Member_BAO_MembershipType',
298 'localizable' => 0,
299 'FKClassName' => 'CRM_Contact_DAO_Contact',
300 'add' => '1.5',
301 ],
302 'financial_type_id' => [
303 'name' => 'financial_type_id',
304 'type' => CRM_Utils_Type::T_INT,
305 'title' => ts('Membership Financial Type'),
306 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
307 'required' => TRUE,
308 'where' => 'civicrm_membership_type.financial_type_id',
309 'table_name' => 'civicrm_membership_type',
310 'entity' => 'MembershipType',
311 'bao' => 'CRM_Member_BAO_MembershipType',
312 'localizable' => 0,
313 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
314 'pseudoconstant' => [
315 'table' => 'civicrm_financial_type',
316 'keyColumn' => 'id',
317 'labelColumn' => 'name',
318 ],
319 'add' => '4.3',
320 ],
321 'minimum_fee' => [
322 'name' => 'minimum_fee',
323 'type' => CRM_Utils_Type::T_MONEY,
324 'title' => ts('Membership Type Minimum Fee'),
325 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'),
326 'precision' => [
327 18,
328 9,
329 ],
330 'where' => 'civicrm_membership_type.minimum_fee',
331 'default' => '0',
332 'table_name' => 'civicrm_membership_type',
333 'entity' => 'MembershipType',
334 'bao' => 'CRM_Member_BAO_MembershipType',
335 'localizable' => 0,
336 'html' => [
337 'type' => 'Text',
338 'label' => ts("Minimum Fee"),
339 ],
340 'add' => '1.5',
341 ],
342 'duration_unit' => [
343 'name' => 'duration_unit',
344 'type' => CRM_Utils_Type::T_STRING,
345 'title' => ts('Membership Type Duration Unit'),
346 'description' => ts('Unit in which membership period is expressed.'),
347 'maxlength' => 8,
348 'size' => CRM_Utils_Type::EIGHT,
349 'where' => 'civicrm_membership_type.duration_unit',
350 'table_name' => 'civicrm_membership_type',
351 'entity' => 'MembershipType',
352 'bao' => 'CRM_Member_BAO_MembershipType',
353 'localizable' => 0,
354 'html' => [
355 'type' => 'Select',
356 ],
357 'pseudoconstant' => [
358 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
359 ],
360 'add' => '1.5',
361 ],
362 'duration_interval' => [
363 'name' => 'duration_interval',
364 'type' => CRM_Utils_Type::T_INT,
365 'title' => ts('Membership Type Duration Interval'),
366 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
367 'where' => 'civicrm_membership_type.duration_interval',
368 'table_name' => 'civicrm_membership_type',
369 'entity' => 'MembershipType',
370 'bao' => 'CRM_Member_BAO_MembershipType',
371 'localizable' => 0,
372 'html' => [
373 'type' => 'Text',
374 ],
375 'add' => '1.5',
376 ],
377 'period_type' => [
378 'name' => 'period_type',
379 'type' => CRM_Utils_Type::T_STRING,
380 'title' => ts('Membership Type Plan'),
381 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
382 'required' => TRUE,
383 'maxlength' => 8,
384 'size' => CRM_Utils_Type::EIGHT,
385 'where' => 'civicrm_membership_type.period_type',
386 'table_name' => 'civicrm_membership_type',
387 'entity' => 'MembershipType',
388 'bao' => 'CRM_Member_BAO_MembershipType',
389 'localizable' => 0,
390 'html' => [
391 'type' => 'Select',
392 ],
393 'pseudoconstant' => [
394 'callback' => 'CRM_Core_SelectValues::periodType',
395 ],
396 'add' => '1.5',
397 ],
398 'fixed_period_start_day' => [
399 'name' => 'fixed_period_start_day',
400 'type' => CRM_Utils_Type::T_INT,
401 'title' => ts('Fixed Period Start Day'),
402 '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.'),
403 'where' => 'civicrm_membership_type.fixed_period_start_day',
404 'table_name' => 'civicrm_membership_type',
405 'entity' => 'MembershipType',
406 'bao' => 'CRM_Member_BAO_MembershipType',
407 'localizable' => 0,
408 'add' => '1.5',
409 ],
410 'fixed_period_rollover_day' => [
411 'name' => 'fixed_period_rollover_day',
412 'type' => CRM_Utils_Type::T_INT,
413 'title' => ts('Fixed Period Rollover Day'),
414 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
415 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
416 'table_name' => 'civicrm_membership_type',
417 'entity' => 'MembershipType',
418 'bao' => 'CRM_Member_BAO_MembershipType',
419 'localizable' => 0,
420 'add' => '1.5',
421 ],
422 'relationship_type_id' => [
423 'name' => 'relationship_type_id',
424 'type' => CRM_Utils_Type::T_STRING,
425 'title' => ts('Membership Type Relationship'),
426 'description' => ts('FK to Relationship Type ID'),
427 'maxlength' => 64,
428 'size' => CRM_Utils_Type::BIG,
429 'where' => 'civicrm_membership_type.relationship_type_id',
430 'table_name' => 'civicrm_membership_type',
431 'entity' => 'MembershipType',
432 'bao' => 'CRM_Member_BAO_MembershipType',
433 'localizable' => 0,
434 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
435 'add' => '1.5',
436 ],
437 'relationship_direction' => [
438 'name' => 'relationship_direction',
439 'type' => CRM_Utils_Type::T_STRING,
440 'title' => ts('Relationship Direction'),
441 'maxlength' => 128,
442 'size' => CRM_Utils_Type::HUGE,
443 'where' => 'civicrm_membership_type.relationship_direction',
444 'table_name' => 'civicrm_membership_type',
445 'entity' => 'MembershipType',
446 'bao' => 'CRM_Member_BAO_MembershipType',
447 'localizable' => 0,
448 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
449 'add' => '1.7',
450 ],
451 'max_related' => [
452 'name' => 'max_related',
453 'type' => CRM_Utils_Type::T_INT,
454 'title' => ts('Max Related Members for Type'),
455 'description' => ts('Maximum number of related memberships.'),
456 'where' => 'civicrm_membership_type.max_related',
457 'table_name' => 'civicrm_membership_type',
458 'entity' => 'MembershipType',
459 'bao' => 'CRM_Member_BAO_MembershipType',
460 'localizable' => 0,
461 'html' => [
462 'type' => 'Text',
463 'label' => ts("Max Related"),
464 ],
465 'add' => '4.3',
466 ],
467 'visibility' => [
468 'name' => 'visibility',
469 'type' => CRM_Utils_Type::T_STRING,
470 'title' => ts('Visible'),
471 'maxlength' => 64,
472 'size' => CRM_Utils_Type::BIG,
473 'where' => 'civicrm_membership_type.visibility',
474 'table_name' => 'civicrm_membership_type',
475 'entity' => 'MembershipType',
476 'bao' => 'CRM_Member_BAO_MembershipType',
477 'localizable' => 0,
478 'html' => [
479 'type' => 'Select',
480 ],
481 'pseudoconstant' => [
482 'callback' => 'CRM_Core_SelectValues::memberVisibility',
483 ],
484 'add' => '1.5',
485 ],
486 'weight' => [
487 'name' => 'weight',
488 'type' => CRM_Utils_Type::T_INT,
489 'title' => ts('Order'),
490 'where' => 'civicrm_membership_type.weight',
491 'table_name' => 'civicrm_membership_type',
492 'entity' => 'MembershipType',
493 'bao' => 'CRM_Member_BAO_MembershipType',
494 'localizable' => 0,
495 'html' => [
496 'type' => 'Text',
497 ],
498 'add' => '1.5',
499 ],
500 'receipt_text_signup' => [
501 'name' => 'receipt_text_signup',
502 'type' => CRM_Utils_Type::T_STRING,
503 'title' => ts('Membership Type Receipt Text'),
504 'description' => ts('Receipt Text for membership signup'),
505 'maxlength' => 255,
506 'size' => CRM_Utils_Type::HUGE,
507 'where' => 'civicrm_membership_type.receipt_text_signup',
508 'table_name' => 'civicrm_membership_type',
509 'entity' => 'MembershipType',
510 'bao' => 'CRM_Member_BAO_MembershipType',
511 'localizable' => 0,
512 'html' => [
513 'type' => 'TextArea',
514 ],
515 'add' => '2.0',
516 ],
517 'receipt_text_renewal' => [
518 'name' => 'receipt_text_renewal',
519 'type' => CRM_Utils_Type::T_STRING,
520 'title' => ts('Membership Type Renewal Text'),
521 'description' => ts('Receipt Text for membership renewal'),
522 'maxlength' => 255,
523 'size' => CRM_Utils_Type::HUGE,
524 'where' => 'civicrm_membership_type.receipt_text_renewal',
525 'table_name' => 'civicrm_membership_type',
526 'entity' => 'MembershipType',
527 'bao' => 'CRM_Member_BAO_MembershipType',
528 'localizable' => 0,
529 'html' => [
530 'type' => 'TextArea',
531 ],
532 'add' => '2.0',
533 ],
534 'auto_renew' => [
535 'name' => 'auto_renew',
536 'type' => CRM_Utils_Type::T_BOOLEAN,
537 'title' => ts('Auto Renew'),
538 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
539 'where' => 'civicrm_membership_type.auto_renew',
540 'default' => '0',
541 'table_name' => 'civicrm_membership_type',
542 'entity' => 'MembershipType',
543 'bao' => 'CRM_Member_BAO_MembershipType',
544 'localizable' => 0,
545 'html' => [
546 'type' => 'Radio',
547 ],
548 'pseudoconstant' => [
549 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
550 ],
551 'add' => '3.3',
552 ],
553 'is_active' => [
554 'name' => 'is_active',
555 'type' => CRM_Utils_Type::T_BOOLEAN,
556 'title' => ts('Is Active'),
557 'description' => ts('Is this membership_type enabled'),
558 'where' => 'civicrm_membership_type.is_active',
559 'default' => '1',
560 'table_name' => 'civicrm_membership_type',
561 'entity' => 'MembershipType',
562 'bao' => 'CRM_Member_BAO_MembershipType',
563 'localizable' => 0,
564 'html' => [
565 'type' => 'CheckBox',
566 'label' => ts("Enabled?"),
567 ],
568 'add' => '1.5',
569 ],
570 ];
571 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
572 }
573 return Civi::$statics[__CLASS__]['fields'];
574 }
575
576 /**
577 * Return a mapping from field-name to the corresponding key (as used in fields()).
578 *
579 * @return array
580 * Array(string $name => string $uniqueName).
581 */
582 public static function &fieldKeys() {
583 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
584 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
585 }
586 return Civi::$statics[__CLASS__]['fieldKeys'];
587 }
588
589 /**
590 * Returns the names of this table
591 *
592 * @return string
593 */
594 public static function getTableName() {
595 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
596 }
597
598 /**
599 * Returns if this table needs to be logged
600 *
601 * @return bool
602 */
603 public function getLog() {
604 return self::$_log;
605 }
606
607 /**
608 * Returns the list of fields that can be imported
609 *
610 * @param bool $prefix
611 *
612 * @return array
613 */
614 public static function &import($prefix = FALSE) {
615 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_type', $prefix, []);
616 return $r;
617 }
618
619 /**
620 * Returns the list of fields that can be exported
621 *
622 * @param bool $prefix
623 *
624 * @return array
625 */
626 public static function &export($prefix = FALSE) {
627 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_type', $prefix, []);
628 return $r;
629 }
630
631 /**
632 * Returns the list of indices
633 *
634 * @param bool $localize
635 *
636 * @return array
637 */
638 public static function indices($localize = TRUE) {
639 $indices = [
640 'index_relationship_type_id' => [
641 'name' => 'index_relationship_type_id',
642 'field' => [
643 0 => 'relationship_type_id',
644 ],
645 'localizable' => FALSE,
646 'sig' => 'civicrm_membership_type::0::relationship_type_id',
647 ],
648 ];
649 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
650 }
651
652 }