3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 * @copyright CiviCRM LLC (c) 2004-2017
31 * Generated from xml/schema/CRM/Contribute/Contribution.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:00dd1e00a61c69190a0eefd88d49415e)
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
38 * CRM_Contribute_DAO_Contribution constructor.
40 class CRM_Contribute_DAO_Contribution
extends CRM_Core_DAO
{
42 * Static instance to hold the table name.
46 static $_tableName = 'civicrm_contribution';
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
66 * FK to Financial Type for (total_amount - non_deductible_amount).
70 public $financial_type_id;
72 * The Contribution Page which triggered this contribution
76 public $contribution_page_id;
78 * FK to Payment Instrument
82 public $payment_instrument_id;
84 * Date contribution was received - not necessarily the creation date of the record
90 * Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.
94 public $non_deductible_amount;
96 * Total amount of this contribution. Use market value for non-monetary gifts.
100 public $total_amount;
102 * actual processor fee if known - may be 0.
108 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
114 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
120 * unique invoice id, system generated or passed in
126 * 3 character string, value from config setting or input via user.
132 * when was gift cancelled
141 public $cancel_reason;
143 * when (if) receipt was sent. populated automatically for online donations w/ automatic receipting
147 public $receipt_date;
149 * when (if) was donor thanked
153 public $thankyou_date;
155 * Origin of this Contribution.
164 public $amount_level;
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.
170 public $contribution_recur_id;
180 public $is_pay_later;
185 public $contribution_status_id;
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.
196 public $check_number;
198 * The campaign for which this contribution has been triggered.
204 * unique credit note id, system generated or passed in
208 public $creditnote_id;
210 * Total tax amount of this contribution.
216 * Stores the date when revenue should be recognized.
220 public $revenue_recognition_date;
224 function __construct() {
225 $this->__table
= 'civicrm_contribution';
226 parent
::__construct();
229 * Returns foreign keys and entity references.
232 * [CRM_Core_Reference_Interface]
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']);
245 return Civi
::$statics[__CLASS__
]['links'];
248 * Returns all the column names of this table
252 static function &fields() {
253 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
254 Civi
::$statics[__CLASS__
]['fields'] = array(
255 'contribution_id' => array(
257 'type' => CRM_Utils_Type
::T_INT
,
258 'title' => ts('Contribution ID') ,
259 'description' => 'Contribution ID',
262 'where' => 'civicrm_contribution.id',
263 'headerPattern' => '',
266 'table_name' => 'civicrm_contribution',
267 'entity' => 'Contribution',
268 'bao' => 'CRM_Contribute_BAO_Contribution',
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',
277 'where' => 'civicrm_contribution.contact_id',
278 'headerPattern' => '/contact(.?id)?/i',
279 'dataPattern' => '/^\d+$/',
281 'table_name' => 'civicrm_contribution',
282 'entity' => 'Contribution',
283 'bao' => 'CRM_Contribute_BAO_Contribution',
284 'FKClassName' => 'CRM_Contact_DAO_Contact',
286 'type' => 'EntityRef',
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).',
295 'where' => 'civicrm_contribution.financial_type_id',
296 'headerPattern' => '',
298 'table_name' => 'civicrm_contribution',
299 'entity' => 'Contribution',
300 'bao' => 'CRM_Contribute_BAO_Contribution',
301 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
305 'pseudoconstant' => array(
306 'table' => 'civicrm_financial_type',
308 'labelColumn' => 'name',
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',
317 'where' => 'civicrm_contribution.contribution_page_id',
318 'headerPattern' => '',
321 'table_name' => 'civicrm_contribution',
322 'entity' => 'Contribution',
323 'bao' => 'CRM_Contribute_BAO_Contribution',
324 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
328 'pseudoconstant' => array(
329 'table' => 'civicrm_contribution_page',
331 'labelColumn' => 'title',
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',
345 'pseudoconstant' => array(
346 'optionGroupName' => 'payment_instrument',
347 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
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',
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})?)?$/',
360 'table_name' => 'civicrm_contribution',
361 'entity' => 'Contribution',
362 'bao' => 'CRM_Contribute_BAO_Contribution',
364 'type' => 'Select Date',
365 'format' => 'activityDateTime',
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(
378 'where' => 'civicrm_contribution.non_deductible_amount',
379 'headerPattern' => '/non?.?deduct/i',
380 'dataPattern' => '/^\d+(\.\d{2})?$/',
382 'table_name' => 'civicrm_contribution',
383 'entity' => 'Contribution',
384 'bao' => 'CRM_Contribute_BAO_Contribution',
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.',
395 'precision' => array(
400 'where' => 'civicrm_contribution.total_amount',
401 'headerPattern' => '/^total|(.?^am(ou)?nt)/i',
402 'dataPattern' => '/^\d+(\.\d{2})?$/',
404 'table_name' => 'civicrm_contribution',
405 'entity' => 'Contribution',
406 'bao' => 'CRM_Contribute_BAO_Contribution',
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(
421 'where' => 'civicrm_contribution.fee_amount',
422 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
423 'dataPattern' => '/^\d+(\.\d{2})?$/',
425 'table_name' => 'civicrm_contribution',
426 'entity' => 'Contribution',
427 'bao' => 'CRM_Contribute_BAO_Contribution',
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(
442 'where' => 'civicrm_contribution.net_amount',
443 'headerPattern' => '/net(.?am(ou)?nt)?/i',
444 'dataPattern' => '/^\d+(\.\d{2})?$/',
446 'table_name' => 'civicrm_contribution',
447 'entity' => 'Contribution',
448 'bao' => 'CRM_Contribute_BAO_Contribution',
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',
459 'size' => CRM_Utils_Type
::HUGE
,
461 'where' => 'civicrm_contribution.trxn_id',
462 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
465 'table_name' => 'civicrm_contribution',
466 'entity' => 'Contribution',
467 'bao' => 'CRM_Contribute_BAO_Contribution',
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',
478 'size' => CRM_Utils_Type
::HUGE
,
480 'where' => 'civicrm_contribution.invoice_id',
481 'headerPattern' => '/invoice(.?id)?/i',
484 'table_name' => 'civicrm_contribution',
485 'entity' => 'Contribution',
486 'bao' => 'CRM_Contribute_BAO_Contribution',
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.',
497 'size' => CRM_Utils_Type
::FOUR
,
499 'where' => 'civicrm_contribution.currency',
500 'headerPattern' => '/cur(rency)?/i',
501 'dataPattern' => '/^[A-Z]{3}$/i',
504 'table_name' => 'civicrm_contribution',
505 'entity' => 'Contribution',
506 'bao' => 'CRM_Contribute_BAO_Contribution',
510 'pseudoconstant' => array(
511 'table' => 'civicrm_currency',
512 'keyColumn' => 'name',
513 'labelColumn' => 'full_name',
514 'nameColumn' => 'name',
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',
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})?)?$/',
527 'table_name' => 'civicrm_contribution',
528 'entity' => 'Contribution',
529 'bao' => 'CRM_Contribute_BAO_Contribution',
531 'type' => 'Select Date',
532 'format' => 'activityDateTime',
535 'cancel_reason' => array(
536 'name' => 'cancel_reason',
537 'type' => CRM_Utils_Type
::T_TEXT
,
538 'title' => ts('Cancel Reason') ,
540 'where' => 'civicrm_contribution.cancel_reason',
541 'headerPattern' => '/(cancel.?)?reason/i',
544 'table_name' => 'civicrm_contribution',
545 'entity' => 'Contribution',
546 'bao' => 'CRM_Contribute_BAO_Contribution',
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',
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})?)?$/',
561 'table_name' => 'civicrm_contribution',
562 'entity' => 'Contribution',
563 'bao' => 'CRM_Contribute_BAO_Contribution',
565 'type' => 'Select Date',
566 'format' => 'activityDateTime',
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',
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})?)?$/',
579 'table_name' => 'civicrm_contribution',
580 'entity' => 'Contribution',
581 'bao' => 'CRM_Contribute_BAO_Contribution',
583 'type' => 'Select Date',
584 'format' => 'activityDateTime',
587 'contribution_source' => array(
589 'type' => CRM_Utils_Type
::T_STRING
,
590 'title' => ts('Contribution Source') ,
591 'description' => 'Origin of this Contribution.',
593 'size' => CRM_Utils_Type
::HUGE
,
595 'where' => 'civicrm_contribution.source',
596 'headerPattern' => '/source/i',
599 'table_name' => 'civicrm_contribution',
600 'entity' => 'Contribution',
601 'bao' => 'CRM_Contribute_BAO_Contribution',
606 'amount_level' => array(
607 'name' => 'amount_level',
608 'type' => CRM_Utils_Type
::T_TEXT
,
609 'title' => ts('Amount Label') ,
611 'where' => 'civicrm_contribution.amount_level',
612 'headerPattern' => '',
615 'table_name' => 'civicrm_contribution',
616 'entity' => 'Contribution',
617 'bao' => 'CRM_Contribute_BAO_Contribution',
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.',
628 'where' => 'civicrm_contribution.contribution_recur_id',
629 'headerPattern' => '',
631 'table_name' => 'civicrm_contribution',
632 'entity' => 'Contribution',
633 'bao' => 'CRM_Contribute_BAO_Contribution',
634 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
638 'type' => CRM_Utils_Type
::T_BOOLEAN
,
639 'title' => ts('Test') ,
641 'where' => 'civicrm_contribution.is_test',
642 'headerPattern' => '',
645 'table_name' => 'civicrm_contribution',
646 'entity' => 'Contribution',
647 'bao' => 'CRM_Contribute_BAO_Contribution',
649 'type' => 'CheckBox',
652 'is_pay_later' => array(
653 'name' => 'is_pay_later',
654 'type' => CRM_Utils_Type
::T_BOOLEAN
,
655 'title' => ts('Is Pay Later') ,
657 'where' => 'civicrm_contribution.is_pay_later',
658 'headerPattern' => '',
661 'table_name' => 'civicrm_contribution',
662 'entity' => 'Contribution',
663 'bao' => 'CRM_Contribute_BAO_Contribution',
665 'type' => 'CheckBox',
668 'contribution_status_id' => array(
669 'name' => 'contribution_status_id',
670 'type' => CRM_Utils_Type
::T_INT
,
671 'title' => ts('Contribution Status ID') ,
673 'where' => 'civicrm_contribution.contribution_status_id',
674 'headerPattern' => '/status/i',
678 'table_name' => 'civicrm_contribution',
679 'entity' => 'Contribution',
680 'bao' => 'CRM_Contribute_BAO_Contribution',
684 'pseudoconstant' => array(
685 'optionGroupName' => 'contribution_status',
686 'optionEditPath' => 'civicrm/admin/options/contribution_status',
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.',
695 'where' => 'civicrm_contribution.address_id',
696 'headerPattern' => '',
698 'table_name' => 'civicrm_contribution',
699 'entity' => 'Contribution',
700 'bao' => 'CRM_Contribute_BAO_Contribution',
701 'FKClassName' => 'CRM_Core_DAO_Address',
703 'contribution_check_number' => array(
704 'name' => 'check_number',
705 'type' => CRM_Utils_Type
::T_STRING
,
706 'title' => ts('Check Number') ,
710 'where' => 'civicrm_contribution.check_number',
711 'headerPattern' => '/check(.?number)?/i',
714 'table_name' => 'civicrm_contribution',
715 'entity' => 'Contribution',
716 'bao' => 'CRM_Contribute_BAO_Contribution',
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.',
727 'where' => 'civicrm_contribution.campaign_id',
728 'headerPattern' => '',
731 'table_name' => 'civicrm_contribution',
732 'entity' => 'Contribution',
733 'bao' => 'CRM_Contribute_BAO_Contribution',
734 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
738 'pseudoconstant' => array(
739 'table' => 'civicrm_campaign',
741 'labelColumn' => 'title',
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',
750 'size' => CRM_Utils_Type
::HUGE
,
752 'where' => 'civicrm_contribution.creditnote_id',
753 'headerPattern' => '/creditnote(.?id)?/i',
756 'table_name' => 'civicrm_contribution',
757 'entity' => 'Contribution',
758 'bao' => 'CRM_Contribute_BAO_Contribution',
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(
773 'where' => 'civicrm_contribution.tax_amount',
774 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
775 'dataPattern' => '/^\d+(\.\d{2})?$/',
777 'table_name' => 'civicrm_contribution',
778 'entity' => 'Contribution',
779 'bao' => 'CRM_Contribute_BAO_Contribution',
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.',
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})?)?$/',
794 'table_name' => 'civicrm_contribution',
795 'entity' => 'Contribution',
796 'bao' => 'CRM_Contribute_BAO_Contribution',
798 'type' => 'Select Date',
799 'format' => 'activityDateTime',
803 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
805 return Civi
::$statics[__CLASS__
]['fields'];
808 * Return a mapping from field-name to the corresponding key (as used in fields()).
811 * Array(string $name => string $uniqueName).
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()));
817 return Civi
::$statics[__CLASS__
]['fieldKeys'];
820 * Returns the names of this table
824 static function getTableName() {
825 return self
::$_tableName;
828 * Returns if this table needs to be logged
836 * Returns the list of fields that can be imported
838 * @param bool $prefix
842 static function &import($prefix = false) {
843 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution', $prefix, array());
847 * Returns the list of fields that can be exported
849 * @param bool $prefix
853 static function &export($prefix = false) {
854 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution', $prefix, array());