Merge pull request #14922 from civicrm/5.16
[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:95610d5dfc95017698041a9e814a7cda)
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 'contribution_recur_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 'unique_title' => ts('Recurring Contribution Start Date'),
398 'html' => [
399 'type' => 'Select Date',
400 'formatType' => 'activityDateTime',
401 ],
402 ],
403 'contribution_recur_create_date' => [
404 'name' => 'create_date',
405 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
406 'title' => ts('Created Date'),
407 'description' => ts('When this recurring contribution record was created.'),
408 'required' => TRUE,
409 'where' => 'civicrm_contribution_recur.create_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 Create Date'),
415 'html' => [
416 'type' => 'Select Date',
417 'formatType' => 'activityDateTime',
418 ],
419 ],
420 'contribution_recur_modified_date' => [
421 'name' => 'modified_date',
422 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
423 'title' => ts('Modified Date'),
424 'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
425 'where' => 'civicrm_contribution_recur.modified_date',
426 'table_name' => 'civicrm_contribution_recur',
427 'entity' => 'ContributionRecur',
428 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
429 'localizable' => 0,
430 'unique_title' => ts('Recurring Contribution Modified Date'),
431 'html' => [
432 'type' => 'Select Date',
433 'formatType' => 'activityDateTime',
434 ],
435 ],
436 'contribution_recur_cancel_date' => [
437 'name' => 'cancel_date',
438 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
439 'title' => ts('Cancel Date'),
440 'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
441 'where' => 'civicrm_contribution_recur.cancel_date',
442 'table_name' => 'civicrm_contribution_recur',
443 'entity' => 'ContributionRecur',
444 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
445 'localizable' => 0,
446 'unique_title' => ts('Recurring Contribution Cancel Date'),
447 'html' => [
448 'type' => 'Select Date',
449 'formatType' => 'activityDate',
450 ],
451 ],
452 'contribution_recur_cancel_reason' => [
453 'name' => 'cancel_reason',
454 'type' => CRM_Utils_Type::T_TEXT,
455 'title' => ts('Cancellation Reason'),
456 'description' => ts('Free text field for a reason for cancelling'),
457 'where' => 'civicrm_contribution_recur.cancel_reason',
458 'table_name' => 'civicrm_contribution_recur',
459 'entity' => 'ContributionRecur',
460 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
461 'localizable' => 0,
462 'unique_title' => ts('Recurring Contribution Cancel Reason'),
463 'html' => [
464 'type' => 'Text',
465 ],
466 ],
467 'contribution_recur_end_date' => [
468 'name' => 'end_date',
469 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
470 'title' => ts('Recurring Contribution End Date'),
471 'description' => ts('Date this recurring contribution finished successfully'),
472 'where' => 'civicrm_contribution_recur.end_date',
473 'table_name' => 'civicrm_contribution_recur',
474 'entity' => 'ContributionRecur',
475 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
476 'localizable' => 0,
477 'unique_title' => ts('Recurring Contribution End Date'),
478 'html' => [
479 'type' => 'Select Date',
480 'formatType' => 'activityDate',
481 ],
482 ],
483 'contribution_recur_processor_id' => [
484 'name' => 'processor_id',
485 'type' => CRM_Utils_Type::T_STRING,
486 'title' => ts('Processor ID'),
487 'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
488 'maxlength' => 255,
489 'size' => CRM_Utils_Type::HUGE,
490 'where' => 'civicrm_contribution_recur.processor_id',
491 'table_name' => 'civicrm_contribution_recur',
492 'entity' => 'ContributionRecur',
493 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
494 'localizable' => 0,
495 'html' => [
496 'type' => 'Text',
497 ],
498 ],
499 'payment_token_id' => [
500 'name' => 'payment_token_id',
501 'type' => CRM_Utils_Type::T_INT,
502 'title' => ts('Payment Token ID'),
503 'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
504 'where' => 'civicrm_contribution_recur.payment_token_id',
505 'table_name' => 'civicrm_contribution_recur',
506 'entity' => 'ContributionRecur',
507 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
508 'localizable' => 0,
509 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
510 ],
511 'contribution_recur_trxn_id' => [
512 'name' => 'trxn_id',
513 'type' => CRM_Utils_Type::T_STRING,
514 'title' => ts('Transaction ID'),
515 'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
516 'maxlength' => 255,
517 'size' => CRM_Utils_Type::HUGE,
518 'where' => 'civicrm_contribution_recur.trxn_id',
519 'table_name' => 'civicrm_contribution_recur',
520 'entity' => 'ContributionRecur',
521 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
522 'localizable' => 0,
523 'html' => [
524 'type' => 'Text',
525 ],
526 ],
527 'invoice_id' => [
528 'name' => 'invoice_id',
529 'type' => CRM_Utils_Type::T_STRING,
530 'title' => ts('Invoice ID'),
531 'description' => ts('unique invoice id, system generated or passed in'),
532 'maxlength' => 255,
533 'size' => CRM_Utils_Type::HUGE,
534 'where' => 'civicrm_contribution_recur.invoice_id',
535 'table_name' => 'civicrm_contribution_recur',
536 'entity' => 'ContributionRecur',
537 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
538 'localizable' => 0,
539 'html' => [
540 'type' => 'Text',
541 ],
542 ],
543 'contribution_recur_contribution_status_id' => [
544 'name' => 'contribution_status_id',
545 'type' => CRM_Utils_Type::T_INT,
546 'title' => ts('Status'),
547 'import' => TRUE,
548 'where' => 'civicrm_contribution_recur.contribution_status_id',
549 'export' => TRUE,
550 'default' => '1',
551 'table_name' => 'civicrm_contribution_recur',
552 'entity' => 'ContributionRecur',
553 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
554 'localizable' => 0,
555 'html' => [
556 'type' => 'Select',
557 ],
558 'pseudoconstant' => [
559 'optionGroupName' => 'contribution_recur_status',
560 'optionEditPath' => 'civicrm/admin/options/contribution_recur_status',
561 ],
562 ],
563 'is_test' => [
564 'name' => 'is_test',
565 'type' => CRM_Utils_Type::T_BOOLEAN,
566 'title' => ts('Test'),
567 'import' => TRUE,
568 'where' => 'civicrm_contribution_recur.is_test',
569 'export' => TRUE,
570 'default' => '0',
571 'table_name' => 'civicrm_contribution_recur',
572 'entity' => 'ContributionRecur',
573 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
574 'localizable' => 0,
575 'html' => [
576 'type' => 'CheckBox',
577 ],
578 ],
579 'cycle_day' => [
580 'name' => 'cycle_day',
581 'type' => CRM_Utils_Type::T_INT,
582 'title' => ts('Cycle Day'),
583 'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
584 'required' => TRUE,
585 'where' => 'civicrm_contribution_recur.cycle_day',
586 'default' => '1',
587 'table_name' => 'civicrm_contribution_recur',
588 'entity' => 'ContributionRecur',
589 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
590 'localizable' => 0,
591 'html' => [
592 'type' => 'Text',
593 ],
594 ],
595 'contribution_recur_next_sched_contribution_date' => [
596 'name' => 'next_sched_contribution_date',
597 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
598 'title' => ts('Next Scheduled Contribution Date'),
599 'description' => ts('Next scheduled date'),
600 'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
601 'table_name' => 'civicrm_contribution_recur',
602 'entity' => 'ContributionRecur',
603 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
604 'localizable' => 0,
605 'unique_title' => ts('Next Scheduled Recurring Contribution'),
606 'html' => [
607 'type' => 'Select Date',
608 'formatType' => 'activityDate',
609 ],
610 ],
611 'failure_count' => [
612 'name' => 'failure_count',
613 'type' => CRM_Utils_Type::T_INT,
614 'title' => ts('Number of Failures'),
615 'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
616 'where' => 'civicrm_contribution_recur.failure_count',
617 'default' => '0',
618 'table_name' => 'civicrm_contribution_recur',
619 'entity' => 'ContributionRecur',
620 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
621 'localizable' => 0,
622 'html' => [
623 'type' => 'Text',
624 ],
625 ],
626 'contribution_recur_failure_retry_date' => [
627 'name' => 'failure_retry_date',
628 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
629 'title' => ts('Retry Failed Attempt Date'),
630 'description' => ts('Date to retry failed attempt'),
631 'where' => 'civicrm_contribution_recur.failure_retry_date',
632 'table_name' => 'civicrm_contribution_recur',
633 'entity' => 'ContributionRecur',
634 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
635 'localizable' => 0,
636 'unique_title' => ts('Failed Recurring Contribution Retry Date'),
637 'html' => [
638 'type' => 'Select Date',
639 'formatType' => 'activityDate',
640 ],
641 ],
642 'auto_renew' => [
643 'name' => 'auto_renew',
644 'type' => CRM_Utils_Type::T_BOOLEAN,
645 'title' => ts('Auto Renew'),
646 '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.'),
647 'required' => TRUE,
648 'where' => 'civicrm_contribution_recur.auto_renew',
649 'default' => '0',
650 'table_name' => 'civicrm_contribution_recur',
651 'entity' => 'ContributionRecur',
652 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
653 'localizable' => 0,
654 'html' => [
655 'type' => 'CheckBox',
656 ],
657 ],
658 'contribution_recur_payment_processor_id' => [
659 'name' => 'payment_processor_id',
660 'type' => CRM_Utils_Type::T_INT,
661 'title' => ts('Payment Processor'),
662 'description' => ts('Foreign key to civicrm_payment_processor.id'),
663 'where' => 'civicrm_contribution_recur.payment_processor_id',
664 'table_name' => 'civicrm_contribution_recur',
665 'entity' => 'ContributionRecur',
666 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
667 'localizable' => 0,
668 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
669 'html' => [
670 'type' => 'Select',
671 ],
672 'pseudoconstant' => [
673 'table' => 'civicrm_payment_processor',
674 'keyColumn' => 'id',
675 'labelColumn' => 'name',
676 ],
677 ],
678 'financial_type_id' => [
679 'name' => 'financial_type_id',
680 'type' => CRM_Utils_Type::T_INT,
681 'title' => ts('Financial Type'),
682 'description' => ts('FK to Financial Type'),
683 'where' => 'civicrm_contribution_recur.financial_type_id',
684 'export' => FALSE,
685 'table_name' => 'civicrm_contribution_recur',
686 'entity' => 'ContributionRecur',
687 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
688 'localizable' => 0,
689 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
690 'html' => [
691 'type' => 'Select',
692 ],
693 'pseudoconstant' => [
694 'table' => 'civicrm_financial_type',
695 'keyColumn' => 'id',
696 'labelColumn' => 'name',
697 ],
698 ],
699 'payment_instrument_id' => [
700 'name' => 'payment_instrument_id',
701 'type' => CRM_Utils_Type::T_INT,
702 'title' => ts('Payment Method'),
703 'description' => ts('FK to Payment Instrument'),
704 'where' => 'civicrm_contribution_recur.payment_instrument_id',
705 'table_name' => 'civicrm_contribution_recur',
706 'entity' => 'ContributionRecur',
707 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
708 'localizable' => 0,
709 'html' => [
710 'type' => 'Select',
711 ],
712 'pseudoconstant' => [
713 'optionGroupName' => 'payment_instrument',
714 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
715 ],
716 ],
717 'contribution_campaign_id' => [
718 'name' => 'campaign_id',
719 'type' => CRM_Utils_Type::T_INT,
720 'title' => ts('Campaign'),
721 'description' => ts('The campaign for which this contribution has been triggered.'),
722 'import' => TRUE,
723 'where' => 'civicrm_contribution_recur.campaign_id',
724 'export' => TRUE,
725 'table_name' => 'civicrm_contribution_recur',
726 'entity' => 'ContributionRecur',
727 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
728 'localizable' => 0,
729 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
730 'html' => [
731 'type' => 'Select',
732 ],
733 'pseudoconstant' => [
734 'table' => 'civicrm_campaign',
735 'keyColumn' => 'id',
736 'labelColumn' => 'title',
737 ],
738 ],
739 'is_email_receipt' => [
740 'name' => 'is_email_receipt',
741 'type' => CRM_Utils_Type::T_BOOLEAN,
742 'title' => ts('Send email Receipt?'),
743 'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
744 'where' => 'civicrm_contribution_recur.is_email_receipt',
745 'default' => '1',
746 'table_name' => 'civicrm_contribution_recur',
747 'entity' => 'ContributionRecur',
748 'bao' => 'CRM_Contribute_BAO_ContributionRecur',
749 'localizable' => 0,
750 'html' => [
751 'type' => 'CheckBox',
752 ],
753 ],
754 ];
755 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
756 }
757 return Civi::$statics[__CLASS__]['fields'];
758 }
759
760 /**
761 * Return a mapping from field-name to the corresponding key (as used in fields()).
762 *
763 * @return array
764 * Array(string $name => string $uniqueName).
765 */
766 public static function &fieldKeys() {
767 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
768 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
769 }
770 return Civi::$statics[__CLASS__]['fieldKeys'];
771 }
772
773 /**
774 * Returns the names of this table
775 *
776 * @return string
777 */
778 public static function getTableName() {
779 return self::$_tableName;
780 }
781
782 /**
783 * Returns if this table needs to be logged
784 *
785 * @return bool
786 */
787 public function getLog() {
788 return self::$_log;
789 }
790
791 /**
792 * Returns the list of fields that can be imported
793 *
794 * @param bool $prefix
795 *
796 * @return array
797 */
798 public static function &import($prefix = FALSE) {
799 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_recur', $prefix, []);
800 return $r;
801 }
802
803 /**
804 * Returns the list of fields that can be exported
805 *
806 * @param bool $prefix
807 *
808 * @return array
809 */
810 public static function &export($prefix = FALSE) {
811 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_recur', $prefix, []);
812 return $r;
813 }
814
815 /**
816 * Returns the list of indices
817 *
818 * @param bool $localize
819 *
820 * @return array
821 */
822 public static function indices($localize = TRUE) {
823 $indices = [
824 'UI_contrib_trxn_id' => [
825 'name' => 'UI_contrib_trxn_id',
826 'field' => [
827 0 => 'trxn_id',
828 ],
829 'localizable' => FALSE,
830 'unique' => TRUE,
831 'sig' => 'civicrm_contribution_recur::1::trxn_id',
832 ],
833 'UI_contrib_invoice_id' => [
834 'name' => 'UI_contrib_invoice_id',
835 'field' => [
836 0 => 'invoice_id',
837 ],
838 'localizable' => FALSE,
839 'unique' => TRUE,
840 'sig' => 'civicrm_contribution_recur::1::invoice_id',
841 ],
842 'index_contribution_status' => [
843 'name' => 'index_contribution_status',
844 'field' => [
845 0 => 'contribution_status_id',
846 ],
847 'localizable' => FALSE,
848 'sig' => 'civicrm_contribution_recur::0::contribution_status_id',
849 ],
850 'UI_contribution_recur_payment_instrument_id' => [
851 'name' => 'UI_contribution_recur_payment_instrument_id',
852 'field' => [
853 0 => 'payment_instrument_id',
854 ],
855 'localizable' => FALSE,
856 'sig' => 'civicrm_contribution_recur::0::payment_instrument_id',
857 ],
858 ];
859 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
860 }
861
862 }