5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Pledge/Pledge.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:49bcf54cf3de315f6e8f07519eb1b5f2)
13 * Database access object for the Pledge entity.
15 class CRM_Pledge_DAO_Pledge
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '2.1';
18 const COMPONENT
= 'CiviPledge';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_pledge';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-paper-plane';
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 public static $_log = TRUE;
49 * Foreign key to civicrm_contact.id .
56 * FK to Financial Type
60 public $financial_type_id;
63 * The Contribution Page which triggered this contribution
67 public $contribution_page_id;
70 * Total pledged amount.
77 * Original amount for each of the installments.
81 public $original_installment_amount;
84 * 3 character string, value from config setting or input via user.
91 * Time units for recurrence of pledge payments.
95 public $frequency_unit;
98 * Number of time units for recurrence of pledge payments.
102 public $frequency_interval;
105 * 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.
109 public $frequency_day;
112 * Total number of payments to be made.
116 public $installments;
119 * The date the first scheduled pledge occurs.
126 * When this pledge record was created.
133 * When a pledge acknowledgement message was sent to the contributor.
137 public $acknowledge_date;
140 * Last updated date for this pledge record.
144 public $modified_date;
147 * Date this pledge was cancelled by contributor.
154 * Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).
161 * The maximum number of payment reminders to send for any given payment.
165 public $max_reminders;
168 * Send initial reminder this many days prior to the payment due date.
172 public $initial_reminder_day;
175 * Send additional reminder this many days after last one sent, up to maximum number of reminders.
179 public $additional_reminder_day;
182 * Implicit foreign key to civicrm_option_values in the pledge_status option group.
194 * The campaign for which this pledge has been initiated.
203 public function __construct() {
204 $this->__table
= 'civicrm_pledge';
205 parent
::__construct();
209 * Returns localized title of this entity.
211 * @param bool $plural
212 * Whether to return the plural version of the title.
214 public static function getEntityTitle($plural = FALSE) {
215 return $plural ?
ts('Pledges') : ts('Pledge');
219 * Returns user-friendly description of this entity.
223 public static function getEntityDescription() {
224 return ts('Promises to contribute at a future time, either in full, or at regular intervals until a total goal is reached.');
228 * Returns foreign keys and entity references.
231 * [CRM_Core_Reference_Interface]
233 public static function getReferenceColumns() {
234 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
235 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
236 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
237 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
238 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
239 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
240 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
242 return Civi
::$statics[__CLASS__
]['links'];
246 * Returns all the column names of this table
250 public static function &fields() {
251 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
252 Civi
::$statics[__CLASS__
]['fields'] = [
255 'type' => CRM_Utils_Type
::T_INT
,
256 'title' => ts('Pledge ID'),
257 'description' => ts('Pledge ID'),
260 'where' => 'civicrm_pledge.id',
262 'table_name' => 'civicrm_pledge',
263 'entity' => 'Pledge',
264 'bao' => 'CRM_Pledge_BAO_Pledge',
272 'pledge_contact_id' => [
273 'name' => 'contact_id',
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Contact ID'),
276 'description' => ts('Foreign key to civicrm_contact.id .'),
279 'where' => 'civicrm_pledge.contact_id',
281 'table_name' => 'civicrm_pledge',
282 'entity' => 'Pledge',
283 'bao' => 'CRM_Pledge_BAO_Pledge',
285 'FKClassName' => 'CRM_Contact_DAO_Contact',
287 'type' => 'EntityRef',
288 'label' => ts("Contact"),
292 'pledge_financial_type_id' => [
293 'name' => 'financial_type_id',
294 'type' => CRM_Utils_Type
::T_INT
,
295 'title' => ts('Financial Type ID'),
296 'description' => ts('FK to Financial Type'),
297 'where' => 'civicrm_pledge.financial_type_id',
298 'table_name' => 'civicrm_pledge',
299 'entity' => 'Pledge',
300 'bao' => 'CRM_Pledge_BAO_Pledge',
302 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
305 'label' => ts("Financial Type"),
307 'pseudoconstant' => [
308 'table' => 'civicrm_financial_type',
310 'labelColumn' => 'name',
314 'pledge_contribution_page_id' => [
315 'name' => 'contribution_page_id',
316 'type' => CRM_Utils_Type
::T_INT
,
317 'title' => ts('Contribution Page ID'),
318 'description' => ts('The Contribution Page which triggered this contribution'),
319 'where' => 'civicrm_pledge.contribution_page_id',
320 'table_name' => 'civicrm_pledge',
321 'entity' => 'Pledge',
322 'bao' => 'CRM_Pledge_BAO_Pledge',
324 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
326 'label' => ts("Contribution Page"),
332 'type' => CRM_Utils_Type
::T_MONEY
,
333 'title' => ts('Total Pledged'),
334 'description' => ts('Total pledged amount.'),
341 'where' => 'civicrm_pledge.amount',
343 'table_name' => 'civicrm_pledge',
344 'entity' => 'Pledge',
345 'bao' => 'CRM_Pledge_BAO_Pledge',
352 'pledge_original_installment_amount' => [
353 'name' => 'original_installment_amount',
354 'type' => CRM_Utils_Type
::T_MONEY
,
355 'title' => ts('Original Installment Amount'),
356 'description' => ts('Original amount for each of the installments.'),
362 'where' => 'civicrm_pledge.original_installment_amount',
364 'table_name' => 'civicrm_pledge',
365 'entity' => 'Pledge',
366 'bao' => 'CRM_Pledge_BAO_Pledge',
374 'name' => 'currency',
375 'type' => CRM_Utils_Type
::T_STRING
,
376 'title' => ts('Pledge Currency'),
377 'description' => ts('3 character string, value from config setting or input via user.'),
379 'size' => CRM_Utils_Type
::FOUR
,
380 'where' => 'civicrm_pledge.currency',
382 'table_name' => 'civicrm_pledge',
383 'entity' => 'Pledge',
384 'bao' => 'CRM_Pledge_BAO_Pledge',
389 'pseudoconstant' => [
390 'table' => 'civicrm_currency',
391 'keyColumn' => 'name',
392 'labelColumn' => 'full_name',
393 'nameColumn' => 'name',
394 'abbrColumn' => 'symbol',
398 'pledge_frequency_unit' => [
399 'name' => 'frequency_unit',
400 'type' => CRM_Utils_Type
::T_STRING
,
401 'title' => ts('Pledge Frequency Unit'),
402 'description' => ts('Time units for recurrence of pledge payments.'),
405 'size' => CRM_Utils_Type
::EIGHT
,
406 'where' => 'civicrm_pledge.frequency_unit',
407 'default' => 'month',
408 'table_name' => 'civicrm_pledge',
409 'entity' => 'Pledge',
410 'bao' => 'CRM_Pledge_BAO_Pledge',
415 'pseudoconstant' => [
416 'optionGroupName' => 'recur_frequency_units',
417 'keyColumn' => 'name',
418 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
422 'pledge_frequency_interval' => [
423 'name' => 'frequency_interval',
424 'type' => CRM_Utils_Type
::T_INT
,
425 'title' => ts('Pledge Frequency Interval'),
426 'description' => ts('Number of time units for recurrence of pledge payments.'),
428 'where' => 'civicrm_pledge.frequency_interval',
430 'table_name' => 'civicrm_pledge',
431 'entity' => 'Pledge',
432 'bao' => 'CRM_Pledge_BAO_Pledge',
440 'name' => 'frequency_day',
441 'type' => CRM_Utils_Type
::T_INT
,
442 'title' => ts('Pledge day'),
443 '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.'),
445 'where' => 'civicrm_pledge.frequency_day',
447 'table_name' => 'civicrm_pledge',
448 'entity' => 'Pledge',
449 'bao' => 'CRM_Pledge_BAO_Pledge',
457 'name' => 'installments',
458 'type' => CRM_Utils_Type
::T_INT
,
459 'title' => ts('Pledge Number of Installments'),
460 'description' => ts('Total number of payments to be made.'),
462 'where' => 'civicrm_pledge.installments',
465 'table_name' => 'civicrm_pledge',
466 'entity' => 'Pledge',
467 'bao' => 'CRM_Pledge_BAO_Pledge',
474 'pledge_start_date' => [
475 'name' => 'start_date',
476 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
477 'title' => ts('Pledge Start Date'),
478 'description' => ts('The date the first scheduled pledge occurs.'),
480 'where' => 'civicrm_pledge.start_date',
482 'table_name' => 'civicrm_pledge',
483 'entity' => 'Pledge',
484 'bao' => 'CRM_Pledge_BAO_Pledge',
486 'unique_title' => ts('Payments Start Date'),
488 'type' => 'Select Date',
489 'formatType' => 'activityDate',
493 'pledge_create_date' => [
494 'name' => 'create_date',
495 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
496 'title' => ts('Pledge Made'),
497 'description' => ts('When this pledge record was created.'),
500 'where' => 'civicrm_pledge.create_date',
502 'table_name' => 'civicrm_pledge',
503 'entity' => 'Pledge',
504 'bao' => 'CRM_Pledge_BAO_Pledge',
507 'type' => 'Select Date',
508 'formatType' => 'activityDate',
512 'acknowledge_date' => [
513 'name' => 'acknowledge_date',
514 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
515 'title' => ts('Pledge Acknowledged'),
516 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
517 'where' => 'civicrm_pledge.acknowledge_date',
518 'table_name' => 'civicrm_pledge',
519 'entity' => 'Pledge',
520 'bao' => 'CRM_Pledge_BAO_Pledge',
523 'type' => 'Select Date',
524 'formatType' => 'activityDate',
529 'name' => 'modified_date',
530 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
531 'title' => ts('Pledge Modified Date'),
532 'description' => ts('Last updated date for this pledge record.'),
533 'where' => 'civicrm_pledge.modified_date',
534 'table_name' => 'civicrm_pledge',
535 'entity' => 'Pledge',
536 'bao' => 'CRM_Pledge_BAO_Pledge',
542 'name' => 'cancel_date',
543 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
544 'title' => ts('Pledge Cancelled Date'),
545 'description' => ts('Date this pledge was cancelled by contributor.'),
546 'where' => 'civicrm_pledge.cancel_date',
547 'table_name' => 'civicrm_pledge',
548 'entity' => 'Pledge',
549 'bao' => 'CRM_Pledge_BAO_Pledge',
552 'type' => 'Select Date',
553 'formatType' => 'activityDate',
557 'pledge_end_date' => [
558 'name' => 'end_date',
559 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
560 'title' => ts('Pledge End Date'),
561 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
562 'where' => 'civicrm_pledge.end_date',
564 'table_name' => 'civicrm_pledge',
565 'entity' => 'Pledge',
566 'bao' => 'CRM_Pledge_BAO_Pledge',
568 'unique_title' => ts('Payments Ended Date'),
570 'type' => 'Select Date',
571 'formatType' => 'activityDate',
576 'name' => 'max_reminders',
577 'type' => CRM_Utils_Type
::T_INT
,
578 'title' => ts('Maximum Number of Reminders'),
579 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
580 'where' => 'civicrm_pledge.max_reminders',
582 'table_name' => 'civicrm_pledge',
583 'entity' => 'Pledge',
584 'bao' => 'CRM_Pledge_BAO_Pledge',
591 'initial_reminder_day' => [
592 'name' => 'initial_reminder_day',
593 'type' => CRM_Utils_Type
::T_INT
,
594 'title' => ts('Initial Reminder Day'),
595 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
596 'where' => 'civicrm_pledge.initial_reminder_day',
598 'table_name' => 'civicrm_pledge',
599 'entity' => 'Pledge',
600 'bao' => 'CRM_Pledge_BAO_Pledge',
607 'additional_reminder_day' => [
608 'name' => 'additional_reminder_day',
609 'type' => CRM_Utils_Type
::T_INT
,
610 'title' => ts('Additional Reminder Days'),
611 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
612 'where' => 'civicrm_pledge.additional_reminder_day',
614 'table_name' => 'civicrm_pledge',
615 'entity' => 'Pledge',
616 'bao' => 'CRM_Pledge_BAO_Pledge',
623 'pledge_status_id' => [
624 'name' => 'status_id',
625 'type' => CRM_Utils_Type
::T_INT
,
626 'title' => ts('Pledge Status ID'),
627 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
630 'where' => 'civicrm_pledge.status_id',
632 'table_name' => 'civicrm_pledge',
633 'entity' => 'Pledge',
634 'bao' => 'CRM_Pledge_BAO_Pledge',
639 'pseudoconstant' => [
640 'optionGroupName' => 'pledge_status',
641 'optionEditPath' => 'civicrm/admin/options/pledge_status',
645 'pledge_is_test' => [
647 'type' => CRM_Utils_Type
::T_BOOLEAN
,
648 'title' => ts('Test'),
651 'where' => 'civicrm_pledge.is_test',
654 'table_name' => 'civicrm_pledge',
655 'entity' => 'Pledge',
656 'bao' => 'CRM_Pledge_BAO_Pledge',
659 'type' => 'CheckBox',
663 'pledge_campaign_id' => [
664 'name' => 'campaign_id',
665 'type' => CRM_Utils_Type
::T_INT
,
666 'title' => ts('Campaign ID'),
667 'description' => ts('The campaign for which this pledge has been initiated.'),
669 'where' => 'civicrm_pledge.campaign_id',
671 'table_name' => 'civicrm_pledge',
672 'entity' => 'Pledge',
673 'bao' => 'CRM_Pledge_BAO_Pledge',
675 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
676 'component' => 'CiviCampaign',
678 'type' => 'EntityRef',
679 'label' => ts("Campaign"),
684 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
686 return Civi
::$statics[__CLASS__
]['fields'];
690 * Return a mapping from field-name to the corresponding key (as used in fields()).
693 * Array(string $name => string $uniqueName).
695 public static function &fieldKeys() {
696 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
697 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
699 return Civi
::$statics[__CLASS__
]['fieldKeys'];
703 * Returns the names of this table
707 public static function getTableName() {
708 return self
::$_tableName;
712 * Returns if this table needs to be logged
716 public function getLog() {
721 * Returns the list of fields that can be imported
723 * @param bool $prefix
727 public static function &import($prefix = FALSE) {
728 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
733 * Returns the list of fields that can be exported
735 * @param bool $prefix
739 public static function &export($prefix = FALSE) {
740 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
745 * Returns the list of indices
747 * @param bool $localize
751 public static function indices($localize = TRUE) {
754 'name' => 'index_status',
758 'localizable' => FALSE,
759 'sig' => 'civicrm_pledge::0::status_id',
762 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;