Fixed CRM-20330: provided a way to generate a table with a composite primary key...
[civicrm-core.git] / CRM / Contribute / DAO / Contribution.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Contribute/Contribution.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
022785d8 33 * (GenCodeChecksum:bff397bf9cf2dc2fef96d7c5ab560158)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Contribute_DAO_Contribution constructor.
39 */
e501603b
TO
40class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_contribution';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Contribution ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * FK to Contact ID
61 *
62 * @var int unsigned
63 */
64 public $contact_id;
65 /**
66 * FK to Financial Type for (total_amount - non_deductible_amount).
67 *
68 * @var int unsigned
69 */
70 public $financial_type_id;
71 /**
72 * The Contribution Page which triggered this contribution
73 *
74 * @var int unsigned
75 */
76 public $contribution_page_id;
77 /**
78 * FK to Payment Instrument
79 *
80 * @var int unsigned
81 */
82 public $payment_instrument_id;
83 /**
84 * Date contribution was received - not necessarily the creation date of the record
85 *
86 * @var datetime
87 */
88 public $receive_date;
89 /**
90 * Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.
91 *
92 * @var float
93 */
94 public $non_deductible_amount;
95 /**
96 * Total amount of this contribution. Use market value for non-monetary gifts.
97 *
98 * @var float
99 */
100 public $total_amount;
101 /**
102 * actual processor fee if known - may be 0.
103 *
104 * @var float
105 */
106 public $fee_amount;
107 /**
108 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
109 *
110 * @var float
111 */
112 public $net_amount;
113 /**
114 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
115 *
116 * @var string
117 */
118 public $trxn_id;
119 /**
120 * unique invoice id, system generated or passed in
121 *
122 * @var string
123 */
124 public $invoice_id;
125 /**
126 * 3 character string, value from config setting or input via user.
127 *
128 * @var string
129 */
130 public $currency;
131 /**
132 * when was gift cancelled
133 *
134 * @var datetime
135 */
136 public $cancel_date;
137 /**
138 *
139 * @var text
140 */
141 public $cancel_reason;
142 /**
143 * when (if) receipt was sent. populated automatically for online donations w/ automatic receipting
144 *
145 * @var datetime
146 */
147 public $receipt_date;
148 /**
149 * when (if) was donor thanked
150 *
151 * @var datetime
152 */
153 public $thankyou_date;
154 /**
155 * Origin of this Contribution.
156 *
157 * @var string
158 */
159 public $source;
160 /**
161 *
162 * @var text
163 */
164 public $amount_level;
165 /**
166 * Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
167 *
168 * @var int unsigned
169 */
170 public $contribution_recur_id;
171 /**
172 *
173 * @var boolean
174 */
175 public $is_test;
176 /**
177 *
178 * @var boolean
179 */
180 public $is_pay_later;
181 /**
182 *
183 * @var int unsigned
184 */
185 public $contribution_status_id;
186 /**
187 * Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.
188 *
189 * @var int unsigned
190 */
191 public $address_id;
192 /**
193 *
194 * @var string
195 */
196 public $check_number;
197 /**
198 * The campaign for which this contribution has been triggered.
199 *
200 * @var int unsigned
201 */
202 public $campaign_id;
203 /**
204 * unique credit note id, system generated or passed in
205 *
206 * @var string
207 */
208 public $creditnote_id;
209 /**
210 * Total tax amount of this contribution.
211 *
212 * @var float
213 */
214 public $tax_amount;
215 /**
216 * Stores the date when revenue should be recognized.
217 *
218 * @var datetime
219 */
220 public $revenue_recognition_date;
221 /**
f41f0342 222 * Class constructor.
e501603b
TO
223 */
224 function __construct() {
225 $this->__table = 'civicrm_contribution';
226 parent::__construct();
227 }
228 /**
f41f0342 229 * Returns foreign keys and entity references.
e501603b
TO
230 *
231 * @return array
232 * [CRM_Core_Reference_Interface]
233 */
234 static function getReferenceColumns() {
346aaaba
TO
235 if (!isset(Civi::$statics[__CLASS__]['links'])) {
236 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
237 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
238 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
239 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_page_id', 'civicrm_contribution_page', 'id');
240 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
241 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'address_id', 'civicrm_address', 'id');
242 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
243 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 244 }
346aaaba 245 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
246 }
247 /**
248 * Returns all the column names of this table
249 *
250 * @return array
251 */
252 static function &fields() {
346aaaba
TO
253 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
254 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
255 'contribution_id' => array(
256 'name' => 'id',
257 'type' => CRM_Utils_Type::T_INT,
258 'title' => ts('Contribution ID') ,
259 'description' => 'Contribution ID',
260 'required' => true,
261 'import' => true,
262 'where' => 'civicrm_contribution.id',
263 'headerPattern' => '',
264 'dataPattern' => '',
265 'export' => true,
522a26c9 266 'table_name' => 'civicrm_contribution',
267 'entity' => 'Contribution',
268 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
269 ) ,
270 'contribution_contact_id' => array(
271 'name' => 'contact_id',
272 'type' => CRM_Utils_Type::T_INT,
273 'title' => ts('Contact ID') ,
274 'description' => 'FK to Contact ID',
275 'required' => true,
276 'import' => true,
277 'where' => 'civicrm_contribution.contact_id',
278 'headerPattern' => '/contact(.?id)?/i',
279 'dataPattern' => '/^\d+$/',
280 'export' => true,
522a26c9 281 'table_name' => 'civicrm_contribution',
282 'entity' => 'Contribution',
283 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
284 'FKClassName' => 'CRM_Contact_DAO_Contact',
285 'html' => array(
286 'type' => 'EntityRef',
287 ) ,
288 ) ,
289 'financial_type_id' => array(
290 'name' => 'financial_type_id',
291 'type' => CRM_Utils_Type::T_INT,
292 'title' => ts('Financial Type') ,
293 'description' => 'FK to Financial Type for (total_amount - non_deductible_amount).',
3123273f 294 'export' => true,
e501603b
TO
295 'where' => 'civicrm_contribution.financial_type_id',
296 'headerPattern' => '',
297 'dataPattern' => '',
522a26c9 298 'table_name' => 'civicrm_contribution',
299 'entity' => 'Contribution',
300 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
301 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
302 'html' => array(
303 'type' => 'Select',
304 ) ,
305 'pseudoconstant' => array(
306 'table' => 'civicrm_financial_type',
307 'keyColumn' => 'id',
308 'labelColumn' => 'name',
309 )
310 ) ,
311 'contribution_page_id' => array(
312 'name' => 'contribution_page_id',
313 'type' => CRM_Utils_Type::T_INT,
314 'title' => ts('Contribution Page ID') ,
315 'description' => 'The Contribution Page which triggered this contribution',
316 'import' => true,
317 'where' => 'civicrm_contribution.contribution_page_id',
318 'headerPattern' => '',
319 'dataPattern' => '',
320 'export' => true,
522a26c9 321 'table_name' => 'civicrm_contribution',
322 'entity' => 'Contribution',
323 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
324 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
325 'html' => array(
326 'type' => 'Select',
327 ) ,
328 'pseudoconstant' => array(
329 'table' => 'civicrm_contribution_page',
330 'keyColumn' => 'id',
331 'labelColumn' => 'title',
332 )
333 ) ,
334 'payment_instrument_id' => array(
335 'name' => 'payment_instrument_id',
336 'type' => CRM_Utils_Type::T_INT,
9d5c7f14 337 'title' => ts('Payment Method ID') ,
e501603b 338 'description' => 'FK to Payment Instrument',
9d5c7f14 339 'export' => true,
340 'where' => 'civicrm_contribution.payment_instrument_id',
341 'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
342 'dataPattern' => '',
522a26c9 343 'table_name' => 'civicrm_contribution',
344 'entity' => 'Contribution',
345 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
346 'html' => array(
347 'type' => 'Select',
348 ) ,
349 'pseudoconstant' => array(
350 'optionGroupName' => 'payment_instrument',
351 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
352 )
353 ) ,
354 'receive_date' => array(
355 'name' => 'receive_date',
356 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
357 'title' => ts('Date Received') ,
358 'description' => 'Date contribution was received - not necessarily the creation date of the record',
359 'import' => true,
360 'where' => 'civicrm_contribution.receive_date',
361 'headerPattern' => '/receive(.?date)?/i',
362 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
363 'export' => true,
522a26c9 364 'table_name' => 'civicrm_contribution',
365 'entity' => 'Contribution',
366 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
367 'html' => array(
368 'type' => 'Select Date',
24317d89 369 'formatType' => 'activityDateTime',
e501603b
TO
370 ) ,
371 ) ,
372 'non_deductible_amount' => array(
373 'name' => 'non_deductible_amount',
374 'type' => CRM_Utils_Type::T_MONEY,
375 'title' => ts('Non-deductible Amount') ,
376 'description' => 'Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.',
377 'precision' => array(
378 20,
379 2
380 ) ,
381 'import' => true,
382 'where' => 'civicrm_contribution.non_deductible_amount',
383 'headerPattern' => '/non?.?deduct/i',
384 'dataPattern' => '/^\d+(\.\d{2})?$/',
385 'export' => true,
522a26c9 386 'table_name' => 'civicrm_contribution',
387 'entity' => 'Contribution',
388 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
389 'html' => array(
390 'type' => 'Text',
391 ) ,
392 ) ,
393 'total_amount' => array(
394 'name' => 'total_amount',
395 'type' => CRM_Utils_Type::T_MONEY,
396 'title' => ts('Total Amount') ,
397 'description' => 'Total amount of this contribution. Use market value for non-monetary gifts.',
398 'required' => true,
399 'precision' => array(
400 20,
401 2
402 ) ,
403 'import' => true,
404 'where' => 'civicrm_contribution.total_amount',
405 'headerPattern' => '/^total|(.?^am(ou)?nt)/i',
406 'dataPattern' => '/^\d+(\.\d{2})?$/',
407 'export' => true,
522a26c9 408 'table_name' => 'civicrm_contribution',
409 'entity' => 'Contribution',
410 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
411 'html' => array(
412 'type' => 'Text',
413 ) ,
414 ) ,
415 'fee_amount' => array(
416 'name' => 'fee_amount',
417 'type' => CRM_Utils_Type::T_MONEY,
418 'title' => ts('Fee Amount') ,
419 'description' => 'actual processor fee if known - may be 0.',
420 'precision' => array(
421 20,
422 2
423 ) ,
424 'import' => true,
425 'where' => 'civicrm_contribution.fee_amount',
426 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
427 'dataPattern' => '/^\d+(\.\d{2})?$/',
428 'export' => true,
522a26c9 429 'table_name' => 'civicrm_contribution',
430 'entity' => 'Contribution',
431 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
432 'html' => array(
433 'type' => 'Text',
434 ) ,
435 ) ,
436 'net_amount' => array(
437 'name' => 'net_amount',
438 'type' => CRM_Utils_Type::T_MONEY,
439 'title' => ts('Net Amount') ,
440 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
441 'precision' => array(
442 20,
443 2
444 ) ,
445 'import' => true,
446 'where' => 'civicrm_contribution.net_amount',
447 'headerPattern' => '/net(.?am(ou)?nt)?/i',
448 'dataPattern' => '/^\d+(\.\d{2})?$/',
449 'export' => true,
522a26c9 450 'table_name' => 'civicrm_contribution',
451 'entity' => 'Contribution',
452 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
453 'html' => array(
454 'type' => 'Text',
455 ) ,
456 ) ,
457 'trxn_id' => array(
458 'name' => 'trxn_id',
459 'type' => CRM_Utils_Type::T_STRING,
460 'title' => ts('Transaction ID') ,
461 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
462 'maxlength' => 255,
463 'size' => CRM_Utils_Type::HUGE,
464 'import' => true,
465 'where' => 'civicrm_contribution.trxn_id',
466 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
467 'dataPattern' => '',
468 'export' => true,
522a26c9 469 'table_name' => 'civicrm_contribution',
470 'entity' => 'Contribution',
471 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
472 'html' => array(
473 'type' => 'Text',
474 ) ,
475 ) ,
476 'invoice_id' => array(
477 'name' => 'invoice_id',
478 'type' => CRM_Utils_Type::T_STRING,
479 'title' => ts('Invoice ID') ,
480 'description' => 'unique invoice id, system generated or passed in',
481 'maxlength' => 255,
482 'size' => CRM_Utils_Type::HUGE,
483 'import' => true,
484 'where' => 'civicrm_contribution.invoice_id',
485 'headerPattern' => '/invoice(.?id)?/i',
486 'dataPattern' => '',
487 'export' => true,
522a26c9 488 'table_name' => 'civicrm_contribution',
489 'entity' => 'Contribution',
490 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
491 'html' => array(
492 'type' => 'Text',
493 ) ,
494 ) ,
495 'currency' => array(
496 'name' => 'currency',
497 'type' => CRM_Utils_Type::T_STRING,
498 'title' => ts('Currency') ,
499 'description' => '3 character string, value from config setting or input via user.',
500 'maxlength' => 3,
501 'size' => CRM_Utils_Type::FOUR,
502 'import' => true,
503 'where' => 'civicrm_contribution.currency',
504 'headerPattern' => '/cur(rency)?/i',
505 'dataPattern' => '/^[A-Z]{3}$/i',
506 'export' => true,
507 'default' => 'NULL',
522a26c9 508 'table_name' => 'civicrm_contribution',
509 'entity' => 'Contribution',
510 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
511 'html' => array(
512 'type' => 'Select',
513 ) ,
514 'pseudoconstant' => array(
515 'table' => 'civicrm_currency',
516 'keyColumn' => 'name',
517 'labelColumn' => 'full_name',
518 'nameColumn' => 'name',
519 )
520 ) ,
521 'cancel_date' => array(
522 'name' => 'cancel_date',
523 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
524 'title' => ts('Cancel Date') ,
525 'description' => 'when was gift cancelled',
526 'import' => true,
527 'where' => 'civicrm_contribution.cancel_date',
528 'headerPattern' => '/cancel(.?date)?/i',
529 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
530 'export' => true,
522a26c9 531 'table_name' => 'civicrm_contribution',
532 'entity' => 'Contribution',
533 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
534 'html' => array(
535 'type' => 'Select Date',
24317d89 536 'formatType' => 'activityDateTime',
e501603b
TO
537 ) ,
538 ) ,
539 'cancel_reason' => array(
540 'name' => 'cancel_reason',
541 'type' => CRM_Utils_Type::T_TEXT,
542 'title' => ts('Cancel Reason') ,
543 'import' => true,
544 'where' => 'civicrm_contribution.cancel_reason',
545 'headerPattern' => '/(cancel.?)?reason/i',
546 'dataPattern' => '',
547 'export' => true,
522a26c9 548 'table_name' => 'civicrm_contribution',
549 'entity' => 'Contribution',
550 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
551 'html' => array(
552 'type' => 'Text',
553 ) ,
554 ) ,
555 'receipt_date' => array(
556 'name' => 'receipt_date',
557 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
558 'title' => ts('Receipt Date') ,
559 'description' => 'when (if) receipt was sent. populated automatically for online donations w/ automatic receipting',
560 'import' => true,
561 'where' => 'civicrm_contribution.receipt_date',
562 'headerPattern' => '/receipt(.?date)?/i',
563 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
564 'export' => true,
522a26c9 565 'table_name' => 'civicrm_contribution',
566 'entity' => 'Contribution',
567 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
568 'html' => array(
569 'type' => 'Select Date',
24317d89 570 'formatType' => 'activityDateTime',
e501603b
TO
571 ) ,
572 ) ,
573 'thankyou_date' => array(
574 'name' => 'thankyou_date',
575 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
576 'title' => ts('Thank-you Date') ,
577 'description' => 'when (if) was donor thanked',
578 'import' => true,
579 'where' => 'civicrm_contribution.thankyou_date',
580 'headerPattern' => '/thank(s|(.?you))?(.?date)?/i',
581 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
582 'export' => true,
522a26c9 583 'table_name' => 'civicrm_contribution',
584 'entity' => 'Contribution',
585 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
586 'html' => array(
587 'type' => 'Select Date',
24317d89 588 'formatType' => 'activityDateTime',
e501603b
TO
589 ) ,
590 ) ,
591 'contribution_source' => array(
592 'name' => 'source',
593 'type' => CRM_Utils_Type::T_STRING,
594 'title' => ts('Contribution Source') ,
595 'description' => 'Origin of this Contribution.',
596 'maxlength' => 255,
597 'size' => CRM_Utils_Type::HUGE,
598 'import' => true,
599 'where' => 'civicrm_contribution.source',
600 'headerPattern' => '/source/i',
601 'dataPattern' => '',
602 'export' => true,
522a26c9 603 'table_name' => 'civicrm_contribution',
604 'entity' => 'Contribution',
605 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
606 'html' => array(
607 'type' => 'Text',
608 ) ,
609 ) ,
610 'amount_level' => array(
611 'name' => 'amount_level',
612 'type' => CRM_Utils_Type::T_TEXT,
613 'title' => ts('Amount Label') ,
614 'import' => true,
615 'where' => 'civicrm_contribution.amount_level',
616 'headerPattern' => '',
617 'dataPattern' => '',
618 'export' => true,
522a26c9 619 'table_name' => 'civicrm_contribution',
620 'entity' => 'Contribution',
621 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
622 'html' => array(
623 'type' => 'Text',
624 ) ,
625 ) ,
626 'contribution_recur_id' => array(
627 'name' => 'contribution_recur_id',
628 'type' => CRM_Utils_Type::T_INT,
629 'title' => ts('Recurring Contribution ID') ,
630 'description' => 'Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.',
3123273f 631 'export' => true,
632 'where' => 'civicrm_contribution.contribution_recur_id',
633 'headerPattern' => '',
634 'dataPattern' => '',
522a26c9 635 'table_name' => 'civicrm_contribution',
636 'entity' => 'Contribution',
637 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
638 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
639 ) ,
640 'is_test' => array(
641 'name' => 'is_test',
642 'type' => CRM_Utils_Type::T_BOOLEAN,
643 'title' => ts('Test') ,
644 'import' => true,
645 'where' => 'civicrm_contribution.is_test',
646 'headerPattern' => '',
647 'dataPattern' => '',
648 'export' => true,
522a26c9 649 'table_name' => 'civicrm_contribution',
650 'entity' => 'Contribution',
651 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
652 'html' => array(
653 'type' => 'CheckBox',
654 ) ,
655 ) ,
656 'is_pay_later' => array(
657 'name' => 'is_pay_later',
658 'type' => CRM_Utils_Type::T_BOOLEAN,
659 'title' => ts('Is Pay Later') ,
660 'import' => true,
661 'where' => 'civicrm_contribution.is_pay_later',
662 'headerPattern' => '',
663 'dataPattern' => '',
664 'export' => true,
522a26c9 665 'table_name' => 'civicrm_contribution',
666 'entity' => 'Contribution',
667 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
668 'html' => array(
669 'type' => 'CheckBox',
670 ) ,
671 ) ,
672 'contribution_status_id' => array(
673 'name' => 'contribution_status_id',
674 'type' => CRM_Utils_Type::T_INT,
675 'title' => ts('Contribution Status ID') ,
676 'import' => true,
677 'where' => 'civicrm_contribution.contribution_status_id',
678 'headerPattern' => '/status/i',
679 'dataPattern' => '',
680 'export' => true,
681 'default' => '1',
522a26c9 682 'table_name' => 'civicrm_contribution',
683 'entity' => 'Contribution',
684 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
685 'html' => array(
686 'type' => 'Select',
687 ) ,
688 'pseudoconstant' => array(
689 'optionGroupName' => 'contribution_status',
690 'optionEditPath' => 'civicrm/admin/options/contribution_status',
691 )
692 ) ,
3123273f 693 'contribution_address_id' => array(
e501603b
TO
694 'name' => 'address_id',
695 'type' => CRM_Utils_Type::T_INT,
696 'title' => ts('Contribution Address') ,
697 'description' => 'Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.',
3123273f 698 'export' => true,
699 'where' => 'civicrm_contribution.address_id',
700 'headerPattern' => '',
701 'dataPattern' => '',
522a26c9 702 'table_name' => 'civicrm_contribution',
703 'entity' => 'Contribution',
704 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
705 'FKClassName' => 'CRM_Core_DAO_Address',
706 ) ,
7bc1d4da 707 'contribution_check_number' => array(
e501603b
TO
708 'name' => 'check_number',
709 'type' => CRM_Utils_Type::T_STRING,
710 'title' => ts('Check Number') ,
711 'maxlength' => 255,
712 'size' => 6,
713 'import' => true,
714 'where' => 'civicrm_contribution.check_number',
715 'headerPattern' => '/check(.?number)?/i',
716 'dataPattern' => '',
717 'export' => true,
522a26c9 718 'table_name' => 'civicrm_contribution',
719 'entity' => 'Contribution',
720 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
721 'html' => array(
722 'type' => 'Text',
723 ) ,
724 ) ,
725 'contribution_campaign_id' => array(
726 'name' => 'campaign_id',
727 'type' => CRM_Utils_Type::T_INT,
728 'title' => ts('Campaign') ,
729 'description' => 'The campaign for which this contribution has been triggered.',
730 'import' => true,
731 'where' => 'civicrm_contribution.campaign_id',
732 'headerPattern' => '',
733 'dataPattern' => '',
734 'export' => true,
522a26c9 735 'table_name' => 'civicrm_contribution',
736 'entity' => 'Contribution',
737 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
738 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
739 'html' => array(
740 'type' => 'Select',
741 ) ,
742 'pseudoconstant' => array(
743 'table' => 'civicrm_campaign',
744 'keyColumn' => 'id',
745 'labelColumn' => 'title',
746 )
747 ) ,
748 'creditnote_id' => array(
749 'name' => 'creditnote_id',
750 'type' => CRM_Utils_Type::T_STRING,
751 'title' => ts('Credit Note ID') ,
752 'description' => 'unique credit note id, system generated or passed in',
753 'maxlength' => 255,
754 'size' => CRM_Utils_Type::HUGE,
755 'import' => true,
756 'where' => 'civicrm_contribution.creditnote_id',
757 'headerPattern' => '/creditnote(.?id)?/i',
758 'dataPattern' => '',
759 'export' => true,
522a26c9 760 'table_name' => 'civicrm_contribution',
761 'entity' => 'Contribution',
762 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
763 'html' => array(
764 'type' => 'Text',
765 ) ,
766 ) ,
767 'tax_amount' => array(
768 'name' => 'tax_amount',
769 'type' => CRM_Utils_Type::T_MONEY,
770 'title' => ts('Tax Amount') ,
771 'description' => 'Total tax amount of this contribution.',
772 'precision' => array(
773 20,
774 2
775 ) ,
776 'import' => true,
777 'where' => 'civicrm_contribution.tax_amount',
778 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
779 'dataPattern' => '/^\d+(\.\d{2})?$/',
780 'export' => true,
522a26c9 781 'table_name' => 'civicrm_contribution',
782 'entity' => 'Contribution',
783 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
784 'html' => array(
785 'type' => 'Text',
786 ) ,
787 ) ,
788 'revenue_recognition_date' => array(
789 'name' => 'revenue_recognition_date',
790 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
791 'title' => ts('Revenue Recognition Date') ,
792 'description' => 'Stores the date when revenue should be recognized.',
793 'import' => true,
794 'where' => 'civicrm_contribution.revenue_recognition_date',
795 'headerPattern' => '/revenue(.?date)?/i',
796 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
797 'export' => true,
522a26c9 798 'table_name' => 'civicrm_contribution',
799 'entity' => 'Contribution',
800 'bao' => 'CRM_Contribute_BAO_Contribution',
e501603b
TO
801 'html' => array(
802 'type' => 'Select Date',
24317d89 803 'formatType' => 'activityDateTime',
e501603b
TO
804 ) ,
805 ) ,
806 );
346aaaba 807 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 808 }
346aaaba 809 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
810 }
811 /**
bd8e0b14 812 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
813 *
814 * @return array
bd8e0b14 815 * Array(string $name => string $uniqueName).
e501603b
TO
816 */
817 static function &fieldKeys() {
bd8e0b14
TO
818 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
819 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 820 }
bd8e0b14 821 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
822 }
823 /**
824 * Returns the names of this table
825 *
826 * @return string
827 */
828 static function getTableName() {
829 return self::$_tableName;
830 }
831 /**
832 * Returns if this table needs to be logged
833 *
834 * @return boolean
835 */
836 function getLog() {
837 return self::$_log;
838 }
839 /**
840 * Returns the list of fields that can be imported
841 *
842 * @param bool $prefix
843 *
844 * @return array
845 */
846 static function &import($prefix = false) {
60808919
TO
847 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution', $prefix, array());
848 return $r;
e501603b
TO
849 }
850 /**
851 * Returns the list of fields that can be exported
852 *
853 * @param bool $prefix
854 *
855 * @return array
856 */
857 static function &export($prefix = false) {
60808919
TO
858 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution', $prefix, array());
859 return $r;
e501603b
TO
860 }
861}