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