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