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:0a7eaba45ea7d692276b351cd9cee473)
13 * Database access object for the ContributionRecur entity.
15 class CRM_Contribute_DAO_ContributionRecur
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_contribution_recur';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
32 * Contribution Recur ID
39 * Foreign key to civicrm_contact.id.
46 * Amount to be collected (including any sales tax) by payment processor each recurrence.
53 * 3 character string, value from config setting or input via user.
60 * Time units for recurrence of payment.
64 public $frequency_unit;
67 * Number of time units for recurrence of payment.
71 public $frequency_interval;
74 * Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.
81 * The date the first scheduled recurring contribution occurs.
88 * When this recurring contribution record was created.
95 * Last updated date for this record. mostly the last time a payment was received
99 public $modified_date;
102 * Date this recurring contribution was cancelled by contributor- if we can get access to it
109 * Free text field for a reason for cancelling
113 public $cancel_reason;
116 * Date this recurring contribution finished successfully
123 * Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??
127 public $processor_id;
130 * Optionally used to store a link to a payment token used for this recurring contribution.
134 public $payment_token_id;
137 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
144 * unique invoice id, system generated or passed in
153 public $contribution_status_id;
161 * Day in the period when the payment should be charged e.g. 1st of month, 15th etc.
168 * Next scheduled date
172 public $next_sched_contribution_date;
175 * Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.
179 public $failure_count;
182 * Date to retry failed attempt
186 public $failure_retry_date;
189 * Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.
196 * Foreign key to civicrm_payment_processor.id
200 public $payment_processor_id;
203 * FK to Financial Type
207 public $financial_type_id;
210 * FK to Payment Instrument
214 public $payment_instrument_id;
217 * The campaign for which this contribution has been triggered.
224 * if true, receipt is automatically emailed to contact on each successful payment
228 public $is_email_receipt;
233 public function __construct() {
234 $this->__table
= 'civicrm_contribution_recur';
235 parent
::__construct();
239 * Returns localized title of this entity.
241 public static function getEntityTitle() {
242 return ts('Recurring Contributions');
246 * Returns foreign keys and entity references.
249 * [CRM_Core_Reference_Interface]
251 public static function getReferenceColumns() {
252 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
253 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
254 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
255 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
256 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
257 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
258 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
259 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
261 return Civi
::$statics[__CLASS__
]['links'];
265 * Returns all the column names of this table
269 public static function &fields() {
270 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
271 Civi
::$statics[__CLASS__
]['fields'] = [
272 'contribution_recur_id' => [
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Recurring Contribution ID'),
276 'description' => ts('Contribution Recur ID'),
278 'where' => 'civicrm_contribution_recur.id',
279 'table_name' => 'civicrm_contribution_recur',
280 'entity' => 'ContributionRecur',
281 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
285 'name' => 'contact_id',
286 'type' => CRM_Utils_Type
::T_INT
,
287 'title' => ts('Contact'),
288 'description' => ts('Foreign key to civicrm_contact.id.'),
290 'where' => 'civicrm_contribution_recur.contact_id',
291 'table_name' => 'civicrm_contribution_recur',
292 'entity' => 'ContributionRecur',
293 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
295 'FKClassName' => 'CRM_Contact_DAO_Contact',
297 'type' => 'EntityRef',
302 'type' => CRM_Utils_Type
::T_MONEY
,
303 'title' => ts('Amount'),
304 'description' => ts('Amount to be collected (including any sales tax) by payment processor each recurrence.'),
310 'where' => 'civicrm_contribution_recur.amount',
311 'table_name' => 'civicrm_contribution_recur',
312 'entity' => 'ContributionRecur',
313 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
320 'name' => 'currency',
321 'type' => CRM_Utils_Type
::T_STRING
,
322 'title' => ts('Currency'),
323 'description' => ts('3 character string, value from config setting or input via user.'),
325 'size' => CRM_Utils_Type
::FOUR
,
326 'where' => 'civicrm_contribution_recur.currency',
328 'table_name' => 'civicrm_contribution_recur',
329 'entity' => 'ContributionRecur',
330 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
335 'pseudoconstant' => [
336 'table' => 'civicrm_currency',
337 'keyColumn' => 'name',
338 'labelColumn' => 'full_name',
339 'nameColumn' => 'name',
340 'abbrColumn' => 'symbol',
343 'frequency_unit' => [
344 'name' => 'frequency_unit',
345 'type' => CRM_Utils_Type
::T_STRING
,
346 'title' => ts('Frequency Unit'),
347 'description' => ts('Time units for recurrence of payment.'),
349 'size' => CRM_Utils_Type
::EIGHT
,
350 'where' => 'civicrm_contribution_recur.frequency_unit',
351 'default' => 'month',
352 'table_name' => 'civicrm_contribution_recur',
353 'entity' => 'ContributionRecur',
354 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
359 'pseudoconstant' => [
360 'optionGroupName' => 'recur_frequency_units',
361 'keyColumn' => 'name',
362 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
365 'frequency_interval' => [
366 'name' => 'frequency_interval',
367 'type' => CRM_Utils_Type
::T_INT
,
368 'title' => ts('Interval (number of units)'),
369 'description' => ts('Number of time units for recurrence of payment.'),
371 'where' => 'civicrm_contribution_recur.frequency_interval',
372 'table_name' => 'civicrm_contribution_recur',
373 'entity' => 'ContributionRecur',
374 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
381 'name' => 'installments',
382 'type' => CRM_Utils_Type
::T_INT
,
383 'title' => ts('Number of Installments'),
384 '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.'),
385 'where' => 'civicrm_contribution_recur.installments',
386 'table_name' => 'civicrm_contribution_recur',
387 'entity' => 'ContributionRecur',
388 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
394 'contribution_recur_start_date' => [
395 'name' => 'start_date',
396 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
397 'title' => ts('Start Date'),
398 'description' => ts('The date the first scheduled recurring contribution occurs.'),
400 'where' => 'civicrm_contribution_recur.start_date',
401 'table_name' => 'civicrm_contribution_recur',
402 'entity' => 'ContributionRecur',
403 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
405 'unique_title' => ts('Recurring Contribution Start Date'),
407 'type' => 'Select Date',
408 'formatType' => 'activityDateTime',
411 'contribution_recur_create_date' => [
412 'name' => 'create_date',
413 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
414 'title' => ts('Created Date'),
415 'description' => ts('When this recurring contribution record was created.'),
417 'where' => 'civicrm_contribution_recur.create_date',
418 'table_name' => 'civicrm_contribution_recur',
419 'entity' => 'ContributionRecur',
420 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
422 'unique_title' => ts('Recurring Contribution Create Date'),
424 'type' => 'Select Date',
425 'formatType' => 'activityDateTime',
428 'contribution_recur_modified_date' => [
429 'name' => 'modified_date',
430 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
431 'title' => ts('Modified Date'),
432 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
433 'where' => 'civicrm_contribution_recur.modified_date',
434 'table_name' => 'civicrm_contribution_recur',
435 'entity' => 'ContributionRecur',
436 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
438 'unique_title' => ts('Recurring Contribution Modified Date'),
440 'type' => 'Select Date',
441 'formatType' => 'activityDateTime',
444 'contribution_recur_cancel_date' => [
445 'name' => 'cancel_date',
446 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
447 'title' => ts('Cancel Date'),
448 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
449 'where' => 'civicrm_contribution_recur.cancel_date',
450 'table_name' => 'civicrm_contribution_recur',
451 'entity' => 'ContributionRecur',
452 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
454 'unique_title' => ts('Recurring Contribution Cancel Date'),
456 'type' => 'Select Date',
457 'formatType' => 'activityDate',
460 'contribution_recur_cancel_reason' => [
461 'name' => 'cancel_reason',
462 'type' => CRM_Utils_Type
::T_TEXT
,
463 'title' => ts('Cancellation Reason'),
464 'description' => ts('Free text field for a reason for cancelling'),
465 'where' => 'civicrm_contribution_recur.cancel_reason',
466 'table_name' => 'civicrm_contribution_recur',
467 'entity' => 'ContributionRecur',
468 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
470 'unique_title' => ts('Recurring Contribution Cancel Reason'),
475 'contribution_recur_end_date' => [
476 'name' => 'end_date',
477 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
478 'title' => ts('Recurring Contribution End Date'),
479 'description' => ts('Date this recurring contribution finished successfully'),
480 'where' => 'civicrm_contribution_recur.end_date',
481 'table_name' => 'civicrm_contribution_recur',
482 'entity' => 'ContributionRecur',
483 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
485 'unique_title' => ts('Recurring Contribution End Date'),
487 'type' => 'Select Date',
488 'formatType' => 'activityDate',
491 'contribution_recur_processor_id' => [
492 'name' => 'processor_id',
493 'type' => CRM_Utils_Type
::T_STRING
,
494 'title' => ts('Processor ID'),
495 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
497 'size' => CRM_Utils_Type
::HUGE
,
498 'where' => 'civicrm_contribution_recur.processor_id',
499 'table_name' => 'civicrm_contribution_recur',
500 'entity' => 'ContributionRecur',
501 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
507 'payment_token_id' => [
508 'name' => 'payment_token_id',
509 'type' => CRM_Utils_Type
::T_INT
,
510 'title' => ts('Payment Token ID'),
511 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
512 'where' => 'civicrm_contribution_recur.payment_token_id',
513 'table_name' => 'civicrm_contribution_recur',
514 'entity' => 'ContributionRecur',
515 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
517 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
519 'contribution_recur_trxn_id' => [
521 'type' => CRM_Utils_Type
::T_STRING
,
522 'title' => ts('Transaction ID'),
523 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
525 'size' => CRM_Utils_Type
::HUGE
,
526 'where' => 'civicrm_contribution_recur.trxn_id',
527 'table_name' => 'civicrm_contribution_recur',
528 'entity' => 'ContributionRecur',
529 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
536 'name' => 'invoice_id',
537 'type' => CRM_Utils_Type
::T_STRING
,
538 'title' => ts('Invoice ID'),
539 'description' => ts('unique invoice id, system generated or passed in'),
541 'size' => CRM_Utils_Type
::HUGE
,
542 'where' => 'civicrm_contribution_recur.invoice_id',
543 'table_name' => 'civicrm_contribution_recur',
544 'entity' => 'ContributionRecur',
545 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
551 'contribution_recur_contribution_status_id' => [
552 'name' => 'contribution_status_id',
553 'type' => CRM_Utils_Type
::T_INT
,
554 'title' => ts('Status'),
556 'where' => 'civicrm_contribution_recur.contribution_status_id',
559 'table_name' => 'civicrm_contribution_recur',
560 'entity' => 'ContributionRecur',
561 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
566 'pseudoconstant' => [
567 'optionGroupName' => 'contribution_recur_status',
568 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
573 'type' => CRM_Utils_Type
::T_BOOLEAN
,
574 'title' => ts('Test'),
576 'where' => 'civicrm_contribution_recur.is_test',
579 'table_name' => 'civicrm_contribution_recur',
580 'entity' => 'ContributionRecur',
581 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
584 'type' => 'CheckBox',
588 'name' => 'cycle_day',
589 'type' => CRM_Utils_Type
::T_INT
,
590 'title' => ts('Cycle Day'),
591 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
593 'where' => 'civicrm_contribution_recur.cycle_day',
595 'table_name' => 'civicrm_contribution_recur',
596 'entity' => 'ContributionRecur',
597 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
603 'contribution_recur_next_sched_contribution_date' => [
604 'name' => 'next_sched_contribution_date',
605 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
606 'title' => ts('Next Scheduled Contribution Date'),
607 'description' => ts('Next scheduled date'),
608 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
609 'table_name' => 'civicrm_contribution_recur',
610 'entity' => 'ContributionRecur',
611 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
613 'unique_title' => ts('Next Scheduled Recurring Contribution'),
615 'type' => 'Select Date',
616 'formatType' => 'activityDate',
620 'name' => 'failure_count',
621 'type' => CRM_Utils_Type
::T_INT
,
622 'title' => ts('Number of Failures'),
623 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
624 'where' => 'civicrm_contribution_recur.failure_count',
626 'table_name' => 'civicrm_contribution_recur',
627 'entity' => 'ContributionRecur',
628 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
634 'contribution_recur_failure_retry_date' => [
635 'name' => 'failure_retry_date',
636 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
637 'title' => ts('Retry Failed Attempt Date'),
638 'description' => ts('Date to retry failed attempt'),
639 'where' => 'civicrm_contribution_recur.failure_retry_date',
640 'table_name' => 'civicrm_contribution_recur',
641 'entity' => 'ContributionRecur',
642 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
644 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
646 'type' => 'Select Date',
647 'formatType' => 'activityDate',
651 'name' => 'auto_renew',
652 'type' => CRM_Utils_Type
::T_BOOLEAN
,
653 'title' => ts('Auto Renew'),
654 '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.'),
656 'where' => 'civicrm_contribution_recur.auto_renew',
658 'table_name' => 'civicrm_contribution_recur',
659 'entity' => 'ContributionRecur',
660 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
663 'type' => 'CheckBox',
666 'contribution_recur_payment_processor_id' => [
667 'name' => 'payment_processor_id',
668 'type' => CRM_Utils_Type
::T_INT
,
669 'title' => ts('Payment Processor'),
670 'description' => ts('Foreign key to civicrm_payment_processor.id'),
671 'where' => 'civicrm_contribution_recur.payment_processor_id',
672 'table_name' => 'civicrm_contribution_recur',
673 'entity' => 'ContributionRecur',
674 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
676 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
680 'pseudoconstant' => [
681 'table' => 'civicrm_payment_processor',
683 'labelColumn' => 'name',
686 'financial_type_id' => [
687 'name' => 'financial_type_id',
688 'type' => CRM_Utils_Type
::T_INT
,
689 'title' => ts('Financial Type'),
690 'description' => ts('FK to Financial Type'),
691 'where' => 'civicrm_contribution_recur.financial_type_id',
693 'table_name' => 'civicrm_contribution_recur',
694 'entity' => 'ContributionRecur',
695 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
697 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
701 'pseudoconstant' => [
702 'table' => 'civicrm_financial_type',
704 'labelColumn' => 'name',
707 'payment_instrument_id' => [
708 'name' => 'payment_instrument_id',
709 'type' => CRM_Utils_Type
::T_INT
,
710 'title' => ts('Payment Method'),
711 'description' => ts('FK to Payment Instrument'),
712 'where' => 'civicrm_contribution_recur.payment_instrument_id',
713 'table_name' => 'civicrm_contribution_recur',
714 'entity' => 'ContributionRecur',
715 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
720 'pseudoconstant' => [
721 'optionGroupName' => 'payment_instrument',
722 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
725 'contribution_campaign_id' => [
726 'name' => 'campaign_id',
727 'type' => CRM_Utils_Type
::T_INT
,
728 'title' => ts('Campaign'),
729 'description' => ts('The campaign for which this contribution has been triggered.'),
731 'where' => 'civicrm_contribution_recur.campaign_id',
733 'table_name' => 'civicrm_contribution_recur',
734 'entity' => 'ContributionRecur',
735 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
737 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
741 'pseudoconstant' => [
742 'table' => 'civicrm_campaign',
744 'labelColumn' => 'title',
747 'is_email_receipt' => [
748 'name' => 'is_email_receipt',
749 'type' => CRM_Utils_Type
::T_BOOLEAN
,
750 'title' => ts('Send email Receipt?'),
751 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
752 'where' => 'civicrm_contribution_recur.is_email_receipt',
754 'table_name' => 'civicrm_contribution_recur',
755 'entity' => 'ContributionRecur',
756 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
759 'type' => 'CheckBox',
763 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
765 return Civi
::$statics[__CLASS__
]['fields'];
769 * Return a mapping from field-name to the corresponding key (as used in fields()).
772 * Array(string $name => string $uniqueName).
774 public static function &fieldKeys() {
775 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
776 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
778 return Civi
::$statics[__CLASS__
]['fieldKeys'];
782 * Returns the names of this table
786 public static function getTableName() {
787 return self
::$_tableName;
791 * Returns if this table needs to be logged
795 public function getLog() {
800 * Returns the list of fields that can be imported
802 * @param bool $prefix
806 public static function &import($prefix = FALSE) {
807 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
812 * Returns the list of fields that can be exported
814 * @param bool $prefix
818 public static function &export($prefix = FALSE) {
819 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
824 * Returns the list of indices
826 * @param bool $localize
830 public static function indices($localize = TRUE) {
832 'UI_contrib_trxn_id' => [
833 'name' => 'UI_contrib_trxn_id',
837 'localizable' => FALSE,
839 'sig' => 'civicrm_contribution_recur::1::trxn_id',
841 'UI_contrib_invoice_id' => [
842 'name' => 'UI_contrib_invoice_id',
846 'localizable' => FALSE,
848 'sig' => 'civicrm_contribution_recur::1::invoice_id',
850 'index_contribution_status' => [
851 'name' => 'index_contribution_status',
853 0 => 'contribution_status_id',
855 'localizable' => FALSE,
856 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
858 'UI_contribution_recur_payment_instrument_id' => [
859 'name' => 'UI_contribution_recur_payment_instrument_id',
861 0 => 'payment_instrument_id',
863 'localizable' => FALSE,
864 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
867 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;