CRM-14885 - Import DAO's
[civicrm-core.git] / CRM / Member / DAO / Membership.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Member/Membership.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:b9b436f1d3cc569db8b8c05adb8240b5)
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Member_DAO_Membership extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_membership';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = true;
83 /**
84 * Membership Id
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * FK to Contact ID
91 *
92 * @var int unsigned
93 */
94 public $contact_id;
95 /**
96 * FK to Membership Type
97 *
98 * @var int unsigned
99 */
100 public $membership_type_id;
101 /**
102 * Beginning of initial membership period (member since...).
103 *
104 * @var date
105 */
106 public $join_date;
107 /**
108 * Beginning of current uninterrupted membership period.
109 *
110 * @var date
111 */
112 public $start_date;
113 /**
114 * Current membership period expire date.
115 *
116 * @var date
117 */
118 public $end_date;
119 /**
120 *
121 * @var string
122 */
123 public $source;
124 /**
125 * FK to Membership Status
126 *
127 * @var int unsigned
128 */
129 public $status_id;
130 /**
131 * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.
132 *
133 * @var boolean
134 */
135 public $is_override;
136 /**
137 * Optional FK to Parent Membership.
138 *
139 * @var int unsigned
140 */
141 public $owner_membership_id;
142 /**
143 * Maximum number of related memberships (membership_type override).
144 *
145 * @var int
146 */
147 public $max_related;
148 /**
149 *
150 * @var boolean
151 */
152 public $is_test;
153 /**
154 *
155 * @var boolean
156 */
157 public $is_pay_later;
158 /**
159 * Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
160 *
161 * @var int unsigned
162 */
163 public $contribution_recur_id;
164 /**
165 * The campaign for which this membership is attached.
166 *
167 * @var int unsigned
168 */
169 public $campaign_id;
170 /**
171 * class constructor
172 *
173 * @return civicrm_membership
174 */
175 function __construct() {
176 $this->__table = 'civicrm_membership';
177 parent::__construct();
178 }
179 /**
180 * Returns foreign keys and entity references
181 *
182 * @return array
183 * [CRM_Core_Reference_Interface]
184 */
185 static function getReferenceColumns() {
186 if (!self::$_links) {
187 self::$_links = static ::createReferenceColumns(__CLASS__);
188 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
189 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'membership_type_id', 'civicrm_membership_type', 'id');
190 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'status_id', 'civicrm_membership_status', 'id');
191 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'owner_membership_id', 'civicrm_membership', 'id');
192 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
193 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
194 }
195 return self::$_links;
196 }
197 /**
198 * Returns all the column names of this table
199 *
200 * @return array
201 */
202 static function &fields() {
203 if (!(self::$_fields)) {
204 self::$_fields = array(
205 'membership_id' => array(
206 'name' => 'id',
207 'type' => CRM_Utils_Type::T_INT,
208 'title' => ts('Membership ID') ,
209 'description' => 'Membership Id',
210 'required' => true,
211 'import' => true,
212 'where' => 'civicrm_membership.id',
213 'headerPattern' => '/^(m(embership\s)?id)$/i',
214 'dataPattern' => '',
215 'export' => true,
216 ) ,
217 'membership_contact_id' => array(
218 'name' => 'contact_id',
219 'type' => CRM_Utils_Type::T_INT,
220 'title' => ts('Contact ID') ,
221 'description' => 'FK to Contact ID',
222 'required' => true,
223 'import' => true,
224 'where' => 'civicrm_membership.contact_id',
225 'headerPattern' => '/contact(.?id)?/i',
226 'dataPattern' => '/^\d+$/',
227 'export' => true,
228 'FKClassName' => 'CRM_Contact_DAO_Contact',
229 'html' => array(
230 'type' => 'EntityRef',
231 ) ,
232 ) ,
233 'membership_type_id' => array(
234 'name' => 'membership_type_id',
235 'type' => CRM_Utils_Type::T_INT,
236 'title' => ts('Membership Type Id') ,
237 'description' => 'FK to Membership Type',
238 'required' => true,
239 'import' => true,
240 'where' => 'civicrm_membership.membership_type_id',
241 'headerPattern' => '/^(m(embership\s)?type)$/i',
242 'dataPattern' => '',
243 'export' => false,
244 'FKClassName' => 'CRM_Member_DAO_MembershipType',
245 'html' => array(
246 'type' => 'Select',
247 ) ,
248 'pseudoconstant' => array(
249 'table' => 'civicrm_membership_type',
250 'keyColumn' => 'id',
251 'labelColumn' => 'name',
252 )
253 ) ,
254 'join_date' => array(
255 'name' => 'join_date',
256 'type' => CRM_Utils_Type::T_DATE,
257 'title' => ts('Member Since') ,
258 'description' => 'Beginning of initial membership period (member since...).',
259 'import' => true,
260 'where' => 'civicrm_membership.join_date',
261 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
262 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
263 'export' => true,
264 'html' => array(
265 'type' => 'Select Date',
266 ) ,
267 ) ,
268 'membership_start_date' => array(
269 'name' => 'start_date',
270 'type' => CRM_Utils_Type::T_DATE,
271 'title' => ts('Membership Start Date') ,
272 'description' => 'Beginning of current uninterrupted membership period.',
273 'import' => true,
274 'where' => 'civicrm_membership.start_date',
275 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
276 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
277 'export' => true,
278 'html' => array(
279 'type' => 'Select Date',
280 ) ,
281 ) ,
282 'membership_end_date' => array(
283 'name' => 'end_date',
284 'type' => CRM_Utils_Type::T_DATE,
285 'title' => ts('Membership Expiration Date') ,
286 'description' => 'Current membership period expire date.',
287 'import' => true,
288 'where' => 'civicrm_membership.end_date',
289 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
290 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
291 'export' => true,
292 'html' => array(
293 'type' => 'Select Date',
294 ) ,
295 ) ,
296 'membership_source' => array(
297 'name' => 'source',
298 'type' => CRM_Utils_Type::T_STRING,
299 'title' => ts('Source') ,
300 'maxlength' => 128,
301 'size' => CRM_Utils_Type::HUGE,
302 'import' => true,
303 'where' => 'civicrm_membership.source',
304 'headerPattern' => '/^(member(ship?))?source$/i',
305 'dataPattern' => '',
306 'export' => true,
307 'html' => array(
308 'type' => 'Text',
309 ) ,
310 ) ,
311 'status_id' => array(
312 'name' => 'status_id',
313 'type' => CRM_Utils_Type::T_INT,
314 'title' => ts('Membership Status Id') ,
315 'description' => 'FK to Membership Status',
316 'required' => true,
317 'import' => true,
318 'where' => 'civicrm_membership.status_id',
319 'headerPattern' => '/(member(ship|).)?(status)$/i',
320 'dataPattern' => '',
321 'export' => false,
322 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
323 'html' => array(
324 'type' => 'Select',
325 ) ,
326 'pseudoconstant' => array(
327 'table' => 'civicrm_membership_status',
328 'keyColumn' => 'id',
329 'labelColumn' => 'label',
330 )
331 ) ,
332 'is_override' => array(
333 'name' => 'is_override',
334 'type' => CRM_Utils_Type::T_BOOLEAN,
335 'title' => ts('Status Override') ,
336 'description' => 'Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.',
337 'import' => true,
338 'where' => 'civicrm_membership.is_override',
339 'headerPattern' => '/override$/i',
340 'dataPattern' => '',
341 'export' => true,
342 'html' => array(
343 'type' => 'CheckBox',
344 ) ,
345 ) ,
346 'owner_membership_id' => array(
347 'name' => 'owner_membership_id',
348 'type' => CRM_Utils_Type::T_INT,
349 'title' => ts('Primary Member ID') ,
350 'description' => 'Optional FK to Parent Membership.',
351 'export' => true,
352 'where' => 'civicrm_membership.owner_membership_id',
353 'headerPattern' => '',
354 'dataPattern' => '',
355 'FKClassName' => 'CRM_Member_DAO_Membership',
356 ) ,
357 'max_related' => array(
358 'name' => 'max_related',
359 'type' => CRM_Utils_Type::T_INT,
360 'title' => ts('Max Related') ,
361 'description' => 'Maximum number of related memberships (membership_type override).',
362 'html' => array(
363 'type' => 'Text',
364 ) ,
365 ) ,
366 'member_is_test' => array(
367 'name' => 'is_test',
368 'type' => CRM_Utils_Type::T_BOOLEAN,
369 'title' => ts('Test') ,
370 'import' => true,
371 'where' => 'civicrm_membership.is_test',
372 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
373 'dataPattern' => '',
374 'export' => true,
375 'html' => array(
376 'type' => 'CheckBox',
377 ) ,
378 ) ,
379 'member_is_pay_later' => array(
380 'name' => 'is_pay_later',
381 'type' => CRM_Utils_Type::T_BOOLEAN,
382 'title' => ts('Is Pay Later') ,
383 'import' => true,
384 'where' => 'civicrm_membership.is_pay_later',
385 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
386 'dataPattern' => '',
387 'export' => true,
388 'html' => array(
389 'type' => 'CheckBox',
390 ) ,
391 ) ,
392 'contribution_recur_id' => array(
393 'name' => 'contribution_recur_id',
394 'type' => CRM_Utils_Type::T_INT,
395 'title' => ts('Membership Recurring Contribution') ,
396 'description' => 'Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.',
397 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
398 ) ,
399 'member_campaign_id' => array(
400 'name' => 'campaign_id',
401 'type' => CRM_Utils_Type::T_INT,
402 'title' => ts('Campaign') ,
403 'description' => 'The campaign for which this membership is attached.',
404 'import' => true,
405 'where' => 'civicrm_membership.campaign_id',
406 'headerPattern' => '',
407 'dataPattern' => '',
408 'export' => true,
409 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
410 'html' => array(
411 'type' => 'Select',
412 ) ,
413 'pseudoconstant' => array(
414 'table' => 'civicrm_campaign',
415 'keyColumn' => 'id',
416 'labelColumn' => 'title',
417 )
418 ) ,
419 );
420 }
421 return self::$_fields;
422 }
423 /**
424 * Returns an array containing, for each field, the arary key used for that
425 * field in self::$_fields.
426 *
427 * @return array
428 */
429 static function &fieldKeys() {
430 if (!(self::$_fieldKeys)) {
431 self::$_fieldKeys = array(
432 'id' => 'membership_id',
433 'contact_id' => 'membership_contact_id',
434 'membership_type_id' => 'membership_type_id',
435 'join_date' => 'join_date',
436 'start_date' => 'membership_start_date',
437 'end_date' => 'membership_end_date',
438 'source' => 'membership_source',
439 'status_id' => 'status_id',
440 'is_override' => 'is_override',
441 'owner_membership_id' => 'owner_membership_id',
442 'max_related' => 'max_related',
443 'is_test' => 'member_is_test',
444 'is_pay_later' => 'member_is_pay_later',
445 'contribution_recur_id' => 'contribution_recur_id',
446 'campaign_id' => 'member_campaign_id',
447 );
448 }
449 return self::$_fieldKeys;
450 }
451 /**
452 * Returns the names of this table
453 *
454 * @return string
455 */
456 static function getTableName() {
457 return self::$_tableName;
458 }
459 /**
460 * Returns if this table needs to be logged
461 *
462 * @return boolean
463 */
464 function getLog() {
465 return self::$_log;
466 }
467 /**
468 * Returns the list of fields that can be imported
469 *
470 * @param bool $prefix
471 *
472 * @return array
473 */
474 static function &import($prefix = false) {
475 if (!(self::$_import)) {
476 self::$_import = array();
477 $fields = self::fields();
478 foreach($fields as $name => $field) {
479 if (CRM_Utils_Array::value('import', $field)) {
480 if ($prefix) {
481 self::$_import['membership'] = & $fields[$name];
482 } else {
483 self::$_import[$name] = & $fields[$name];
484 }
485 }
486 }
487 }
488 return self::$_import;
489 }
490 /**
491 * Returns the list of fields that can be exported
492 *
493 * @param bool $prefix
494 *
495 * @return array
496 */
497 static function &export($prefix = false) {
498 if (!(self::$_export)) {
499 self::$_export = array();
500 $fields = self::fields();
501 foreach($fields as $name => $field) {
502 if (CRM_Utils_Array::value('export', $field)) {
503 if ($prefix) {
504 self::$_export['membership'] = & $fields[$name];
505 } else {
506 self::$_export[$name] = & $fields[$name];
507 }
508 }
509 }
510 }
511 return self::$_export;
512 }
513}