Regenerate DAO files
[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:713057d2c1a6dcb6cbd6449b8934d28c)
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 public static function getEntityTitle() {
186 return ts('Membership Types');
187 }
188
189 /**
190 * Returns foreign keys and entity references.
191 *
192 * @return array
193 * [CRM_Core_Reference_Interface]
194 */
195 public static function getReferenceColumns() {
196 if (!isset(Civi::$statics[__CLASS__]['links'])) {
197 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
198 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
199 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'member_of_contact_id', 'civicrm_contact', 'id');
200 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
201 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
202 }
203 return Civi::$statics[__CLASS__]['links'];
204 }
205
206 /**
207 * Returns all the column names of this table
208 *
209 * @return array
210 */
211 public static function &fields() {
212 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
213 Civi::$statics[__CLASS__]['fields'] = [
214 'id' => [
215 'name' => 'id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Membership Type ID'),
218 'description' => ts('Membership Id'),
219 'required' => TRUE,
220 'where' => 'civicrm_membership_type.id',
221 'table_name' => 'civicrm_membership_type',
222 'entity' => 'MembershipType',
223 'bao' => 'CRM_Member_BAO_MembershipType',
224 'localizable' => 0,
225 'add' => '1.5',
226 ],
227 'domain_id' => [
228 'name' => 'domain_id',
229 'type' => CRM_Utils_Type::T_INT,
230 'title' => ts('Membership Type Domain'),
231 'description' => ts('Which Domain is this match entry for'),
232 'required' => TRUE,
233 'where' => 'civicrm_membership_type.domain_id',
234 'table_name' => 'civicrm_membership_type',
235 'entity' => 'MembershipType',
236 'bao' => 'CRM_Member_BAO_MembershipType',
237 'localizable' => 0,
238 'FKClassName' => 'CRM_Core_DAO_Domain',
239 'pseudoconstant' => [
240 'table' => 'civicrm_domain',
241 'keyColumn' => 'id',
242 'labelColumn' => 'name',
243 ],
244 'add' => '3.0',
245 ],
246 'membership_type' => [
247 'name' => 'name',
248 'type' => CRM_Utils_Type::T_STRING,
249 'title' => ts('Membership Type'),
250 'description' => ts('Name of Membership Type'),
251 'required' => TRUE,
252 'maxlength' => 128,
253 'size' => CRM_Utils_Type::HUGE,
254 'import' => TRUE,
255 'where' => 'civicrm_membership_type.name',
256 'export' => TRUE,
257 'table_name' => 'civicrm_membership_type',
258 'entity' => 'MembershipType',
259 'bao' => 'CRM_Member_BAO_MembershipType',
260 'localizable' => 1,
261 'html' => [
262 'type' => 'Text',
263 'label' => ts("Name"),
264 ],
265 'add' => '1.5',
266 ],
267 'description' => [
268 'name' => 'description',
269 'type' => CRM_Utils_Type::T_STRING,
270 'title' => ts('Membership Type Description'),
271 'description' => ts('Description of Membership Type'),
272 'maxlength' => 255,
273 'size' => CRM_Utils_Type::HUGE,
274 'where' => 'civicrm_membership_type.description',
275 'table_name' => 'civicrm_membership_type',
276 'entity' => 'MembershipType',
277 'bao' => 'CRM_Member_BAO_MembershipType',
278 'localizable' => 1,
279 'html' => [
280 'type' => 'TextArea',
281 'label' => ts("Description"),
282 ],
283 'add' => '1.5',
284 ],
285 'member_of_contact_id' => [
286 'name' => 'member_of_contact_id',
287 'type' => CRM_Utils_Type::T_INT,
288 'title' => ts('Membership Type Organization'),
289 'description' => ts('Owner organization for this membership type. FK to Contact ID'),
290 'required' => TRUE,
291 'where' => 'civicrm_membership_type.member_of_contact_id',
292 'table_name' => 'civicrm_membership_type',
293 'entity' => 'MembershipType',
294 'bao' => 'CRM_Member_BAO_MembershipType',
295 'localizable' => 0,
296 'FKClassName' => 'CRM_Contact_DAO_Contact',
297 'add' => '1.5',
298 ],
299 'financial_type_id' => [
300 'name' => 'financial_type_id',
301 'type' => CRM_Utils_Type::T_INT,
302 'title' => ts('Membership Financial Type'),
303 'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
304 'required' => TRUE,
305 'where' => 'civicrm_membership_type.financial_type_id',
306 'table_name' => 'civicrm_membership_type',
307 'entity' => 'MembershipType',
308 'bao' => 'CRM_Member_BAO_MembershipType',
309 'localizable' => 0,
310 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
311 'pseudoconstant' => [
312 'table' => 'civicrm_financial_type',
313 'keyColumn' => 'id',
314 'labelColumn' => 'name',
315 ],
316 'add' => '4.3',
317 ],
318 'minimum_fee' => [
319 'name' => 'minimum_fee',
320 'type' => CRM_Utils_Type::T_MONEY,
321 'title' => ts('Membership Type Minimum Fee'),
322 'description' => ts('Minimum fee for this membership (0 for free/complimentary memberships).'),
323 'precision' => [
324 18,
325 9,
326 ],
327 'where' => 'civicrm_membership_type.minimum_fee',
328 'default' => '0',
329 'table_name' => 'civicrm_membership_type',
330 'entity' => 'MembershipType',
331 'bao' => 'CRM_Member_BAO_MembershipType',
332 'localizable' => 0,
333 'html' => [
334 'type' => 'Text',
335 'label' => ts("Minimum Fee"),
336 ],
337 'add' => '1.5',
338 ],
339 'duration_unit' => [
340 'name' => 'duration_unit',
341 'type' => CRM_Utils_Type::T_STRING,
342 'title' => ts('Membership Type Duration Unit'),
343 'description' => ts('Unit in which membership period is expressed.'),
344 'maxlength' => 8,
345 'size' => CRM_Utils_Type::EIGHT,
346 'where' => 'civicrm_membership_type.duration_unit',
347 'table_name' => 'civicrm_membership_type',
348 'entity' => 'MembershipType',
349 'bao' => 'CRM_Member_BAO_MembershipType',
350 'localizable' => 0,
351 'html' => [
352 'type' => 'Select',
353 ],
354 'pseudoconstant' => [
355 'callback' => 'CRM_Core_SelectValues::membershipTypeUnitList',
356 ],
357 'add' => '1.5',
358 ],
359 'duration_interval' => [
360 'name' => 'duration_interval',
361 'type' => CRM_Utils_Type::T_INT,
362 'title' => ts('Membership Type Duration Interval'),
363 'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
364 'where' => 'civicrm_membership_type.duration_interval',
365 'table_name' => 'civicrm_membership_type',
366 'entity' => 'MembershipType',
367 'bao' => 'CRM_Member_BAO_MembershipType',
368 'localizable' => 0,
369 'html' => [
370 'type' => 'Text',
371 ],
372 'add' => '1.5',
373 ],
374 'period_type' => [
375 'name' => 'period_type',
376 'type' => CRM_Utils_Type::T_STRING,
377 'title' => ts('Membership Type Plan'),
378 'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
379 'maxlength' => 8,
380 'size' => CRM_Utils_Type::EIGHT,
381 'where' => 'civicrm_membership_type.period_type',
382 'table_name' => 'civicrm_membership_type',
383 'entity' => 'MembershipType',
384 'bao' => 'CRM_Member_BAO_MembershipType',
385 'localizable' => 0,
386 'html' => [
387 'type' => 'Select',
388 ],
389 'pseudoconstant' => [
390 'callback' => 'CRM_Core_SelectValues::periodType',
391 ],
392 'add' => '1.5',
393 ],
394 'fixed_period_start_day' => [
395 'name' => 'fixed_period_start_day',
396 'type' => CRM_Utils_Type::T_INT,
397 'title' => ts('Fixed Period Start Day'),
398 '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.'),
399 'where' => 'civicrm_membership_type.fixed_period_start_day',
400 'table_name' => 'civicrm_membership_type',
401 'entity' => 'MembershipType',
402 'bao' => 'CRM_Member_BAO_MembershipType',
403 'localizable' => 0,
404 'add' => '1.5',
405 ],
406 'fixed_period_rollover_day' => [
407 'name' => 'fixed_period_rollover_day',
408 'type' => CRM_Utils_Type::T_INT,
409 'title' => ts('Fixed Period Rollover Day'),
410 'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
411 'where' => 'civicrm_membership_type.fixed_period_rollover_day',
412 'table_name' => 'civicrm_membership_type',
413 'entity' => 'MembershipType',
414 'bao' => 'CRM_Member_BAO_MembershipType',
415 'localizable' => 0,
416 'add' => '1.5',
417 ],
418 'relationship_type_id' => [
419 'name' => 'relationship_type_id',
420 'type' => CRM_Utils_Type::T_STRING,
421 'title' => ts('Membership Type Relationship'),
422 'description' => ts('FK to Relationship Type ID'),
423 'maxlength' => 64,
424 'size' => CRM_Utils_Type::BIG,
425 'where' => 'civicrm_membership_type.relationship_type_id',
426 'table_name' => 'civicrm_membership_type',
427 'entity' => 'MembershipType',
428 'bao' => 'CRM_Member_BAO_MembershipType',
429 'localizable' => 0,
430 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
431 'add' => '1.5',
432 ],
433 'relationship_direction' => [
434 'name' => 'relationship_direction',
435 'type' => CRM_Utils_Type::T_STRING,
436 'title' => ts('Relationship Direction'),
437 'maxlength' => 128,
438 'size' => CRM_Utils_Type::HUGE,
439 'where' => 'civicrm_membership_type.relationship_direction',
440 'table_name' => 'civicrm_membership_type',
441 'entity' => 'MembershipType',
442 'bao' => 'CRM_Member_BAO_MembershipType',
443 'localizable' => 0,
444 'serialize' => self::SERIALIZE_SEPARATOR_TRIMMED,
445 'add' => '1.7',
446 ],
447 'max_related' => [
448 'name' => 'max_related',
449 'type' => CRM_Utils_Type::T_INT,
450 'title' => ts('Max Related Members for Type'),
451 'description' => ts('Maximum number of related memberships.'),
452 'where' => 'civicrm_membership_type.max_related',
453 'table_name' => 'civicrm_membership_type',
454 'entity' => 'MembershipType',
455 'bao' => 'CRM_Member_BAO_MembershipType',
456 'localizable' => 0,
457 'html' => [
458 'type' => 'Text',
459 'label' => ts("Max Related"),
460 ],
461 'add' => '4.3',
462 ],
463 'visibility' => [
464 'name' => 'visibility',
465 'type' => CRM_Utils_Type::T_STRING,
466 'title' => ts('Visible'),
467 'maxlength' => 64,
468 'size' => CRM_Utils_Type::BIG,
469 'where' => 'civicrm_membership_type.visibility',
470 'table_name' => 'civicrm_membership_type',
471 'entity' => 'MembershipType',
472 'bao' => 'CRM_Member_BAO_MembershipType',
473 'localizable' => 0,
474 'html' => [
475 'type' => 'Select',
476 ],
477 'pseudoconstant' => [
478 'callback' => 'CRM_Core_SelectValues::memberVisibility',
479 ],
480 'add' => '1.5',
481 ],
482 'weight' => [
483 'name' => 'weight',
484 'type' => CRM_Utils_Type::T_INT,
485 'title' => ts('Order'),
486 'where' => 'civicrm_membership_type.weight',
487 'table_name' => 'civicrm_membership_type',
488 'entity' => 'MembershipType',
489 'bao' => 'CRM_Member_BAO_MembershipType',
490 'localizable' => 0,
491 'html' => [
492 'type' => 'Text',
493 ],
494 'add' => '1.5',
495 ],
496 'receipt_text_signup' => [
497 'name' => 'receipt_text_signup',
498 'type' => CRM_Utils_Type::T_STRING,
499 'title' => ts('Membership Type Receipt Text'),
500 'description' => ts('Receipt Text for membership signup'),
501 'maxlength' => 255,
502 'size' => CRM_Utils_Type::HUGE,
503 'where' => 'civicrm_membership_type.receipt_text_signup',
504 'table_name' => 'civicrm_membership_type',
505 'entity' => 'MembershipType',
506 'bao' => 'CRM_Member_BAO_MembershipType',
507 'localizable' => 0,
508 'html' => [
509 'type' => 'TextArea',
510 ],
511 'add' => '2.0',
512 ],
513 'receipt_text_renewal' => [
514 'name' => 'receipt_text_renewal',
515 'type' => CRM_Utils_Type::T_STRING,
516 'title' => ts('Membership Type Renewal Text'),
517 'description' => ts('Receipt Text for membership renewal'),
518 'maxlength' => 255,
519 'size' => CRM_Utils_Type::HUGE,
520 'where' => 'civicrm_membership_type.receipt_text_renewal',
521 'table_name' => 'civicrm_membership_type',
522 'entity' => 'MembershipType',
523 'bao' => 'CRM_Member_BAO_MembershipType',
524 'localizable' => 0,
525 'html' => [
526 'type' => 'TextArea',
527 ],
528 'add' => '2.0',
529 ],
530 'auto_renew' => [
531 'name' => 'auto_renew',
532 'type' => CRM_Utils_Type::T_BOOLEAN,
533 'title' => ts('Auto Renew'),
534 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
535 'where' => 'civicrm_membership_type.auto_renew',
536 'default' => '0',
537 'table_name' => 'civicrm_membership_type',
538 'entity' => 'MembershipType',
539 'bao' => 'CRM_Member_BAO_MembershipType',
540 'localizable' => 0,
541 'html' => [
542 'type' => 'Radio',
543 ],
544 'pseudoconstant' => [
545 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
546 ],
547 'add' => '3.3',
548 ],
549 'is_active' => [
550 'name' => 'is_active',
551 'type' => CRM_Utils_Type::T_BOOLEAN,
552 'title' => ts('Is Active'),
553 'description' => ts('Is this membership_type enabled'),
554 'where' => 'civicrm_membership_type.is_active',
555 'default' => '1',
556 'table_name' => 'civicrm_membership_type',
557 'entity' => 'MembershipType',
558 'bao' => 'CRM_Member_BAO_MembershipType',
559 'localizable' => 0,
560 'html' => [
561 'type' => 'CheckBox',
562 'label' => ts("Enabled?"),
563 ],
564 'add' => '1.5',
565 ],
566 ];
567 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
568 }
569 return Civi::$statics[__CLASS__]['fields'];
570 }
571
572 /**
573 * Return a mapping from field-name to the corresponding key (as used in fields()).
574 *
575 * @return array
576 * Array(string $name => string $uniqueName).
577 */
578 public static function &fieldKeys() {
579 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
580 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
581 }
582 return Civi::$statics[__CLASS__]['fieldKeys'];
583 }
584
585 /**
586 * Returns the names of this table
587 *
588 * @return string
589 */
590 public static function getTableName() {
591 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
592 }
593
594 /**
595 * Returns if this table needs to be logged
596 *
597 * @return bool
598 */
599 public function getLog() {
600 return self::$_log;
601 }
602
603 /**
604 * Returns the list of fields that can be imported
605 *
606 * @param bool $prefix
607 *
608 * @return array
609 */
610 public static function &import($prefix = FALSE) {
611 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_type', $prefix, []);
612 return $r;
613 }
614
615 /**
616 * Returns the list of fields that can be exported
617 *
618 * @param bool $prefix
619 *
620 * @return array
621 */
622 public static function &export($prefix = FALSE) {
623 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_type', $prefix, []);
624 return $r;
625 }
626
627 /**
628 * Returns the list of indices
629 *
630 * @param bool $localize
631 *
632 * @return array
633 */
634 public static function indices($localize = TRUE) {
635 $indices = [
636 'index_relationship_type_id' => [
637 'name' => 'index_relationship_type_id',
638 'field' => [
639 0 => 'relationship_type_id',
640 ],
641 'localizable' => FALSE,
642 'sig' => 'civicrm_membership_type::0::relationship_type_id',
643 ],
644 ];
645 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
646 }
647
648 }