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