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