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:1eb0ecd4aadee175dadb66464c06dd25)
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 static $_tableName = 'civicrm_contribution_recur';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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 * Date this recurring contribution finished successfully
116 * Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??
120 public $processor_id;
123 * Optionally used to store a link to a payment token used for this recurring contribution.
127 public $payment_token_id;
130 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
137 * unique invoice id, system generated or passed in
146 public $contribution_status_id;
154 * Day in the period when the payment should be charged e.g. 1st of month, 15th etc.
161 * Next scheduled date
165 public $next_sched_contribution_date;
168 * Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.
172 public $failure_count;
175 * Date to retry failed attempt
179 public $failure_retry_date;
182 * Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.
189 * Foreign key to civicrm_payment_processor.id
193 public $payment_processor_id;
196 * FK to Financial Type
200 public $financial_type_id;
203 * FK to Payment Instrument
207 public $payment_instrument_id;
210 * The campaign for which this contribution has been triggered.
217 * if true, receipt is automatically emailed to contact on each successful payment
221 public $is_email_receipt;
226 public function __construct() {
227 $this->__table
= 'civicrm_contribution_recur';
228 parent
::__construct();
232 * Returns foreign keys and entity references.
235 * [CRM_Core_Reference_Interface]
237 public static function getReferenceColumns() {
238 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
239 Civi
::$statics[__CLASS__
]['links'] = static ::createReferenceColumns(__CLASS__
);
240 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
241 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
242 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
243 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
244 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
245 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
247 return Civi
::$statics[__CLASS__
]['links'];
251 * Returns all the column names of this table
255 public static function &fields() {
256 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
257 Civi
::$statics[__CLASS__
]['fields'] = [
260 'type' => CRM_Utils_Type
::T_INT
,
261 'title' => ts('Recurring Contribution ID'),
262 'description' => ts('Contribution Recur ID'),
264 'table_name' => 'civicrm_contribution_recur',
265 'entity' => 'ContributionRecur',
266 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
270 'name' => 'contact_id',
271 'type' => CRM_Utils_Type
::T_INT
,
272 'title' => ts('Contact'),
273 'description' => ts('Foreign key to civicrm_contact.id.'),
275 'table_name' => 'civicrm_contribution_recur',
276 'entity' => 'ContributionRecur',
277 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
279 'FKClassName' => 'CRM_Contact_DAO_Contact',
281 'type' => 'EntityRef',
286 'type' => CRM_Utils_Type
::T_MONEY
,
287 'title' => ts('Amount'),
288 'description' => ts('Amount to be contributed or charged each recurrence.'),
294 'table_name' => 'civicrm_contribution_recur',
295 'entity' => 'ContributionRecur',
296 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
303 'name' => 'currency',
304 'type' => CRM_Utils_Type
::T_STRING
,
305 'title' => ts('Currency'),
306 'description' => ts('3 character string, value from config setting or input via user.'),
308 'size' => CRM_Utils_Type
::FOUR
,
310 'table_name' => 'civicrm_contribution_recur',
311 'entity' => 'ContributionRecur',
312 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
317 'pseudoconstant' => [
318 'table' => 'civicrm_currency',
319 'keyColumn' => 'name',
320 'labelColumn' => 'full_name',
321 'nameColumn' => 'name',
324 'frequency_unit' => [
325 'name' => 'frequency_unit',
326 'type' => CRM_Utils_Type
::T_STRING
,
327 'title' => ts('Frequency Unit'),
328 'description' => ts('Time units for recurrence of payment.'),
330 'size' => CRM_Utils_Type
::EIGHT
,
331 'default' => 'month',
332 'table_name' => 'civicrm_contribution_recur',
333 'entity' => 'ContributionRecur',
334 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
339 'pseudoconstant' => [
340 'optionGroupName' => 'recur_frequency_units',
341 'keyColumn' => 'name',
342 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
345 'frequency_interval' => [
346 'name' => 'frequency_interval',
347 'type' => CRM_Utils_Type
::T_INT
,
348 'title' => ts('Interval (number of units)'),
349 'description' => ts('Number of time units for recurrence of payment.'),
351 'table_name' => 'civicrm_contribution_recur',
352 'entity' => 'ContributionRecur',
353 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
360 'name' => 'installments',
361 'type' => CRM_Utils_Type
::T_INT
,
362 'title' => ts('Number of Installments'),
363 '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.'),
364 'table_name' => 'civicrm_contribution_recur',
365 'entity' => 'ContributionRecur',
366 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
373 'name' => 'start_date',
374 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
375 'title' => ts('Start Date'),
376 'description' => ts('The date the first scheduled recurring contribution occurs.'),
378 'table_name' => 'civicrm_contribution_recur',
379 'entity' => 'ContributionRecur',
380 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
383 'type' => 'Select Date',
384 'formatType' => 'activityDateTime',
388 'name' => 'create_date',
389 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
390 'title' => ts('Created Date'),
391 'description' => ts('When this recurring contribution record was created.'),
393 'table_name' => 'civicrm_contribution_recur',
394 'entity' => 'ContributionRecur',
395 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
398 'type' => 'Select Date',
399 'formatType' => 'activityDateTime',
403 'name' => 'modified_date',
404 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
405 'title' => ts('Modified Date'),
406 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
407 'table_name' => 'civicrm_contribution_recur',
408 'entity' => 'ContributionRecur',
409 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
412 'type' => 'Select Date',
413 'formatType' => 'activityDateTime',
417 'name' => 'cancel_date',
418 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
419 'title' => ts('Cancel Date'),
420 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
421 'table_name' => 'civicrm_contribution_recur',
422 'entity' => 'ContributionRecur',
423 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
426 'type' => 'Select Date',
427 'formatType' => 'activityDate',
431 'name' => 'end_date',
432 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
433 'title' => ts('Recurring Contribution End Date'),
434 'description' => ts('Date this recurring contribution finished successfully'),
435 'table_name' => 'civicrm_contribution_recur',
436 'entity' => 'ContributionRecur',
437 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
440 'type' => 'Select Date',
441 'formatType' => 'activityDate',
445 'name' => 'processor_id',
446 'type' => CRM_Utils_Type
::T_STRING
,
447 'title' => ts('Processor ID'),
448 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
450 'size' => CRM_Utils_Type
::HUGE
,
451 'table_name' => 'civicrm_contribution_recur',
452 'entity' => 'ContributionRecur',
453 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
459 'payment_token_id' => [
460 'name' => 'payment_token_id',
461 'type' => CRM_Utils_Type
::T_INT
,
462 'title' => ts('Payment Token ID'),
463 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
464 'table_name' => 'civicrm_contribution_recur',
465 'entity' => 'ContributionRecur',
466 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
468 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
472 'type' => CRM_Utils_Type
::T_STRING
,
473 'title' => ts('Transaction ID'),
474 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
476 'size' => CRM_Utils_Type
::HUGE
,
477 'table_name' => 'civicrm_contribution_recur',
478 'entity' => 'ContributionRecur',
479 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
486 'name' => 'invoice_id',
487 'type' => CRM_Utils_Type
::T_STRING
,
488 'title' => ts('Invoice ID'),
489 'description' => ts('unique invoice id, system generated or passed in'),
491 'size' => CRM_Utils_Type
::HUGE
,
492 'table_name' => 'civicrm_contribution_recur',
493 'entity' => 'ContributionRecur',
494 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
500 'contribution_status_id' => [
501 'name' => 'contribution_status_id',
502 'type' => CRM_Utils_Type
::T_INT
,
503 'title' => ts('Status'),
505 'where' => 'civicrm_contribution_recur.contribution_status_id',
506 'headerPattern' => '',
510 'table_name' => 'civicrm_contribution_recur',
511 'entity' => 'ContributionRecur',
512 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
517 'pseudoconstant' => [
518 'optionGroupName' => 'contribution_status',
519 'optionEditPath' => 'civicrm/admin/options/contribution_status',
524 'type' => CRM_Utils_Type
::T_BOOLEAN
,
525 'title' => ts('Test'),
527 'where' => 'civicrm_contribution_recur.is_test',
528 'headerPattern' => '',
532 'table_name' => 'civicrm_contribution_recur',
533 'entity' => 'ContributionRecur',
534 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
537 'type' => 'CheckBox',
541 'name' => 'cycle_day',
542 'type' => CRM_Utils_Type
::T_INT
,
543 'title' => ts('Cycle Day'),
544 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
547 'table_name' => 'civicrm_contribution_recur',
548 'entity' => 'ContributionRecur',
549 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
555 'next_sched_contribution_date' => [
556 'name' => 'next_sched_contribution_date',
557 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
558 'title' => ts('Next Scheduled Contribution Date'),
559 'description' => ts('Next scheduled date'),
560 'table_name' => 'civicrm_contribution_recur',
561 'entity' => 'ContributionRecur',
562 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
565 'type' => 'Select Date',
566 'formatType' => 'activityDate',
570 'name' => 'failure_count',
571 'type' => CRM_Utils_Type
::T_INT
,
572 'title' => ts('Number of Failures'),
573 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
575 'table_name' => 'civicrm_contribution_recur',
576 'entity' => 'ContributionRecur',
577 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
583 'failure_retry_date' => [
584 'name' => 'failure_retry_date',
585 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
586 'title' => ts('Retry Failed Attempt Date'),
587 'description' => ts('Date to retry failed attempt'),
588 'table_name' => 'civicrm_contribution_recur',
589 'entity' => 'ContributionRecur',
590 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
593 'type' => 'Select Date',
594 'formatType' => 'activityDate',
598 'name' => 'auto_renew',
599 'type' => CRM_Utils_Type
::T_BOOLEAN
,
600 'title' => ts('Auto Renew'),
601 '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.'),
604 'table_name' => 'civicrm_contribution_recur',
605 'entity' => 'ContributionRecur',
606 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
609 'type' => 'CheckBox',
612 'payment_processor_id' => [
613 'name' => 'payment_processor_id',
614 'type' => CRM_Utils_Type
::T_INT
,
615 'title' => ts('Payment Processor'),
616 'description' => ts('Foreign key to civicrm_payment_processor.id'),
617 'table_name' => 'civicrm_contribution_recur',
618 'entity' => 'ContributionRecur',
619 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
621 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
626 'financial_type_id' => [
627 'name' => 'financial_type_id',
628 'type' => CRM_Utils_Type
::T_INT
,
629 'title' => ts('Financial Type'),
630 'description' => ts('FK to Financial Type'),
632 'where' => 'civicrm_contribution_recur.financial_type_id',
633 'headerPattern' => '',
635 'table_name' => 'civicrm_contribution_recur',
636 'entity' => 'ContributionRecur',
637 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
639 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
643 'pseudoconstant' => [
644 'table' => 'civicrm_financial_type',
646 'labelColumn' => 'name',
649 'payment_instrument_id' => [
650 'name' => 'payment_instrument_id',
651 'type' => CRM_Utils_Type
::T_INT
,
652 'title' => ts('Payment Method'),
653 'description' => ts('FK to Payment Instrument'),
654 'table_name' => 'civicrm_contribution_recur',
655 'entity' => 'ContributionRecur',
656 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
661 'pseudoconstant' => [
662 'optionGroupName' => 'payment_instrument',
663 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
666 'contribution_campaign_id' => [
667 'name' => 'campaign_id',
668 'type' => CRM_Utils_Type
::T_INT
,
669 'title' => ts('Campaign'),
670 'description' => ts('The campaign for which this contribution has been triggered.'),
672 'where' => 'civicrm_contribution_recur.campaign_id',
673 'headerPattern' => '',
676 'table_name' => 'civicrm_contribution_recur',
677 'entity' => 'ContributionRecur',
678 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
680 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
684 'pseudoconstant' => [
685 'table' => 'civicrm_campaign',
687 'labelColumn' => 'title',
690 'is_email_receipt' => [
691 'name' => 'is_email_receipt',
692 'type' => CRM_Utils_Type
::T_BOOLEAN
,
693 'title' => ts('Send email Receipt?'),
694 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
696 'table_name' => 'civicrm_contribution_recur',
697 'entity' => 'ContributionRecur',
698 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
701 'type' => 'CheckBox',
705 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
707 return Civi
::$statics[__CLASS__
]['fields'];
711 * Return a mapping from field-name to the corresponding key (as used in fields()).
714 * Array(string $name => string $uniqueName).
716 public static function &fieldKeys() {
717 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
718 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
720 return Civi
::$statics[__CLASS__
]['fieldKeys'];
724 * Returns the names of this table
728 public static function getTableName() {
729 return self
::$_tableName;
733 * Returns if this table needs to be logged
737 public function getLog() {
742 * Returns the list of fields that can be imported
744 * @param bool $prefix
748 public static function &import($prefix = FALSE) {
749 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
754 * Returns the list of fields that can be exported
756 * @param bool $prefix
760 public static function &export($prefix = FALSE) {
761 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
766 * Returns the list of indices
768 * @param bool $localize
772 public static function indices($localize = TRUE) {
774 'UI_contrib_trxn_id' => [
775 'name' => 'UI_contrib_trxn_id',
779 'localizable' => FALSE,
781 'sig' => 'civicrm_contribution_recur::1::trxn_id',
783 'UI_contrib_invoice_id' => [
784 'name' => 'UI_contrib_invoice_id',
788 'localizable' => FALSE,
790 'sig' => 'civicrm_contribution_recur::1::invoice_id',
792 'index_contribution_status' => [
793 'name' => 'index_contribution_status',
795 0 => 'contribution_status_id',
797 'localizable' => FALSE,
798 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
800 'UI_contribution_recur_payment_instrument_id' => [
801 'name' => 'UI_contribution_recur_payment_instrument_id',
803 0 => 'payment_instrument_id',
805 'localizable' => FALSE,
806 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
809 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;