Merge pull request #9632 from yashodha/CRM-19795
[civicrm-core.git] / CRM / Contribute / DAO / ContributionRecur.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:0d69452bb0935f1146d7f5fdaff295bc)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_contribution_recur';
e501603b
TO
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Contribution Recur ID
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * Foreign key to civicrm_contact.id .
59 *
60 * @var int unsigned
61 */
62 public $contact_id;
63 /**
64 * Amount to be contributed or charged each recurrence.
65 *
66 * @var float
67 */
68 public $amount;
69 /**
70 * 3 character string, value from config setting or input via user.
71 *
72 * @var string
73 */
74 public $currency;
75 /**
76 * Time units for recurrence of payment.
77 *
78 * @var string
79 */
80 public $frequency_unit;
81 /**
82 * Number of time units for recurrence of payment.
83 *
84 * @var int unsigned
85 */
86 public $frequency_interval;
87 /**
88 * Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.
89 *
90 * @var int unsigned
91 */
92 public $installments;
93 /**
94 * The date the first scheduled recurring contribution occurs.
95 *
96 * @var datetime
97 */
98 public $start_date;
99 /**
100 * When this recurring contribution record was created.
101 *
102 * @var datetime
103 */
104 public $create_date;
105 /**
106 * Last updated date for this record. mostly the last time a payment was received
107 *
108 * @var datetime
109 */
110 public $modified_date;
111 /**
112 * Date this recurring contribution was cancelled by contributor- if we can get access to it
113 *
114 * @var datetime
115 */
116 public $cancel_date;
117 /**
118 * Date this recurring contribution finished successfully
119 *
120 * @var datetime
121 */
122 public $end_date;
123 /**
124 * Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??
125 *
126 * @var string
127 */
128 public $processor_id;
129 /**
130 * Optionally used to store a link to a payment token used for this recurring contribution.
131 *
132 * @var int unsigned
133 */
134 public $payment_token_id;
135 /**
136 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
137 *
138 * @var string
139 */
140 public $trxn_id;
141 /**
142 * unique invoice id, system generated or passed in
143 *
144 * @var string
145 */
146 public $invoice_id;
147 /**
148 *
149 * @var int unsigned
150 */
151 public $contribution_status_id;
152 /**
153 *
154 * @var boolean
155 */
156 public $is_test;
157 /**
158 * Day in the period when the payment should be charged e.g. 1st of month, 15th etc.
159 *
160 * @var int unsigned
161 */
162 public $cycle_day;
163 /**
164 * Next scheduled date
165 *
166 * @var datetime
167 */
168 public $next_sched_contribution_date;
169 /**
170 * Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.
171 *
172 * @var int unsigned
173 */
174 public $failure_count;
175 /**
176 * Date to retry failed attempt
177 *
178 * @var datetime
179 */
180 public $failure_retry_date;
181 /**
182 * Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.
183 *
184 * @var boolean
185 */
186 public $auto_renew;
187 /**
188 * Foreign key to civicrm_payment_processor.id
189 *
190 * @var int unsigned
191 */
192 public $payment_processor_id;
193 /**
194 * FK to Financial Type
195 *
196 * @var int unsigned
197 */
198 public $financial_type_id;
199 /**
200 * FK to Payment Instrument
201 *
202 * @var int unsigned
203 */
204 public $payment_instrument_id;
205 /**
206 * The campaign for which this contribution has been triggered.
207 *
208 * @var int unsigned
209 */
210 public $campaign_id;
211 /**
212 * if true, receipt is automatically emailed to contact on each successful payment
213 *
214 * @var boolean
215 */
216 public $is_email_receipt;
217 /**
218 * class constructor
219 *
220 * @return civicrm_contribution_recur
221 */
222 function __construct() {
223 $this->__table = 'civicrm_contribution_recur';
224 parent::__construct();
225 }
226 /**
227 * Returns foreign keys and entity references
228 *
229 * @return array
230 * [CRM_Core_Reference_Interface]
231 */
232 static function getReferenceColumns() {
346aaaba
TO
233 if (!isset(Civi::$statics[__CLASS__]['links'])) {
234 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
235 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
236 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'payment_token_id', 'civicrm_payment_token', 'id');
237 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'payment_processor_id', 'civicrm_payment_processor', 'id');
238 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
239 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
240 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 241 }
346aaaba 242 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
243 }
244 /**
245 * Returns all the column names of this table
246 *
247 * @return array
248 */
249 static function &fields() {
346aaaba
TO
250 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
251 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
252 'id' => array(
253 'name' => 'id',
254 'type' => CRM_Utils_Type::T_INT,
255 'title' => ts('Recurring Contribution ID') ,
256 'description' => 'Contribution Recur ID',
257 'required' => true,
258 ) ,
259 'contact_id' => array(
260 'name' => 'contact_id',
261 'type' => CRM_Utils_Type::T_INT,
262 'title' => ts('Contact ID') ,
263 'description' => 'Foreign key to civicrm_contact.id .',
264 'required' => true,
265 'FKClassName' => 'CRM_Contact_DAO_Contact',
266 ) ,
267 'amount' => array(
268 'name' => 'amount',
269 'type' => CRM_Utils_Type::T_MONEY,
270 'title' => ts('Amount') ,
271 'description' => 'Amount to be contributed or charged each recurrence.',
272 'required' => true,
273 'precision' => array(
274 20,
275 2
276 ) ,
277 'html' => array(
278 'type' => 'Text',
279 ) ,
280 ) ,
281 'currency' => array(
282 'name' => 'currency',
283 'type' => CRM_Utils_Type::T_STRING,
284 'title' => ts('Currency') ,
285 'description' => '3 character string, value from config setting or input via user.',
286 'maxlength' => 3,
287 'size' => CRM_Utils_Type::FOUR,
288 'default' => 'NULL',
289 'html' => array(
290 'type' => 'Select',
291 ) ,
292 'pseudoconstant' => array(
293 'table' => 'civicrm_currency',
294 'keyColumn' => 'name',
295 'labelColumn' => 'full_name',
296 'nameColumn' => 'name',
297 )
298 ) ,
299 'frequency_unit' => array(
300 'name' => 'frequency_unit',
301 'type' => CRM_Utils_Type::T_STRING,
302 'title' => ts('Frequency Unit') ,
303 'description' => 'Time units for recurrence of payment.',
304 'maxlength' => 8,
305 'size' => CRM_Utils_Type::EIGHT,
306 'default' => 'month',
307 'html' => array(
308 'type' => 'Select',
309 ) ,
310 'pseudoconstant' => array(
311 'optionGroupName' => 'recur_frequency_units',
312 'keyColumn' => 'name',
313 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
314 )
315 ) ,
316 'frequency_interval' => array(
317 'name' => 'frequency_interval',
318 'type' => CRM_Utils_Type::T_INT,
319 'title' => ts('Interval (number of units)') ,
320 'description' => 'Number of time units for recurrence of payment.',
321 'required' => true,
322 'html' => array(
323 'type' => 'Text',
324 ) ,
325 ) ,
326 'installments' => array(
327 'name' => 'installments',
328 'type' => CRM_Utils_Type::T_INT,
329 'title' => ts('Number of Installments') ,
330 'description' => 'Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.',
331 'html' => array(
332 'type' => 'Text',
333 ) ,
334 ) ,
335 'start_date' => array(
336 'name' => 'start_date',
337 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
338 'title' => ts('Recurring Contribution Started Date') ,
339 'description' => 'The date the first scheduled recurring contribution occurs.',
340 'required' => true,
341 'html' => array(
342 'type' => 'Select Date',
343 ) ,
344 ) ,
345 'create_date' => array(
346 'name' => 'create_date',
347 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
348 'title' => ts('Recurring Contribution Created Date') ,
349 'description' => 'When this recurring contribution record was created.',
350 'required' => true,
351 'html' => array(
352 'type' => 'Select Date',
353 ) ,
354 ) ,
355 'modified_date' => array(
356 'name' => 'modified_date',
357 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
358 'title' => ts('Recurring Contribution Modified Date') ,
359 'description' => 'Last updated date for this record. mostly the last time a payment was received',
360 'html' => array(
361 'type' => 'Select Date',
362 ) ,
363 ) ,
364 'cancel_date' => array(
365 'name' => 'cancel_date',
366 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
367 'title' => ts('Recurring Contribution Cancel Date') ,
368 'description' => 'Date this recurring contribution was cancelled by contributor- if we can get access to it',
369 'html' => array(
370 'type' => 'Select Date',
371 ) ,
372 ) ,
373 'end_date' => array(
374 'name' => 'end_date',
375 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
376 'title' => ts('Recurring Contribution End Date') ,
377 'description' => 'Date this recurring contribution finished successfully',
378 'html' => array(
379 'type' => 'Select Date',
380 ) ,
381 ) ,
382 'processor_id' => array(
383 'name' => 'processor_id',
384 'type' => CRM_Utils_Type::T_STRING,
385 'title' => ts('Processor ID') ,
386 'description' => 'Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??',
387 'maxlength' => 255,
388 'size' => CRM_Utils_Type::HUGE,
389 ) ,
390 'payment_token_id' => array(
391 'name' => 'payment_token_id',
392 'type' => CRM_Utils_Type::T_INT,
393 'title' => ts('Payment Token ID') ,
394 'description' => 'Optionally used to store a link to a payment token used for this recurring contribution.',
395 'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
396 ) ,
397 'trxn_id' => array(
398 'name' => 'trxn_id',
399 'type' => CRM_Utils_Type::T_STRING,
400 'title' => ts('Transaction ID') ,
401 'description' => 'unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method',
402 'maxlength' => 255,
403 'size' => CRM_Utils_Type::HUGE,
404 ) ,
405 'invoice_id' => array(
406 'name' => 'invoice_id',
407 'type' => CRM_Utils_Type::T_STRING,
408 'title' => ts('Invoice ID') ,
409 'description' => 'unique invoice id, system generated or passed in',
410 'maxlength' => 255,
411 'size' => CRM_Utils_Type::HUGE,
412 ) ,
413 'contribution_status_id' => array(
414 'name' => 'contribution_status_id',
415 'type' => CRM_Utils_Type::T_INT,
416 'title' => ts('Recurring Contribution Status') ,
417 'import' => true,
418 'where' => 'civicrm_contribution_recur.contribution_status_id',
419 'headerPattern' => '',
420 'dataPattern' => '',
421 'export' => true,
422 'default' => '1',
423 'pseudoconstant' => array(
424 'optionGroupName' => 'contribution_status',
425 'optionEditPath' => 'civicrm/admin/options/contribution_status',
426 )
427 ) ,
428 'is_test' => array(
429 'name' => 'is_test',
430 'type' => CRM_Utils_Type::T_BOOLEAN,
431 'title' => ts('Test') ,
432 'import' => true,
433 'where' => 'civicrm_contribution_recur.is_test',
434 'headerPattern' => '',
435 'dataPattern' => '',
436 'export' => true,
437fafcf
TO
437 'html' => array(
438 'type' => 'CheckBox',
439 ) ,
e501603b
TO
440 ) ,
441 'cycle_day' => array(
442 'name' => 'cycle_day',
443 'type' => CRM_Utils_Type::T_INT,
444 'title' => ts('Number of Cycle Day') ,
445 'description' => 'Day in the period when the payment should be charged e.g. 1st of month, 15th etc.',
446 'required' => true,
447 'default' => '1',
437fafcf
TO
448 'html' => array(
449 'type' => 'Text',
450 ) ,
e501603b
TO
451 ) ,
452 'next_sched_contribution_date' => array(
453 'name' => 'next_sched_contribution_date',
454 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
455 'title' => ts('Next Scheduled Contribution Date') ,
456 'description' => 'Next scheduled date',
457 'html' => array(
458 'type' => 'Select Date',
459 ) ,
460 ) ,
461 'failure_count' => array(
462 'name' => 'failure_count',
463 'type' => CRM_Utils_Type::T_INT,
464 'title' => ts('Number of Failures') ,
465 'description' => 'Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.',
437fafcf
TO
466 'html' => array(
467 'type' => 'Text',
468 ) ,
e501603b
TO
469 ) ,
470 'failure_retry_date' => array(
471 'name' => 'failure_retry_date',
472 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
473 'title' => ts('Retry Failed Attempt Date') ,
474 'description' => 'Date to retry failed attempt',
475 'html' => array(
476 'type' => 'Select Date',
477 ) ,
478 ) ,
479 'auto_renew' => array(
480 'name' => 'auto_renew',
481 'type' => CRM_Utils_Type::T_BOOLEAN,
482 'title' => ts('Auto Renew') ,
483 'description' => 'Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.',
484 'required' => true,
437fafcf
TO
485 'html' => array(
486 'type' => 'CheckBox',
487 ) ,
e501603b
TO
488 ) ,
489 'payment_processor_id' => array(
490 'name' => 'payment_processor_id',
491 'type' => CRM_Utils_Type::T_INT,
492 'title' => ts('Payment Processor') ,
493 'description' => 'Foreign key to civicrm_payment_processor.id',
494 'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
495 ) ,
496 'financial_type_id' => array(
497 'name' => 'financial_type_id',
498 'type' => CRM_Utils_Type::T_INT,
499 'title' => ts('Financial Type') ,
500 'description' => 'FK to Financial Type',
501 'export' => false,
502 'where' => 'civicrm_contribution_recur.financial_type_id',
503 'headerPattern' => '',
504 'dataPattern' => '',
505 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
506 'pseudoconstant' => array(
507 'table' => 'civicrm_financial_type',
508 'keyColumn' => 'id',
509 'labelColumn' => 'name',
510 )
511 ) ,
512 'payment_instrument_id' => array(
513 'name' => 'payment_instrument_id',
514 'type' => CRM_Utils_Type::T_INT,
515 'title' => ts('Payment Method') ,
516 'description' => 'FK to Payment Instrument',
517 'html' => array(
518 'type' => 'Select',
519 ) ,
520 'pseudoconstant' => array(
521 'optionGroupName' => 'payment_instrument',
522 'optionEditPath' => 'civicrm/admin/options/payment_instrument',
523 )
524 ) ,
525 'contribution_campaign_id' => array(
526 'name' => 'campaign_id',
527 'type' => CRM_Utils_Type::T_INT,
528 'title' => ts('Campaign') ,
529 'description' => 'The campaign for which this contribution has been triggered.',
530 'import' => true,
531 'where' => 'civicrm_contribution_recur.campaign_id',
532 'headerPattern' => '',
533 'dataPattern' => '',
534 'export' => true,
535 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
536 'pseudoconstant' => array(
537 'table' => 'civicrm_campaign',
538 'keyColumn' => 'id',
539 'labelColumn' => 'title',
540 )
541 ) ,
542 'is_email_receipt' => array(
543 'name' => 'is_email_receipt',
544 'type' => CRM_Utils_Type::T_BOOLEAN,
545 'title' => ts('Send email Receipt?') ,
546 'description' => 'if true, receipt is automatically emailed to contact on each successful payment',
547 'default' => '1',
437fafcf
TO
548 'html' => array(
549 'type' => 'CheckBox',
550 ) ,
e501603b
TO
551 ) ,
552 );
346aaaba 553 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 554 }
346aaaba 555 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
556 }
557 /**
bd8e0b14 558 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
559 *
560 * @return array
bd8e0b14 561 * Array(string $name => string $uniqueName).
e501603b
TO
562 */
563 static function &fieldKeys() {
bd8e0b14
TO
564 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
565 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 566 }
bd8e0b14 567 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
568 }
569 /**
570 * Returns the names of this table
571 *
572 * @return string
573 */
574 static function getTableName() {
575 return self::$_tableName;
576 }
577 /**
578 * Returns if this table needs to be logged
579 *
580 * @return boolean
581 */
582 function getLog() {
583 return self::$_log;
584 }
585 /**
586 * Returns the list of fields that can be imported
587 *
588 * @param bool $prefix
589 *
590 * @return array
591 */
592 static function &import($prefix = false) {
60808919
TO
593 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_recur', $prefix, array());
594 return $r;
e501603b
TO
595 }
596 /**
597 * Returns the list of fields that can be exported
598 *
599 * @param bool $prefix
600 *
601 * @return array
602 */
603 static function &export($prefix = false) {
60808919
TO
604 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_recur', $prefix, array());
605 return $r;
e501603b
TO
606 }
607}