3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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-2016
31 * Generated from xml/schema/CRM/Contribute/Contribution.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:f4c8d34b6650ac5eafbfbd3d6b8a51ca)
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Contribute_DAO_Contribution
extends CRM_Core_DAO
{
39 * static instance to hold the table name
43 static $_tableName = 'civicrm_contribution';
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
64 * FK to Financial Type for (total_amount - non_deductible_amount).
68 public $financial_type_id;
70 * The Contribution Page which triggered this contribution
74 public $contribution_page_id;
76 * FK to Payment Instrument
80 public $payment_instrument_id;
82 * Date contribution was received - not necessarily the creation date of the record
88 * Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.
92 public $non_deductible_amount;
94 * Total amount of this contribution. Use market value for non-monetary gifts.
100 * actual processor fee if known - may be 0.
106 * actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.
112 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
118 * unique invoice id, system generated or passed in
124 * 3 character string, value from config setting or input via user.
130 * when was gift cancelled
139 public $cancel_reason;
141 * when (if) receipt was sent. populated automatically for online donations w/ automatic receipting
145 public $receipt_date;
147 * when (if) was donor thanked
151 public $thankyou_date;
153 * Origin of this Contribution.
162 public $amount_level;
164 * 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.
168 public $contribution_recur_id;
178 public $is_pay_later;
183 public $contribution_status_id;
185 * Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.
194 public $check_number;
196 * The campaign for which this contribution has been triggered.
202 * unique credit note id, system generated or passed in
206 public $creditnote_id;
208 * Total tax amount of this contribution.
214 * Stores the date when revenue should be recognized.
218 public $revenue_recognition_date;
222 * @return civicrm_contribution
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' => '',
267 'contribution_contact_id' => array(
268 'name' => 'contact_id',
269 'type' => CRM_Utils_Type
::T_INT
,
270 'title' => ts('Contact ID') ,
271 'description' => 'FK to Contact ID',
274 'where' => 'civicrm_contribution.contact_id',
275 'headerPattern' => '/contact(.?id)?/i',
276 'dataPattern' => '/^\d+$/',
278 'FKClassName' => 'CRM_Contact_DAO_Contact',
280 'type' => 'EntityRef',
283 'financial_type_id' => array(
284 'name' => 'financial_type_id',
285 'type' => CRM_Utils_Type
::T_INT
,
286 'title' => ts('Financial Type') ,
287 'description' => 'FK to Financial Type for (total_amount - non_deductible_amount).',
289 'where' => 'civicrm_contribution.financial_type_id',
290 'headerPattern' => '',
292 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
296 'pseudoconstant' => array(
297 'table' => 'civicrm_financial_type',
299 'labelColumn' => 'name',
302 'contribution_page_id' => array(
303 'name' => 'contribution_page_id',
304 'type' => CRM_Utils_Type
::T_INT
,
305 'title' => ts('Contribution Page ID') ,
306 'description' => 'The Contribution Page which triggered this contribution',
308 'where' => 'civicrm_contribution.contribution_page_id',
309 'headerPattern' => '',
312 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
316 'pseudoconstant' => array(
317 'table' => 'civicrm_contribution_page',
319 'labelColumn' => 'title',
322 'payment_instrument_id' => array(
323 'name' => 'payment_instrument_id',
324 'type' => CRM_Utils_Type
::T_INT
,
325 'title' => ts('Payment Method') ,
326 'description' => 'FK to Payment Instrument',
330 'pseudoconstant' => array(
331 'optionGroupName' => 'payment_instrument',
332 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
335 'receive_date' => array(
336 'name' => 'receive_date',
337 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
338 'title' => ts('Date Received') ,
339 'description' => 'Date contribution was received - not necessarily the creation date of the record',
341 'where' => 'civicrm_contribution.receive_date',
342 'headerPattern' => '/receive(.?date)?/i',
343 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
346 'type' => 'Select Date',
349 'non_deductible_amount' => array(
350 'name' => 'non_deductible_amount',
351 'type' => CRM_Utils_Type
::T_MONEY
,
352 'title' => ts('Non-deductible Amount') ,
353 'description' => 'Portion of total amount which is NOT tax deductible. Equal to total_amount for non-deductible financial types.',
354 'precision' => array(
359 'where' => 'civicrm_contribution.non_deductible_amount',
360 'headerPattern' => '/non?.?deduct/i',
361 'dataPattern' => '/^\d+(\.\d{2})?$/',
367 'total_amount' => array(
368 'name' => 'total_amount',
369 'type' => CRM_Utils_Type
::T_MONEY
,
370 'title' => ts('Total Amount') ,
371 'description' => 'Total amount of this contribution. Use market value for non-monetary gifts.',
373 'precision' => array(
378 'where' => 'civicrm_contribution.total_amount',
379 'headerPattern' => '/^total|(.?^am(ou)?nt)/i',
380 'dataPattern' => '/^\d+(\.\d{2})?$/',
386 'fee_amount' => array(
387 'name' => 'fee_amount',
388 'type' => CRM_Utils_Type
::T_MONEY
,
389 'title' => ts('Fee Amount') ,
390 'description' => 'actual processor fee if known - may be 0.',
391 'precision' => array(
396 'where' => 'civicrm_contribution.fee_amount',
397 'headerPattern' => '/fee(.?am(ou)?nt)?/i',
398 'dataPattern' => '/^\d+(\.\d{2})?$/',
404 'net_amount' => array(
405 'name' => 'net_amount',
406 'type' => CRM_Utils_Type
::T_MONEY
,
407 'title' => ts('Net Amount') ,
408 'description' => 'actual funds transfer amount. total less fees. if processor does not report actual fee during transaction, this is set to total_amount.',
409 'precision' => array(
414 'where' => 'civicrm_contribution.net_amount',
415 'headerPattern' => '/net(.?am(ou)?nt)?/i',
416 'dataPattern' => '/^\d+(\.\d{2})?$/',
424 'type' => CRM_Utils_Type
::T_STRING
,
425 'title' => ts('Transaction ID') ,
426 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
428 'size' => CRM_Utils_Type
::HUGE
,
430 'where' => 'civicrm_contribution.trxn_id',
431 'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
438 'invoice_id' => array(
439 'name' => 'invoice_id',
440 'type' => CRM_Utils_Type
::T_STRING
,
441 'title' => ts('Invoice ID') ,
442 'description' => 'unique invoice id, system generated or passed in',
444 'size' => CRM_Utils_Type
::HUGE
,
446 'where' => 'civicrm_contribution.invoice_id',
447 'headerPattern' => '/invoice(.?id)?/i',
455 'name' => 'currency',
456 'type' => CRM_Utils_Type
::T_STRING
,
457 'title' => ts('Currency') ,
458 'description' => '3 character string, value from config setting or input via user.',
460 'size' => CRM_Utils_Type
::FOUR
,
462 'where' => 'civicrm_contribution.currency',
463 'headerPattern' => '/cur(rency)?/i',
464 'dataPattern' => '/^[A-Z]{3}$/i',
470 'pseudoconstant' => array(
471 'table' => 'civicrm_currency',
472 'keyColumn' => 'name',
473 'labelColumn' => 'full_name',
474 'nameColumn' => 'name',
477 'cancel_date' => array(
478 'name' => 'cancel_date',
479 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
480 'title' => ts('Cancel Date') ,
481 'description' => 'when was gift cancelled',
483 'where' => 'civicrm_contribution.cancel_date',
484 'headerPattern' => '/cancel(.?date)?/i',
485 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
488 'type' => 'Select Date',
491 'cancel_reason' => array(
492 'name' => 'cancel_reason',
493 'type' => CRM_Utils_Type
::T_TEXT
,
494 'title' => ts('Cancel Reason') ,
496 'where' => 'civicrm_contribution.cancel_reason',
497 'headerPattern' => '/(cancel.?)?reason/i',
504 'receipt_date' => array(
505 'name' => 'receipt_date',
506 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
507 'title' => ts('Receipt Date') ,
508 'description' => 'when (if) receipt was sent. populated automatically for online donations w/ automatic receipting',
510 'where' => 'civicrm_contribution.receipt_date',
511 'headerPattern' => '/receipt(.?date)?/i',
512 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
515 'type' => 'Select Date',
518 'thankyou_date' => array(
519 'name' => 'thankyou_date',
520 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
521 'title' => ts('Thank-you Date') ,
522 'description' => 'when (if) was donor thanked',
524 'where' => 'civicrm_contribution.thankyou_date',
525 'headerPattern' => '/thank(s|(.?you))?(.?date)?/i',
526 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
529 'type' => 'Select Date',
532 'contribution_source' => array(
534 'type' => CRM_Utils_Type
::T_STRING
,
535 'title' => ts('Contribution Source') ,
536 'description' => 'Origin of this Contribution.',
538 'size' => CRM_Utils_Type
::HUGE
,
540 'where' => 'civicrm_contribution.source',
541 'headerPattern' => '/source/i',
548 'amount_level' => array(
549 'name' => 'amount_level',
550 'type' => CRM_Utils_Type
::T_TEXT
,
551 'title' => ts('Amount Label') ,
553 'where' => 'civicrm_contribution.amount_level',
554 'headerPattern' => '',
561 'contribution_recur_id' => array(
562 'name' => 'contribution_recur_id',
563 'type' => CRM_Utils_Type
::T_INT
,
564 'title' => ts('Recurring Contribution ID') ,
565 '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.',
566 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
570 'type' => CRM_Utils_Type
::T_BOOLEAN
,
571 'title' => ts('Test') ,
573 'where' => 'civicrm_contribution.is_test',
574 'headerPattern' => '',
578 'type' => 'CheckBox',
581 'is_pay_later' => array(
582 'name' => 'is_pay_later',
583 'type' => CRM_Utils_Type
::T_BOOLEAN
,
584 'title' => ts('Is Pay Later') ,
586 'where' => 'civicrm_contribution.is_pay_later',
587 'headerPattern' => '',
591 'type' => 'CheckBox',
594 'contribution_status_id' => array(
595 'name' => 'contribution_status_id',
596 'type' => CRM_Utils_Type
::T_INT
,
597 'title' => ts('Contribution Status ID') ,
599 'where' => 'civicrm_contribution.contribution_status_id',
600 'headerPattern' => '/status/i',
607 'pseudoconstant' => array(
608 'optionGroupName' => 'contribution_status',
609 'optionEditPath' => 'civicrm/admin/options/contribution_status',
612 'address_id' => array(
613 'name' => 'address_id',
614 'type' => CRM_Utils_Type
::T_INT
,
615 'title' => ts('Contribution Address') ,
616 '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.',
617 'FKClassName' => 'CRM_Core_DAO_Address',
619 'check_number' => array(
620 'name' => 'check_number',
621 'type' => CRM_Utils_Type
::T_STRING
,
622 'title' => ts('Check Number') ,
626 'where' => 'civicrm_contribution.check_number',
627 'headerPattern' => '/check(.?number)?/i',
634 'contribution_campaign_id' => array(
635 'name' => 'campaign_id',
636 'type' => CRM_Utils_Type
::T_INT
,
637 'title' => ts('Campaign') ,
638 'description' => 'The campaign for which this contribution has been triggered.',
640 'where' => 'civicrm_contribution.campaign_id',
641 'headerPattern' => '',
644 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
648 'pseudoconstant' => array(
649 'table' => 'civicrm_campaign',
651 'labelColumn' => 'title',
654 'creditnote_id' => array(
655 'name' => 'creditnote_id',
656 'type' => CRM_Utils_Type
::T_STRING
,
657 'title' => ts('Credit Note ID') ,
658 'description' => 'unique credit note id, system generated or passed in',
660 'size' => CRM_Utils_Type
::HUGE
,
662 'where' => 'civicrm_contribution.creditnote_id',
663 'headerPattern' => '/creditnote(.?id)?/i',
670 'tax_amount' => array(
671 'name' => 'tax_amount',
672 'type' => CRM_Utils_Type
::T_MONEY
,
673 'title' => ts('Tax Amount') ,
674 'description' => 'Total tax amount of this contribution.',
675 'precision' => array(
680 'where' => 'civicrm_contribution.tax_amount',
681 'headerPattern' => '/tax(.?am(ou)?nt)?/i',
682 'dataPattern' => '/^\d+(\.\d{2})?$/',
688 'revenue_recognition_date' => array(
689 'name' => 'revenue_recognition_date',
690 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
691 'title' => ts('Revenue Recognition Date') ,
692 'description' => 'Stores the date when revenue should be recognized.',
694 'where' => 'civicrm_contribution.revenue_recognition_date',
695 'headerPattern' => '/revenue(.?date)?/i',
696 'dataPattern' => '/^\d{4}-?\d{2}-?\d{2} ?(\d{2}:?\d{2}:?(\d{2})?)?$/',
699 'type' => 'Select Date',
703 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
705 return Civi
::$statics[__CLASS__
]['fields'];
708 * Return a mapping from field-name to the corresponding key (as used in fields()).
711 * Array(string $name => string $uniqueName).
713 static function &fieldKeys() {
714 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
715 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
717 return Civi
::$statics[__CLASS__
]['fieldKeys'];
720 * Returns the names of this table
724 static function getTableName() {
725 return self
::$_tableName;
728 * Returns if this table needs to be logged
736 * Returns the list of fields that can be imported
738 * @param bool $prefix
742 static function &import($prefix = false) {
743 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution', $prefix, array());
747 * Returns the list of fields that can be exported
749 * @param bool $prefix
753 static function &export($prefix = false) {
754 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution', $prefix, array());