Merge pull request #18554 from civicrm/5.30
[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:ba5f7682a5f99b682f70cd45097feb56)
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 * @param bool $plural
244 * Whether to return the plural version of the title.
245 */
246 public static function getEntityTitle($plural = FALSE) {
247 return $plural ? ts('Recurring Contributions') : ts('Recurring Contribution');
248 }
249
250 /**
251 * Returns foreign keys and entity references.
252 *
253 * @return array
254 * [CRM_Core_Reference_Interface]
255 */
256 public static function getReferenceColumns() {
257 if (!isset(Civi::$statics[__CLASS__]['links'])) {
258 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
259 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
260 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id');
261 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id');
262 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
263 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
264 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
265 }
266 return Civi::$statics[__CLASS__]['links'];
267 }
268
269 /**
270 * Returns all the column names of this table
271 *
272 * @return array
273 */
274 public static function &fields() {
275 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
276 Civi::$statics[__CLASS__]['fields'] = [
277 'contribution_recur_id' => [
278 'name' => 'id',
279 'type' => CRM_Utils_Type::T_INT,
280 'title' => ts('Recurring Contribution ID'),
281 'description' => ts('Contribution Recur ID'),
282 'required' => TRUE,
283 'where' => 'civicrm_contribution_recur.id',
284 'table_name' => 'civicrm_contribution_recur',
285 'entity' => 'ContributionRecur',
286 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
287 'localizable' => 0,
288 'add' => '1.6',
289 ],
290 'contact_id' => [
291 'name' => 'contact_id',
292 'type' => CRM_Utils_Type::T_INT,
293 'title' => ts('Contact'),
294 'description' => ts('Foreign key to civicrm_contact.id.'),
295 'required' => TRUE,
296 'where' => 'civicrm_contribution_recur.contact_id',
297 'table_name' => 'civicrm_contribution_recur',
298 'entity' => 'ContributionRecur',
299 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
300 'localizable' => 0,
301 'FKClassName' => 'CRM_Contact_DAO_Contact',
302 'html' => [
303 'type' => 'EntityRef',
304 ],
305 'add' => '1.6',
306 ],
307 'amount' => [
308 'name' => 'amount',
309 'type' => CRM_Utils_Type::T_MONEY,
310 'title' => ts('Amount'),
311 'description' => ts('Amount to be collected (including any sales tax) by payment processor each recurrence.'),
312 'required' => TRUE,
313 'precision' => [
314 20,
315 2,
316 ],
317 'where' => 'civicrm_contribution_recur.amount',
318 'table_name' => 'civicrm_contribution_recur',
319 'entity' => 'ContributionRecur',
320 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
321 'localizable' => 0,
322 'html' => [
323 'type' => 'Text',
324 ],
325 'add' => '1.6',
326 ],
327 'currency' => [
328 'name' => 'currency',
329 'type' => CRM_Utils_Type::T_STRING,
330 'title' => ts('Currency'),
331 'description' => ts('3 character string, value from config setting or input via user.'),
332 'maxlength' => 3,
333 'size' => CRM_Utils_Type::FOUR,
334 'where' => 'civicrm_contribution_recur.currency',
335 'default' => 'NULL',
336 'table_name' => 'civicrm_contribution_recur',
337 'entity' => 'ContributionRecur',
338 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
339 'localizable' => 0,
340 'html' => [
341 'type' => 'Select',
342 ],
343 'pseudoconstant' => [
344 'table' => 'civicrm_currency',
345 'keyColumn' => 'name',
346 'labelColumn' => 'full_name',
347 'nameColumn' => 'name',
348 'abbrColumn' => 'symbol',
349 ],
350 'add' => '3.2',
351 ],
352 'frequency_unit' => [
353 'name' => 'frequency_unit',
354 'type' => CRM_Utils_Type::T_STRING,
355 'title' => ts('Frequency Unit'),
356 'description' => ts('Time units for recurrence of payment.'),
357 'maxlength' => 8,
358 'size' => CRM_Utils_Type::EIGHT,
359 'where' => 'civicrm_contribution_recur.frequency_unit',
360 'default' => 'month',
361 'table_name' => 'civicrm_contribution_recur',
362 'entity' => 'ContributionRecur',
363 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
364 'localizable' => 0,
365 'html' => [
366 'type' => 'Select',
367 ],
368 'pseudoconstant' => [
369 'optionGroupName' => 'recur_frequency_units',
370 'keyColumn' => 'name',
371 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
372 ],
373 'add' => '1.6',
374 ],
375 'frequency_interval' => [
376 'name' => 'frequency_interval',
377 'type' => CRM_Utils_Type::T_INT,
378 'title' => ts('Interval (number of units)'),
379 'description' => ts('Number of time units for recurrence of payment.'),
380 'required' => TRUE,
381 'where' => 'civicrm_contribution_recur.frequency_interval',
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 'installments' => [
392 'name' => 'installments',
393 'type' => CRM_Utils_Type::T_INT,
394 'title' => ts('Number of Installments'),
395 '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.'),
396 'where' => 'civicrm_contribution_recur.installments',
397 'table_name' => 'civicrm_contribution_recur',
398 'entity' => 'ContributionRecur',
399 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
400 'localizable' => 0,
401 'html' => [
402 'type' => 'Text',
403 ],
404 'add' => '1.6',
405 ],
406 'contribution_recur_start_date' => [
407 'name' => 'start_date',
408 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
409 'title' => ts('Start Date'),
410 'description' => ts('The date the first scheduled recurring contribution occurs.'),
411 'required' => TRUE,
412 'where' => 'civicrm_contribution_recur.start_date',
413 'table_name' => 'civicrm_contribution_recur',
414 'entity' => 'ContributionRecur',
415 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
416 'localizable' => 0,
417 'unique_title' => ts('Recurring Contribution Start Date'),
418 'html' => [
419 'type' => 'Select Date',
420 'formatType' => 'activityDateTime',
421 ],
422 'add' => '1.6',
423 ],
424 'contribution_recur_create_date' => [
425 'name' => 'create_date',
426 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
427 'title' => ts('Created Date'),
428 'description' => ts('When this recurring contribution record was created.'),
429 'required' => TRUE,
430 'where' => 'civicrm_contribution_recur.create_date',
431 'table_name' => 'civicrm_contribution_recur',
432 'entity' => 'ContributionRecur',
433 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
434 'localizable' => 0,
435 'unique_title' => ts('Recurring Contribution Create Date'),
436 'html' => [
437 'type' => 'Select Date',
438 'formatType' => 'activityDateTime',
439 ],
440 'add' => '1.6',
441 ],
442 'contribution_recur_modified_date' => [
443 'name' => 'modified_date',
444 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
445 'title' => ts('Modified Date'),
446 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
447 'where' => 'civicrm_contribution_recur.modified_date',
448 'table_name' => 'civicrm_contribution_recur',
449 'entity' => 'ContributionRecur',
450 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
451 'localizable' => 0,
452 'unique_title' => ts('Recurring Contribution Modified Date'),
453 'html' => [
454 'type' => 'Select Date',
455 'formatType' => 'activityDateTime',
456 ],
457 'add' => '1.6',
458 ],
459 'contribution_recur_cancel_date' => [
460 'name' => 'cancel_date',
461 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
462 'title' => ts('Cancel Date'),
463 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
464 'where' => 'civicrm_contribution_recur.cancel_date',
465 'table_name' => 'civicrm_contribution_recur',
466 'entity' => 'ContributionRecur',
467 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
468 'localizable' => 0,
469 'unique_title' => ts('Recurring Contribution Cancel Date'),
470 'html' => [
471 'type' => 'Select Date',
472 'formatType' => 'activityDate',
473 ],
474 'add' => '1.6',
475 ],
476 'contribution_recur_cancel_reason' => [
477 'name' => 'cancel_reason',
478 'type' => CRM_Utils_Type::T_TEXT,
479 'title' => ts('Cancellation Reason'),
480 'description' => ts('Free text field for a reason for cancelling'),
481 'where' => 'civicrm_contribution_recur.cancel_reason',
482 'table_name' => 'civicrm_contribution_recur',
483 'entity' => 'ContributionRecur',
484 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
485 'localizable' => 0,
486 'unique_title' => ts('Recurring Contribution Cancel Reason'),
487 'html' => [
488 'type' => 'Text',
489 ],
490 'add' => '5.13',
491 ],
492 'contribution_recur_end_date' => [
493 'name' => 'end_date',
494 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
495 'title' => ts('Recurring Contribution End Date'),
496 'description' => ts('Date this recurring contribution finished successfully'),
497 'where' => 'civicrm_contribution_recur.end_date',
498 'table_name' => 'civicrm_contribution_recur',
499 'entity' => 'ContributionRecur',
500 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
501 'localizable' => 0,
502 'unique_title' => ts('Recurring Contribution End Date'),
503 'html' => [
504 'type' => 'Select Date',
505 'formatType' => 'activityDate',
506 ],
507 'add' => '1.6',
508 ],
509 'contribution_recur_processor_id' => [
510 'name' => 'processor_id',
511 'type' => CRM_Utils_Type::T_STRING,
512 'title' => ts('Processor ID'),
513 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
514 'maxlength' => 255,
515 'size' => CRM_Utils_Type::HUGE,
516 'where' => 'civicrm_contribution_recur.processor_id',
517 'table_name' => 'civicrm_contribution_recur',
518 'entity' => 'ContributionRecur',
519 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
520 'localizable' => 0,
521 'html' => [
522 'type' => 'Text',
523 ],
524 'add' => '1.6',
525 ],
526 'payment_token_id' => [
527 'name' => 'payment_token_id',
528 'type' => CRM_Utils_Type::T_INT,
529 'title' => ts('Payment Token ID'),
530 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
531 'where' => 'civicrm_contribution_recur.payment_token_id',
532 'table_name' => 'civicrm_contribution_recur',
533 'entity' => 'ContributionRecur',
534 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
535 'localizable' => 0,
536 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
537 'add' => '4.6',
538 ],
539 'contribution_recur_trxn_id' => [
540 'name' => 'trxn_id',
541 'type' => CRM_Utils_Type::T_STRING,
542 'title' => ts('Transaction ID'),
543 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
544 'maxlength' => 255,
545 'size' => CRM_Utils_Type::HUGE,
546 'where' => 'civicrm_contribution_recur.trxn_id',
547 'table_name' => 'civicrm_contribution_recur',
548 'entity' => 'ContributionRecur',
549 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
550 'localizable' => 0,
551 'html' => [
552 'type' => 'Text',
553 ],
554 'add' => '1.6',
555 ],
556 'invoice_id' => [
557 'name' => 'invoice_id',
558 'type' => CRM_Utils_Type::T_STRING,
559 'title' => ts('Invoice ID'),
560 'description' => ts('unique invoice id, system generated or passed in'),
561 'maxlength' => 255,
562 'size' => CRM_Utils_Type::HUGE,
563 'where' => 'civicrm_contribution_recur.invoice_id',
564 'table_name' => 'civicrm_contribution_recur',
565 'entity' => 'ContributionRecur',
566 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
567 'localizable' => 0,
568 'html' => [
569 'type' => 'Text',
570 ],
571 'add' => '1.6',
572 ],
573 'contribution_recur_contribution_status_id' => [
574 'name' => 'contribution_status_id',
575 'type' => CRM_Utils_Type::T_INT,
576 'title' => ts('Status'),
577 'import' => TRUE,
578 'where' => 'civicrm_contribution_recur.contribution_status_id',
579 'export' => TRUE,
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' => 'Select',
587 ],
588 'pseudoconstant' => [
589 'optionGroupName' => 'contribution_recur_status',
590 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
591 ],
592 'add' => '1.6',
593 ],
594 'is_test' => [
595 'name' => 'is_test',
596 'type' => CRM_Utils_Type::T_BOOLEAN,
597 'title' => ts('Test'),
598 'import' => TRUE,
599 'where' => 'civicrm_contribution_recur.is_test',
600 'export' => TRUE,
601 'default' => '0',
602 'table_name' => 'civicrm_contribution_recur',
603 'entity' => 'ContributionRecur',
604 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
605 'localizable' => 0,
606 'html' => [
607 'type' => 'CheckBox',
608 ],
609 'add' => NULL,
610 ],
611 'cycle_day' => [
612 'name' => 'cycle_day',
613 'type' => CRM_Utils_Type::T_INT,
614 'title' => ts('Cycle Day'),
615 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
616 'required' => TRUE,
617 'where' => 'civicrm_contribution_recur.cycle_day',
618 'default' => '1',
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 'contribution_recur_next_sched_contribution_date' => [
629 'name' => 'next_sched_contribution_date',
630 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
631 'title' => ts('Next Scheduled Contribution Date'),
632 'description' => ts('Next scheduled date'),
633 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
634 'table_name' => 'civicrm_contribution_recur',
635 'entity' => 'ContributionRecur',
636 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
637 'localizable' => 0,
638 'unique_title' => ts('Next Scheduled Recurring Contribution'),
639 'html' => [
640 'type' => 'Select Date',
641 'formatType' => 'activityDate',
642 ],
643 'add' => '4.4',
644 ],
645 'failure_count' => [
646 'name' => 'failure_count',
647 'type' => CRM_Utils_Type::T_INT,
648 'title' => ts('Number of Failures'),
649 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
650 'where' => 'civicrm_contribution_recur.failure_count',
651 'default' => '0',
652 'table_name' => 'civicrm_contribution_recur',
653 'entity' => 'ContributionRecur',
654 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
655 'localizable' => 0,
656 'html' => [
657 'type' => 'Text',
658 ],
659 'add' => '1.6',
660 ],
661 'contribution_recur_failure_retry_date' => [
662 'name' => 'failure_retry_date',
663 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
664 'title' => ts('Retry Failed Attempt Date'),
665 'description' => ts('Date to retry failed attempt'),
666 'where' => 'civicrm_contribution_recur.failure_retry_date',
667 'table_name' => 'civicrm_contribution_recur',
668 'entity' => 'ContributionRecur',
669 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
670 'localizable' => 0,
671 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
672 'html' => [
673 'type' => 'Select Date',
674 'formatType' => 'activityDate',
675 ],
676 'add' => '1.6',
677 ],
678 'auto_renew' => [
679 'name' => 'auto_renew',
680 'type' => CRM_Utils_Type::T_BOOLEAN,
681 'title' => ts('Auto Renew'),
682 '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.'),
683 'required' => TRUE,
684 'where' => 'civicrm_contribution_recur.auto_renew',
685 'default' => '0',
686 'table_name' => 'civicrm_contribution_recur',
687 'entity' => 'ContributionRecur',
688 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
689 'localizable' => 0,
690 'html' => [
691 'type' => 'CheckBox',
692 ],
693 'add' => '1.6',
694 ],
695 'contribution_recur_payment_processor_id' => [
696 'name' => 'payment_processor_id',
697 'type' => CRM_Utils_Type::T_INT,
698 'title' => ts('Payment Processor'),
699 'description' => ts('Foreign key to civicrm_payment_processor.id'),
700 'where' => 'civicrm_contribution_recur.payment_processor_id',
701 'table_name' => 'civicrm_contribution_recur',
702 'entity' => 'ContributionRecur',
703 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
704 'localizable' => 0,
705 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
706 'html' => [
707 'type' => 'Select',
708 ],
709 'pseudoconstant' => [
710 'table' => 'civicrm_payment_processor',
711 'keyColumn' => 'id',
712 'labelColumn' => 'name',
713 ],
714 'add' => '3.3',
715 ],
716 'financial_type_id' => [
717 'name' => 'financial_type_id',
718 'type' => CRM_Utils_Type::T_INT,
719 'title' => ts('Financial Type'),
720 'description' => ts('FK to Financial Type'),
721 'where' => 'civicrm_contribution_recur.financial_type_id',
722 'export' => FALSE,
723 'table_name' => 'civicrm_contribution_recur',
724 'entity' => 'ContributionRecur',
725 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
726 'localizable' => 0,
727 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
728 'html' => [
729 'type' => 'Select',
730 ],
731 'pseudoconstant' => [
732 'table' => 'civicrm_financial_type',
733 'keyColumn' => 'id',
734 'labelColumn' => 'name',
735 ],
736 'add' => '4.3',
737 ],
738 'payment_instrument_id' => [
739 'name' => 'payment_instrument_id',
740 'type' => CRM_Utils_Type::T_INT,
741 'title' => ts('Payment Method'),
742 'description' => ts('FK to Payment Instrument'),
743 'where' => 'civicrm_contribution_recur.payment_instrument_id',
744 'table_name' => 'civicrm_contribution_recur',
745 'entity' => 'ContributionRecur',
746 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
747 'localizable' => 0,
748 'html' => [
749 'type' => 'Select',
750 ],
751 'pseudoconstant' => [
752 'optionGroupName' => 'payment_instrument',
753 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
754 ],
755 'add' => '4.1',
756 ],
757 'contribution_campaign_id' => [
758 'name' => 'campaign_id',
759 'type' => CRM_Utils_Type::T_INT,
760 'title' => ts('Campaign'),
761 'description' => ts('The campaign for which this contribution has been triggered.'),
762 'import' => TRUE,
763 'where' => 'civicrm_contribution_recur.campaign_id',
764 'export' => TRUE,
765 'table_name' => 'civicrm_contribution_recur',
766 'entity' => 'ContributionRecur',
767 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
768 'localizable' => 0,
769 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
770 'html' => [
771 'type' => 'Select',
772 ],
773 'pseudoconstant' => [
774 'table' => 'civicrm_campaign',
775 'keyColumn' => 'id',
776 'labelColumn' => 'title',
777 ],
778 'add' => '4.1',
779 ],
780 'is_email_receipt' => [
781 'name' => 'is_email_receipt',
782 'type' => CRM_Utils_Type::T_BOOLEAN,
783 'title' => ts('Send email Receipt?'),
784 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
785 'where' => 'civicrm_contribution_recur.is_email_receipt',
786 'default' => '1',
787 'table_name' => 'civicrm_contribution_recur',
788 'entity' => 'ContributionRecur',
789 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
790 'localizable' => 0,
791 'html' => [
792 'type' => 'CheckBox',
793 ],
794 'add' => '4.1',
795 ],
796 ];
797 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
798 }
799 return Civi::$statics[__CLASS__]['fields'];
800 }
801
802 /**
803 * Return a mapping from field-name to the corresponding key (as used in fields()).
804 *
805 * @return array
806 * Array(string $name => string $uniqueName).
807 */
808 public static function &fieldKeys() {
809 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
810 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
811 }
812 return Civi::$statics[__CLASS__]['fieldKeys'];
813 }
814
815 /**
816 * Returns the names of this table
817 *
818 * @return string
819 */
820 public static function getTableName() {
821 return self::$_tableName;
822 }
823
824 /**
825 * Returns if this table needs to be logged
826 *
827 * @return bool
828 */
829 public function getLog() {
830 return self::$_log;
831 }
832
833 /**
834 * Returns the list of fields that can be imported
835 *
836 * @param bool $prefix
837 *
838 * @return array
839 */
840 public static function &import($prefix = FALSE) {
841 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_recur', $prefix, []);
842 return $r;
843 }
844
845 /**
846 * Returns the list of fields that can be exported
847 *
848 * @param bool $prefix
849 *
850 * @return array
851 */
852 public static function &export($prefix = FALSE) {
853 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_recur', $prefix, []);
854 return $r;
855 }
856
857 /**
858 * Returns the list of indices
859 *
860 * @param bool $localize
861 *
862 * @return array
863 */
864 public static function indices($localize = TRUE) {
865 $indices = [
866 'UI_contrib_trxn_id' => [
867 'name' => 'UI_contrib_trxn_id',
868 'field' => [
869 0 => 'trxn_id',
870 ],
871 'localizable' => FALSE,
872 'unique' => TRUE,
873 'sig' => 'civicrm_contribution_recur::1::trxn_id',
874 ],
875 'UI_contrib_invoice_id' => [
876 'name' => 'UI_contrib_invoice_id',
877 'field' => [
878 0 => 'invoice_id',
879 ],
880 'localizable' => FALSE,
881 'unique' => TRUE,
882 'sig' => 'civicrm_contribution_recur::1::invoice_id',
883 ],
884 'index_contribution_status' => [
885 'name' => 'index_contribution_status',
886 'field' => [
887 0 => 'contribution_status_id',
888 ],
889 'localizable' => FALSE,
890 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
891 ],
892 'UI_contribution_recur_payment_instrument_id' => [
893 'name' => 'UI_contribution_recur_payment_instrument_id',
894 'field' => [
895 0 => 'payment_instrument_id',
896 ],
897 'localizable' => FALSE,
898 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
899 ],
900 ];
901 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
902 }
903
904 }