Add function Core_Component::isEnabled
[civicrm-core.git] / CRM / Contribute / DAO / ContributionRecur.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5f08744178821ce074d21fe4cdddbdaa)
10 */
11
12 /**
13 * Database access object for the ContributionRecur entity.
14 */
15 class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.6';
18 const COMPONENT = 'CiviContribute';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_contribution_recur';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = TRUE;
33
34 /**
35 * Contribution Recur ID
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * Foreign key to civicrm_contact.id.
43 *
44 * @var int
45 */
46 public $contact_id;
47
48 /**
49 * Amount to be collected (including any sales tax) by payment processor each recurrence.
50 *
51 * @var float
52 */
53 public $amount;
54
55 /**
56 * 3 character string, value from config setting or input via user.
57 *
58 * @var string
59 */
60 public $currency;
61
62 /**
63 * Time units for recurrence of payment.
64 *
65 * @var string
66 */
67 public $frequency_unit;
68
69 /**
70 * Number of time units for recurrence of payment.
71 *
72 * @var int
73 */
74 public $frequency_interval;
75
76 /**
77 * Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.
78 *
79 * @var int
80 */
81 public $installments;
82
83 /**
84 * The date the first scheduled recurring contribution occurs.
85 *
86 * @var datetime
87 */
88 public $start_date;
89
90 /**
91 * When this recurring contribution record was created.
92 *
93 * @var datetime
94 */
95 public $create_date;
96
97 /**
98 * Last updated date for this record. mostly the last time a payment was received
99 *
100 * @var timestamp
101 */
102 public $modified_date;
103
104 /**
105 * Date this recurring contribution was cancelled by contributor- if we can get access to it
106 *
107 * @var datetime
108 */
109 public $cancel_date;
110
111 /**
112 * Free text field for a reason for cancelling
113 *
114 * @var text
115 */
116 public $cancel_reason;
117
118 /**
119 * Date this recurring contribution finished successfully
120 *
121 * @var datetime
122 */
123 public $end_date;
124
125 /**
126 * Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??
127 *
128 * @var string
129 */
130 public $processor_id;
131
132 /**
133 * Optionally used to store a link to a payment token used for this recurring contribution.
134 *
135 * @var int
136 */
137 public $payment_token_id;
138
139 /**
140 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
141 *
142 * @var string
143 */
144 public $trxn_id;
145
146 /**
147 * unique invoice id, system generated or passed in
148 *
149 * @var string
150 */
151 public $invoice_id;
152
153 /**
154 * @var int
155 */
156 public $contribution_status_id;
157
158 /**
159 * @var bool
160 */
161 public $is_test;
162
163 /**
164 * Day in the period when the payment should be charged e.g. 1st of month, 15th etc.
165 *
166 * @var int
167 */
168 public $cycle_day;
169
170 /**
171 * Next scheduled date
172 *
173 * @var datetime
174 */
175 public $next_sched_contribution_date;
176
177 /**
178 * Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.
179 *
180 * @var int
181 */
182 public $failure_count;
183
184 /**
185 * Date to retry failed attempt
186 *
187 * @var datetime
188 */
189 public $failure_retry_date;
190
191 /**
192 * Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.
193 *
194 * @var bool
195 */
196 public $auto_renew;
197
198 /**
199 * Foreign key to civicrm_payment_processor.id
200 *
201 * @var int
202 */
203 public $payment_processor_id;
204
205 /**
206 * FK to Financial Type
207 *
208 * @var int
209 */
210 public $financial_type_id;
211
212 /**
213 * FK to Payment Instrument
214 *
215 * @var int
216 */
217 public $payment_instrument_id;
218
219 /**
220 * The campaign for which this contribution has been triggered.
221 *
222 * @var int
223 */
224 public $campaign_id;
225
226 /**
227 * if true, receipt is automatically emailed to contact on each successful payment
228 *
229 * @var bool
230 */
231 public $is_email_receipt;
232
233 /**
234 * Class constructor.
235 */
236 public function __construct() {
237 $this->__table = 'civicrm_contribution_recur';
238 parent::__construct();
239 }
240
241 /**
242 * Returns localized title of this entity.
243 *
244 * @param bool $plural
245 * Whether to return the plural version of the title.
246 */
247 public static function getEntityTitle($plural = FALSE) {
248 return $plural ? ts('Recurring Contributions') : ts('Recurring Contribution');
249 }
250
251 /**
252 * Returns foreign keys and entity references.
253 *
254 * @return array
255 * [CRM_Core_Reference_Interface]
256 */
257 public static function getReferenceColumns() {
258 if (!isset(Civi::$statics[__CLASS__]['links'])) {
259 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
260 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
261 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
262 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
263 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
264 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
265 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
266 }
267 return Civi::$statics[__CLASS__]['links'];
268 }
269
270 /**
271 * Returns all the column names of this table
272 *
273 * @return array
274 */
275 public static function &fields() {
276 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
277 Civi::$statics[__CLASS__]['fields'] = [
278 'contribution_recur_id' => [
279 'name' => 'id',
280 'type' => CRM_Utils_Type::T_INT,
281 'title' => ts('Recurring Contribution ID'),
282 'description' => ts('Contribution Recur ID'),
283 'required' => TRUE,
284 'where' => 'civicrm_contribution_recur.id',
285 'table_name' => 'civicrm_contribution_recur',
286 'entity' => 'ContributionRecur',
287 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
288 'localizable' => 0,
289 'html' => [
290 'type' => 'Number',
291 ],
292 'readonly' => TRUE,
293 'add' => '1.6',
294 ],
295 'contact_id' => [
296 'name' => 'contact_id',
297 'type' => CRM_Utils_Type::T_INT,
298 'title' => ts('Contact ID'),
299 'description' => ts('Foreign key to civicrm_contact.id.'),
300 'required' => TRUE,
301 'where' => 'civicrm_contribution_recur.contact_id',
302 'table_name' => 'civicrm_contribution_recur',
303 'entity' => 'ContributionRecur',
304 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
305 'localizable' => 0,
306 'FKClassName' => 'CRM_Contact_DAO_Contact',
307 'html' => [
308 'type' => 'EntityRef',
309 'label' => ts("Contact"),
310 ],
311 'add' => '1.6',
312 ],
313 'amount' => [
314 'name' => 'amount',
315 'type' => CRM_Utils_Type::T_MONEY,
316 'title' => ts('Amount'),
317 'description' => ts('Amount to be collected (including any sales tax) by payment processor each recurrence.'),
318 'required' => TRUE,
319 'precision' => [
320 20,
321 2,
322 ],
323 'where' => 'civicrm_contribution_recur.amount',
324 'table_name' => 'civicrm_contribution_recur',
325 'entity' => 'ContributionRecur',
326 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
327 'localizable' => 0,
328 'html' => [
329 'type' => 'Text',
330 ],
331 'add' => '1.6',
332 ],
333 'currency' => [
334 'name' => 'currency',
335 'type' => CRM_Utils_Type::T_STRING,
336 'title' => ts('Currency'),
337 'description' => ts('3 character string, value from config setting or input via user.'),
338 'maxlength' => 3,
339 'size' => CRM_Utils_Type::FOUR,
340 'where' => 'civicrm_contribution_recur.currency',
341 'default' => NULL,
342 'table_name' => 'civicrm_contribution_recur',
343 'entity' => 'ContributionRecur',
344 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
345 'localizable' => 0,
346 'html' => [
347 'type' => 'Select',
348 ],
349 'pseudoconstant' => [
350 'table' => 'civicrm_currency',
351 'keyColumn' => 'name',
352 'labelColumn' => 'full_name',
353 'nameColumn' => 'name',
354 'abbrColumn' => 'symbol',
355 ],
356 'add' => '3.2',
357 ],
358 'frequency_unit' => [
359 'name' => 'frequency_unit',
360 'type' => CRM_Utils_Type::T_STRING,
361 'title' => ts('Frequency Unit'),
362 'description' => ts('Time units for recurrence of payment.'),
363 'maxlength' => 8,
364 'size' => CRM_Utils_Type::EIGHT,
365 'where' => 'civicrm_contribution_recur.frequency_unit',
366 'default' => 'month',
367 'table_name' => 'civicrm_contribution_recur',
368 'entity' => 'ContributionRecur',
369 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
370 'localizable' => 0,
371 'html' => [
372 'type' => 'Select',
373 ],
374 'pseudoconstant' => [
375 'optionGroupName' => 'recur_frequency_units',
376 'keyColumn' => 'name',
377 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
378 ],
379 'add' => '1.6',
380 ],
381 'frequency_interval' => [
382 'name' => 'frequency_interval',
383 'type' => CRM_Utils_Type::T_INT,
384 'title' => ts('Interval (number of units)'),
385 'description' => ts('Number of time units for recurrence of payment.'),
386 'required' => TRUE,
387 'where' => 'civicrm_contribution_recur.frequency_interval',
388 'default' => '1',
389 'table_name' => 'civicrm_contribution_recur',
390 'entity' => 'ContributionRecur',
391 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
392 'localizable' => 0,
393 'html' => [
394 'type' => 'Text',
395 ],
396 'add' => '1.6',
397 ],
398 'installments' => [
399 'name' => 'installments',
400 'type' => CRM_Utils_Type::T_INT,
401 'title' => ts('Number of Installments'),
402 '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.'),
403 'where' => 'civicrm_contribution_recur.installments',
404 'table_name' => 'civicrm_contribution_recur',
405 'entity' => 'ContributionRecur',
406 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
407 'localizable' => 0,
408 'html' => [
409 'type' => 'Text',
410 ],
411 'add' => '1.6',
412 ],
413 'contribution_recur_start_date' => [
414 'name' => 'start_date',
415 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
416 'title' => ts('Start Date'),
417 'description' => ts('The date the first scheduled recurring contribution occurs.'),
418 'required' => TRUE,
419 'where' => 'civicrm_contribution_recur.start_date',
420 'default' => 'CURRENT_TIMESTAMP',
421 'table_name' => 'civicrm_contribution_recur',
422 'entity' => 'ContributionRecur',
423 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
424 'localizable' => 0,
425 'unique_title' => ts('Recurring Contribution Start Date'),
426 'html' => [
427 'type' => 'Select Date',
428 'formatType' => 'activityDateTime',
429 ],
430 'add' => '1.6',
431 ],
432 'contribution_recur_create_date' => [
433 'name' => 'create_date',
434 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
435 'title' => ts('Created Date'),
436 'description' => ts('When this recurring contribution record was created.'),
437 'required' => TRUE,
438 'where' => 'civicrm_contribution_recur.create_date',
439 'default' => 'CURRENT_TIMESTAMP',
440 'table_name' => 'civicrm_contribution_recur',
441 'entity' => 'ContributionRecur',
442 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
443 'localizable' => 0,
444 'unique_title' => ts('Recurring Contribution Create Date'),
445 'html' => [
446 'type' => 'Select Date',
447 'formatType' => 'activityDateTime',
448 ],
449 'add' => '1.6',
450 ],
451 'contribution_recur_modified_date' => [
452 'name' => 'modified_date',
453 'type' => CRM_Utils_Type::T_TIMESTAMP,
454 'title' => ts('Modified Date'),
455 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
456 'where' => 'civicrm_contribution_recur.modified_date',
457 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
458 'table_name' => 'civicrm_contribution_recur',
459 'entity' => 'ContributionRecur',
460 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
461 'localizable' => 0,
462 'unique_title' => ts('Recurring Contribution Modified Date'),
463 'html' => [
464 'type' => 'Select Date',
465 'formatType' => 'activityDateTime',
466 ],
467 'readonly' => TRUE,
468 'add' => '1.6',
469 ],
470 'contribution_recur_cancel_date' => [
471 'name' => 'cancel_date',
472 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
473 'title' => ts('Cancel Date'),
474 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
475 'where' => 'civicrm_contribution_recur.cancel_date',
476 'table_name' => 'civicrm_contribution_recur',
477 'entity' => 'ContributionRecur',
478 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
479 'localizable' => 0,
480 'unique_title' => ts('Recurring Contribution Cancel Date'),
481 'html' => [
482 'type' => 'Select Date',
483 'formatType' => 'activityDate',
484 ],
485 'add' => '1.6',
486 ],
487 'contribution_recur_cancel_reason' => [
488 'name' => 'cancel_reason',
489 'type' => CRM_Utils_Type::T_TEXT,
490 'title' => ts('Cancellation Reason'),
491 'description' => ts('Free text field for a reason for cancelling'),
492 'where' => 'civicrm_contribution_recur.cancel_reason',
493 'table_name' => 'civicrm_contribution_recur',
494 'entity' => 'ContributionRecur',
495 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
496 'localizable' => 0,
497 'unique_title' => ts('Recurring Contribution Cancel Reason'),
498 'html' => [
499 'type' => 'Text',
500 ],
501 'add' => '5.13',
502 ],
503 'contribution_recur_end_date' => [
504 'name' => 'end_date',
505 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
506 'title' => ts('Recurring Contribution End Date'),
507 'description' => ts('Date this recurring contribution finished successfully'),
508 'where' => 'civicrm_contribution_recur.end_date',
509 'table_name' => 'civicrm_contribution_recur',
510 'entity' => 'ContributionRecur',
511 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
512 'localizable' => 0,
513 'unique_title' => ts('Recurring Contribution End Date'),
514 'html' => [
515 'type' => 'Select Date',
516 'formatType' => 'activityDate',
517 ],
518 'add' => '1.6',
519 ],
520 'contribution_recur_processor_id' => [
521 'name' => 'processor_id',
522 'type' => CRM_Utils_Type::T_STRING,
523 'title' => ts('Processor ID'),
524 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
525 'maxlength' => 255,
526 'size' => CRM_Utils_Type::HUGE,
527 'where' => 'civicrm_contribution_recur.processor_id',
528 'table_name' => 'civicrm_contribution_recur',
529 'entity' => 'ContributionRecur',
530 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
531 'localizable' => 0,
532 'html' => [
533 'type' => 'Text',
534 ],
535 'add' => '1.6',
536 ],
537 'payment_token_id' => [
538 'name' => 'payment_token_id',
539 'type' => CRM_Utils_Type::T_INT,
540 'title' => ts('Payment Token ID'),
541 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
542 'where' => 'civicrm_contribution_recur.payment_token_id',
543 'table_name' => 'civicrm_contribution_recur',
544 'entity' => 'ContributionRecur',
545 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
546 'localizable' => 0,
547 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
548 'html' => [
549 'label' => ts("Payment Token"),
550 ],
551 'add' => '4.6',
552 ],
553 'contribution_recur_trxn_id' => [
554 'name' => 'trxn_id',
555 'type' => CRM_Utils_Type::T_STRING,
556 'title' => ts('Transaction ID'),
557 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
558 'maxlength' => 255,
559 'size' => CRM_Utils_Type::HUGE,
560 'where' => 'civicrm_contribution_recur.trxn_id',
561 'table_name' => 'civicrm_contribution_recur',
562 'entity' => 'ContributionRecur',
563 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
564 'localizable' => 0,
565 'html' => [
566 'type' => 'Text',
567 ],
568 'add' => '1.6',
569 ],
570 'invoice_id' => [
571 'name' => 'invoice_id',
572 'type' => CRM_Utils_Type::T_STRING,
573 'title' => ts('Invoice ID'),
574 'description' => ts('unique invoice id, system generated or passed in'),
575 'maxlength' => 255,
576 'size' => CRM_Utils_Type::HUGE,
577 'where' => 'civicrm_contribution_recur.invoice_id',
578 'table_name' => 'civicrm_contribution_recur',
579 'entity' => 'ContributionRecur',
580 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
581 'localizable' => 0,
582 'html' => [
583 'type' => 'Text',
584 ],
585 'add' => '1.6',
586 ],
587 'contribution_recur_contribution_status_id' => [
588 'name' => 'contribution_status_id',
589 'type' => CRM_Utils_Type::T_INT,
590 'title' => ts('Status'),
591 'import' => TRUE,
592 'where' => 'civicrm_contribution_recur.contribution_status_id',
593 'export' => TRUE,
594 'default' => '2',
595 'table_name' => 'civicrm_contribution_recur',
596 'entity' => 'ContributionRecur',
597 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
598 'localizable' => 0,
599 'html' => [
600 'type' => 'Select',
601 ],
602 'pseudoconstant' => [
603 'optionGroupName' => 'contribution_recur_status',
604 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
605 ],
606 'add' => '1.6',
607 ],
608 'is_test' => [
609 'name' => 'is_test',
610 'type' => CRM_Utils_Type::T_BOOLEAN,
611 'title' => ts('Test'),
612 'import' => TRUE,
613 'where' => 'civicrm_contribution_recur.is_test',
614 'export' => TRUE,
615 'default' => '0',
616 'table_name' => 'civicrm_contribution_recur',
617 'entity' => 'ContributionRecur',
618 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
619 'localizable' => 0,
620 'html' => [
621 'type' => 'CheckBox',
622 ],
623 'add' => NULL,
624 ],
625 'cycle_day' => [
626 'name' => 'cycle_day',
627 'type' => CRM_Utils_Type::T_INT,
628 'title' => ts('Cycle Day'),
629 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
630 'required' => TRUE,
631 'where' => 'civicrm_contribution_recur.cycle_day',
632 'default' => '1',
633 'table_name' => 'civicrm_contribution_recur',
634 'entity' => 'ContributionRecur',
635 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
636 'localizable' => 0,
637 'html' => [
638 'type' => 'Text',
639 ],
640 'add' => '1.6',
641 ],
642 'contribution_recur_next_sched_contribution_date' => [
643 'name' => 'next_sched_contribution_date',
644 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
645 'title' => ts('Next Scheduled Contribution Date'),
646 'description' => ts('Next scheduled date'),
647 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
648 'table_name' => 'civicrm_contribution_recur',
649 'entity' => 'ContributionRecur',
650 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
651 'localizable' => 0,
652 'unique_title' => ts('Next Scheduled Recurring Contribution'),
653 'html' => [
654 'type' => 'Select Date',
655 'formatType' => 'activityDate',
656 ],
657 'add' => '4.4',
658 ],
659 'failure_count' => [
660 'name' => 'failure_count',
661 'type' => CRM_Utils_Type::T_INT,
662 'title' => ts('Number of Failures'),
663 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
664 'where' => 'civicrm_contribution_recur.failure_count',
665 'default' => '0',
666 'table_name' => 'civicrm_contribution_recur',
667 'entity' => 'ContributionRecur',
668 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
669 'localizable' => 0,
670 'html' => [
671 'type' => 'Text',
672 ],
673 'add' => '1.6',
674 ],
675 'contribution_recur_failure_retry_date' => [
676 'name' => 'failure_retry_date',
677 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
678 'title' => ts('Retry Failed Attempt Date'),
679 'description' => ts('Date to retry failed attempt'),
680 'where' => 'civicrm_contribution_recur.failure_retry_date',
681 'table_name' => 'civicrm_contribution_recur',
682 'entity' => 'ContributionRecur',
683 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
684 'localizable' => 0,
685 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
686 'html' => [
687 'type' => 'Select Date',
688 'formatType' => 'activityDate',
689 ],
690 'add' => '1.6',
691 ],
692 'auto_renew' => [
693 'name' => 'auto_renew',
694 'type' => CRM_Utils_Type::T_BOOLEAN,
695 'title' => ts('Auto Renew'),
696 '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.'),
697 'required' => TRUE,
698 'where' => 'civicrm_contribution_recur.auto_renew',
699 'default' => '0',
700 'table_name' => 'civicrm_contribution_recur',
701 'entity' => 'ContributionRecur',
702 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
703 'localizable' => 0,
704 'html' => [
705 'type' => 'CheckBox',
706 ],
707 'add' => '1.6',
708 ],
709 'contribution_recur_payment_processor_id' => [
710 'name' => 'payment_processor_id',
711 'type' => CRM_Utils_Type::T_INT,
712 'title' => ts('Payment Processor ID'),
713 'description' => ts('Foreign key to civicrm_payment_processor.id'),
714 'where' => 'civicrm_contribution_recur.payment_processor_id',
715 'table_name' => 'civicrm_contribution_recur',
716 'entity' => 'ContributionRecur',
717 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
718 'localizable' => 0,
719 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
720 'html' => [
721 'type' => 'Select',
722 'label' => ts("Payment Processor"),
723 ],
724 'pseudoconstant' => [
725 'table' => 'civicrm_payment_processor',
726 'keyColumn' => 'id',
727 'labelColumn' => 'name',
728 ],
729 'add' => '3.3',
730 ],
731 'financial_type_id' => [
732 'name' => 'financial_type_id',
733 'type' => CRM_Utils_Type::T_INT,
734 'title' => ts('Financial Type ID'),
735 'description' => ts('FK to Financial Type'),
736 'where' => 'civicrm_contribution_recur.financial_type_id',
737 'export' => FALSE,
738 'table_name' => 'civicrm_contribution_recur',
739 'entity' => 'ContributionRecur',
740 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
741 'localizable' => 0,
742 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
743 'html' => [
744 'type' => 'Select',
745 'label' => ts("Financial Type"),
746 ],
747 'pseudoconstant' => [
748 'table' => 'civicrm_financial_type',
749 'keyColumn' => 'id',
750 'labelColumn' => 'name',
751 ],
752 'add' => '4.3',
753 ],
754 'payment_instrument_id' => [
755 'name' => 'payment_instrument_id',
756 'type' => CRM_Utils_Type::T_INT,
757 'title' => ts('Payment Method'),
758 'description' => ts('FK to Payment Instrument'),
759 'where' => 'civicrm_contribution_recur.payment_instrument_id',
760 'table_name' => 'civicrm_contribution_recur',
761 'entity' => 'ContributionRecur',
762 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
763 'localizable' => 0,
764 'html' => [
765 'type' => 'Select',
766 ],
767 'pseudoconstant' => [
768 'optionGroupName' => 'payment_instrument',
769 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
770 ],
771 'add' => '4.1',
772 ],
773 'contribution_campaign_id' => [
774 'name' => 'campaign_id',
775 'type' => CRM_Utils_Type::T_INT,
776 'title' => ts('Campaign ID'),
777 'description' => ts('The campaign for which this contribution has been triggered.'),
778 'import' => TRUE,
779 'where' => 'civicrm_contribution_recur.campaign_id',
780 'export' => TRUE,
781 'table_name' => 'civicrm_contribution_recur',
782 'entity' => 'ContributionRecur',
783 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
784 'localizable' => 0,
785 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
786 'component' => 'CiviCampaign',
787 'html' => [
788 'type' => 'EntityRef',
789 'label' => ts("Campaign"),
790 ],
791 'pseudoconstant' => [
792 'table' => 'civicrm_campaign',
793 'keyColumn' => 'id',
794 'labelColumn' => 'title',
795 'prefetch' => 'FALSE',
796 ],
797 'add' => '4.1',
798 ],
799 'is_email_receipt' => [
800 'name' => 'is_email_receipt',
801 'type' => CRM_Utils_Type::T_BOOLEAN,
802 'title' => ts('Send email Receipt?'),
803 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
804 'where' => 'civicrm_contribution_recur.is_email_receipt',
805 'default' => '1',
806 'table_name' => 'civicrm_contribution_recur',
807 'entity' => 'ContributionRecur',
808 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
809 'localizable' => 0,
810 'html' => [
811 'type' => 'CheckBox',
812 ],
813 'add' => '4.1',
814 ],
815 ];
816 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
817 }
818 return Civi::$statics[__CLASS__]['fields'];
819 }
820
821 /**
822 * Return a mapping from field-name to the corresponding key (as used in fields()).
823 *
824 * @return array
825 * Array(string $name => string $uniqueName).
826 */
827 public static function &fieldKeys() {
828 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
829 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
830 }
831 return Civi::$statics[__CLASS__]['fieldKeys'];
832 }
833
834 /**
835 * Returns the names of this table
836 *
837 * @return string
838 */
839 public static function getTableName() {
840 return self::$_tableName;
841 }
842
843 /**
844 * Returns if this table needs to be logged
845 *
846 * @return bool
847 */
848 public function getLog() {
849 return self::$_log;
850 }
851
852 /**
853 * Returns the list of fields that can be imported
854 *
855 * @param bool $prefix
856 *
857 * @return array
858 */
859 public static function &import($prefix = FALSE) {
860 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_recur', $prefix, []);
861 return $r;
862 }
863
864 /**
865 * Returns the list of fields that can be exported
866 *
867 * @param bool $prefix
868 *
869 * @return array
870 */
871 public static function &export($prefix = FALSE) {
872 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_recur', $prefix, []);
873 return $r;
874 }
875
876 /**
877 * Returns the list of indices
878 *
879 * @param bool $localize
880 *
881 * @return array
882 */
883 public static function indices($localize = TRUE) {
884 $indices = [
885 'UI_contrib_trxn_id' => [
886 'name' => 'UI_contrib_trxn_id',
887 'field' => [
888 0 => 'trxn_id',
889 ],
890 'localizable' => FALSE,
891 'unique' => TRUE,
892 'sig' => 'civicrm_contribution_recur::1::trxn_id',
893 ],
894 'UI_contrib_invoice_id' => [
895 'name' => 'UI_contrib_invoice_id',
896 'field' => [
897 0 => 'invoice_id',
898 ],
899 'localizable' => FALSE,
900 'unique' => TRUE,
901 'sig' => 'civicrm_contribution_recur::1::invoice_id',
902 ],
903 'index_contribution_status' => [
904 'name' => 'index_contribution_status',
905 'field' => [
906 0 => 'contribution_status_id',
907 ],
908 'localizable' => FALSE,
909 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
910 ],
911 'UI_contribution_recur_payment_instrument_id' => [
912 'name' => 'UI_contribution_recur_payment_instrument_id',
913 'field' => [
914 0 => 'payment_instrument_id',
915 ],
916 'localizable' => FALSE,
917 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
918 ],
919 ];
920 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
921 }
922
923 }