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