Merge pull request #11142 from JMAConsulting/CRM-21260
[civicrm-core.git] / CRM / Pledge / DAO / Pledge.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2017
6 *
7 * Generated from xml/schema/CRM/Pledge/Pledge.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0e2129564a1877226e6dfce2840ce831)
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 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 static $_log = TRUE;
30
31 /**
32 * Pledge ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * Foreign key to civicrm_contact.id .
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
44
45 /**
46 * FK to Financial Type
47 *
48 * @var int unsigned
49 */
50 public $financial_type_id;
51
52 /**
53 * The Contribution Page which triggered this contribution
54 *
55 * @var int unsigned
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 unsigned
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 unsigned
98 */
99 public $frequency_day;
100
101 /**
102 * Total number of payments to be made.
103 *
104 * @var int unsigned
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 unsigned
154 */
155 public $max_reminders;
156
157 /**
158 * Send initial reminder this many days prior to the payment due date.
159 *
160 * @var int unsigned
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 unsigned
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 unsigned
175 */
176 public $status_id;
177
178 /**
179 * @var boolean
180 */
181 public $is_test;
182
183 /**
184 * The campaign for which this pledge has been initiated.
185 *
186 * @var int unsigned
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' => 'Pledge ID',
229 'required' => TRUE,
230 'import' => TRUE,
231 'where' => 'civicrm_pledge.id',
232 'headerPattern' => '',
233 'dataPattern' => '',
234 'export' => TRUE,
235 'table_name' => 'civicrm_pledge',
236 'entity' => 'Pledge',
237 'bao' => 'CRM_Pledge_BAO_Pledge',
238 'localizable' => 0,
239 ],
240 'pledge_contact_id' => [
241 'name' => 'contact_id',
242 'type' => CRM_Utils_Type::T_INT,
243 'title' => ts('Contact ID'),
244 'description' => 'Foreign key to civicrm_contact.id .',
245 'required' => TRUE,
246 'import' => TRUE,
247 'where' => 'civicrm_pledge.contact_id',
248 'headerPattern' => '',
249 'dataPattern' => '',
250 'export' => TRUE,
251 'table_name' => 'civicrm_pledge',
252 'entity' => 'Pledge',
253 'bao' => 'CRM_Pledge_BAO_Pledge',
254 'localizable' => 0,
255 'FKClassName' => 'CRM_Contact_DAO_Contact',
256 'html' => [
257 'type' => 'EntityRef',
258 ],
259 ],
260 'pledge_financial_type_id' => [
261 'name' => 'financial_type_id',
262 'type' => CRM_Utils_Type::T_INT,
263 'title' => ts('Type'),
264 'description' => 'FK to Financial Type',
265 'table_name' => 'civicrm_pledge',
266 'entity' => 'Pledge',
267 'bao' => 'CRM_Pledge_BAO_Pledge',
268 'localizable' => 0,
269 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
270 'html' => [
271 'type' => 'Select',
272 ],
273 'pseudoconstant' => [
274 'table' => 'civicrm_financial_type',
275 'keyColumn' => 'id',
276 'labelColumn' => 'name',
277 ]
278 ],
279 'pledge_contribution_page_id' => [
280 'name' => 'contribution_page_id',
281 'type' => CRM_Utils_Type::T_INT,
282 'title' => ts('Pledge Contribution Page'),
283 'description' => 'The Contribution Page which triggered this contribution',
284 'table_name' => 'civicrm_pledge',
285 'entity' => 'Pledge',
286 'bao' => 'CRM_Pledge_BAO_Pledge',
287 'localizable' => 0,
288 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
289 ],
290 'pledge_amount' => [
291 'name' => 'amount',
292 'type' => CRM_Utils_Type::T_MONEY,
293 'title' => ts('Total Pledged'),
294 'description' => 'Total pledged amount.',
295 'required' => TRUE,
296 'precision' => [
297 20,
298 2
299 ],
300 'import' => TRUE,
301 'where' => 'civicrm_pledge.amount',
302 'headerPattern' => '',
303 'dataPattern' => '',
304 'export' => TRUE,
305 'table_name' => 'civicrm_pledge',
306 'entity' => 'Pledge',
307 'bao' => 'CRM_Pledge_BAO_Pledge',
308 'localizable' => 0,
309 'html' => [
310 'type' => 'Text',
311 ],
312 ],
313 'pledge_original_installment_amount' => [
314 'name' => 'original_installment_amount',
315 'type' => CRM_Utils_Type::T_MONEY,
316 'title' => ts('Original Installment Amount'),
317 'description' => 'Original amount for each of the installments.',
318 'required' => TRUE,
319 'precision' => [
320 20,
321 2
322 ],
323 'export' => TRUE,
324 'where' => 'civicrm_pledge.original_installment_amount',
325 'headerPattern' => '',
326 'dataPattern' => '',
327 'table_name' => 'civicrm_pledge',
328 'entity' => 'Pledge',
329 'bao' => 'CRM_Pledge_BAO_Pledge',
330 'localizable' => 0,
331 'html' => [
332 'type' => 'Text',
333 ],
334 ],
335 'currency' => [
336 'name' => 'currency',
337 'type' => CRM_Utils_Type::T_STRING,
338 'title' => ts('Pledge Currency'),
339 'description' => '3 character string, value from config setting or input via user.',
340 'maxlength' => 3,
341 'size' => CRM_Utils_Type::FOUR,
342 'default' => 'NULL',
343 'table_name' => 'civicrm_pledge',
344 'entity' => 'Pledge',
345 'bao' => 'CRM_Pledge_BAO_Pledge',
346 'localizable' => 0,
347 'html' => [
348 'type' => 'Select',
349 ],
350 'pseudoconstant' => [
351 'table' => 'civicrm_currency',
352 'keyColumn' => 'name',
353 'labelColumn' => 'full_name',
354 'nameColumn' => 'name',
355 ]
356 ],
357 'pledge_frequency_unit' => [
358 'name' => 'frequency_unit',
359 'type' => CRM_Utils_Type::T_STRING,
360 'title' => ts('Pledge Frequency Unit'),
361 'description' => 'Time units for recurrence of pledge payments.',
362 'maxlength' => 8,
363 'size' => CRM_Utils_Type::EIGHT,
364 'default' => 'month',
365 'table_name' => 'civicrm_pledge',
366 'entity' => 'Pledge',
367 'bao' => 'CRM_Pledge_BAO_Pledge',
368 'localizable' => 0,
369 'html' => [
370 'type' => 'Select',
371 ],
372 'pseudoconstant' => [
373 'optionGroupName' => 'recur_frequency_units',
374 'keyColumn' => 'name',
375 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
376 ]
377 ],
378 'pledge_frequency_interval' => [
379 'name' => 'frequency_interval',
380 'type' => CRM_Utils_Type::T_INT,
381 'title' => ts('Pledge Frequency Interval'),
382 'description' => 'Number of time units for recurrence of pledge payments.',
383 'required' => TRUE,
384 'default' => '1',
385 'table_name' => 'civicrm_pledge',
386 'entity' => 'Pledge',
387 'bao' => 'CRM_Pledge_BAO_Pledge',
388 'localizable' => 0,
389 'html' => [
390 'type' => 'Text',
391 ],
392 ],
393 'frequency_day' => [
394 'name' => 'frequency_day',
395 'type' => CRM_Utils_Type::T_INT,
396 'title' => ts('Pledge day'),
397 '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.',
398 'required' => TRUE,
399 'default' => '3',
400 'table_name' => 'civicrm_pledge',
401 'entity' => 'Pledge',
402 'bao' => 'CRM_Pledge_BAO_Pledge',
403 'localizable' => 0,
404 'html' => [
405 'type' => 'Select',
406 ],
407 ],
408 'installments' => [
409 'name' => 'installments',
410 'type' => CRM_Utils_Type::T_INT,
411 'title' => ts('Pledge Number of Installments'),
412 'description' => 'Total number of payments to be made.',
413 'export' => TRUE,
414 'where' => 'civicrm_pledge.installments',
415 'headerPattern' => '',
416 'dataPattern' => '',
417 'default' => '1',
418 'table_name' => 'civicrm_pledge',
419 'entity' => 'Pledge',
420 'bao' => 'CRM_Pledge_BAO_Pledge',
421 'localizable' => 0,
422 'html' => [
423 'type' => 'Text',
424 ],
425 ],
426 'start_date' => [
427 'name' => 'start_date',
428 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
429 'title' => ts('Pledge Start Date'),
430 'description' => 'The date the first scheduled pledge occurs.',
431 'required' => TRUE,
432 'table_name' => 'civicrm_pledge',
433 'entity' => 'Pledge',
434 'bao' => 'CRM_Pledge_BAO_Pledge',
435 'localizable' => 0,
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' => 'When this pledge record was created.',
445 'required' => TRUE,
446 'import' => TRUE,
447 'where' => 'civicrm_pledge.create_date',
448 'headerPattern' => '',
449 'dataPattern' => '',
450 'export' => TRUE,
451 'table_name' => 'civicrm_pledge',
452 'entity' => 'Pledge',
453 'bao' => 'CRM_Pledge_BAO_Pledge',
454 'localizable' => 0,
455 'html' => [
456 'type' => 'Select Date',
457 ],
458 ],
459 'acknowledge_date' => [
460 'name' => 'acknowledge_date',
461 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
462 'title' => ts('Pledge Acknowledged'),
463 'description' => 'When a pledge acknowledgement message was sent to the contributor.',
464 'table_name' => 'civicrm_pledge',
465 'entity' => 'Pledge',
466 'bao' => 'CRM_Pledge_BAO_Pledge',
467 'localizable' => 0,
468 'html' => [
469 'type' => 'Select Date',
470 ],
471 ],
472 'modified_date' => [
473 'name' => 'modified_date',
474 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
475 'title' => ts('Pledge Modified Date'),
476 'description' => 'Last updated date for this pledge record.',
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' => 'Date this pledge was cancelled by contributor.',
487 'table_name' => 'civicrm_pledge',
488 'entity' => 'Pledge',
489 'bao' => 'CRM_Pledge_BAO_Pledge',
490 'localizable' => 0,
491 'html' => [
492 'type' => 'Select Date',
493 ],
494 ],
495 'end_date' => [
496 'name' => 'end_date',
497 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
498 'title' => ts('Pledge End Date'),
499 'description' => 'Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).',
500 'table_name' => 'civicrm_pledge',
501 'entity' => 'Pledge',
502 'bao' => 'CRM_Pledge_BAO_Pledge',
503 'localizable' => 0,
504 'html' => [
505 'type' => 'Select Date',
506 ],
507 ],
508 'max_reminders' => [
509 'name' => 'max_reminders',
510 'type' => CRM_Utils_Type::T_INT,
511 'title' => ts('Maximum Number of Reminders'),
512 'description' => 'The maximum number of payment reminders to send for any given payment.',
513 'default' => '1',
514 'table_name' => 'civicrm_pledge',
515 'entity' => 'Pledge',
516 'bao' => 'CRM_Pledge_BAO_Pledge',
517 'localizable' => 0,
518 'html' => [
519 'type' => 'Text',
520 ],
521 ],
522 'initial_reminder_day' => [
523 'name' => 'initial_reminder_day',
524 'type' => CRM_Utils_Type::T_INT,
525 'title' => ts('Initial Reminder Day'),
526 'description' => 'Send initial reminder this many days prior to the payment due date.',
527 'default' => '5',
528 'table_name' => 'civicrm_pledge',
529 'entity' => 'Pledge',
530 'bao' => 'CRM_Pledge_BAO_Pledge',
531 'localizable' => 0,
532 'html' => [
533 'type' => 'Select',
534 ],
535 ],
536 'additional_reminder_day' => [
537 'name' => 'additional_reminder_day',
538 'type' => CRM_Utils_Type::T_INT,
539 'title' => ts('Additional Reminder Days'),
540 'description' => 'Send additional reminder this many days after last one sent, up to maximum number of reminders.',
541 'default' => '5',
542 'table_name' => 'civicrm_pledge',
543 'entity' => 'Pledge',
544 'bao' => 'CRM_Pledge_BAO_Pledge',
545 'localizable' => 0,
546 'html' => [
547 'type' => 'Text',
548 ],
549 ],
550 'pledge_status_id' => [
551 'name' => 'status_id',
552 'type' => CRM_Utils_Type::T_INT,
553 'title' => ts('Pledge Status Id'),
554 'description' => 'Implicit foreign key to civicrm_option_values in the pledge_status option group.',
555 'import' => TRUE,
556 'where' => 'civicrm_pledge.status_id',
557 'headerPattern' => '',
558 'dataPattern' => '',
559 'export' => FALSE,
560 'table_name' => 'civicrm_pledge',
561 'entity' => 'Pledge',
562 'bao' => 'CRM_Pledge_BAO_Pledge',
563 'localizable' => 0,
564 'pseudoconstant' => [
565 'optionGroupName' => 'pledge_status',
566 'optionEditPath' => 'civicrm/admin/options/pledge_status',
567 ]
568 ],
569 'pledge_is_test' => [
570 'name' => 'is_test',
571 'type' => CRM_Utils_Type::T_BOOLEAN,
572 'title' => ts('Test'),
573 'import' => TRUE,
574 'where' => 'civicrm_pledge.is_test',
575 'headerPattern' => '',
576 'dataPattern' => '',
577 'export' => TRUE,
578 'table_name' => 'civicrm_pledge',
579 'entity' => 'Pledge',
580 'bao' => 'CRM_Pledge_BAO_Pledge',
581 'localizable' => 0,
582 'html' => [
583 'type' => 'CheckBox',
584 ],
585 ],
586 'pledge_campaign_id' => [
587 'name' => 'campaign_id',
588 'type' => CRM_Utils_Type::T_INT,
589 'title' => ts('Campaign'),
590 'description' => 'The campaign for which this pledge has been initiated.',
591 'import' => TRUE,
592 'where' => 'civicrm_pledge.campaign_id',
593 'headerPattern' => '',
594 'dataPattern' => '',
595 'export' => TRUE,
596 'table_name' => 'civicrm_pledge',
597 'entity' => 'Pledge',
598 'bao' => 'CRM_Pledge_BAO_Pledge',
599 'localizable' => 0,
600 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
601 'html' => [
602 'type' => 'Select',
603 ],
604 'pseudoconstant' => [
605 'table' => 'civicrm_campaign',
606 'keyColumn' => 'id',
607 'labelColumn' => 'title',
608 ]
609 ],
610 ];
611 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
612 }
613 return Civi::$statics[__CLASS__]['fields'];
614 }
615
616 /**
617 * Return a mapping from field-name to the corresponding key (as used in fields()).
618 *
619 * @return array
620 * Array(string $name => string $uniqueName).
621 */
622 public static function &fieldKeys() {
623 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
624 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
625 }
626 return Civi::$statics[__CLASS__]['fieldKeys'];
627 }
628
629 /**
630 * Returns the names of this table
631 *
632 * @return string
633 */
634 public static function getTableName() {
635 return self::$_tableName;
636 }
637
638 /**
639 * Returns if this table needs to be logged
640 *
641 * @return bool
642 */
643 public function getLog() {
644 return self::$_log;
645 }
646
647 /**
648 * Returns the list of fields that can be imported
649 *
650 * @param bool $prefix
651 *
652 * @return array
653 */
654 public static function &import($prefix = FALSE) {
655 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'pledge', $prefix, []);
656 return $r;
657 }
658
659 /**
660 * Returns the list of fields that can be exported
661 *
662 * @param bool $prefix
663 *
664 * @return array
665 */
666 public static function &export($prefix = FALSE) {
667 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'pledge', $prefix, []);
668 return $r;
669 }
670
671 /**
672 * Returns the list of indices
673 *
674 * @param bool $localize
675 *
676 * @return array
677 */
678 public static function indices($localize = TRUE) {
679 $indices = [
680 'index_status' => [
681 'name' => 'index_status',
682 'field' => [
683 0 => 'status_id',
684 ],
685 'localizable' => FALSE,
686 'sig' => 'civicrm_pledge::0::status_id',
687 ],
688 ];
689 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
690 }
691
692 }