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:decf43c002d0e4ded0fe5f2a2e2f7bd0)
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 public static function getEntityTitle() {
244 return ts('Recurring Contributions');
248 * Returns foreign keys and entity references.
251 * [CRM_Core_Reference_Interface]
253 public static function getReferenceColumns() {
254 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
255 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
256 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
257 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
258 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
259 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
260 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
261 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
263 return Civi
::$statics[__CLASS__
]['links'];
267 * Returns all the column names of this table
271 public static function &fields() {
272 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
273 Civi
::$statics[__CLASS__
]['fields'] = [
274 'contribution_recur_id' => [
276 'type' => CRM_Utils_Type
::T_INT
,
277 'title' => ts('Recurring Contribution ID'),
278 'description' => ts('Contribution Recur ID'),
280 'where' => 'civicrm_contribution_recur.id',
281 'table_name' => 'civicrm_contribution_recur',
282 'entity' => 'ContributionRecur',
283 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
288 'name' => 'contact_id',
289 'type' => CRM_Utils_Type
::T_INT
,
290 'title' => ts('Contact'),
291 'description' => ts('Foreign key to civicrm_contact.id.'),
293 'where' => 'civicrm_contribution_recur.contact_id',
294 'table_name' => 'civicrm_contribution_recur',
295 'entity' => 'ContributionRecur',
296 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
298 'FKClassName' => 'CRM_Contact_DAO_Contact',
300 'type' => 'EntityRef',
306 'type' => CRM_Utils_Type
::T_MONEY
,
307 'title' => ts('Amount'),
308 'description' => ts('Amount to be collected (including any sales tax) by payment processor each recurrence.'),
314 'where' => 'civicrm_contribution_recur.amount',
315 'table_name' => 'civicrm_contribution_recur',
316 'entity' => 'ContributionRecur',
317 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
325 'name' => 'currency',
326 'type' => CRM_Utils_Type
::T_STRING
,
327 'title' => ts('Currency'),
328 'description' => ts('3 character string, value from config setting or input via user.'),
330 'size' => CRM_Utils_Type
::FOUR
,
331 'where' => 'civicrm_contribution_recur.currency',
333 'table_name' => 'civicrm_contribution_recur',
334 'entity' => 'ContributionRecur',
335 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
340 'pseudoconstant' => [
341 'table' => 'civicrm_currency',
342 'keyColumn' => 'name',
343 'labelColumn' => 'full_name',
344 'nameColumn' => 'name',
345 'abbrColumn' => 'symbol',
349 'frequency_unit' => [
350 'name' => 'frequency_unit',
351 'type' => CRM_Utils_Type
::T_STRING
,
352 'title' => ts('Frequency Unit'),
353 'description' => ts('Time units for recurrence of payment.'),
355 'size' => CRM_Utils_Type
::EIGHT
,
356 'where' => 'civicrm_contribution_recur.frequency_unit',
357 'default' => 'month',
358 'table_name' => 'civicrm_contribution_recur',
359 'entity' => 'ContributionRecur',
360 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
365 'pseudoconstant' => [
366 'optionGroupName' => 'recur_frequency_units',
367 'keyColumn' => 'name',
368 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
372 'frequency_interval' => [
373 'name' => 'frequency_interval',
374 'type' => CRM_Utils_Type
::T_INT
,
375 'title' => ts('Interval (number of units)'),
376 'description' => ts('Number of time units for recurrence of payment.'),
378 'where' => 'civicrm_contribution_recur.frequency_interval',
379 'table_name' => 'civicrm_contribution_recur',
380 'entity' => 'ContributionRecur',
381 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
389 'name' => 'installments',
390 'type' => CRM_Utils_Type
::T_INT
,
391 'title' => ts('Number of Installments'),
392 '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.'),
393 'where' => 'civicrm_contribution_recur.installments',
394 'table_name' => 'civicrm_contribution_recur',
395 'entity' => 'ContributionRecur',
396 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
403 'contribution_recur_start_date' => [
404 'name' => 'start_date',
405 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
406 'title' => ts('Start Date'),
407 'description' => ts('The date the first scheduled recurring contribution occurs.'),
409 'where' => 'civicrm_contribution_recur.start_date',
410 'table_name' => 'civicrm_contribution_recur',
411 'entity' => 'ContributionRecur',
412 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
414 'unique_title' => ts('Recurring Contribution Start Date'),
416 'type' => 'Select Date',
417 'formatType' => 'activityDateTime',
421 'contribution_recur_create_date' => [
422 'name' => 'create_date',
423 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
424 'title' => ts('Created Date'),
425 'description' => ts('When this recurring contribution record was created.'),
427 'where' => 'civicrm_contribution_recur.create_date',
428 'table_name' => 'civicrm_contribution_recur',
429 'entity' => 'ContributionRecur',
430 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
432 'unique_title' => ts('Recurring Contribution Create Date'),
434 'type' => 'Select Date',
435 'formatType' => 'activityDateTime',
439 'contribution_recur_modified_date' => [
440 'name' => 'modified_date',
441 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
442 'title' => ts('Modified Date'),
443 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
444 'where' => 'civicrm_contribution_recur.modified_date',
445 'table_name' => 'civicrm_contribution_recur',
446 'entity' => 'ContributionRecur',
447 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
449 'unique_title' => ts('Recurring Contribution Modified Date'),
451 'type' => 'Select Date',
452 'formatType' => 'activityDateTime',
456 'contribution_recur_cancel_date' => [
457 'name' => 'cancel_date',
458 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
459 'title' => ts('Cancel Date'),
460 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
461 'where' => 'civicrm_contribution_recur.cancel_date',
462 'table_name' => 'civicrm_contribution_recur',
463 'entity' => 'ContributionRecur',
464 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
466 'unique_title' => ts('Recurring Contribution Cancel Date'),
468 'type' => 'Select Date',
469 'formatType' => 'activityDate',
473 'contribution_recur_cancel_reason' => [
474 'name' => 'cancel_reason',
475 'type' => CRM_Utils_Type
::T_TEXT
,
476 'title' => ts('Cancellation Reason'),
477 'description' => ts('Free text field for a reason for cancelling'),
478 'where' => 'civicrm_contribution_recur.cancel_reason',
479 'table_name' => 'civicrm_contribution_recur',
480 'entity' => 'ContributionRecur',
481 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
483 'unique_title' => ts('Recurring Contribution Cancel Reason'),
489 'contribution_recur_end_date' => [
490 'name' => 'end_date',
491 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
492 'title' => ts('Recurring Contribution End Date'),
493 'description' => ts('Date this recurring contribution finished successfully'),
494 'where' => 'civicrm_contribution_recur.end_date',
495 'table_name' => 'civicrm_contribution_recur',
496 'entity' => 'ContributionRecur',
497 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
499 'unique_title' => ts('Recurring Contribution End Date'),
501 'type' => 'Select Date',
502 'formatType' => 'activityDate',
506 'contribution_recur_processor_id' => [
507 'name' => 'processor_id',
508 'type' => CRM_Utils_Type
::T_STRING
,
509 'title' => ts('Processor ID'),
510 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
512 'size' => CRM_Utils_Type
::HUGE
,
513 'where' => 'civicrm_contribution_recur.processor_id',
514 'table_name' => 'civicrm_contribution_recur',
515 'entity' => 'ContributionRecur',
516 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
523 'payment_token_id' => [
524 'name' => 'payment_token_id',
525 'type' => CRM_Utils_Type
::T_INT
,
526 'title' => ts('Payment Token ID'),
527 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
528 'where' => 'civicrm_contribution_recur.payment_token_id',
529 'table_name' => 'civicrm_contribution_recur',
530 'entity' => 'ContributionRecur',
531 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
533 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
536 'contribution_recur_trxn_id' => [
538 'type' => CRM_Utils_Type
::T_STRING
,
539 'title' => ts('Transaction ID'),
540 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
542 'size' => CRM_Utils_Type
::HUGE
,
543 'where' => 'civicrm_contribution_recur.trxn_id',
544 'table_name' => 'civicrm_contribution_recur',
545 'entity' => 'ContributionRecur',
546 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
554 'name' => 'invoice_id',
555 'type' => CRM_Utils_Type
::T_STRING
,
556 'title' => ts('Invoice ID'),
557 'description' => ts('unique invoice id, system generated or passed in'),
559 'size' => CRM_Utils_Type
::HUGE
,
560 'where' => 'civicrm_contribution_recur.invoice_id',
561 'table_name' => 'civicrm_contribution_recur',
562 'entity' => 'ContributionRecur',
563 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
570 'contribution_recur_contribution_status_id' => [
571 'name' => 'contribution_status_id',
572 'type' => CRM_Utils_Type
::T_INT
,
573 'title' => ts('Status'),
575 'where' => 'civicrm_contribution_recur.contribution_status_id',
578 'table_name' => 'civicrm_contribution_recur',
579 'entity' => 'ContributionRecur',
580 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
585 'pseudoconstant' => [
586 'optionGroupName' => 'contribution_recur_status',
587 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
593 'type' => CRM_Utils_Type
::T_BOOLEAN
,
594 'title' => ts('Test'),
596 'where' => 'civicrm_contribution_recur.is_test',
599 'table_name' => 'civicrm_contribution_recur',
600 'entity' => 'ContributionRecur',
601 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
604 'type' => 'CheckBox',
609 'name' => 'cycle_day',
610 'type' => CRM_Utils_Type
::T_INT
,
611 'title' => ts('Cycle Day'),
612 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
614 'where' => 'civicrm_contribution_recur.cycle_day',
616 'table_name' => 'civicrm_contribution_recur',
617 'entity' => 'ContributionRecur',
618 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
625 'contribution_recur_next_sched_contribution_date' => [
626 'name' => 'next_sched_contribution_date',
627 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
628 'title' => ts('Next Scheduled Contribution Date'),
629 'description' => ts('Next scheduled date'),
630 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
631 'table_name' => 'civicrm_contribution_recur',
632 'entity' => 'ContributionRecur',
633 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
635 'unique_title' => ts('Next Scheduled Recurring Contribution'),
637 'type' => 'Select Date',
638 'formatType' => 'activityDate',
643 'name' => 'failure_count',
644 'type' => CRM_Utils_Type
::T_INT
,
645 'title' => ts('Number of Failures'),
646 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
647 'where' => 'civicrm_contribution_recur.failure_count',
649 'table_name' => 'civicrm_contribution_recur',
650 'entity' => 'ContributionRecur',
651 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
658 'contribution_recur_failure_retry_date' => [
659 'name' => 'failure_retry_date',
660 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
661 'title' => ts('Retry Failed Attempt Date'),
662 'description' => ts('Date to retry failed attempt'),
663 'where' => 'civicrm_contribution_recur.failure_retry_date',
664 'table_name' => 'civicrm_contribution_recur',
665 'entity' => 'ContributionRecur',
666 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
668 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
670 'type' => 'Select Date',
671 'formatType' => 'activityDate',
676 'name' => 'auto_renew',
677 'type' => CRM_Utils_Type
::T_BOOLEAN
,
678 'title' => ts('Auto Renew'),
679 '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.'),
681 'where' => 'civicrm_contribution_recur.auto_renew',
683 'table_name' => 'civicrm_contribution_recur',
684 'entity' => 'ContributionRecur',
685 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
688 'type' => 'CheckBox',
692 'contribution_recur_payment_processor_id' => [
693 'name' => 'payment_processor_id',
694 'type' => CRM_Utils_Type
::T_INT
,
695 'title' => ts('Payment Processor'),
696 'description' => ts('Foreign key to civicrm_payment_processor.id'),
697 'where' => 'civicrm_contribution_recur.payment_processor_id',
698 'table_name' => 'civicrm_contribution_recur',
699 'entity' => 'ContributionRecur',
700 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
702 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
706 'pseudoconstant' => [
707 'table' => 'civicrm_payment_processor',
709 'labelColumn' => 'name',
713 'financial_type_id' => [
714 'name' => 'financial_type_id',
715 'type' => CRM_Utils_Type
::T_INT
,
716 'title' => ts('Financial Type'),
717 'description' => ts('FK to Financial Type'),
718 'where' => 'civicrm_contribution_recur.financial_type_id',
720 'table_name' => 'civicrm_contribution_recur',
721 'entity' => 'ContributionRecur',
722 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
724 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
728 'pseudoconstant' => [
729 'table' => 'civicrm_financial_type',
731 'labelColumn' => 'name',
735 'payment_instrument_id' => [
736 'name' => 'payment_instrument_id',
737 'type' => CRM_Utils_Type
::T_INT
,
738 'title' => ts('Payment Method'),
739 'description' => ts('FK to Payment Instrument'),
740 'where' => 'civicrm_contribution_recur.payment_instrument_id',
741 'table_name' => 'civicrm_contribution_recur',
742 'entity' => 'ContributionRecur',
743 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
748 'pseudoconstant' => [
749 'optionGroupName' => 'payment_instrument',
750 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
754 'contribution_campaign_id' => [
755 'name' => 'campaign_id',
756 'type' => CRM_Utils_Type
::T_INT
,
757 'title' => ts('Campaign'),
758 'description' => ts('The campaign for which this contribution has been triggered.'),
760 'where' => 'civicrm_contribution_recur.campaign_id',
762 'table_name' => 'civicrm_contribution_recur',
763 'entity' => 'ContributionRecur',
764 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
766 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
770 'pseudoconstant' => [
771 'table' => 'civicrm_campaign',
773 'labelColumn' => 'title',
777 'is_email_receipt' => [
778 'name' => 'is_email_receipt',
779 'type' => CRM_Utils_Type
::T_BOOLEAN
,
780 'title' => ts('Send email Receipt?'),
781 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
782 'where' => 'civicrm_contribution_recur.is_email_receipt',
784 'table_name' => 'civicrm_contribution_recur',
785 'entity' => 'ContributionRecur',
786 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
789 'type' => 'CheckBox',
794 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
796 return Civi
::$statics[__CLASS__
]['fields'];
800 * Return a mapping from field-name to the corresponding key (as used in fields()).
803 * Array(string $name => string $uniqueName).
805 public static function &fieldKeys() {
806 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
807 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
809 return Civi
::$statics[__CLASS__
]['fieldKeys'];
813 * Returns the names of this table
817 public static function getTableName() {
818 return self
::$_tableName;
822 * Returns if this table needs to be logged
826 public function getLog() {
831 * Returns the list of fields that can be imported
833 * @param bool $prefix
837 public static function &import($prefix = FALSE) {
838 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
843 * Returns the list of fields that can be exported
845 * @param bool $prefix
849 public static function &export($prefix = FALSE) {
850 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
855 * Returns the list of indices
857 * @param bool $localize
861 public static function indices($localize = TRUE) {
863 'UI_contrib_trxn_id' => [
864 'name' => 'UI_contrib_trxn_id',
868 'localizable' => FALSE,
870 'sig' => 'civicrm_contribution_recur::1::trxn_id',
872 'UI_contrib_invoice_id' => [
873 'name' => 'UI_contrib_invoice_id',
877 'localizable' => FALSE,
879 'sig' => 'civicrm_contribution_recur::1::invoice_id',
881 'index_contribution_status' => [
882 'name' => 'index_contribution_status',
884 0 => 'contribution_status_id',
886 'localizable' => FALSE,
887 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
889 'UI_contribution_recur_payment_instrument_id' => [
890 'name' => 'UI_contribution_recur_payment_instrument_id',
892 0 => 'payment_instrument_id',
894 'localizable' => FALSE,
895 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
898 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;