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