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