Merge pull request #14734 from yashodha/dev-1104
[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:117f63c183c68fcf5bd882f3fc40173e)
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 ],
351 ],
352 'pledge_frequency_unit' => [
353 'name' => 'frequency_unit',
354 'type' => CRM_Utils_Type::T_STRING,
355 'title' => ts('Pledge Frequency Unit'),
356 'description' => ts('Time units for recurrence of pledge payments.'),
357 'maxlength' => 8,
358 'size' => CRM_Utils_Type::EIGHT,
359 'where' => 'civicrm_pledge.frequency_unit',
360 'default' => 'month',
361 'table_name' => 'civicrm_pledge',
362 'entity' => 'Pledge',
363 'bao' => 'CRM_Pledge_BAO_Pledge',
364 'localizable' => 0,
365 'html' => [
366 'type' => 'Select',
367 ],
368 'pseudoconstant' => [
369 'optionGroupName' => 'recur_frequency_units',
370 'keyColumn' => 'name',
371 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
372 ],
373 ],
374 'pledge_frequency_interval' => [
375 'name' => 'frequency_interval',
376 'type' => CRM_Utils_Type::T_INT,
377 'title' => ts('Pledge Frequency Interval'),
378 'description' => ts('Number of time units for recurrence of pledge payments.'),
379 'required' => TRUE,
380 'where' => 'civicrm_pledge.frequency_interval',
381 'default' => '1',
382 'table_name' => 'civicrm_pledge',
383 'entity' => 'Pledge',
384 'bao' => 'CRM_Pledge_BAO_Pledge',
385 'localizable' => 0,
386 'html' => [
387 'type' => 'Text',
388 ],
389 ],
390 'frequency_day' => [
391 'name' => 'frequency_day',
392 'type' => CRM_Utils_Type::T_INT,
393 'title' => ts('Pledge day'),
394 '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.'),
395 'required' => TRUE,
396 'where' => 'civicrm_pledge.frequency_day',
397 'default' => '3',
398 'table_name' => 'civicrm_pledge',
399 'entity' => 'Pledge',
400 'bao' => 'CRM_Pledge_BAO_Pledge',
401 'localizable' => 0,
402 'html' => [
403 'type' => 'Select',
404 ],
405 ],
406 'installments' => [
407 'name' => 'installments',
408 'type' => CRM_Utils_Type::T_INT,
409 'title' => ts('Pledge Number of Installments'),
410 'description' => ts('Total number of payments to be made.'),
411 'where' => 'civicrm_pledge.installments',
412 'export' => TRUE,
413 'default' => '1',
414 'table_name' => 'civicrm_pledge',
415 'entity' => 'Pledge',
416 'bao' => 'CRM_Pledge_BAO_Pledge',
417 'localizable' => 0,
418 'html' => [
419 'type' => 'Text',
420 ],
421 ],
422 'start_date' => [
423 'name' => 'start_date',
424 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
425 'title' => ts('Pledge Start Date'),
426 'description' => ts('The date the first scheduled pledge occurs.'),
427 'required' => TRUE,
428 'where' => 'civicrm_pledge.start_date',
429 'table_name' => 'civicrm_pledge',
430 'entity' => 'Pledge',
431 'bao' => 'CRM_Pledge_BAO_Pledge',
432 'localizable' => 0,
433 'html' => [
434 'type' => 'Select Date',
435 ],
436 ],
437 'pledge_create_date' => [
438 'name' => 'create_date',
439 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
440 'title' => ts('Pledge Made'),
441 'description' => ts('When this pledge record was created.'),
442 'required' => TRUE,
443 'import' => TRUE,
444 'where' => 'civicrm_pledge.create_date',
445 'export' => TRUE,
446 'table_name' => 'civicrm_pledge',
447 'entity' => 'Pledge',
448 'bao' => 'CRM_Pledge_BAO_Pledge',
449 'localizable' => 0,
450 'html' => [
451 'type' => 'Select Date',
452 ],
453 ],
454 'acknowledge_date' => [
455 'name' => 'acknowledge_date',
456 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
457 'title' => ts('Pledge Acknowledged'),
458 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
459 'where' => 'civicrm_pledge.acknowledge_date',
460 'table_name' => 'civicrm_pledge',
461 'entity' => 'Pledge',
462 'bao' => 'CRM_Pledge_BAO_Pledge',
463 'localizable' => 0,
464 'html' => [
465 'type' => 'Select Date',
466 ],
467 ],
468 'modified_date' => [
469 'name' => 'modified_date',
470 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
471 'title' => ts('Pledge Modified Date'),
472 'description' => ts('Last updated date for this pledge record.'),
473 'where' => 'civicrm_pledge.modified_date',
474 'table_name' => 'civicrm_pledge',
475 'entity' => 'Pledge',
476 'bao' => 'CRM_Pledge_BAO_Pledge',
477 'localizable' => 0,
478 ],
479 'cancel_date' => [
480 'name' => 'cancel_date',
481 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
482 'title' => ts('Pledge Cancelled Date'),
483 'description' => ts('Date this pledge was cancelled by contributor.'),
484 'where' => 'civicrm_pledge.cancel_date',
485 'table_name' => 'civicrm_pledge',
486 'entity' => 'Pledge',
487 'bao' => 'CRM_Pledge_BAO_Pledge',
488 'localizable' => 0,
489 'html' => [
490 'type' => 'Select Date',
491 ],
492 ],
493 'end_date' => [
494 'name' => 'end_date',
495 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
496 'title' => ts('Pledge End Date'),
497 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
498 'where' => 'civicrm_pledge.end_date',
499 'table_name' => 'civicrm_pledge',
500 'entity' => 'Pledge',
501 'bao' => 'CRM_Pledge_BAO_Pledge',
502 'localizable' => 0,
503 'html' => [
504 'type' => 'Select Date',
505 ],
506 ],
507 'max_reminders' => [
508 'name' => 'max_reminders',
509 'type' => CRM_Utils_Type::T_INT,
510 'title' => ts('Maximum Number of Reminders'),
511 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
512 'where' => 'civicrm_pledge.max_reminders',
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' => ts('Send initial reminder this many days prior to the payment due date.'),
527 'where' => 'civicrm_pledge.initial_reminder_day',
528 'default' => '5',
529 'table_name' => 'civicrm_pledge',
530 'entity' => 'Pledge',
531 'bao' => 'CRM_Pledge_BAO_Pledge',
532 'localizable' => 0,
533 'html' => [
534 'type' => 'Select',
535 ],
536 ],
537 'additional_reminder_day' => [
538 'name' => 'additional_reminder_day',
539 'type' => CRM_Utils_Type::T_INT,
540 'title' => ts('Additional Reminder Days'),
541 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
542 'where' => 'civicrm_pledge.additional_reminder_day',
543 'default' => '5',
544 'table_name' => 'civicrm_pledge',
545 'entity' => 'Pledge',
546 'bao' => 'CRM_Pledge_BAO_Pledge',
547 'localizable' => 0,
548 'html' => [
549 'type' => 'Text',
550 ],
551 ],
552 'pledge_status_id' => [
553 'name' => 'status_id',
554 'type' => CRM_Utils_Type::T_INT,
555 'title' => ts('Pledge Status Id'),
556 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
557 'import' => TRUE,
558 'where' => 'civicrm_pledge.status_id',
559 'export' => FALSE,
560 'table_name' => 'civicrm_pledge',
561 'entity' => 'Pledge',
562 'bao' => 'CRM_Pledge_BAO_Pledge',
563 'localizable' => 0,
564 'html' => [
565 'type' => 'Select',
566 ],
567 'pseudoconstant' => [
568 'optionGroupName' => 'pledge_status',
569 'optionEditPath' => 'civicrm/admin/options/pledge_status',
570 ],
571 ],
572 'pledge_is_test' => [
573 'name' => 'is_test',
574 'type' => CRM_Utils_Type::T_BOOLEAN,
575 'title' => ts('Test'),
576 'import' => TRUE,
577 'where' => 'civicrm_pledge.is_test',
578 'export' => TRUE,
579 'default' => '0',
580 'table_name' => 'civicrm_pledge',
581 'entity' => 'Pledge',
582 'bao' => 'CRM_Pledge_BAO_Pledge',
583 'localizable' => 0,
584 'html' => [
585 'type' => 'CheckBox',
586 ],
587 ],
588 'pledge_campaign_id' => [
589 'name' => 'campaign_id',
590 'type' => CRM_Utils_Type::T_INT,
591 'title' => ts('Campaign'),
592 'description' => ts('The campaign for which this pledge has been initiated.'),
593 'import' => TRUE,
594 'where' => 'civicrm_pledge.campaign_id',
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 }