CRM-14885 - Import DAO's
[civicrm-core.git] / CRM / Pledge / DAO / Pledge.php
CommitLineData
e501603b
TO
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/Pledge/Pledge.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:db51fcee346b89501025824b7b0cb45f)
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_pledge';
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 instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = true;
83 /**
84 * Pledge ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Foreign key to civicrm_contact.id .
91 *
92 * @var int unsigned
93 */
94 public $contact_id;
95 /**
96 * FK to Financial Type
97 *
98 * @var int unsigned
99 */
100 public $financial_type_id;
101 /**
102 * The Contribution Page which triggered this contribution
103 *
104 * @var int unsigned
105 */
106 public $contribution_page_id;
107 /**
108 * Total pledged amount.
109 *
110 * @var float
111 */
112 public $amount;
113 /**
114 * Original amount for each of the installments.
115 *
116 * @var float
117 */
118 public $original_installment_amount;
119 /**
120 * 3 character string, value from config setting or input via user.
121 *
122 * @var string
123 */
124 public $currency;
125 /**
126 * Time units for recurrence of pledge payments.
127 *
128 * @var string
129 */
130 public $frequency_unit;
131 /**
132 * Number of time units for recurrence of pledge payments.
133 *
134 * @var int unsigned
135 */
136 public $frequency_interval;
137 /**
138 * Day in the period when the pledge payment is due e.g. 1st of month, 15th etc. Use this to set the scheduled dates for pledge payments.
139 *
140 * @var int unsigned
141 */
142 public $frequency_day;
143 /**
144 * Total number of payments to be made.
145 *
146 * @var int unsigned
147 */
148 public $installments;
149 /**
150 * The date the first scheduled pledge occurs.
151 *
152 * @var datetime
153 */
154 public $start_date;
155 /**
156 * When this pledge record was created.
157 *
158 * @var datetime
159 */
160 public $create_date;
161 /**
162 * When a pledge acknowledgement message was sent to the contributor.
163 *
164 * @var datetime
165 */
166 public $acknowledge_date;
167 /**
168 * Last updated date for this pledge record.
169 *
170 * @var datetime
171 */
172 public $modified_date;
173 /**
174 * Date this pledge was cancelled by contributor.
175 *
176 * @var datetime
177 */
178 public $cancel_date;
179 /**
180 * Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).
181 *
182 * @var datetime
183 */
184 public $end_date;
185 /**
186 * The maximum number of payment reminders to send for any given payment.
187 *
188 * @var int unsigned
189 */
190 public $max_reminders;
191 /**
192 * Send initial reminder this many days prior to the payment due date.
193 *
194 * @var int unsigned
195 */
196 public $initial_reminder_day;
197 /**
198 * Send additional reminder this many days after last one sent, up to maximum number of reminders.
199 *
200 * @var int unsigned
201 */
202 public $additional_reminder_day;
203 /**
204 * Implicit foreign key to civicrm_option_values in the contribution_status option group.
205 *
206 * @var int unsigned
207 */
208 public $status_id;
209 /**
210 *
211 * @var boolean
212 */
213 public $is_test;
214 /**
215 * The campaign for which this pledge has been initiated.
216 *
217 * @var int unsigned
218 */
219 public $campaign_id;
220 /**
221 * class constructor
222 *
223 * @return civicrm_pledge
224 */
225 function __construct() {
226 $this->__table = 'civicrm_pledge';
227 parent::__construct();
228 }
229 /**
230 * Returns foreign keys and entity references
231 *
232 * @return array
233 * [CRM_Core_Reference_Interface]
234 */
235 static function getReferenceColumns() {
236 if (!self::$_links) {
237 self::$_links = static ::createReferenceColumns(__CLASS__);
238 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
239 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'financial_type_id', 'civicrm_financial_type', 'id');
240 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contribution_page_id', 'civicrm_contribution_page', 'id');
241 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
242 }
243 return self::$_links;
244 }
245 /**
246 * Returns all the column names of this table
247 *
248 * @return array
249 */
250 static function &fields() {
251 if (!(self::$_fields)) {
252 self::$_fields = array(
253 'pledge_id' => array(
254 'name' => 'id',
255 'type' => CRM_Utils_Type::T_INT,
256 'title' => ts('Pledge ID') ,
257 'description' => 'Pledge ID',
258 'required' => true,
259 'import' => true,
260 'where' => 'civicrm_pledge.id',
261 'headerPattern' => '',
262 'dataPattern' => '',
263 'export' => true,
264 ) ,
265 'pledge_contact_id' => array(
266 'name' => 'contact_id',
267 'type' => CRM_Utils_Type::T_INT,
268 'title' => ts('Contact ID') ,
269 'description' => 'Foreign key to civicrm_contact.id .',
270 'required' => true,
271 'import' => true,
272 'where' => 'civicrm_pledge.contact_id',
273 'headerPattern' => '',
274 'dataPattern' => '',
275 'export' => true,
276 'FKClassName' => 'CRM_Contact_DAO_Contact',
277 'html' => array(
278 'type' => 'EntityRef',
279 ) ,
280 ) ,
281 'pledge_financial_type_id' => array(
282 'name' => 'financial_type_id',
283 'type' => CRM_Utils_Type::T_INT,
284 'title' => ts('Type') ,
285 'description' => 'FK to Financial Type',
286 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
287 'html' => array(
288 'type' => 'Select',
289 ) ,
290 'pseudoconstant' => array(
291 'table' => 'civicrm_financial_type',
292 'keyColumn' => 'id',
293 'labelColumn' => 'name',
294 )
295 ) ,
296 'pledge_contribution_page_id' => array(
297 'name' => 'contribution_page_id',
298 'type' => CRM_Utils_Type::T_INT,
299 'title' => ts('Pledge Contribution Page') ,
300 'description' => 'The Contribution Page which triggered this contribution',
301 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
302 ) ,
303 'pledge_amount' => array(
304 'name' => 'amount',
305 'type' => CRM_Utils_Type::T_MONEY,
306 'title' => ts('Total Pledged') ,
307 'description' => 'Total pledged amount.',
308 'required' => true,
309 'precision' => array(
310 20,
311 2
312 ) ,
313 'import' => true,
314 'where' => 'civicrm_pledge.amount',
315 'headerPattern' => '',
316 'dataPattern' => '',
317 'export' => true,
318 'html' => array(
319 'type' => 'Text',
320 ) ,
321 ) ,
322 'pledge_original_installment_amount' => array(
323 'name' => 'original_installment_amount',
324 'type' => CRM_Utils_Type::T_MONEY,
325 'title' => ts('Original Installment Amount') ,
326 'description' => 'Original amount for each of the installments.',
327 'required' => true,
328 'precision' => array(
329 20,
330 2
331 ) ,
332 'html' => array(
333 'type' => 'Text',
334 ) ,
335 ) ,
336 'currency' => array(
337 'name' => 'currency',
338 'type' => CRM_Utils_Type::T_STRING,
339 'title' => ts('Pledge Currency') ,
340 'description' => '3 character string, value from config setting or input via user.',
341 'maxlength' => 3,
342 'size' => CRM_Utils_Type::FOUR,
343 'default' => 'NULL',
344 'html' => array(
345 'type' => 'Select',
346 ) ,
347 'pseudoconstant' => array(
348 'table' => 'civicrm_currency',
349 'keyColumn' => 'name',
350 'labelColumn' => 'full_name',
351 'nameColumn' => 'name',
352 )
353 ) ,
354 'pledge_frequency_unit' => array(
355 'name' => 'frequency_unit',
356 'type' => CRM_Utils_Type::T_STRING,
357 'title' => ts('Pledge Frequency Unit') ,
358 'description' => 'Time units for recurrence of pledge payments.',
359 'maxlength' => 8,
360 'size' => CRM_Utils_Type::EIGHT,
361 'default' => 'month',
362 'html' => array(
363 'type' => 'Select',
364 ) ,
365 'pseudoconstant' => array(
366 'optionGroupName' => 'recur_frequency_units',
367 'keyColumn' => 'name',
368 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
369 )
370 ) ,
371 'pledge_frequency_interval' => array(
372 'name' => 'frequency_interval',
373 'type' => CRM_Utils_Type::T_INT,
374 'title' => ts('Pledge Frequency Interval') ,
375 'description' => 'Number of time units for recurrence of pledge payments.',
376 'required' => true,
377 'default' => '1',
378 'html' => array(
379 'type' => 'Text',
380 ) ,
381 ) ,
382 'frequency_day' => array(
383 'name' => 'frequency_day',
384 'type' => CRM_Utils_Type::T_INT,
385 'title' => ts('Pledge day') ,
386 'description' => 'Day in the period when the pledge payment is due e.g. 1st of month, 15th etc. Use this to set the scheduled dates for pledge payments.',
387 'required' => true,
388 'default' => '3',
389 'html' => array(
390 'type' => 'Select',
391 ) ,
392 ) ,
393 'installments' => array(
394 'name' => 'installments',
395 'type' => CRM_Utils_Type::T_INT,
396 'title' => ts('Pledge Number of Installments') ,
397 'description' => 'Total number of payments to be made.',
398 'default' => '1',
399 'html' => array(
400 'type' => 'Text',
401 ) ,
402 ) ,
403 'start_date' => array(
404 'name' => 'start_date',
405 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
406 'title' => ts('Pledge Start Date') ,
407 'description' => 'The date the first scheduled pledge occurs.',
408 'required' => true,
409 'html' => array(
410 'type' => 'Select Date',
411 ) ,
412 ) ,
413 'pledge_create_date' => array(
414 'name' => 'create_date',
415 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
416 'title' => ts('Pledge Made') ,
417 'description' => 'When this pledge record was created.',
418 'required' => true,
419 'import' => true,
420 'where' => 'civicrm_pledge.create_date',
421 'headerPattern' => '',
422 'dataPattern' => '',
423 'export' => true,
424 'html' => array(
425 'type' => 'Select Date',
426 ) ,
427 ) ,
428 'acknowledge_date' => array(
429 'name' => 'acknowledge_date',
430 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
431 'title' => ts('Pledge Acknowledged') ,
432 'description' => 'When a pledge acknowledgement message was sent to the contributor.',
433 'html' => array(
434 'type' => 'Select Date',
435 ) ,
436 ) ,
437 'modified_date' => array(
438 'name' => 'modified_date',
439 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
440 'title' => ts('Pledge Modified Date') ,
441 'description' => 'Last updated date for this pledge record.',
442 ) ,
443 'cancel_date' => array(
444 'name' => 'cancel_date',
445 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
446 'title' => ts('Pledge Cancelled Date') ,
447 'description' => 'Date this pledge was cancelled by contributor.',
448 'html' => array(
449 'type' => 'Select Date',
450 ) ,
451 ) ,
452 'end_date' => array(
453 'name' => 'end_date',
454 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
455 'title' => ts('Pledge End Date') ,
456 'description' => 'Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).',
457 'html' => array(
458 'type' => 'Select Date',
459 ) ,
460 ) ,
461 'max_reminders' => array(
462 'name' => 'max_reminders',
463 'type' => CRM_Utils_Type::T_INT,
464 'title' => ts('Maximum Number of Reminders') ,
465 'description' => 'The maximum number of payment reminders to send for any given payment.',
466 'default' => '1',
467 'html' => array(
468 'type' => 'Text',
469 ) ,
470 ) ,
471 'initial_reminder_day' => array(
472 'name' => 'initial_reminder_day',
473 'type' => CRM_Utils_Type::T_INT,
474 'title' => ts('Initial Reminder Day') ,
475 'description' => 'Send initial reminder this many days prior to the payment due date.',
476 'default' => '5',
477 'html' => array(
478 'type' => 'Select',
479 ) ,
480 ) ,
481 'additional_reminder_day' => array(
482 'name' => 'additional_reminder_day',
483 'type' => CRM_Utils_Type::T_INT,
484 'title' => ts('Additional Reminder Days') ,
485 'description' => 'Send additional reminder this many days after last one sent, up to maximum number of reminders.',
486 'default' => '5',
487 'html' => array(
488 'type' => 'Text',
489 ) ,
490 ) ,
491 'pledge_status_id' => array(
492 'name' => 'status_id',
493 'type' => CRM_Utils_Type::T_INT,
494 'title' => ts('Pledge Status Id') ,
495 'description' => 'Implicit foreign key to civicrm_option_values in the contribution_status option group.',
496 'import' => true,
497 'where' => 'civicrm_pledge.status_id',
498 'headerPattern' => '',
499 'dataPattern' => '',
500 'export' => false,
501 'pseudoconstant' => array(
502 'optionGroupName' => 'contribution_status',
503 'optionEditPath' => 'civicrm/admin/options/contribution_status',
504 )
505 ) ,
506 'pledge_is_test' => array(
507 'name' => 'is_test',
508 'type' => CRM_Utils_Type::T_BOOLEAN,
509 'title' => ts('Test') ,
510 'import' => true,
511 'where' => 'civicrm_pledge.is_test',
512 'headerPattern' => '',
513 'dataPattern' => '',
514 'export' => true,
515 'html' => array(
516 'type' => 'CheckBox',
517 ) ,
518 ) ,
519 'pledge_campaign_id' => array(
520 'name' => 'campaign_id',
521 'type' => CRM_Utils_Type::T_INT,
522 'title' => ts('Campaign') ,
523 'description' => 'The campaign for which this pledge has been initiated.',
524 'import' => true,
525 'where' => 'civicrm_pledge.campaign_id',
526 'headerPattern' => '',
527 'dataPattern' => '',
528 'export' => true,
529 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
530 'html' => array(
531 'type' => 'Select',
532 ) ,
533 'pseudoconstant' => array(
534 'table' => 'civicrm_campaign',
535 'keyColumn' => 'id',
536 'labelColumn' => 'title',
537 )
538 ) ,
539 );
540 }
541 return self::$_fields;
542 }
543 /**
544 * Returns an array containing, for each field, the arary key used for that
545 * field in self::$_fields.
546 *
547 * @return array
548 */
549 static function &fieldKeys() {
550 if (!(self::$_fieldKeys)) {
551 self::$_fieldKeys = array(
552 'id' => 'pledge_id',
553 'contact_id' => 'pledge_contact_id',
554 'financial_type_id' => 'pledge_financial_type_id',
555 'contribution_page_id' => 'pledge_contribution_page_id',
556 'amount' => 'pledge_amount',
557 'original_installment_amount' => 'pledge_original_installment_amount',
558 'currency' => 'currency',
559 'frequency_unit' => 'pledge_frequency_unit',
560 'frequency_interval' => 'pledge_frequency_interval',
561 'frequency_day' => 'frequency_day',
562 'installments' => 'installments',
563 'start_date' => 'start_date',
564 'create_date' => 'pledge_create_date',
565 'acknowledge_date' => 'acknowledge_date',
566 'modified_date' => 'modified_date',
567 'cancel_date' => 'cancel_date',
568 'end_date' => 'end_date',
569 'max_reminders' => 'max_reminders',
570 'initial_reminder_day' => 'initial_reminder_day',
571 'additional_reminder_day' => 'additional_reminder_day',
572 'status_id' => 'pledge_status_id',
573 'is_test' => 'pledge_is_test',
574 'campaign_id' => 'pledge_campaign_id',
575 );
576 }
577 return self::$_fieldKeys;
578 }
579 /**
580 * Returns the names of this table
581 *
582 * @return string
583 */
584 static function getTableName() {
585 return self::$_tableName;
586 }
587 /**
588 * Returns if this table needs to be logged
589 *
590 * @return boolean
591 */
592 function getLog() {
593 return self::$_log;
594 }
595 /**
596 * Returns the list of fields that can be imported
597 *
598 * @param bool $prefix
599 *
600 * @return array
601 */
602 static function &import($prefix = false) {
603 if (!(self::$_import)) {
604 self::$_import = array();
605 $fields = self::fields();
606 foreach($fields as $name => $field) {
607 if (CRM_Utils_Array::value('import', $field)) {
608 if ($prefix) {
609 self::$_import['pledge'] = & $fields[$name];
610 } else {
611 self::$_import[$name] = & $fields[$name];
612 }
613 }
614 }
615 }
616 return self::$_import;
617 }
618 /**
619 * Returns the list of fields that can be exported
620 *
621 * @param bool $prefix
622 *
623 * @return array
624 */
625 static function &export($prefix = false) {
626 if (!(self::$_export)) {
627 self::$_export = array();
628 $fields = self::fields();
629 foreach($fields as $name => $field) {
630 if (CRM_Utils_Array::value('export', $field)) {
631 if ($prefix) {
632 self::$_export['pledge'] = & $fields[$name];
633 } else {
634 self::$_export[$name] = & $fields[$name];
635 }
636 }
637 }
638 }
639 return self::$_export;
640 }
641}