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