Fix comments on DAO files
[civicrm-core.git] / CRM / Contribute / DAO / ContributionRecur.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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
29 * @copyright CiviCRM LLC (c) 2004-2017
30 *
31 * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:0d69452bb0935f1146d7f5fdaff295bc)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 /**
38 * CRM_Contribute_DAO_ContributionRecur constructor.
39 */
40 class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
41 /**
42 * Static instance to hold the table name.
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_contribution_recur';
47 /**
48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Contribution Recur ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Foreign key to civicrm_contact.id .
61 *
62 * @var int unsigned
63 */
64 public $contact_id;
65 /**
66 * Amount to be contributed or charged each recurrence.
67 *
68 * @var float
69 */
70 public $amount;
71 /**
72 * 3 character string, value from config setting or input via user.
73 *
74 * @var string
75 */
76 public $currency;
77 /**
78 * Time units for recurrence of payment.
79 *
80 * @var string
81 */
82 public $frequency_unit;
83 /**
84 * Number of time units for recurrence of payment.
85 *
86 * @var int unsigned
87 */
88 public $frequency_interval;
89 /**
90 * Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.
91 *
92 * @var int unsigned
93 */
94 public $installments;
95 /**
96 * The date the first scheduled recurring contribution occurs.
97 *
98 * @var datetime
99 */
100 public $start_date;
101 /**
102 * When this recurring contribution record was created.
103 *
104 * @var datetime
105 */
106 public $create_date;
107 /**
108 * Last updated date for this record. mostly the last time a payment was received
109 *
110 * @var datetime
111 */
112 public $modified_date;
113 /**
114 * Date this recurring contribution was cancelled by contributor- if we can get access to it
115 *
116 * @var datetime
117 */
118 public $cancel_date;
119 /**
120 * Date this recurring contribution finished successfully
121 *
122 * @var datetime
123 */
124 public $end_date;
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;
131 /**
132 * Optionally used to store a link to a payment token used for this recurring contribution.
133 *
134 * @var int unsigned
135 */
136 public $payment_token_id;
137 /**
138 * unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method
139 *
140 * @var string
141 */
142 public $trxn_id;
143 /**
144 * unique invoice id, system generated or passed in
145 *
146 * @var string
147 */
148 public $invoice_id;
149 /**
150 *
151 * @var int unsigned
152 */
153 public $contribution_status_id;
154 /**
155 *
156 * @var boolean
157 */
158 public $is_test;
159 /**
160 * Day in the period when the payment should be charged e.g. 1st of month, 15th etc.
161 *
162 * @var int unsigned
163 */
164 public $cycle_day;
165 /**
166 * Next scheduled date
167 *
168 * @var datetime
169 */
170 public $next_sched_contribution_date;
171 /**
172 * Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.
173 *
174 * @var int unsigned
175 */
176 public $failure_count;
177 /**
178 * Date to retry failed attempt
179 *
180 * @var datetime
181 */
182 public $failure_retry_date;
183 /**
184 * Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.
185 *
186 * @var boolean
187 */
188 public $auto_renew;
189 /**
190 * Foreign key to civicrm_payment_processor.id
191 *
192 * @var int unsigned
193 */
194 public $payment_processor_id;
195 /**
196 * FK to Financial Type
197 *
198 * @var int unsigned
199 */
200 public $financial_type_id;
201 /**
202 * FK to Payment Instrument
203 *
204 * @var int unsigned
205 */
206 public $payment_instrument_id;
207 /**
208 * The campaign for which this contribution has been triggered.
209 *
210 * @var int unsigned
211 */
212 public $campaign_id;
213 /**
214 * if true, receipt is automatically emailed to contact on each successful payment
215 *
216 * @var boolean
217 */
218 public $is_email_receipt;
219 /**
220 * Class constructor.
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() {
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']);
241 }
242 return Civi::$statics[__CLASS__]['links'];
243 }
244 /**
245 * Returns all the column names of this table
246 *
247 * @return array
248 */
249 static function &fields() {
250 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
251 Civi::$statics[__CLASS__]['fields'] = array(
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,
437 'html' => array(
438 'type' => 'CheckBox',
439 ) ,
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',
448 'html' => array(
449 'type' => 'Text',
450 ) ,
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.',
466 'html' => array(
467 'type' => 'Text',
468 ) ,
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,
485 'html' => array(
486 'type' => 'CheckBox',
487 ) ,
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',
548 'html' => array(
549 'type' => 'CheckBox',
550 ) ,
551 ) ,
552 );
553 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
554 }
555 return Civi::$statics[__CLASS__]['fields'];
556 }
557 /**
558 * Return a mapping from field-name to the corresponding key (as used in fields()).
559 *
560 * @return array
561 * Array(string $name => string $uniqueName).
562 */
563 static function &fieldKeys() {
564 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
565 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
566 }
567 return Civi::$statics[__CLASS__]['fieldKeys'];
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) {
593 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contribution_recur', $prefix, array());
594 return $r;
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) {
604 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contribution_recur', $prefix, array());
605 return $r;
606 }
607 }