5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1efdc763e4b5337f0dc4f9f13bd2d719)
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 contributed or charged 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 foreign keys and entity references.
242 * [CRM_Core_Reference_Interface]
244 public static function getReferenceColumns() {
245 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
246 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
247 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
248 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
249 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
250 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
251 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
252 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
254 return Civi
::$statics[__CLASS__
]['links'];
258 * Returns all the column names of this table
262 public static function &fields() {
263 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
264 Civi
::$statics[__CLASS__
]['fields'] = [
265 'contribution_recur_id' => [
267 'type' => CRM_Utils_Type
::T_INT
,
268 'title' => ts('Recurring Contribution ID'),
269 'description' => ts('Contribution Recur ID'),
271 'where' => 'civicrm_contribution_recur.id',
272 'table_name' => 'civicrm_contribution_recur',
273 'entity' => 'ContributionRecur',
274 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
278 'name' => 'contact_id',
279 'type' => CRM_Utils_Type
::T_INT
,
280 'title' => ts('Contact'),
281 'description' => ts('Foreign key to civicrm_contact.id.'),
283 'where' => 'civicrm_contribution_recur.contact_id',
284 'table_name' => 'civicrm_contribution_recur',
285 'entity' => 'ContributionRecur',
286 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
288 'FKClassName' => 'CRM_Contact_DAO_Contact',
290 'type' => 'EntityRef',
295 'type' => CRM_Utils_Type
::T_MONEY
,
296 'title' => ts('Amount'),
297 'description' => ts('Amount to be contributed or charged each recurrence.'),
303 'where' => 'civicrm_contribution_recur.amount',
304 'table_name' => 'civicrm_contribution_recur',
305 'entity' => 'ContributionRecur',
306 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
313 'name' => 'currency',
314 'type' => CRM_Utils_Type
::T_STRING
,
315 'title' => ts('Currency'),
316 'description' => ts('3 character string, value from config setting or input via user.'),
318 'size' => CRM_Utils_Type
::FOUR
,
319 'where' => 'civicrm_contribution_recur.currency',
321 'table_name' => 'civicrm_contribution_recur',
322 'entity' => 'ContributionRecur',
323 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
328 'pseudoconstant' => [
329 'table' => 'civicrm_currency',
330 'keyColumn' => 'name',
331 'labelColumn' => 'full_name',
332 'nameColumn' => 'name',
335 'frequency_unit' => [
336 'name' => 'frequency_unit',
337 'type' => CRM_Utils_Type
::T_STRING
,
338 'title' => ts('Frequency Unit'),
339 'description' => ts('Time units for recurrence of payment.'),
341 'size' => CRM_Utils_Type
::EIGHT
,
342 'where' => 'civicrm_contribution_recur.frequency_unit',
343 'default' => 'month',
344 'table_name' => 'civicrm_contribution_recur',
345 'entity' => 'ContributionRecur',
346 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
351 'pseudoconstant' => [
352 'optionGroupName' => 'recur_frequency_units',
353 'keyColumn' => 'name',
354 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
357 'frequency_interval' => [
358 'name' => 'frequency_interval',
359 'type' => CRM_Utils_Type
::T_INT
,
360 'title' => ts('Interval (number of units)'),
361 'description' => ts('Number of time units for recurrence of payment.'),
363 'where' => 'civicrm_contribution_recur.frequency_interval',
364 'table_name' => 'civicrm_contribution_recur',
365 'entity' => 'ContributionRecur',
366 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
373 'name' => 'installments',
374 'type' => CRM_Utils_Type
::T_INT
,
375 'title' => ts('Number of Installments'),
376 '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.'),
377 'where' => 'civicrm_contribution_recur.installments',
378 'table_name' => 'civicrm_contribution_recur',
379 'entity' => 'ContributionRecur',
380 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
387 'name' => 'start_date',
388 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
389 'title' => ts('Start Date'),
390 'description' => ts('The date the first scheduled recurring contribution occurs.'),
392 'where' => 'civicrm_contribution_recur.start_date',
393 'table_name' => 'civicrm_contribution_recur',
394 'entity' => 'ContributionRecur',
395 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
398 'type' => 'Select Date',
399 'formatType' => 'activityDateTime',
403 'name' => 'create_date',
404 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
405 'title' => ts('Created Date'),
406 'description' => ts('When this recurring contribution record was created.'),
408 'where' => 'civicrm_contribution_recur.create_date',
409 'table_name' => 'civicrm_contribution_recur',
410 'entity' => 'ContributionRecur',
411 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
414 'type' => 'Select Date',
415 'formatType' => 'activityDateTime',
419 'name' => 'modified_date',
420 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
421 'title' => ts('Modified Date'),
422 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
423 'where' => 'civicrm_contribution_recur.modified_date',
424 'table_name' => 'civicrm_contribution_recur',
425 'entity' => 'ContributionRecur',
426 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
429 'type' => 'Select Date',
430 'formatType' => 'activityDateTime',
434 'name' => 'cancel_date',
435 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
436 'title' => ts('Cancel Date'),
437 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
438 'where' => 'civicrm_contribution_recur.cancel_date',
439 'table_name' => 'civicrm_contribution_recur',
440 'entity' => 'ContributionRecur',
441 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
444 'type' => 'Select Date',
445 'formatType' => 'activityDate',
448 'contribution_recur_cancel_reason' => [
449 'name' => 'cancel_reason',
450 'type' => CRM_Utils_Type
::T_TEXT
,
451 'title' => ts('Cancellation Reason'),
452 'description' => ts('Free text field for a reason for cancelling'),
453 'where' => 'civicrm_contribution_recur.cancel_reason',
454 'table_name' => 'civicrm_contribution_recur',
455 'entity' => 'ContributionRecur',
456 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
463 'name' => 'end_date',
464 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
465 'title' => ts('Recurring Contribution End Date'),
466 'description' => ts('Date this recurring contribution finished successfully'),
467 'where' => 'civicrm_contribution_recur.end_date',
468 'table_name' => 'civicrm_contribution_recur',
469 'entity' => 'ContributionRecur',
470 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
473 'type' => 'Select Date',
474 'formatType' => 'activityDate',
477 'contribution_recur_processor_id' => [
478 'name' => 'processor_id',
479 'type' => CRM_Utils_Type
::T_STRING
,
480 'title' => ts('Processor ID'),
481 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
483 'size' => CRM_Utils_Type
::HUGE
,
484 'where' => 'civicrm_contribution_recur.processor_id',
485 'table_name' => 'civicrm_contribution_recur',
486 'entity' => 'ContributionRecur',
487 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
493 'payment_token_id' => [
494 'name' => 'payment_token_id',
495 'type' => CRM_Utils_Type
::T_INT
,
496 'title' => ts('Payment Token ID'),
497 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
498 'where' => 'civicrm_contribution_recur.payment_token_id',
499 'table_name' => 'civicrm_contribution_recur',
500 'entity' => 'ContributionRecur',
501 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
503 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
505 'contribution_recur_trxn_id' => [
507 'type' => CRM_Utils_Type
::T_STRING
,
508 'title' => ts('Transaction ID'),
509 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
511 'size' => CRM_Utils_Type
::HUGE
,
512 'where' => 'civicrm_contribution_recur.trxn_id',
513 'table_name' => 'civicrm_contribution_recur',
514 'entity' => 'ContributionRecur',
515 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
522 'name' => 'invoice_id',
523 'type' => CRM_Utils_Type
::T_STRING
,
524 'title' => ts('Invoice ID'),
525 'description' => ts('unique invoice id, system generated or passed in'),
527 'size' => CRM_Utils_Type
::HUGE
,
528 'where' => 'civicrm_contribution_recur.invoice_id',
529 'table_name' => 'civicrm_contribution_recur',
530 'entity' => 'ContributionRecur',
531 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
537 'contribution_recur_contribution_status_id' => [
538 'name' => 'contribution_status_id',
539 'type' => CRM_Utils_Type
::T_INT
,
540 'title' => ts('Status'),
542 'where' => 'civicrm_contribution_recur.contribution_status_id',
545 'table_name' => 'civicrm_contribution_recur',
546 'entity' => 'ContributionRecur',
547 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
552 'pseudoconstant' => [
553 'optionGroupName' => 'contribution_recur_status',
554 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
559 'type' => CRM_Utils_Type
::T_BOOLEAN
,
560 'title' => ts('Test'),
562 'where' => 'civicrm_contribution_recur.is_test',
565 'table_name' => 'civicrm_contribution_recur',
566 'entity' => 'ContributionRecur',
567 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
570 'type' => 'CheckBox',
574 'name' => 'cycle_day',
575 'type' => CRM_Utils_Type
::T_INT
,
576 'title' => ts('Cycle Day'),
577 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
579 'where' => 'civicrm_contribution_recur.cycle_day',
581 'table_name' => 'civicrm_contribution_recur',
582 'entity' => 'ContributionRecur',
583 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
589 'next_sched_contribution_date' => [
590 'name' => 'next_sched_contribution_date',
591 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
592 'title' => ts('Next Scheduled Contribution Date'),
593 'description' => ts('Next scheduled date'),
594 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
595 'table_name' => 'civicrm_contribution_recur',
596 'entity' => 'ContributionRecur',
597 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
600 'type' => 'Select Date',
601 'formatType' => 'activityDate',
605 'name' => 'failure_count',
606 'type' => CRM_Utils_Type
::T_INT
,
607 'title' => ts('Number of Failures'),
608 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
609 'where' => 'civicrm_contribution_recur.failure_count',
611 'table_name' => 'civicrm_contribution_recur',
612 'entity' => 'ContributionRecur',
613 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
619 'failure_retry_date' => [
620 'name' => 'failure_retry_date',
621 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
622 'title' => ts('Retry Failed Attempt Date'),
623 'description' => ts('Date to retry failed attempt'),
624 'where' => 'civicrm_contribution_recur.failure_retry_date',
625 'table_name' => 'civicrm_contribution_recur',
626 'entity' => 'ContributionRecur',
627 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
630 'type' => 'Select Date',
631 'formatType' => 'activityDate',
635 'name' => 'auto_renew',
636 'type' => CRM_Utils_Type
::T_BOOLEAN
,
637 'title' => ts('Auto Renew'),
638 '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.'),
640 'where' => 'civicrm_contribution_recur.auto_renew',
642 'table_name' => 'civicrm_contribution_recur',
643 'entity' => 'ContributionRecur',
644 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
647 'type' => 'CheckBox',
650 'contribution_recur_payment_processor_id' => [
651 'name' => 'payment_processor_id',
652 'type' => CRM_Utils_Type
::T_INT
,
653 'title' => ts('Payment Processor'),
654 'description' => ts('Foreign key to civicrm_payment_processor.id'),
655 'where' => 'civicrm_contribution_recur.payment_processor_id',
656 'table_name' => 'civicrm_contribution_recur',
657 'entity' => 'ContributionRecur',
658 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
660 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
664 'pseudoconstant' => [
665 'table' => 'civicrm_payment_processor',
667 'labelColumn' => 'name',
670 'financial_type_id' => [
671 'name' => 'financial_type_id',
672 'type' => CRM_Utils_Type
::T_INT
,
673 'title' => ts('Financial Type'),
674 'description' => ts('FK to Financial Type'),
675 'where' => 'civicrm_contribution_recur.financial_type_id',
677 'table_name' => 'civicrm_contribution_recur',
678 'entity' => 'ContributionRecur',
679 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
681 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
685 'pseudoconstant' => [
686 'table' => 'civicrm_financial_type',
688 'labelColumn' => 'name',
691 'payment_instrument_id' => [
692 'name' => 'payment_instrument_id',
693 'type' => CRM_Utils_Type
::T_INT
,
694 'title' => ts('Payment Method'),
695 'description' => ts('FK to Payment Instrument'),
696 'where' => 'civicrm_contribution_recur.payment_instrument_id',
697 'table_name' => 'civicrm_contribution_recur',
698 'entity' => 'ContributionRecur',
699 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
704 'pseudoconstant' => [
705 'optionGroupName' => 'payment_instrument',
706 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
709 'contribution_campaign_id' => [
710 'name' => 'campaign_id',
711 'type' => CRM_Utils_Type
::T_INT
,
712 'title' => ts('Campaign'),
713 'description' => ts('The campaign for which this contribution has been triggered.'),
715 'where' => 'civicrm_contribution_recur.campaign_id',
717 'table_name' => 'civicrm_contribution_recur',
718 'entity' => 'ContributionRecur',
719 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
721 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
725 'pseudoconstant' => [
726 'table' => 'civicrm_campaign',
728 'labelColumn' => 'title',
731 'is_email_receipt' => [
732 'name' => 'is_email_receipt',
733 'type' => CRM_Utils_Type
::T_BOOLEAN
,
734 'title' => ts('Send email Receipt?'),
735 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
736 'where' => 'civicrm_contribution_recur.is_email_receipt',
738 'table_name' => 'civicrm_contribution_recur',
739 'entity' => 'ContributionRecur',
740 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
743 'type' => 'CheckBox',
747 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
749 return Civi
::$statics[__CLASS__
]['fields'];
753 * Return a mapping from field-name to the corresponding key (as used in fields()).
756 * Array(string $name => string $uniqueName).
758 public static function &fieldKeys() {
759 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
760 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
762 return Civi
::$statics[__CLASS__
]['fieldKeys'];
766 * Returns the names of this table
770 public static function getTableName() {
771 return self
::$_tableName;
775 * Returns if this table needs to be logged
779 public function getLog() {
784 * Returns the list of fields that can be imported
786 * @param bool $prefix
790 public static function &import($prefix = FALSE) {
791 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
796 * Returns the list of fields that can be exported
798 * @param bool $prefix
802 public static function &export($prefix = FALSE) {
803 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
808 * Returns the list of indices
810 * @param bool $localize
814 public static function indices($localize = TRUE) {
816 'UI_contrib_trxn_id' => [
817 'name' => 'UI_contrib_trxn_id',
821 'localizable' => FALSE,
823 'sig' => 'civicrm_contribution_recur::1::trxn_id',
825 'UI_contrib_invoice_id' => [
826 'name' => 'UI_contrib_invoice_id',
830 'localizable' => FALSE,
832 'sig' => 'civicrm_contribution_recur::1::invoice_id',
834 'index_contribution_status' => [
835 'name' => 'index_contribution_status',
837 0 => 'contribution_status_id',
839 'localizable' => FALSE,
840 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
842 'UI_contribution_recur_payment_instrument_id' => [
843 'name' => 'UI_contribution_recur_payment_instrument_id',
845 0 => 'payment_instrument_id',
847 'localizable' => FALSE,
848 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
851 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;