Regenerate DAO files
[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:27003a5c2de79b60b4114bc92b65cc07)
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 public static function getEntityTitle() {
211 return ts('Pledges');
212 }
213
214 /**
215 * Returns foreign keys and entity references.
216 *
217 * @return array
218 * [CRM_Core_Reference_Interface]
219 */
220 public static function getReferenceColumns() {
221 if (!isset(Civi::$statics[__CLASS__]['links'])) {
222 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
223 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
224 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
225 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
226 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
227 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
228 }
229 return Civi::$statics[__CLASS__]['links'];
230 }
231
232 /**
233 * Returns all the column names of this table
234 *
235 * @return array
236 */
237 public static function &fields() {
238 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
239 Civi::$statics[__CLASS__]['fields'] = [
240 'pledge_id' => [
241 'name' => 'id',
242 'type' => CRM_Utils_Type::T_INT,
243 'title' => ts('Pledge ID'),
244 'description' => ts('Pledge ID'),
245 'required' => TRUE,
246 'import' => TRUE,
247 'where' => 'civicrm_pledge.id',
248 'export' => TRUE,
249 'table_name' => 'civicrm_pledge',
250 'entity' => 'Pledge',
251 'bao' => 'CRM_Pledge_BAO_Pledge',
252 'localizable' => 0,
253 'add' => '2.1',
254 ],
255 'pledge_contact_id' => [
256 'name' => 'contact_id',
257 'type' => CRM_Utils_Type::T_INT,
258 'title' => ts('Contact ID'),
259 'description' => ts('Foreign key to civicrm_contact.id .'),
260 'required' => TRUE,
261 'import' => TRUE,
262 'where' => 'civicrm_pledge.contact_id',
263 'export' => TRUE,
264 'table_name' => 'civicrm_pledge',
265 'entity' => 'Pledge',
266 'bao' => 'CRM_Pledge_BAO_Pledge',
267 'localizable' => 0,
268 'FKClassName' => 'CRM_Contact_DAO_Contact',
269 'html' => [
270 'type' => 'EntityRef',
271 ],
272 'add' => '2.1',
273 ],
274 'pledge_financial_type_id' => [
275 'name' => 'financial_type_id',
276 'type' => CRM_Utils_Type::T_INT,
277 'title' => ts('Type'),
278 'description' => ts('FK to Financial Type'),
279 'where' => 'civicrm_pledge.financial_type_id',
280 'table_name' => 'civicrm_pledge',
281 'entity' => 'Pledge',
282 'bao' => 'CRM_Pledge_BAO_Pledge',
283 'localizable' => 0,
284 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
285 'html' => [
286 'type' => 'Select',
287 ],
288 'pseudoconstant' => [
289 'table' => 'civicrm_financial_type',
290 'keyColumn' => 'id',
291 'labelColumn' => 'name',
292 ],
293 'add' => '4.3',
294 ],
295 'pledge_contribution_page_id' => [
296 'name' => 'contribution_page_id',
297 'type' => CRM_Utils_Type::T_INT,
298 'title' => ts('Pledge Contribution Page'),
299 'description' => ts('The Contribution Page which triggered this contribution'),
300 'where' => 'civicrm_pledge.contribution_page_id',
301 'table_name' => 'civicrm_pledge',
302 'entity' => 'Pledge',
303 'bao' => 'CRM_Pledge_BAO_Pledge',
304 'localizable' => 0,
305 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
306 'add' => '2.1',
307 ],
308 'pledge_amount' => [
309 'name' => 'amount',
310 'type' => CRM_Utils_Type::T_MONEY,
311 'title' => ts('Total Pledged'),
312 'description' => ts('Total pledged amount.'),
313 'required' => TRUE,
314 'precision' => [
315 20,
316 2,
317 ],
318 'import' => TRUE,
319 'where' => 'civicrm_pledge.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 'add' => '2.1',
329 ],
330 'pledge_original_installment_amount' => [
331 'name' => 'original_installment_amount',
332 'type' => CRM_Utils_Type::T_MONEY,
333 'title' => ts('Original Installment Amount'),
334 'description' => ts('Original amount for each of the installments.'),
335 'required' => TRUE,
336 'precision' => [
337 20,
338 2,
339 ],
340 'where' => 'civicrm_pledge.original_installment_amount',
341 'export' => TRUE,
342 'table_name' => 'civicrm_pledge',
343 'entity' => 'Pledge',
344 'bao' => 'CRM_Pledge_BAO_Pledge',
345 'localizable' => 0,
346 'html' => [
347 'type' => 'Text',
348 ],
349 'add' => '3.2',
350 ],
351 'currency' => [
352 'name' => 'currency',
353 'type' => CRM_Utils_Type::T_STRING,
354 'title' => ts('Pledge Currency'),
355 'description' => ts('3 character string, value from config setting or input via user.'),
356 'maxlength' => 3,
357 'size' => CRM_Utils_Type::FOUR,
358 'where' => 'civicrm_pledge.currency',
359 'default' => 'NULL',
360 'table_name' => 'civicrm_pledge',
361 'entity' => 'Pledge',
362 'bao' => 'CRM_Pledge_BAO_Pledge',
363 'localizable' => 0,
364 'html' => [
365 'type' => 'Select',
366 ],
367 'pseudoconstant' => [
368 'table' => 'civicrm_currency',
369 'keyColumn' => 'name',
370 'labelColumn' => 'full_name',
371 'nameColumn' => 'name',
372 'abbrColumn' => 'symbol',
373 ],
374 'add' => '3.2',
375 ],
376 'pledge_frequency_unit' => [
377 'name' => 'frequency_unit',
378 'type' => CRM_Utils_Type::T_STRING,
379 'title' => ts('Pledge Frequency Unit'),
380 'description' => ts('Time units for recurrence of pledge payments.'),
381 'maxlength' => 8,
382 'size' => CRM_Utils_Type::EIGHT,
383 'where' => 'civicrm_pledge.frequency_unit',
384 'default' => 'month',
385 'table_name' => 'civicrm_pledge',
386 'entity' => 'Pledge',
387 'bao' => 'CRM_Pledge_BAO_Pledge',
388 'localizable' => 0,
389 'html' => [
390 'type' => 'Select',
391 ],
392 'pseudoconstant' => [
393 'optionGroupName' => 'recur_frequency_units',
394 'keyColumn' => 'name',
395 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
396 ],
397 'add' => '2.1',
398 ],
399 'pledge_frequency_interval' => [
400 'name' => 'frequency_interval',
401 'type' => CRM_Utils_Type::T_INT,
402 'title' => ts('Pledge Frequency Interval'),
403 'description' => ts('Number of time units for recurrence of pledge payments.'),
404 'required' => TRUE,
405 'where' => 'civicrm_pledge.frequency_interval',
406 'default' => '1',
407 'table_name' => 'civicrm_pledge',
408 'entity' => 'Pledge',
409 'bao' => 'CRM_Pledge_BAO_Pledge',
410 'localizable' => 0,
411 'html' => [
412 'type' => 'Text',
413 ],
414 'add' => '2.1',
415 ],
416 'frequency_day' => [
417 'name' => 'frequency_day',
418 'type' => CRM_Utils_Type::T_INT,
419 'title' => ts('Pledge day'),
420 '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.'),
421 'required' => TRUE,
422 'where' => 'civicrm_pledge.frequency_day',
423 'default' => '3',
424 'table_name' => 'civicrm_pledge',
425 'entity' => 'Pledge',
426 'bao' => 'CRM_Pledge_BAO_Pledge',
427 'localizable' => 0,
428 'html' => [
429 'type' => 'Select',
430 ],
431 'add' => '2.1',
432 ],
433 'installments' => [
434 'name' => 'installments',
435 'type' => CRM_Utils_Type::T_INT,
436 'title' => ts('Pledge Number of Installments'),
437 'description' => ts('Total number of payments to be made.'),
438 'where' => 'civicrm_pledge.installments',
439 'export' => TRUE,
440 'default' => '1',
441 'table_name' => 'civicrm_pledge',
442 'entity' => 'Pledge',
443 'bao' => 'CRM_Pledge_BAO_Pledge',
444 'localizable' => 0,
445 'html' => [
446 'type' => 'Text',
447 ],
448 'add' => '2.1',
449 ],
450 'pledge_start_date' => [
451 'name' => 'start_date',
452 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
453 'title' => ts('Pledge Start Date'),
454 'description' => ts('The date the first scheduled pledge occurs.'),
455 'required' => TRUE,
456 'where' => 'civicrm_pledge.start_date',
457 'export' => TRUE,
458 'table_name' => 'civicrm_pledge',
459 'entity' => 'Pledge',
460 'bao' => 'CRM_Pledge_BAO_Pledge',
461 'localizable' => 0,
462 'unique_title' => ts('Payments Start Date'),
463 'html' => [
464 'type' => 'Select Date',
465 'formatType' => 'activityDate',
466 ],
467 'add' => '2.1',
468 ],
469 'pledge_create_date' => [
470 'name' => 'create_date',
471 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
472 'title' => ts('Pledge Made'),
473 'description' => ts('When this pledge record was created.'),
474 'required' => TRUE,
475 'import' => TRUE,
476 'where' => 'civicrm_pledge.create_date',
477 'export' => TRUE,
478 'table_name' => 'civicrm_pledge',
479 'entity' => 'Pledge',
480 'bao' => 'CRM_Pledge_BAO_Pledge',
481 'localizable' => 0,
482 'html' => [
483 'type' => 'Select Date',
484 'formatType' => 'activityDate',
485 ],
486 'add' => '2.1',
487 ],
488 'acknowledge_date' => [
489 'name' => 'acknowledge_date',
490 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
491 'title' => ts('Pledge Acknowledged'),
492 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
493 'where' => 'civicrm_pledge.acknowledge_date',
494 'table_name' => 'civicrm_pledge',
495 'entity' => 'Pledge',
496 'bao' => 'CRM_Pledge_BAO_Pledge',
497 'localizable' => 0,
498 'html' => [
499 'type' => 'Select Date',
500 'formatType' => 'activityDate',
501 ],
502 'add' => '2.1',
503 ],
504 'modified_date' => [
505 'name' => 'modified_date',
506 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
507 'title' => ts('Pledge Modified Date'),
508 'description' => ts('Last updated date for this pledge record.'),
509 'where' => 'civicrm_pledge.modified_date',
510 'table_name' => 'civicrm_pledge',
511 'entity' => 'Pledge',
512 'bao' => 'CRM_Pledge_BAO_Pledge',
513 'localizable' => 0,
514 'add' => '2.1',
515 ],
516 'cancel_date' => [
517 'name' => 'cancel_date',
518 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
519 'title' => ts('Pledge Cancelled Date'),
520 'description' => ts('Date this pledge was cancelled by contributor.'),
521 'where' => 'civicrm_pledge.cancel_date',
522 'table_name' => 'civicrm_pledge',
523 'entity' => 'Pledge',
524 'bao' => 'CRM_Pledge_BAO_Pledge',
525 'localizable' => 0,
526 'html' => [
527 'type' => 'Select Date',
528 'formatType' => 'activityDate',
529 ],
530 'add' => '2.1',
531 ],
532 'pledge_end_date' => [
533 'name' => 'end_date',
534 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
535 'title' => ts('Pledge End Date'),
536 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
537 'where' => 'civicrm_pledge.end_date',
538 'export' => TRUE,
539 'table_name' => 'civicrm_pledge',
540 'entity' => 'Pledge',
541 'bao' => 'CRM_Pledge_BAO_Pledge',
542 'localizable' => 0,
543 'unique_title' => ts('Payments Ended Date'),
544 'html' => [
545 'type' => 'Select Date',
546 'formatType' => 'activityDate',
547 ],
548 'add' => '2.1',
549 ],
550 'max_reminders' => [
551 'name' => 'max_reminders',
552 'type' => CRM_Utils_Type::T_INT,
553 'title' => ts('Maximum Number of Reminders'),
554 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
555 'where' => 'civicrm_pledge.max_reminders',
556 'default' => '1',
557 'table_name' => 'civicrm_pledge',
558 'entity' => 'Pledge',
559 'bao' => 'CRM_Pledge_BAO_Pledge',
560 'localizable' => 0,
561 'html' => [
562 'type' => 'Text',
563 ],
564 'add' => '2.1',
565 ],
566 'initial_reminder_day' => [
567 'name' => 'initial_reminder_day',
568 'type' => CRM_Utils_Type::T_INT,
569 'title' => ts('Initial Reminder Day'),
570 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
571 'where' => 'civicrm_pledge.initial_reminder_day',
572 'default' => '5',
573 'table_name' => 'civicrm_pledge',
574 'entity' => 'Pledge',
575 'bao' => 'CRM_Pledge_BAO_Pledge',
576 'localizable' => 0,
577 'html' => [
578 'type' => 'Select',
579 ],
580 'add' => '2.1',
581 ],
582 'additional_reminder_day' => [
583 'name' => 'additional_reminder_day',
584 'type' => CRM_Utils_Type::T_INT,
585 'title' => ts('Additional Reminder Days'),
586 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
587 'where' => 'civicrm_pledge.additional_reminder_day',
588 'default' => '5',
589 'table_name' => 'civicrm_pledge',
590 'entity' => 'Pledge',
591 'bao' => 'CRM_Pledge_BAO_Pledge',
592 'localizable' => 0,
593 'html' => [
594 'type' => 'Text',
595 ],
596 'add' => '2.1',
597 ],
598 'pledge_status_id' => [
599 'name' => 'status_id',
600 'type' => CRM_Utils_Type::T_INT,
601 'title' => ts('Pledge Status Id'),
602 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
603 'import' => TRUE,
604 'where' => 'civicrm_pledge.status_id',
605 'export' => FALSE,
606 'table_name' => 'civicrm_pledge',
607 'entity' => 'Pledge',
608 'bao' => 'CRM_Pledge_BAO_Pledge',
609 'localizable' => 0,
610 'html' => [
611 'type' => 'Select',
612 ],
613 'pseudoconstant' => [
614 'optionGroupName' => 'pledge_status',
615 'optionEditPath' => 'civicrm/admin/options/pledge_status',
616 ],
617 'add' => '2.1',
618 ],
619 'pledge_is_test' => [
620 'name' => 'is_test',
621 'type' => CRM_Utils_Type::T_BOOLEAN,
622 'title' => ts('Test'),
623 'import' => TRUE,
624 'where' => 'civicrm_pledge.is_test',
625 'export' => TRUE,
626 'default' => '0',
627 'table_name' => 'civicrm_pledge',
628 'entity' => 'Pledge',
629 'bao' => 'CRM_Pledge_BAO_Pledge',
630 'localizable' => 0,
631 'html' => [
632 'type' => 'CheckBox',
633 ],
634 'add' => NULL,
635 ],
636 'pledge_campaign_id' => [
637 'name' => 'campaign_id',
638 'type' => CRM_Utils_Type::T_INT,
639 'title' => ts('Campaign'),
640 'description' => ts('The campaign for which this pledge has been initiated.'),
641 'import' => TRUE,
642 'where' => 'civicrm_pledge.campaign_id',
643 'export' => TRUE,
644 'table_name' => 'civicrm_pledge',
645 'entity' => 'Pledge',
646 'bao' => 'CRM_Pledge_BAO_Pledge',
647 'localizable' => 0,
648 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
649 'html' => [
650 'type' => 'Select',
651 ],
652 'pseudoconstant' => [
653 'table' => 'civicrm_campaign',
654 'keyColumn' => 'id',
655 'labelColumn' => 'title',
656 ],
657 'add' => '3.4',
658 ],
659 ];
660 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
661 }
662 return Civi::$statics[__CLASS__]['fields'];
663 }
664
665 /**
666 * Return a mapping from field-name to the corresponding key (as used in fields()).
667 *
668 * @return array
669 * Array(string $name => string $uniqueName).
670 */
671 public static function &fieldKeys() {
672 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
673 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
674 }
675 return Civi::$statics[__CLASS__]['fieldKeys'];
676 }
677
678 /**
679 * Returns the names of this table
680 *
681 * @return string
682 */
683 public static function getTableName() {
684 return self::$_tableName;
685 }
686
687 /**
688 * Returns if this table needs to be logged
689 *
690 * @return bool
691 */
692 public function getLog() {
693 return self::$_log;
694 }
695
696 /**
697 * Returns the list of fields that can be imported
698 *
699 * @param bool $prefix
700 *
701 * @return array
702 */
703 public static function &import($prefix = FALSE) {
704 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'pledge', $prefix, []);
705 return $r;
706 }
707
708 /**
709 * Returns the list of fields that can be exported
710 *
711 * @param bool $prefix
712 *
713 * @return array
714 */
715 public static function &export($prefix = FALSE) {
716 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'pledge', $prefix, []);
717 return $r;
718 }
719
720 /**
721 * Returns the list of indices
722 *
723 * @param bool $localize
724 *
725 * @return array
726 */
727 public static function indices($localize = TRUE) {
728 $indices = [
729 'index_status' => [
730 'name' => 'index_status',
731 'field' => [
732 0 => 'status_id',
733 ],
734 'localizable' => FALSE,
735 'sig' => 'civicrm_pledge::0::status_id',
736 ],
737 ];
738 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
739 }
740
741 }