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