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