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