5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ba5f7682a5f99b682f70cd45097feb56)
13 * Database access object for the ContributionRecur entity.
15 class CRM_Contribute_DAO_ContributionRecur
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.6';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_contribution_recur';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
34 * Contribution Recur ID
41 * Foreign key to civicrm_contact.id.
48 * Amount to be collected (including any sales tax) by payment processor each recurrence.
55 * 3 character string, value from config setting or input via user.
62 * Time units for recurrence of payment.
66 public $frequency_unit;
69 * Number of time units for recurrence of payment.
73 public $frequency_interval;
76 * Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.
83 * The date the first scheduled recurring contribution occurs.
90 * When this recurring contribution record was created.
97 * Last updated date for this record. mostly the last time a payment was received
101 public $modified_date;
104 * Date this recurring contribution was cancelled by contributor- if we can get access to it
111 * Free text field for a reason for cancelling
115 public $cancel_reason;
118 * Date this recurring contribution finished successfully
125 * Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??
129 public $processor_id;
132 * Optionally used to store a link to a payment token used for this recurring contribution.
136 public $payment_token_id;
139 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
146 * unique invoice id, system generated or passed in
155 public $contribution_status_id;
163 * Day in the period when the payment should be charged e.g. 1st of month, 15th etc.
170 * Next scheduled date
174 public $next_sched_contribution_date;
177 * Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.
181 public $failure_count;
184 * Date to retry failed attempt
188 public $failure_retry_date;
191 * Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.
198 * Foreign key to civicrm_payment_processor.id
202 public $payment_processor_id;
205 * FK to Financial Type
209 public $financial_type_id;
212 * FK to Payment Instrument
216 public $payment_instrument_id;
219 * The campaign for which this contribution has been triggered.
226 * if true, receipt is automatically emailed to contact on each successful payment
230 public $is_email_receipt;
235 public function __construct() {
236 $this->__table
= 'civicrm_contribution_recur';
237 parent
::__construct();
241 * Returns localized title of this entity.
243 * @param bool $plural
244 * Whether to return the plural version of the title.
246 public static function getEntityTitle($plural = FALSE) {
247 return $plural ?
ts('Recurring Contributions') : ts('Recurring Contribution');
251 * Returns foreign keys and entity references.
254 * [CRM_Core_Reference_Interface]
256 public static function getReferenceColumns() {
257 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
258 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
259 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
260 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
261 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
262 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
263 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
264 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
266 return Civi
::$statics[__CLASS__
]['links'];
270 * Returns all the column names of this table
274 public static function &fields() {
275 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
276 Civi
::$statics[__CLASS__
]['fields'] = [
277 'contribution_recur_id' => [
279 'type' => CRM_Utils_Type
::T_INT
,
280 'title' => ts('Recurring Contribution ID'),
281 'description' => ts('Contribution Recur ID'),
283 'where' => 'civicrm_contribution_recur.id',
284 'table_name' => 'civicrm_contribution_recur',
285 'entity' => 'ContributionRecur',
286 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
291 'name' => 'contact_id',
292 'type' => CRM_Utils_Type
::T_INT
,
293 'title' => ts('Contact'),
294 'description' => ts('Foreign key to civicrm_contact.id.'),
296 'where' => 'civicrm_contribution_recur.contact_id',
297 'table_name' => 'civicrm_contribution_recur',
298 'entity' => 'ContributionRecur',
299 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
301 'FKClassName' => 'CRM_Contact_DAO_Contact',
303 'type' => 'EntityRef',
309 'type' => CRM_Utils_Type
::T_MONEY
,
310 'title' => ts('Amount'),
311 'description' => ts('Amount to be collected (including any sales tax) by payment processor each recurrence.'),
317 'where' => 'civicrm_contribution_recur.amount',
318 'table_name' => 'civicrm_contribution_recur',
319 'entity' => 'ContributionRecur',
320 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
328 'name' => 'currency',
329 'type' => CRM_Utils_Type
::T_STRING
,
330 'title' => ts('Currency'),
331 'description' => ts('3 character string, value from config setting or input via user.'),
333 'size' => CRM_Utils_Type
::FOUR
,
334 'where' => 'civicrm_contribution_recur.currency',
336 'table_name' => 'civicrm_contribution_recur',
337 'entity' => 'ContributionRecur',
338 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
343 'pseudoconstant' => [
344 'table' => 'civicrm_currency',
345 'keyColumn' => 'name',
346 'labelColumn' => 'full_name',
347 'nameColumn' => 'name',
348 'abbrColumn' => 'symbol',
352 'frequency_unit' => [
353 'name' => 'frequency_unit',
354 'type' => CRM_Utils_Type
::T_STRING
,
355 'title' => ts('Frequency Unit'),
356 'description' => ts('Time units for recurrence of payment.'),
358 'size' => CRM_Utils_Type
::EIGHT
,
359 'where' => 'civicrm_contribution_recur.frequency_unit',
360 'default' => 'month',
361 'table_name' => 'civicrm_contribution_recur',
362 'entity' => 'ContributionRecur',
363 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
368 'pseudoconstant' => [
369 'optionGroupName' => 'recur_frequency_units',
370 'keyColumn' => 'name',
371 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
375 'frequency_interval' => [
376 'name' => 'frequency_interval',
377 'type' => CRM_Utils_Type
::T_INT
,
378 'title' => ts('Interval (number of units)'),
379 'description' => ts('Number of time units for recurrence of payment.'),
381 'where' => 'civicrm_contribution_recur.frequency_interval',
382 'table_name' => 'civicrm_contribution_recur',
383 'entity' => 'ContributionRecur',
384 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
392 'name' => 'installments',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Number of Installments'),
395 'description' => ts('Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.'),
396 'where' => 'civicrm_contribution_recur.installments',
397 'table_name' => 'civicrm_contribution_recur',
398 'entity' => 'ContributionRecur',
399 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
406 'contribution_recur_start_date' => [
407 'name' => 'start_date',
408 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
409 'title' => ts('Start Date'),
410 'description' => ts('The date the first scheduled recurring contribution occurs.'),
412 'where' => 'civicrm_contribution_recur.start_date',
413 'table_name' => 'civicrm_contribution_recur',
414 'entity' => 'ContributionRecur',
415 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
417 'unique_title' => ts('Recurring Contribution Start Date'),
419 'type' => 'Select Date',
420 'formatType' => 'activityDateTime',
424 'contribution_recur_create_date' => [
425 'name' => 'create_date',
426 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
427 'title' => ts('Created Date'),
428 'description' => ts('When this recurring contribution record was created.'),
430 'where' => 'civicrm_contribution_recur.create_date',
431 'table_name' => 'civicrm_contribution_recur',
432 'entity' => 'ContributionRecur',
433 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
435 'unique_title' => ts('Recurring Contribution Create Date'),
437 'type' => 'Select Date',
438 'formatType' => 'activityDateTime',
442 'contribution_recur_modified_date' => [
443 'name' => 'modified_date',
444 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
445 'title' => ts('Modified Date'),
446 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
447 'where' => 'civicrm_contribution_recur.modified_date',
448 'table_name' => 'civicrm_contribution_recur',
449 'entity' => 'ContributionRecur',
450 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
452 'unique_title' => ts('Recurring Contribution Modified Date'),
454 'type' => 'Select Date',
455 'formatType' => 'activityDateTime',
459 'contribution_recur_cancel_date' => [
460 'name' => 'cancel_date',
461 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
462 'title' => ts('Cancel Date'),
463 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
464 'where' => 'civicrm_contribution_recur.cancel_date',
465 'table_name' => 'civicrm_contribution_recur',
466 'entity' => 'ContributionRecur',
467 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
469 'unique_title' => ts('Recurring Contribution Cancel Date'),
471 'type' => 'Select Date',
472 'formatType' => 'activityDate',
476 'contribution_recur_cancel_reason' => [
477 'name' => 'cancel_reason',
478 'type' => CRM_Utils_Type
::T_TEXT
,
479 'title' => ts('Cancellation Reason'),
480 'description' => ts('Free text field for a reason for cancelling'),
481 'where' => 'civicrm_contribution_recur.cancel_reason',
482 'table_name' => 'civicrm_contribution_recur',
483 'entity' => 'ContributionRecur',
484 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
486 'unique_title' => ts('Recurring Contribution Cancel Reason'),
492 'contribution_recur_end_date' => [
493 'name' => 'end_date',
494 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
495 'title' => ts('Recurring Contribution End Date'),
496 'description' => ts('Date this recurring contribution finished successfully'),
497 'where' => 'civicrm_contribution_recur.end_date',
498 'table_name' => 'civicrm_contribution_recur',
499 'entity' => 'ContributionRecur',
500 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
502 'unique_title' => ts('Recurring Contribution End Date'),
504 'type' => 'Select Date',
505 'formatType' => 'activityDate',
509 'contribution_recur_processor_id' => [
510 'name' => 'processor_id',
511 'type' => CRM_Utils_Type
::T_STRING
,
512 'title' => ts('Processor ID'),
513 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
515 'size' => CRM_Utils_Type
::HUGE
,
516 'where' => 'civicrm_contribution_recur.processor_id',
517 'table_name' => 'civicrm_contribution_recur',
518 'entity' => 'ContributionRecur',
519 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
526 'payment_token_id' => [
527 'name' => 'payment_token_id',
528 'type' => CRM_Utils_Type
::T_INT
,
529 'title' => ts('Payment Token ID'),
530 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
531 'where' => 'civicrm_contribution_recur.payment_token_id',
532 'table_name' => 'civicrm_contribution_recur',
533 'entity' => 'ContributionRecur',
534 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
536 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
539 'contribution_recur_trxn_id' => [
541 'type' => CRM_Utils_Type
::T_STRING
,
542 'title' => ts('Transaction ID'),
543 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
545 'size' => CRM_Utils_Type
::HUGE
,
546 'where' => 'civicrm_contribution_recur.trxn_id',
547 'table_name' => 'civicrm_contribution_recur',
548 'entity' => 'ContributionRecur',
549 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
557 'name' => 'invoice_id',
558 'type' => CRM_Utils_Type
::T_STRING
,
559 'title' => ts('Invoice ID'),
560 'description' => ts('unique invoice id, system generated or passed in'),
562 'size' => CRM_Utils_Type
::HUGE
,
563 'where' => 'civicrm_contribution_recur.invoice_id',
564 'table_name' => 'civicrm_contribution_recur',
565 'entity' => 'ContributionRecur',
566 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
573 'contribution_recur_contribution_status_id' => [
574 'name' => 'contribution_status_id',
575 'type' => CRM_Utils_Type
::T_INT
,
576 'title' => ts('Status'),
578 'where' => 'civicrm_contribution_recur.contribution_status_id',
581 'table_name' => 'civicrm_contribution_recur',
582 'entity' => 'ContributionRecur',
583 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
588 'pseudoconstant' => [
589 'optionGroupName' => 'contribution_recur_status',
590 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
596 'type' => CRM_Utils_Type
::T_BOOLEAN
,
597 'title' => ts('Test'),
599 'where' => 'civicrm_contribution_recur.is_test',
602 'table_name' => 'civicrm_contribution_recur',
603 'entity' => 'ContributionRecur',
604 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
607 'type' => 'CheckBox',
612 'name' => 'cycle_day',
613 'type' => CRM_Utils_Type
::T_INT
,
614 'title' => ts('Cycle Day'),
615 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
617 'where' => 'civicrm_contribution_recur.cycle_day',
619 'table_name' => 'civicrm_contribution_recur',
620 'entity' => 'ContributionRecur',
621 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
628 'contribution_recur_next_sched_contribution_date' => [
629 'name' => 'next_sched_contribution_date',
630 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
631 'title' => ts('Next Scheduled Contribution Date'),
632 'description' => ts('Next scheduled date'),
633 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
634 'table_name' => 'civicrm_contribution_recur',
635 'entity' => 'ContributionRecur',
636 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
638 'unique_title' => ts('Next Scheduled Recurring Contribution'),
640 'type' => 'Select Date',
641 'formatType' => 'activityDate',
646 'name' => 'failure_count',
647 'type' => CRM_Utils_Type
::T_INT
,
648 'title' => ts('Number of Failures'),
649 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
650 'where' => 'civicrm_contribution_recur.failure_count',
652 'table_name' => 'civicrm_contribution_recur',
653 'entity' => 'ContributionRecur',
654 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
661 'contribution_recur_failure_retry_date' => [
662 'name' => 'failure_retry_date',
663 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
664 'title' => ts('Retry Failed Attempt Date'),
665 'description' => ts('Date to retry failed attempt'),
666 'where' => 'civicrm_contribution_recur.failure_retry_date',
667 'table_name' => 'civicrm_contribution_recur',
668 'entity' => 'ContributionRecur',
669 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
671 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
673 'type' => 'Select Date',
674 'formatType' => 'activityDate',
679 'name' => 'auto_renew',
680 'type' => CRM_Utils_Type
::T_BOOLEAN
,
681 'title' => ts('Auto Renew'),
682 'description' => ts('Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.'),
684 'where' => 'civicrm_contribution_recur.auto_renew',
686 'table_name' => 'civicrm_contribution_recur',
687 'entity' => 'ContributionRecur',
688 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
691 'type' => 'CheckBox',
695 'contribution_recur_payment_processor_id' => [
696 'name' => 'payment_processor_id',
697 'type' => CRM_Utils_Type
::T_INT
,
698 'title' => ts('Payment Processor'),
699 'description' => ts('Foreign key to civicrm_payment_processor.id'),
700 'where' => 'civicrm_contribution_recur.payment_processor_id',
701 'table_name' => 'civicrm_contribution_recur',
702 'entity' => 'ContributionRecur',
703 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
705 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
709 'pseudoconstant' => [
710 'table' => 'civicrm_payment_processor',
712 'labelColumn' => 'name',
716 'financial_type_id' => [
717 'name' => 'financial_type_id',
718 'type' => CRM_Utils_Type
::T_INT
,
719 'title' => ts('Financial Type'),
720 'description' => ts('FK to Financial Type'),
721 'where' => 'civicrm_contribution_recur.financial_type_id',
723 'table_name' => 'civicrm_contribution_recur',
724 'entity' => 'ContributionRecur',
725 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
727 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
731 'pseudoconstant' => [
732 'table' => 'civicrm_financial_type',
734 'labelColumn' => 'name',
738 'payment_instrument_id' => [
739 'name' => 'payment_instrument_id',
740 'type' => CRM_Utils_Type
::T_INT
,
741 'title' => ts('Payment Method'),
742 'description' => ts('FK to Payment Instrument'),
743 'where' => 'civicrm_contribution_recur.payment_instrument_id',
744 'table_name' => 'civicrm_contribution_recur',
745 'entity' => 'ContributionRecur',
746 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
751 'pseudoconstant' => [
752 'optionGroupName' => 'payment_instrument',
753 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
757 'contribution_campaign_id' => [
758 'name' => 'campaign_id',
759 'type' => CRM_Utils_Type
::T_INT
,
760 'title' => ts('Campaign'),
761 'description' => ts('The campaign for which this contribution has been triggered.'),
763 'where' => 'civicrm_contribution_recur.campaign_id',
765 'table_name' => 'civicrm_contribution_recur',
766 'entity' => 'ContributionRecur',
767 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
769 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
773 'pseudoconstant' => [
774 'table' => 'civicrm_campaign',
776 'labelColumn' => 'title',
780 'is_email_receipt' => [
781 'name' => 'is_email_receipt',
782 'type' => CRM_Utils_Type
::T_BOOLEAN
,
783 'title' => ts('Send email Receipt?'),
784 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
785 'where' => 'civicrm_contribution_recur.is_email_receipt',
787 'table_name' => 'civicrm_contribution_recur',
788 'entity' => 'ContributionRecur',
789 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
792 'type' => 'CheckBox',
797 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
799 return Civi
::$statics[__CLASS__
]['fields'];
803 * Return a mapping from field-name to the corresponding key (as used in fields()).
806 * Array(string $name => string $uniqueName).
808 public static function &fieldKeys() {
809 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
810 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
812 return Civi
::$statics[__CLASS__
]['fieldKeys'];
816 * Returns the names of this table
820 public static function getTableName() {
821 return self
::$_tableName;
825 * Returns if this table needs to be logged
829 public function getLog() {
834 * Returns the list of fields that can be imported
836 * @param bool $prefix
840 public static function &import($prefix = FALSE) {
841 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
846 * Returns the list of fields that can be exported
848 * @param bool $prefix
852 public static function &export($prefix = FALSE) {
853 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
858 * Returns the list of indices
860 * @param bool $localize
864 public static function indices($localize = TRUE) {
866 'UI_contrib_trxn_id' => [
867 'name' => 'UI_contrib_trxn_id',
871 'localizable' => FALSE,
873 'sig' => 'civicrm_contribution_recur::1::trxn_id',
875 'UI_contrib_invoice_id' => [
876 'name' => 'UI_contrib_invoice_id',
880 'localizable' => FALSE,
882 'sig' => 'civicrm_contribution_recur::1::invoice_id',
884 'index_contribution_status' => [
885 'name' => 'index_contribution_status',
887 0 => 'contribution_status_id',
889 'localizable' => FALSE,
890 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
892 'UI_contribution_recur_payment_instrument_id' => [
893 'name' => 'UI_contribution_recur_payment_instrument_id',
895 0 => 'payment_instrument_id',
897 'localizable' => FALSE,
898 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
901 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;