Merge pull request #14322 from AlainBenbassat/5.14
[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 '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 ],
409 'relationship_direction' => [
410 'name' => 'relationship_direction',
411 'type' => CRM_Utils_Type::T_STRING,
412 'title' => ts('Relationship Direction'),
413 'maxlength' => 128,
414 'size' => CRM_Utils_Type::HUGE,
415 'where' => 'civicrm_membership_type.relationship_direction',
416 'table_name' => 'civicrm_membership_type',
417 'entity' => 'MembershipType',
418 'bao' => 'CRM_Member_BAO_MembershipType',
419 'localizable' => 0,
420 ],
421 'max_related' => [
422 'name' => 'max_related',
423 'type' => CRM_Utils_Type::T_INT,
424 'title' => ts('Max Related Members for Type'),
425 'description' => ts('Maximum number of related memberships.'),
426 'where' => 'civicrm_membership_type.max_related',
427 'table_name' => 'civicrm_membership_type',
428 'entity' => 'MembershipType',
429 'bao' => 'CRM_Member_BAO_MembershipType',
430 'localizable' => 0,
431 'html' => [
432 'type' => 'Text',
433 'label' => ts("Max Related"),
434 ],
435 ],
436 'visibility' => [
437 'name' => 'visibility',
438 'type' => CRM_Utils_Type::T_STRING,
439 'title' => ts('Visible'),
440 'maxlength' => 64,
441 'size' => CRM_Utils_Type::BIG,
442 'where' => 'civicrm_membership_type.visibility',
443 'table_name' => 'civicrm_membership_type',
444 'entity' => 'MembershipType',
445 'bao' => 'CRM_Member_BAO_MembershipType',
446 'localizable' => 0,
447 'html' => [
448 'type' => 'Select',
449 ],
450 'pseudoconstant' => [
451 'callback' => 'CRM_Core_SelectValues::memberVisibility',
452 ]
453 ],
454 'weight' => [
455 'name' => 'weight',
456 'type' => CRM_Utils_Type::T_INT,
457 'title' => ts('Order'),
458 'where' => 'civicrm_membership_type.weight',
459 'table_name' => 'civicrm_membership_type',
460 'entity' => 'MembershipType',
461 'bao' => 'CRM_Member_BAO_MembershipType',
462 'localizable' => 0,
463 'html' => [
464 'type' => 'Text',
465 ],
466 ],
467 'receipt_text_signup' => [
468 'name' => 'receipt_text_signup',
469 'type' => CRM_Utils_Type::T_STRING,
470 'title' => ts('Membership Type Receipt Text'),
471 'description' => ts('Receipt Text for membership signup'),
472 'maxlength' => 255,
473 'size' => CRM_Utils_Type::HUGE,
474 'where' => 'civicrm_membership_type.receipt_text_signup',
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 'receipt_text_renewal' => [
484 'name' => 'receipt_text_renewal',
485 'type' => CRM_Utils_Type::T_STRING,
486 'title' => ts('Membership Type Renewal Text'),
487 'description' => ts('Receipt Text for membership renewal'),
488 'maxlength' => 255,
489 'size' => CRM_Utils_Type::HUGE,
490 'where' => 'civicrm_membership_type.receipt_text_renewal',
491 'table_name' => 'civicrm_membership_type',
492 'entity' => 'MembershipType',
493 'bao' => 'CRM_Member_BAO_MembershipType',
494 'localizable' => 0,
495 'html' => [
496 'type' => 'TextArea',
497 ],
498 ],
499 'auto_renew' => [
500 'name' => 'auto_renew',
501 'type' => CRM_Utils_Type::T_BOOLEAN,
502 'title' => ts('Auto Renew'),
503 'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
504 'where' => 'civicrm_membership_type.auto_renew',
505 'default' => '0',
506 'table_name' => 'civicrm_membership_type',
507 'entity' => 'MembershipType',
508 'bao' => 'CRM_Member_BAO_MembershipType',
509 'localizable' => 0,
510 'html' => [
511 'type' => 'Radio',
512 ],
513 'pseudoconstant' => [
514 'callback' => 'CRM_Core_SelectValues::memberAutoRenew',
515 ]
516 ],
517 'is_active' => [
518 'name' => 'is_active',
519 'type' => CRM_Utils_Type::T_BOOLEAN,
520 'title' => ts('Is Active'),
521 'description' => ts('Is this membership_type enabled'),
522 'where' => 'civicrm_membership_type.is_active',
523 'default' => '1',
524 'table_name' => 'civicrm_membership_type',
525 'entity' => 'MembershipType',
526 'bao' => 'CRM_Member_BAO_MembershipType',
527 'localizable' => 0,
528 'html' => [
529 'type' => 'CheckBox',
530 'label' => ts("Enabled?"),
531 ],
532 ],
533 ];
534 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
535 }
536 return Civi::$statics[__CLASS__]['fields'];
537 }
538
539 /**
540 * Return a mapping from field-name to the corresponding key (as used in fields()).
541 *
542 * @return array
543 * Array(string $name => string $uniqueName).
544 */
545 public static function &fieldKeys() {
546 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
547 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
548 }
549 return Civi::$statics[__CLASS__]['fieldKeys'];
550 }
551
552 /**
553 * Returns the names of this table
554 *
555 * @return string
556 */
557 public static function getTableName() {
558 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
559 }
560
561 /**
562 * Returns if this table needs to be logged
563 *
564 * @return bool
565 */
566 public function getLog() {
567 return self::$_log;
568 }
569
570 /**
571 * Returns the list of fields that can be imported
572 *
573 * @param bool $prefix
574 *
575 * @return array
576 */
577 public static function &import($prefix = FALSE) {
578 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership_type', $prefix, []);
579 return $r;
580 }
581
582 /**
583 * Returns the list of fields that can be exported
584 *
585 * @param bool $prefix
586 *
587 * @return array
588 */
589 public static function &export($prefix = FALSE) {
590 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership_type', $prefix, []);
591 return $r;
592 }
593
594 /**
595 * Returns the list of indices
596 *
597 * @param bool $localize
598 *
599 * @return array
600 */
601 public static function indices($localize = TRUE) {
602 $indices = [
603 'index_relationship_type_id' => [
604 'name' => 'index_relationship_type_id',
605 'field' => [
606 0 => 'relationship_type_id',
607 ],
608 'localizable' => FALSE,
609 'sig' => 'civicrm_membership_type::0::relationship_type_id',
610 ],
611 ];
612 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
613 }
614
615 }