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