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:95610d5dfc95017698041a9e814a7cda)
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',
386 'contribution_recur_start_date' => [
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',
397 'unique_title' => ts('Recurring Contribution Start Date'),
399 'type' => 'Select Date',
400 'formatType' => 'activityDateTime',
403 'contribution_recur_create_date' => [
404 'name' => 'create_date',
405 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
406 'title' => ts('Created Date'),
407 'description' => ts('When this recurring contribution record was created.'),
409 'where' => 'civicrm_contribution_recur.create_date',
410 'table_name' => 'civicrm_contribution_recur',
411 'entity' => 'ContributionRecur',
412 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
414 'unique_title' => ts('Recurring Contribution Create Date'),
416 'type' => 'Select Date',
417 'formatType' => 'activityDateTime',
420 'contribution_recur_modified_date' => [
421 'name' => 'modified_date',
422 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
423 'title' => ts('Modified Date'),
424 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
425 'where' => 'civicrm_contribution_recur.modified_date',
426 'table_name' => 'civicrm_contribution_recur',
427 'entity' => 'ContributionRecur',
428 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
430 'unique_title' => ts('Recurring Contribution Modified Date'),
432 'type' => 'Select Date',
433 'formatType' => 'activityDateTime',
436 'contribution_recur_cancel_date' => [
437 'name' => 'cancel_date',
438 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
439 'title' => ts('Cancel Date'),
440 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
441 'where' => 'civicrm_contribution_recur.cancel_date',
442 'table_name' => 'civicrm_contribution_recur',
443 'entity' => 'ContributionRecur',
444 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
446 'unique_title' => ts('Recurring Contribution Cancel Date'),
448 'type' => 'Select Date',
449 'formatType' => 'activityDate',
452 'contribution_recur_cancel_reason' => [
453 'name' => 'cancel_reason',
454 'type' => CRM_Utils_Type
::T_TEXT
,
455 'title' => ts('Cancellation Reason'),
456 'description' => ts('Free text field for a reason for cancelling'),
457 'where' => 'civicrm_contribution_recur.cancel_reason',
458 'table_name' => 'civicrm_contribution_recur',
459 'entity' => 'ContributionRecur',
460 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
462 'unique_title' => ts('Recurring Contribution Cancel Reason'),
467 'contribution_recur_end_date' => [
468 'name' => 'end_date',
469 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
470 'title' => ts('Recurring Contribution End Date'),
471 'description' => ts('Date this recurring contribution finished successfully'),
472 'where' => 'civicrm_contribution_recur.end_date',
473 'table_name' => 'civicrm_contribution_recur',
474 'entity' => 'ContributionRecur',
475 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
477 'unique_title' => ts('Recurring Contribution End Date'),
479 'type' => 'Select Date',
480 'formatType' => 'activityDate',
483 'contribution_recur_processor_id' => [
484 'name' => 'processor_id',
485 'type' => CRM_Utils_Type
::T_STRING
,
486 'title' => ts('Processor ID'),
487 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
489 'size' => CRM_Utils_Type
::HUGE
,
490 'where' => 'civicrm_contribution_recur.processor_id',
491 'table_name' => 'civicrm_contribution_recur',
492 'entity' => 'ContributionRecur',
493 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
499 'payment_token_id' => [
500 'name' => 'payment_token_id',
501 'type' => CRM_Utils_Type
::T_INT
,
502 'title' => ts('Payment Token ID'),
503 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
504 'where' => 'civicrm_contribution_recur.payment_token_id',
505 'table_name' => 'civicrm_contribution_recur',
506 'entity' => 'ContributionRecur',
507 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
509 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
511 'contribution_recur_trxn_id' => [
513 'type' => CRM_Utils_Type
::T_STRING
,
514 'title' => ts('Transaction ID'),
515 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
517 'size' => CRM_Utils_Type
::HUGE
,
518 'where' => 'civicrm_contribution_recur.trxn_id',
519 'table_name' => 'civicrm_contribution_recur',
520 'entity' => 'ContributionRecur',
521 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
528 'name' => 'invoice_id',
529 'type' => CRM_Utils_Type
::T_STRING
,
530 'title' => ts('Invoice ID'),
531 'description' => ts('unique invoice id, system generated or passed in'),
533 'size' => CRM_Utils_Type
::HUGE
,
534 'where' => 'civicrm_contribution_recur.invoice_id',
535 'table_name' => 'civicrm_contribution_recur',
536 'entity' => 'ContributionRecur',
537 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
543 'contribution_recur_contribution_status_id' => [
544 'name' => 'contribution_status_id',
545 'type' => CRM_Utils_Type
::T_INT
,
546 'title' => ts('Status'),
548 'where' => 'civicrm_contribution_recur.contribution_status_id',
551 'table_name' => 'civicrm_contribution_recur',
552 'entity' => 'ContributionRecur',
553 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
558 'pseudoconstant' => [
559 'optionGroupName' => 'contribution_recur_status',
560 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
565 'type' => CRM_Utils_Type
::T_BOOLEAN
,
566 'title' => ts('Test'),
568 'where' => 'civicrm_contribution_recur.is_test',
571 'table_name' => 'civicrm_contribution_recur',
572 'entity' => 'ContributionRecur',
573 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
576 'type' => 'CheckBox',
580 'name' => 'cycle_day',
581 'type' => CRM_Utils_Type
::T_INT
,
582 'title' => ts('Cycle Day'),
583 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
585 'where' => 'civicrm_contribution_recur.cycle_day',
587 'table_name' => 'civicrm_contribution_recur',
588 'entity' => 'ContributionRecur',
589 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
595 'contribution_recur_next_sched_contribution_date' => [
596 'name' => 'next_sched_contribution_date',
597 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
598 'title' => ts('Next Scheduled Contribution Date'),
599 'description' => ts('Next scheduled date'),
600 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
601 'table_name' => 'civicrm_contribution_recur',
602 'entity' => 'ContributionRecur',
603 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
605 'unique_title' => ts('Next Scheduled Recurring Contribution'),
607 'type' => 'Select Date',
608 'formatType' => 'activityDate',
612 'name' => 'failure_count',
613 'type' => CRM_Utils_Type
::T_INT
,
614 'title' => ts('Number of Failures'),
615 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
616 'where' => 'civicrm_contribution_recur.failure_count',
618 'table_name' => 'civicrm_contribution_recur',
619 'entity' => 'ContributionRecur',
620 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
626 'contribution_recur_failure_retry_date' => [
627 'name' => 'failure_retry_date',
628 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
629 'title' => ts('Retry Failed Attempt Date'),
630 'description' => ts('Date to retry failed attempt'),
631 'where' => 'civicrm_contribution_recur.failure_retry_date',
632 'table_name' => 'civicrm_contribution_recur',
633 'entity' => 'ContributionRecur',
634 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
636 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
638 'type' => 'Select Date',
639 'formatType' => 'activityDate',
643 'name' => 'auto_renew',
644 'type' => CRM_Utils_Type
::T_BOOLEAN
,
645 'title' => ts('Auto Renew'),
646 '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.'),
648 'where' => 'civicrm_contribution_recur.auto_renew',
650 'table_name' => 'civicrm_contribution_recur',
651 'entity' => 'ContributionRecur',
652 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
655 'type' => 'CheckBox',
658 'contribution_recur_payment_processor_id' => [
659 'name' => 'payment_processor_id',
660 'type' => CRM_Utils_Type
::T_INT
,
661 'title' => ts('Payment Processor'),
662 'description' => ts('Foreign key to civicrm_payment_processor.id'),
663 'where' => 'civicrm_contribution_recur.payment_processor_id',
664 'table_name' => 'civicrm_contribution_recur',
665 'entity' => 'ContributionRecur',
666 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
668 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
672 'pseudoconstant' => [
673 'table' => 'civicrm_payment_processor',
675 'labelColumn' => 'name',
678 'financial_type_id' => [
679 'name' => 'financial_type_id',
680 'type' => CRM_Utils_Type
::T_INT
,
681 'title' => ts('Financial Type'),
682 'description' => ts('FK to Financial Type'),
683 'where' => 'civicrm_contribution_recur.financial_type_id',
685 'table_name' => 'civicrm_contribution_recur',
686 'entity' => 'ContributionRecur',
687 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
689 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
693 'pseudoconstant' => [
694 'table' => 'civicrm_financial_type',
696 'labelColumn' => 'name',
699 'payment_instrument_id' => [
700 'name' => 'payment_instrument_id',
701 'type' => CRM_Utils_Type
::T_INT
,
702 'title' => ts('Payment Method'),
703 'description' => ts('FK to Payment Instrument'),
704 'where' => 'civicrm_contribution_recur.payment_instrument_id',
705 'table_name' => 'civicrm_contribution_recur',
706 'entity' => 'ContributionRecur',
707 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
712 'pseudoconstant' => [
713 'optionGroupName' => 'payment_instrument',
714 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
717 'contribution_campaign_id' => [
718 'name' => 'campaign_id',
719 'type' => CRM_Utils_Type
::T_INT
,
720 'title' => ts('Campaign'),
721 'description' => ts('The campaign for which this contribution has been triggered.'),
723 'where' => 'civicrm_contribution_recur.campaign_id',
725 'table_name' => 'civicrm_contribution_recur',
726 'entity' => 'ContributionRecur',
727 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
729 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
733 'pseudoconstant' => [
734 'table' => 'civicrm_campaign',
736 'labelColumn' => 'title',
739 'is_email_receipt' => [
740 'name' => 'is_email_receipt',
741 'type' => CRM_Utils_Type
::T_BOOLEAN
,
742 'title' => ts('Send email Receipt?'),
743 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
744 'where' => 'civicrm_contribution_recur.is_email_receipt',
746 'table_name' => 'civicrm_contribution_recur',
747 'entity' => 'ContributionRecur',
748 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
751 'type' => 'CheckBox',
755 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
757 return Civi
::$statics[__CLASS__
]['fields'];
761 * Return a mapping from field-name to the corresponding key (as used in fields()).
764 * Array(string $name => string $uniqueName).
766 public static function &fieldKeys() {
767 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
768 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
770 return Civi
::$statics[__CLASS__
]['fieldKeys'];
774 * Returns the names of this table
778 public static function getTableName() {
779 return self
::$_tableName;
783 * Returns if this table needs to be logged
787 public function getLog() {
792 * Returns the list of fields that can be imported
794 * @param bool $prefix
798 public static function &import($prefix = FALSE) {
799 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
804 * Returns the list of fields that can be exported
806 * @param bool $prefix
810 public static function &export($prefix = FALSE) {
811 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
816 * Returns the list of indices
818 * @param bool $localize
822 public static function indices($localize = TRUE) {
824 'UI_contrib_trxn_id' => [
825 'name' => 'UI_contrib_trxn_id',
829 'localizable' => FALSE,
831 'sig' => 'civicrm_contribution_recur::1::trxn_id',
833 'UI_contrib_invoice_id' => [
834 'name' => 'UI_contrib_invoice_id',
838 'localizable' => FALSE,
840 'sig' => 'civicrm_contribution_recur::1::invoice_id',
842 'index_contribution_status' => [
843 'name' => 'index_contribution_status',
845 0 => 'contribution_status_id',
847 'localizable' => FALSE,
848 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
850 'UI_contribution_recur_payment_instrument_id' => [
851 'name' => 'UI_contribution_recur_payment_instrument_id',
853 0 => 'payment_instrument_id',
855 'localizable' => FALSE,
856 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
859 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;