Merge pull request #9711 from KarinG/master
[civicrm-core.git] / CRM / Contribute / DAO / Contribution.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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-2017
30 *
31 * Generated from xml/schema/CRM/Contribute/Contribution.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:00dd1e00a61c69190a0eefd88d49415e)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Contribute_DAO_Contribution constructor.
39 */
40 class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_contribution';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 /**
222 * Class constructor.
223 */
224 function __construct() {
225 $this->__table = 'civicrm_contribution';
226 parent::__construct();
227 }
228 /**
229 * Returns foreign keys and entity references.
230 *
231 * @return array
232 * [CRM_Core_Reference_Interface]
233 */
234 static function getReferenceColumns() {
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']);
244 }
245 return Civi::$statics[__CLASS__]['links'];
246 }
247 /**
248 * Returns all the column names of this table
249 *
250 * @return array
251 */
252 static function &fields() {
253 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
254 Civi::$statics[__CLASS__]['fields'] = array(
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,
266 'table_name' => 'civicrm_contribution',
267 'entity' => 'Contribution',
268 'bao' => 'CRM_Contribute_BAO_Contribution',
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,
281 'table_name' => 'civicrm_contribution',
282 'entity' => 'Contribution',
283 'bao' => 'CRM_Contribute_BAO_Contribution',
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).',
294 'export' => true,
295 'where' => 'civicrm_contribution.financial_type_id',
296 'headerPattern' => '',
297 'dataPattern' => '',
298 'table_name' => 'civicrm_contribution',
299 'entity' => 'Contribution',
300 'bao' => 'CRM_Contribute_BAO_Contribution',
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,
321 'table_name' => 'civicrm_contribution',
322 'entity' => 'Contribution',
323 'bao' => 'CRM_Contribute_BAO_Contribution',
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,
337 'title' => ts('Payment Method') ,
338 'description' => 'FK to Payment Instrument',
339 'table_name' => 'civicrm_contribution',
340 'entity' => 'Contribution',
341 'bao' => 'CRM_Contribute_BAO_Contribution',
342 'html' => array(
343 'type' => 'Select',
344 ) ,
345 'pseudoconstant' => array(
346 'optionGroupName' => 'payment_instrument',
347 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
348 )
349 ) ,
350 'receive_date' => array(
351 'name' => 'receive_date',
352 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
353 'title' => ts('Date Received') ,
354 'description' => 'Date contribution was received - not necessarily the creation date of the record',
355 'import' => true,
356 'where' => 'civicrm_contribution.receive_date',
357 'headerPattern' => '/receive(.?date)?/i',
358 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
359 'export' => true,
360 'table_name' => 'civicrm_contribution',
361 'entity' => 'Contribution',
362 'bao' => 'CRM_Contribute_BAO_Contribution',
363 'html' => array(
364 'type' => 'Select Date',
365 'format' => 'activityDateTime',
366 ) ,
367 ) ,
368 'non_deductible_amount' => array(
369 'name' => 'non_deductible_amount',
370 'type' => CRM_Utils_Type::T_MONEY,
371 'title' => ts('Non-deductible Amount') ,
372 'description' => 'Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.',
373 'precision' => array(
374 20,
375 2
376 ) ,
377 'import' => true,
378 'where' => 'civicrm_contribution.non_deductible_amount',
379 'headerPattern' => '/non?.?deduct/i',
380 'dataPattern' => '/^\d+(\.\d{2})?$/',
381 'export' => true,
382 'table_name' => 'civicrm_contribution',
383 'entity' => 'Contribution',
384 'bao' => 'CRM_Contribute_BAO_Contribution',
385 'html' => array(
386 'type' => 'Text',
387 ) ,
388 ) ,
389 'total_amount' => array(
390 'name' => 'total_amount',
391 'type' => CRM_Utils_Type::T_MONEY,
392 'title' => ts('Total Amount') ,
393 'description' => 'Total amount of this contribution. Use market value for non-monetary gifts.',
394 'required' => true,
395 'precision' => array(
396 20,
397 2
398 ) ,
399 'import' => true,
400 'where' => 'civicrm_contribution.total_amount',
401 'headerPattern' => '/^total|(.?^am(ou)?nt)/i',
402 'dataPattern' => '/^\d+(\.\d{2})?$/',
403 'export' => true,
404 'table_name' => 'civicrm_contribution',
405 'entity' => 'Contribution',
406 'bao' => 'CRM_Contribute_BAO_Contribution',
407 'html' => array(
408 'type' => 'Text',
409 ) ,
410 ) ,
411 'fee_amount' => array(
412 'name' => 'fee_amount',
413 'type' => CRM_Utils_Type::T_MONEY,
414 'title' => ts('Fee Amount') ,
415 'description' => 'actual processor fee if known - may be 0.',
416 'precision' => array(
417 20,
418 2
419 ) ,
420 'import' => true,
421 'where' => 'civicrm_contribution.fee_amount',
422 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
423 'dataPattern' => '/^\d+(\.\d{2})?$/',
424 'export' => true,
425 'table_name' => 'civicrm_contribution',
426 'entity' => 'Contribution',
427 'bao' => 'CRM_Contribute_BAO_Contribution',
428 'html' => array(
429 'type' => 'Text',
430 ) ,
431 ) ,
432 'net_amount' => array(
433 'name' => 'net_amount',
434 'type' => CRM_Utils_Type::T_MONEY,
435 'title' => ts('Net Amount') ,
436 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
437 'precision' => array(
438 20,
439 2
440 ) ,
441 'import' => true,
442 'where' => 'civicrm_contribution.net_amount',
443 'headerPattern' => '/net(.?am(ou)?nt)?/i',
444 'dataPattern' => '/^\d+(\.\d{2})?$/',
445 'export' => true,
446 'table_name' => 'civicrm_contribution',
447 'entity' => 'Contribution',
448 'bao' => 'CRM_Contribute_BAO_Contribution',
449 'html' => array(
450 'type' => 'Text',
451 ) ,
452 ) ,
453 'trxn_id' => array(
454 'name' => 'trxn_id',
455 'type' => CRM_Utils_Type::T_STRING,
456 'title' => ts('Transaction ID') ,
457 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
458 'maxlength' => 255,
459 'size' => CRM_Utils_Type::HUGE,
460 'import' => true,
461 'where' => 'civicrm_contribution.trxn_id',
462 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
463 'dataPattern' => '',
464 'export' => true,
465 'table_name' => 'civicrm_contribution',
466 'entity' => 'Contribution',
467 'bao' => 'CRM_Contribute_BAO_Contribution',
468 'html' => array(
469 'type' => 'Text',
470 ) ,
471 ) ,
472 'invoice_id' => array(
473 'name' => 'invoice_id',
474 'type' => CRM_Utils_Type::T_STRING,
475 'title' => ts('Invoice ID') ,
476 'description' => 'unique invoice id, system generated or passed in',
477 'maxlength' => 255,
478 'size' => CRM_Utils_Type::HUGE,
479 'import' => true,
480 'where' => 'civicrm_contribution.invoice_id',
481 'headerPattern' => '/invoice(.?id)?/i',
482 'dataPattern' => '',
483 'export' => true,
484 'table_name' => 'civicrm_contribution',
485 'entity' => 'Contribution',
486 'bao' => 'CRM_Contribute_BAO_Contribution',
487 'html' => array(
488 'type' => 'Text',
489 ) ,
490 ) ,
491 'currency' => array(
492 'name' => 'currency',
493 'type' => CRM_Utils_Type::T_STRING,
494 'title' => ts('Currency') ,
495 'description' => '3 character string, value from config setting or input via user.',
496 'maxlength' => 3,
497 'size' => CRM_Utils_Type::FOUR,
498 'import' => true,
499 'where' => 'civicrm_contribution.currency',
500 'headerPattern' => '/cur(rency)?/i',
501 'dataPattern' => '/^[A-Z]{3}$/i',
502 'export' => true,
503 'default' => 'NULL',
504 'table_name' => 'civicrm_contribution',
505 'entity' => 'Contribution',
506 'bao' => 'CRM_Contribute_BAO_Contribution',
507 'html' => array(
508 'type' => 'Select',
509 ) ,
510 'pseudoconstant' => array(
511 'table' => 'civicrm_currency',
512 'keyColumn' => 'name',
513 'labelColumn' => 'full_name',
514 'nameColumn' => 'name',
515 )
516 ) ,
517 'cancel_date' => array(
518 'name' => 'cancel_date',
519 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
520 'title' => ts('Cancel Date') ,
521 'description' => 'when was gift cancelled',
522 'import' => true,
523 'where' => 'civicrm_contribution.cancel_date',
524 'headerPattern' => '/cancel(.?date)?/i',
525 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
526 'export' => true,
527 'table_name' => 'civicrm_contribution',
528 'entity' => 'Contribution',
529 'bao' => 'CRM_Contribute_BAO_Contribution',
530 'html' => array(
531 'type' => 'Select Date',
532 'format' => 'activityDateTime',
533 ) ,
534 ) ,
535 'cancel_reason' => array(
536 'name' => 'cancel_reason',
537 'type' => CRM_Utils_Type::T_TEXT,
538 'title' => ts('Cancel Reason') ,
539 'import' => true,
540 'where' => 'civicrm_contribution.cancel_reason',
541 'headerPattern' => '/(cancel.?)?reason/i',
542 'dataPattern' => '',
543 'export' => true,
544 'table_name' => 'civicrm_contribution',
545 'entity' => 'Contribution',
546 'bao' => 'CRM_Contribute_BAO_Contribution',
547 'html' => array(
548 'type' => 'Text',
549 ) ,
550 ) ,
551 'receipt_date' => array(
552 'name' => 'receipt_date',
553 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
554 'title' => ts('Receipt Date') ,
555 'description' => 'when (if) receipt was sent. populated automatically for online donations w/ automatic receipting',
556 'import' => true,
557 'where' => 'civicrm_contribution.receipt_date',
558 'headerPattern' => '/receipt(.?date)?/i',
559 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
560 'export' => true,
561 'table_name' => 'civicrm_contribution',
562 'entity' => 'Contribution',
563 'bao' => 'CRM_Contribute_BAO_Contribution',
564 'html' => array(
565 'type' => 'Select Date',
566 'format' => 'activityDateTime',
567 ) ,
568 ) ,
569 'thankyou_date' => array(
570 'name' => 'thankyou_date',
571 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
572 'title' => ts('Thank-you Date') ,
573 'description' => 'when (if) was donor thanked',
574 'import' => true,
575 'where' => 'civicrm_contribution.thankyou_date',
576 'headerPattern' => '/thank(s|(.?you))?(.?date)?/i',
577 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
578 'export' => true,
579 'table_name' => 'civicrm_contribution',
580 'entity' => 'Contribution',
581 'bao' => 'CRM_Contribute_BAO_Contribution',
582 'html' => array(
583 'type' => 'Select Date',
584 'format' => 'activityDateTime',
585 ) ,
586 ) ,
587 'contribution_source' => array(
588 'name' => 'source',
589 'type' => CRM_Utils_Type::T_STRING,
590 'title' => ts('Contribution Source') ,
591 'description' => 'Origin of this Contribution.',
592 'maxlength' => 255,
593 'size' => CRM_Utils_Type::HUGE,
594 'import' => true,
595 'where' => 'civicrm_contribution.source',
596 'headerPattern' => '/source/i',
597 'dataPattern' => '',
598 'export' => true,
599 'table_name' => 'civicrm_contribution',
600 'entity' => 'Contribution',
601 'bao' => 'CRM_Contribute_BAO_Contribution',
602 'html' => array(
603 'type' => 'Text',
604 ) ,
605 ) ,
606 'amount_level' => array(
607 'name' => 'amount_level',
608 'type' => CRM_Utils_Type::T_TEXT,
609 'title' => ts('Amount Label') ,
610 'import' => true,
611 'where' => 'civicrm_contribution.amount_level',
612 'headerPattern' => '',
613 'dataPattern' => '',
614 'export' => true,
615 'table_name' => 'civicrm_contribution',
616 'entity' => 'Contribution',
617 'bao' => 'CRM_Contribute_BAO_Contribution',
618 'html' => array(
619 'type' => 'Text',
620 ) ,
621 ) ,
622 'contribution_recur_id' => array(
623 'name' => 'contribution_recur_id',
624 'type' => CRM_Utils_Type::T_INT,
625 'title' => ts('Recurring Contribution ID') ,
626 '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.',
627 'export' => true,
628 'where' => 'civicrm_contribution.contribution_recur_id',
629 'headerPattern' => '',
630 'dataPattern' => '',
631 'table_name' => 'civicrm_contribution',
632 'entity' => 'Contribution',
633 'bao' => 'CRM_Contribute_BAO_Contribution',
634 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
635 ) ,
636 'is_test' => array(
637 'name' => 'is_test',
638 'type' => CRM_Utils_Type::T_BOOLEAN,
639 'title' => ts('Test') ,
640 'import' => true,
641 'where' => 'civicrm_contribution.is_test',
642 'headerPattern' => '',
643 'dataPattern' => '',
644 'export' => true,
645 'table_name' => 'civicrm_contribution',
646 'entity' => 'Contribution',
647 'bao' => 'CRM_Contribute_BAO_Contribution',
648 'html' => array(
649 'type' => 'CheckBox',
650 ) ,
651 ) ,
652 'is_pay_later' => array(
653 'name' => 'is_pay_later',
654 'type' => CRM_Utils_Type::T_BOOLEAN,
655 'title' => ts('Is Pay Later') ,
656 'import' => true,
657 'where' => 'civicrm_contribution.is_pay_later',
658 'headerPattern' => '',
659 'dataPattern' => '',
660 'export' => true,
661 'table_name' => 'civicrm_contribution',
662 'entity' => 'Contribution',
663 'bao' => 'CRM_Contribute_BAO_Contribution',
664 'html' => array(
665 'type' => 'CheckBox',
666 ) ,
667 ) ,
668 'contribution_status_id' => array(
669 'name' => 'contribution_status_id',
670 'type' => CRM_Utils_Type::T_INT,
671 'title' => ts('Contribution Status ID') ,
672 'import' => true,
673 'where' => 'civicrm_contribution.contribution_status_id',
674 'headerPattern' => '/status/i',
675 'dataPattern' => '',
676 'export' => true,
677 'default' => '1',
678 'table_name' => 'civicrm_contribution',
679 'entity' => 'Contribution',
680 'bao' => 'CRM_Contribute_BAO_Contribution',
681 'html' => array(
682 'type' => 'Select',
683 ) ,
684 'pseudoconstant' => array(
685 'optionGroupName' => 'contribution_status',
686 'optionEditPath' => 'civicrm/admin/options/contribution_status',
687 )
688 ) ,
689 'contribution_address_id' => array(
690 'name' => 'address_id',
691 'type' => CRM_Utils_Type::T_INT,
692 'title' => ts('Contribution Address') ,
693 '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.',
694 'export' => true,
695 'where' => 'civicrm_contribution.address_id',
696 'headerPattern' => '',
697 'dataPattern' => '',
698 'table_name' => 'civicrm_contribution',
699 'entity' => 'Contribution',
700 'bao' => 'CRM_Contribute_BAO_Contribution',
701 'FKClassName' => 'CRM_Core_DAO_Address',
702 ) ,
703 'contribution_check_number' => array(
704 'name' => 'check_number',
705 'type' => CRM_Utils_Type::T_STRING,
706 'title' => ts('Check Number') ,
707 'maxlength' => 255,
708 'size' => 6,
709 'import' => true,
710 'where' => 'civicrm_contribution.check_number',
711 'headerPattern' => '/check(.?number)?/i',
712 'dataPattern' => '',
713 'export' => true,
714 'table_name' => 'civicrm_contribution',
715 'entity' => 'Contribution',
716 'bao' => 'CRM_Contribute_BAO_Contribution',
717 'html' => array(
718 'type' => 'Text',
719 ) ,
720 ) ,
721 'contribution_campaign_id' => array(
722 'name' => 'campaign_id',
723 'type' => CRM_Utils_Type::T_INT,
724 'title' => ts('Campaign') ,
725 'description' => 'The campaign for which this contribution has been triggered.',
726 'import' => true,
727 'where' => 'civicrm_contribution.campaign_id',
728 'headerPattern' => '',
729 'dataPattern' => '',
730 'export' => true,
731 'table_name' => 'civicrm_contribution',
732 'entity' => 'Contribution',
733 'bao' => 'CRM_Contribute_BAO_Contribution',
734 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
735 'html' => array(
736 'type' => 'Select',
737 ) ,
738 'pseudoconstant' => array(
739 'table' => 'civicrm_campaign',
740 'keyColumn' => 'id',
741 'labelColumn' => 'title',
742 )
743 ) ,
744 'creditnote_id' => array(
745 'name' => 'creditnote_id',
746 'type' => CRM_Utils_Type::T_STRING,
747 'title' => ts('Credit Note ID') ,
748 'description' => 'unique credit note id, system generated or passed in',
749 'maxlength' => 255,
750 'size' => CRM_Utils_Type::HUGE,
751 'import' => true,
752 'where' => 'civicrm_contribution.creditnote_id',
753 'headerPattern' => '/creditnote(.?id)?/i',
754 'dataPattern' => '',
755 'export' => true,
756 'table_name' => 'civicrm_contribution',
757 'entity' => 'Contribution',
758 'bao' => 'CRM_Contribute_BAO_Contribution',
759 'html' => array(
760 'type' => 'Text',
761 ) ,
762 ) ,
763 'tax_amount' => array(
764 'name' => 'tax_amount',
765 'type' => CRM_Utils_Type::T_MONEY,
766 'title' => ts('Tax Amount') ,
767 'description' => 'Total tax amount of this contribution.',
768 'precision' => array(
769 20,
770 2
771 ) ,
772 'import' => true,
773 'where' => 'civicrm_contribution.tax_amount',
774 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
775 'dataPattern' => '/^\d+(\.\d{2})?$/',
776 'export' => true,
777 'table_name' => 'civicrm_contribution',
778 'entity' => 'Contribution',
779 'bao' => 'CRM_Contribute_BAO_Contribution',
780 'html' => array(
781 'type' => 'Text',
782 ) ,
783 ) ,
784 'revenue_recognition_date' => array(
785 'name' => 'revenue_recognition_date',
786 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
787 'title' => ts('Revenue Recognition Date') ,
788 'description' => 'Stores the date when revenue should be recognized.',
789 'import' => true,
790 'where' => 'civicrm_contribution.revenue_recognition_date',
791 'headerPattern' => '/revenue(.?date)?/i',
792 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
793 'export' => true,
794 'table_name' => 'civicrm_contribution',
795 'entity' => 'Contribution',
796 'bao' => 'CRM_Contribute_BAO_Contribution',
797 'html' => array(
798 'type' => 'Select Date',
799 'format' => 'activityDateTime',
800 ) ,
801 ) ,
802 );
803 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
804 }
805 return Civi::$statics[__CLASS__]['fields'];
806 }
807 /**
808 * Return a mapping from field-name to the corresponding key (as used in fields()).
809 *
810 * @return array
811 * Array(string $name => string $uniqueName).
812 */
813 static function &fieldKeys() {
814 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
815 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
816 }
817 return Civi::$statics[__CLASS__]['fieldKeys'];
818 }
819 /**
820 * Returns the names of this table
821 *
822 * @return string
823 */
824 static function getTableName() {
825 return self::$_tableName;
826 }
827 /**
828 * Returns if this table needs to be logged
829 *
830 * @return boolean
831 */
832 function getLog() {
833 return self::$_log;
834 }
835 /**
836 * Returns the list of fields that can be imported
837 *
838 * @param bool $prefix
839 *
840 * @return array
841 */
842 static function &import($prefix = false) {
843 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution', $prefix, array());
844 return $r;
845 }
846 /**
847 * Returns the list of fields that can be exported
848 *
849 * @param bool $prefix
850 *
851 * @return array
852 */
853 static function &export($prefix = false) {
854 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution', $prefix, array());
855 return $r;
856 }
857 }