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