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