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