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