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