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