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