5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:86dee7eccc17a37ef08043f32396b80d)
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' => '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 ID'),
273 'description' => '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',
283 'type' => CRM_Utils_Type
::T_MONEY
,
284 'title' => ts('Amount'),
285 'description' => 'Amount to be contributed or charged each recurrence.',
291 'table_name' => 'civicrm_contribution_recur',
292 'entity' => 'ContributionRecur',
293 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
300 'name' => 'currency',
301 'type' => CRM_Utils_Type
::T_STRING
,
302 'title' => ts('Currency'),
303 'description' => '3 character string, value from config setting or input via user.',
305 'size' => CRM_Utils_Type
::FOUR
,
307 'table_name' => 'civicrm_contribution_recur',
308 'entity' => 'ContributionRecur',
309 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
314 'pseudoconstant' => [
315 'table' => 'civicrm_currency',
316 'keyColumn' => 'name',
317 'labelColumn' => 'full_name',
318 'nameColumn' => 'name',
321 'frequency_unit' => [
322 'name' => 'frequency_unit',
323 'type' => CRM_Utils_Type
::T_STRING
,
324 'title' => ts('Frequency Unit'),
325 'description' => 'Time units for recurrence of payment.',
327 'size' => CRM_Utils_Type
::EIGHT
,
328 'default' => 'month',
329 'table_name' => 'civicrm_contribution_recur',
330 'entity' => 'ContributionRecur',
331 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
336 'pseudoconstant' => [
337 'optionGroupName' => 'recur_frequency_units',
338 'keyColumn' => 'name',
339 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
342 'frequency_interval' => [
343 'name' => 'frequency_interval',
344 'type' => CRM_Utils_Type
::T_INT
,
345 'title' => ts('Interval (number of units)'),
346 'description' => 'Number of time units for recurrence of payment.',
348 'table_name' => 'civicrm_contribution_recur',
349 'entity' => 'ContributionRecur',
350 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
357 'name' => 'installments',
358 'type' => CRM_Utils_Type
::T_INT
,
359 'title' => ts('Number of Installments'),
360 'description' => 'Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.',
361 'table_name' => 'civicrm_contribution_recur',
362 'entity' => 'ContributionRecur',
363 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
370 'name' => 'start_date',
371 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
372 'title' => ts('Recurring Contribution Started Date'),
373 'description' => 'The date the first scheduled recurring contribution occurs.',
375 'table_name' => 'civicrm_contribution_recur',
376 'entity' => 'ContributionRecur',
377 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
380 'type' => 'Select Date',
381 'formatType' => 'activityDate',
385 'name' => 'create_date',
386 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
387 'title' => ts('Recurring Contribution Created Date'),
388 'description' => 'When this recurring contribution record was created.',
390 'table_name' => 'civicrm_contribution_recur',
391 'entity' => 'ContributionRecur',
392 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
395 'type' => 'Select Date',
396 'formatType' => 'activityDate',
400 'name' => 'modified_date',
401 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
402 'title' => ts('Recurring Contribution Modified Date'),
403 'description' => 'Last updated date for this record. mostly the last time a payment was received',
404 'table_name' => 'civicrm_contribution_recur',
405 'entity' => 'ContributionRecur',
406 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
409 'type' => 'Select Date',
410 'formatType' => 'activityDate',
414 'name' => 'cancel_date',
415 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
416 'title' => ts('Recurring Contribution Cancel Date'),
417 'description' => 'Date this recurring contribution was cancelled by contributor- if we can get access to it',
418 'table_name' => 'civicrm_contribution_recur',
419 'entity' => 'ContributionRecur',
420 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
423 'type' => 'Select Date',
424 'formatType' => 'activityDate',
428 'name' => 'end_date',
429 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
430 'title' => ts('Recurring Contribution End Date'),
431 'description' => 'Date this recurring contribution finished successfully',
432 'table_name' => 'civicrm_contribution_recur',
433 'entity' => 'ContributionRecur',
434 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
437 'type' => 'Select Date',
438 'formatType' => 'activityDate',
442 'name' => 'processor_id',
443 'type' => CRM_Utils_Type
::T_STRING
,
444 'title' => ts('Processor ID'),
445 'description' => 'Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??',
447 'size' => CRM_Utils_Type
::HUGE
,
448 'table_name' => 'civicrm_contribution_recur',
449 'entity' => 'ContributionRecur',
450 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
453 'payment_token_id' => [
454 'name' => 'payment_token_id',
455 'type' => CRM_Utils_Type
::T_INT
,
456 'title' => ts('Payment Token ID'),
457 'description' => 'Optionally used to store a link to a payment token used for this recurring contribution.',
458 'table_name' => 'civicrm_contribution_recur',
459 'entity' => 'ContributionRecur',
460 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
462 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
466 'type' => CRM_Utils_Type
::T_STRING
,
467 'title' => ts('Transaction ID'),
468 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
470 'size' => CRM_Utils_Type
::HUGE
,
471 'table_name' => 'civicrm_contribution_recur',
472 'entity' => 'ContributionRecur',
473 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
477 'name' => 'invoice_id',
478 'type' => CRM_Utils_Type
::T_STRING
,
479 'title' => ts('Invoice ID'),
480 'description' => 'unique invoice id, system generated or passed in',
482 'size' => CRM_Utils_Type
::HUGE
,
483 'table_name' => 'civicrm_contribution_recur',
484 'entity' => 'ContributionRecur',
485 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
488 'contribution_status_id' => [
489 'name' => 'contribution_status_id',
490 'type' => CRM_Utils_Type
::T_INT
,
491 'title' => ts('Recurring Contribution Status'),
493 'where' => 'civicrm_contribution_recur.contribution_status_id',
494 'headerPattern' => '',
498 'table_name' => 'civicrm_contribution_recur',
499 'entity' => 'ContributionRecur',
500 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
502 'pseudoconstant' => [
503 'optionGroupName' => 'contribution_status',
504 'optionEditPath' => 'civicrm/admin/options/contribution_status',
509 'type' => CRM_Utils_Type
::T_BOOLEAN
,
510 'title' => ts('Test'),
512 'where' => 'civicrm_contribution_recur.is_test',
513 'headerPattern' => '',
517 'table_name' => 'civicrm_contribution_recur',
518 'entity' => 'ContributionRecur',
519 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
522 'type' => 'CheckBox',
526 'name' => 'cycle_day',
527 'type' => CRM_Utils_Type
::T_INT
,
528 'title' => ts('Number of Cycle Day'),
529 'description' => 'Day in the period when the payment should be charged e.g. 1st of month, 15th etc.',
532 'table_name' => 'civicrm_contribution_recur',
533 'entity' => 'ContributionRecur',
534 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
540 'next_sched_contribution_date' => [
541 'name' => 'next_sched_contribution_date',
542 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
543 'title' => ts('Next Scheduled Contribution Date'),
544 'description' => 'Next scheduled date',
545 'table_name' => 'civicrm_contribution_recur',
546 'entity' => 'ContributionRecur',
547 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
550 'type' => 'Select Date',
551 'formatType' => 'activityDate',
555 'name' => 'failure_count',
556 'type' => CRM_Utils_Type
::T_INT
,
557 'title' => ts('Number of Failures'),
558 'description' => 'Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.',
560 'table_name' => 'civicrm_contribution_recur',
561 'entity' => 'ContributionRecur',
562 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
568 'failure_retry_date' => [
569 'name' => 'failure_retry_date',
570 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
571 'title' => ts('Retry Failed Attempt Date'),
572 'description' => 'Date to retry failed attempt',
573 'table_name' => 'civicrm_contribution_recur',
574 'entity' => 'ContributionRecur',
575 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
578 'type' => 'Select Date',
579 'formatType' => 'activityDate',
583 'name' => 'auto_renew',
584 'type' => CRM_Utils_Type
::T_BOOLEAN
,
585 'title' => ts('Auto Renew'),
586 'description' => 'Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.',
589 'table_name' => 'civicrm_contribution_recur',
590 'entity' => 'ContributionRecur',
591 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
594 'type' => 'CheckBox',
597 'payment_processor_id' => [
598 'name' => 'payment_processor_id',
599 'type' => CRM_Utils_Type
::T_INT
,
600 'title' => ts('Payment Processor'),
601 'description' => 'Foreign key to civicrm_payment_processor.id',
602 'table_name' => 'civicrm_contribution_recur',
603 'entity' => 'ContributionRecur',
604 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
606 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
608 'financial_type_id' => [
609 'name' => 'financial_type_id',
610 'type' => CRM_Utils_Type
::T_INT
,
611 'title' => ts('Financial Type'),
612 'description' => 'FK to Financial Type',
614 'where' => 'civicrm_contribution_recur.financial_type_id',
615 'headerPattern' => '',
617 'table_name' => 'civicrm_contribution_recur',
618 'entity' => 'ContributionRecur',
619 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
621 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
622 'pseudoconstant' => [
623 'table' => 'civicrm_financial_type',
625 'labelColumn' => 'name',
628 'payment_instrument_id' => [
629 'name' => 'payment_instrument_id',
630 'type' => CRM_Utils_Type
::T_INT
,
631 'title' => ts('Payment Method'),
632 'description' => 'FK to Payment Instrument',
633 'table_name' => 'civicrm_contribution_recur',
634 'entity' => 'ContributionRecur',
635 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
640 'pseudoconstant' => [
641 'optionGroupName' => 'payment_instrument',
642 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
645 'contribution_campaign_id' => [
646 'name' => 'campaign_id',
647 'type' => CRM_Utils_Type
::T_INT
,
648 'title' => ts('Campaign'),
649 'description' => 'The campaign for which this contribution has been triggered.',
651 'where' => 'civicrm_contribution_recur.campaign_id',
652 'headerPattern' => '',
655 'table_name' => 'civicrm_contribution_recur',
656 'entity' => 'ContributionRecur',
657 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
659 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
660 'pseudoconstant' => [
661 'table' => 'civicrm_campaign',
663 'labelColumn' => 'title',
666 'is_email_receipt' => [
667 'name' => 'is_email_receipt',
668 'type' => CRM_Utils_Type
::T_BOOLEAN
,
669 'title' => ts('Send email Receipt?'),
670 'description' => 'if true, receipt is automatically emailed to contact on each successful payment',
672 'table_name' => 'civicrm_contribution_recur',
673 'entity' => 'ContributionRecur',
674 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
677 'type' => 'CheckBox',
681 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
683 return Civi
::$statics[__CLASS__
]['fields'];
687 * Return a mapping from field-name to the corresponding key (as used in fields()).
690 * Array(string $name => string $uniqueName).
692 public static function &fieldKeys() {
693 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
694 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
696 return Civi
::$statics[__CLASS__
]['fieldKeys'];
700 * Returns the names of this table
704 public static function getTableName() {
705 return self
::$_tableName;
709 * Returns if this table needs to be logged
713 public function getLog() {
718 * Returns the list of fields that can be imported
720 * @param bool $prefix
724 public static function &import($prefix = FALSE) {
725 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'contribution_recur', $prefix, []);
730 * Returns the list of fields that can be exported
732 * @param bool $prefix
736 public static function &export($prefix = FALSE) {
737 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'contribution_recur', $prefix, []);
742 * Returns the list of indices
744 * @param bool $localize
748 public static function indices($localize = TRUE) {
750 'UI_contrib_trxn_id' => [
751 'name' => 'UI_contrib_trxn_id',
755 'localizable' => FALSE,
757 'sig' => 'civicrm_contribution_recur::1::trxn_id',
759 'UI_contrib_invoice_id' => [
760 'name' => 'UI_contrib_invoice_id',
764 'localizable' => FALSE,
766 'sig' => 'civicrm_contribution_recur::1::invoice_id',
768 'index_contribution_status' => [
769 'name' => 'index_contribution_status',
771 0 => 'contribution_status_id',
773 'localizable' => FALSE,
774 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
776 'UI_contribution_recur_payment_instrument_id' => [
777 'name' => 'UI_contribution_recur_payment_instrument_id',
779 0 => 'payment_instrument_id',
781 'localizable' => FALSE,
782 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
785 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;