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:cbecc4833b44f7758722ef898cb8670b)
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;
44 * @var int|string|null
45 * (SQL type: int unsigned)
46 * Note that values will be retrieved from the database as a string.
51 * Foreign key to civicrm_contact.id .
54 * (SQL type: int unsigned)
55 * Note that values will be retrieved from the database as a string.
60 * FK to Financial Type
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
66 public $financial_type_id;
69 * The Contribution Page which triggered this contribution
71 * @var int|string|null
72 * (SQL type: int unsigned)
73 * Note that values will be retrieved from the database as a string.
75 public $contribution_page_id;
78 * Total pledged amount.
81 * (SQL type: decimal(20,2))
82 * Note that values will be retrieved from the database as a string.
87 * Original amount for each of the installments.
90 * (SQL type: decimal(20,2))
91 * Note that values will be retrieved from the database as a string.
93 public $original_installment_amount;
96 * 3 character string, value from config setting or input via user.
99 * (SQL type: varchar(3))
100 * Note that values will be retrieved from the database as a string.
105 * Time units for recurrence of pledge payments.
108 * (SQL type: varchar(8))
109 * Note that values will be retrieved from the database as a string.
111 public $frequency_unit;
114 * Number of time units for recurrence of pledge payments.
117 * (SQL type: int unsigned)
118 * Note that values will be retrieved from the database as a string.
120 public $frequency_interval;
123 * 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.
126 * (SQL type: int unsigned)
127 * Note that values will be retrieved from the database as a string.
129 public $frequency_day;
132 * Total number of payments to be made.
135 * (SQL type: int unsigned)
136 * Note that values will be retrieved from the database as a string.
138 public $installments;
141 * The date the first scheduled pledge occurs.
144 * (SQL type: datetime)
145 * Note that values will be retrieved from the database as a string.
150 * When this pledge record was created.
153 * (SQL type: datetime)
154 * Note that values will be retrieved from the database as a string.
159 * When a pledge acknowledgement message was sent to the contributor.
162 * (SQL type: datetime)
163 * Note that values will be retrieved from the database as a string.
165 public $acknowledge_date;
168 * Last updated date for this pledge record.
171 * (SQL type: datetime)
172 * Note that values will be retrieved from the database as a string.
174 public $modified_date;
177 * Date this pledge was cancelled by contributor.
180 * (SQL type: datetime)
181 * Note that values will be retrieved from the database as a string.
186 * Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).
189 * (SQL type: datetime)
190 * Note that values will be retrieved from the database as a string.
195 * The maximum number of payment reminders to send for any given payment.
197 * @var int|string|null
198 * (SQL type: int unsigned)
199 * Note that values will be retrieved from the database as a string.
201 public $max_reminders;
204 * Send initial reminder this many days prior to the payment due date.
206 * @var int|string|null
207 * (SQL type: int unsigned)
208 * Note that values will be retrieved from the database as a string.
210 public $initial_reminder_day;
213 * Send additional reminder this many days after last one sent, up to maximum number of reminders.
215 * @var int|string|null
216 * (SQL type: int unsigned)
217 * Note that values will be retrieved from the database as a string.
219 public $additional_reminder_day;
222 * Implicit foreign key to civicrm_option_values in the pledge_status option group.
225 * (SQL type: int unsigned)
226 * Note that values will be retrieved from the database as a string.
232 * (SQL type: tinyint)
233 * Note that values will be retrieved from the database as a string.
238 * The campaign for which this pledge has been initiated.
240 * @var int|string|null
241 * (SQL type: int unsigned)
242 * Note that values will be retrieved from the database as a string.
249 public function __construct() {
250 $this->__table
= 'civicrm_pledge';
251 parent
::__construct();
255 * Returns localized title of this entity.
257 * @param bool $plural
258 * Whether to return the plural version of the title.
260 public static function getEntityTitle($plural = FALSE) {
261 return $plural ?
ts('Pledges') : ts('Pledge');
265 * Returns user-friendly description of this entity.
269 public static function getEntityDescription() {
270 return ts('Promises to contribute at a future time, either in full, or at regular intervals until a total goal is reached.');
274 * Returns foreign keys and entity references.
277 * [CRM_Core_Reference_Interface]
279 public static function getReferenceColumns() {
280 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
281 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
282 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
283 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
284 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
285 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
286 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
288 return Civi
::$statics[__CLASS__
]['links'];
292 * Returns all the column names of this table
296 public static function &fields() {
297 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
298 Civi
::$statics[__CLASS__
]['fields'] = [
301 'type' => CRM_Utils_Type
::T_INT
,
302 'title' => ts('Pledge ID'),
303 'description' => ts('Pledge ID'),
306 'where' => 'civicrm_pledge.id',
308 'table_name' => 'civicrm_pledge',
309 'entity' => 'Pledge',
310 'bao' => 'CRM_Pledge_BAO_Pledge',
318 'pledge_contact_id' => [
319 'name' => 'contact_id',
320 'type' => CRM_Utils_Type
::T_INT
,
321 'title' => ts('Contact ID'),
322 'description' => ts('Foreign key to civicrm_contact.id .'),
325 'where' => 'civicrm_pledge.contact_id',
327 'table_name' => 'civicrm_pledge',
328 'entity' => 'Pledge',
329 'bao' => 'CRM_Pledge_BAO_Pledge',
331 'FKClassName' => 'CRM_Contact_DAO_Contact',
333 'type' => 'EntityRef',
334 'label' => ts("Contact"),
338 'pledge_financial_type_id' => [
339 'name' => 'financial_type_id',
340 'type' => CRM_Utils_Type
::T_INT
,
341 'title' => ts('Financial Type ID'),
342 'description' => ts('FK to Financial Type'),
343 'where' => 'civicrm_pledge.financial_type_id',
344 'table_name' => 'civicrm_pledge',
345 'entity' => 'Pledge',
346 'bao' => 'CRM_Pledge_BAO_Pledge',
348 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
351 'label' => ts("Financial Type"),
353 'pseudoconstant' => [
354 'table' => 'civicrm_financial_type',
356 'labelColumn' => 'name',
360 'pledge_contribution_page_id' => [
361 'name' => 'contribution_page_id',
362 'type' => CRM_Utils_Type
::T_INT
,
363 'title' => ts('Contribution Page ID'),
364 'description' => ts('The Contribution Page which triggered this contribution'),
365 'where' => 'civicrm_pledge.contribution_page_id',
366 'table_name' => 'civicrm_pledge',
367 'entity' => 'Pledge',
368 'bao' => 'CRM_Pledge_BAO_Pledge',
370 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
372 'label' => ts("Contribution Page"),
378 'type' => CRM_Utils_Type
::T_MONEY
,
379 'title' => ts('Total Pledged'),
380 'description' => ts('Total pledged amount.'),
387 'where' => 'civicrm_pledge.amount',
389 'table_name' => 'civicrm_pledge',
390 'entity' => 'Pledge',
391 'bao' => 'CRM_Pledge_BAO_Pledge',
398 'pledge_original_installment_amount' => [
399 'name' => 'original_installment_amount',
400 'type' => CRM_Utils_Type
::T_MONEY
,
401 'title' => ts('Original Installment Amount'),
402 'description' => ts('Original amount for each of the installments.'),
408 'where' => 'civicrm_pledge.original_installment_amount',
410 'table_name' => 'civicrm_pledge',
411 'entity' => 'Pledge',
412 'bao' => 'CRM_Pledge_BAO_Pledge',
420 'name' => 'currency',
421 'type' => CRM_Utils_Type
::T_STRING
,
422 'title' => ts('Pledge Currency'),
423 'description' => ts('3 character string, value from config setting or input via user.'),
425 'size' => CRM_Utils_Type
::FOUR
,
426 'where' => 'civicrm_pledge.currency',
428 'table_name' => 'civicrm_pledge',
429 'entity' => 'Pledge',
430 'bao' => 'CRM_Pledge_BAO_Pledge',
435 'pseudoconstant' => [
436 'table' => 'civicrm_currency',
437 'keyColumn' => 'name',
438 'labelColumn' => 'full_name',
439 'nameColumn' => 'name',
440 'abbrColumn' => 'symbol',
444 'pledge_frequency_unit' => [
445 'name' => 'frequency_unit',
446 'type' => CRM_Utils_Type
::T_STRING
,
447 'title' => ts('Pledge Frequency Unit'),
448 'description' => ts('Time units for recurrence of pledge payments.'),
451 'size' => CRM_Utils_Type
::EIGHT
,
452 'where' => 'civicrm_pledge.frequency_unit',
453 'default' => 'month',
454 'table_name' => 'civicrm_pledge',
455 'entity' => 'Pledge',
456 'bao' => 'CRM_Pledge_BAO_Pledge',
461 'pseudoconstant' => [
462 'optionGroupName' => 'recur_frequency_units',
463 'keyColumn' => 'name',
464 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
468 'pledge_frequency_interval' => [
469 'name' => 'frequency_interval',
470 'type' => CRM_Utils_Type
::T_INT
,
471 'title' => ts('Pledge Frequency Interval'),
472 'description' => ts('Number of time units for recurrence of pledge payments.'),
474 'where' => 'civicrm_pledge.frequency_interval',
476 'table_name' => 'civicrm_pledge',
477 'entity' => 'Pledge',
478 'bao' => 'CRM_Pledge_BAO_Pledge',
486 'name' => 'frequency_day',
487 'type' => CRM_Utils_Type
::T_INT
,
488 'title' => ts('Pledge day'),
489 '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.'),
491 'where' => 'civicrm_pledge.frequency_day',
493 'table_name' => 'civicrm_pledge',
494 'entity' => 'Pledge',
495 'bao' => 'CRM_Pledge_BAO_Pledge',
503 'name' => 'installments',
504 'type' => CRM_Utils_Type
::T_INT
,
505 'title' => ts('Pledge Number of Installments'),
506 'description' => ts('Total number of payments to be made.'),
508 'where' => 'civicrm_pledge.installments',
511 'table_name' => 'civicrm_pledge',
512 'entity' => 'Pledge',
513 'bao' => 'CRM_Pledge_BAO_Pledge',
520 'pledge_start_date' => [
521 'name' => 'start_date',
522 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
523 'title' => ts('Pledge Start Date'),
524 'description' => ts('The date the first scheduled pledge occurs.'),
526 'where' => 'civicrm_pledge.start_date',
528 'table_name' => 'civicrm_pledge',
529 'entity' => 'Pledge',
530 'bao' => 'CRM_Pledge_BAO_Pledge',
532 'unique_title' => ts('Payments Start Date'),
534 'type' => 'Select Date',
535 'formatType' => 'activityDate',
539 'pledge_create_date' => [
540 'name' => 'create_date',
541 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
542 'title' => ts('Pledge Made'),
543 'description' => ts('When this pledge record was created.'),
546 'where' => 'civicrm_pledge.create_date',
548 'table_name' => 'civicrm_pledge',
549 'entity' => 'Pledge',
550 'bao' => 'CRM_Pledge_BAO_Pledge',
553 'type' => 'Select Date',
554 'formatType' => 'activityDate',
558 'acknowledge_date' => [
559 'name' => 'acknowledge_date',
560 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
561 'title' => ts('Pledge Acknowledged'),
562 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
563 'where' => 'civicrm_pledge.acknowledge_date',
564 'table_name' => 'civicrm_pledge',
565 'entity' => 'Pledge',
566 'bao' => 'CRM_Pledge_BAO_Pledge',
569 'type' => 'Select Date',
570 'formatType' => 'activityDate',
575 'name' => 'modified_date',
576 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
577 'title' => ts('Pledge Modified Date'),
578 'description' => ts('Last updated date for this pledge record.'),
579 'where' => 'civicrm_pledge.modified_date',
580 'table_name' => 'civicrm_pledge',
581 'entity' => 'Pledge',
582 'bao' => 'CRM_Pledge_BAO_Pledge',
588 'name' => 'cancel_date',
589 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
590 'title' => ts('Pledge Cancelled Date'),
591 'description' => ts('Date this pledge was cancelled by contributor.'),
592 'where' => 'civicrm_pledge.cancel_date',
593 'table_name' => 'civicrm_pledge',
594 'entity' => 'Pledge',
595 'bao' => 'CRM_Pledge_BAO_Pledge',
598 'type' => 'Select Date',
599 'formatType' => 'activityDate',
603 'pledge_end_date' => [
604 'name' => 'end_date',
605 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
606 'title' => ts('Pledge End Date'),
607 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
608 'where' => 'civicrm_pledge.end_date',
610 'table_name' => 'civicrm_pledge',
611 'entity' => 'Pledge',
612 'bao' => 'CRM_Pledge_BAO_Pledge',
614 'unique_title' => ts('Payments Ended Date'),
616 'type' => 'Select Date',
617 'formatType' => 'activityDate',
622 'name' => 'max_reminders',
623 'type' => CRM_Utils_Type
::T_INT
,
624 'title' => ts('Maximum Number of Reminders'),
625 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
626 'where' => 'civicrm_pledge.max_reminders',
628 'table_name' => 'civicrm_pledge',
629 'entity' => 'Pledge',
630 'bao' => 'CRM_Pledge_BAO_Pledge',
637 'initial_reminder_day' => [
638 'name' => 'initial_reminder_day',
639 'type' => CRM_Utils_Type
::T_INT
,
640 'title' => ts('Initial Reminder Day'),
641 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
642 'where' => 'civicrm_pledge.initial_reminder_day',
644 'table_name' => 'civicrm_pledge',
645 'entity' => 'Pledge',
646 'bao' => 'CRM_Pledge_BAO_Pledge',
653 'additional_reminder_day' => [
654 'name' => 'additional_reminder_day',
655 'type' => CRM_Utils_Type
::T_INT
,
656 'title' => ts('Additional Reminder Days'),
657 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
658 'where' => 'civicrm_pledge.additional_reminder_day',
660 'table_name' => 'civicrm_pledge',
661 'entity' => 'Pledge',
662 'bao' => 'CRM_Pledge_BAO_Pledge',
669 'pledge_status_id' => [
670 'name' => 'status_id',
671 'type' => CRM_Utils_Type
::T_INT
,
672 'title' => ts('Pledge Status ID'),
673 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
676 'where' => 'civicrm_pledge.status_id',
678 'table_name' => 'civicrm_pledge',
679 'entity' => 'Pledge',
680 'bao' => 'CRM_Pledge_BAO_Pledge',
685 'pseudoconstant' => [
686 'optionGroupName' => 'pledge_status',
687 'optionEditPath' => 'civicrm/admin/options/pledge_status',
691 'pledge_is_test' => [
693 'type' => CRM_Utils_Type
::T_BOOLEAN
,
694 'title' => ts('Test'),
697 'where' => 'civicrm_pledge.is_test',
700 'table_name' => 'civicrm_pledge',
701 'entity' => 'Pledge',
702 'bao' => 'CRM_Pledge_BAO_Pledge',
705 'type' => 'CheckBox',
709 'pledge_campaign_id' => [
710 'name' => 'campaign_id',
711 'type' => CRM_Utils_Type
::T_INT
,
712 'title' => ts('Campaign ID'),
713 'description' => ts('The campaign for which this pledge has been initiated.'),
715 'where' => 'civicrm_pledge.campaign_id',
717 'table_name' => 'civicrm_pledge',
718 'entity' => 'Pledge',
719 'bao' => 'CRM_Pledge_BAO_Pledge',
721 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
722 'component' => 'CiviCampaign',
724 'type' => 'EntityRef',
725 'label' => ts("Campaign"),
727 'pseudoconstant' => [
728 'table' => 'civicrm_campaign',
730 'labelColumn' => 'title',
731 'prefetch' => 'FALSE',
736 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
738 return Civi
::$statics[__CLASS__
]['fields'];
742 * Return a mapping from field-name to the corresponding key (as used in fields()).
745 * Array(string $name => string $uniqueName).
747 public static function &fieldKeys() {
748 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
749 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
751 return Civi
::$statics[__CLASS__
]['fieldKeys'];
755 * Returns the names of this table
759 public static function getTableName() {
760 return self
::$_tableName;
764 * Returns if this table needs to be logged
768 public function getLog() {
773 * Returns the list of fields that can be imported
775 * @param bool $prefix
779 public static function &import($prefix = FALSE) {
780 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
785 * Returns the list of fields that can be exported
787 * @param bool $prefix
791 public static function &export($prefix = FALSE) {
792 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
797 * Returns the list of indices
799 * @param bool $localize
803 public static function indices($localize = TRUE) {
806 'name' => 'index_status',
810 'localizable' => FALSE,
811 'sig' => 'civicrm_pledge::0::status_id',
814 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;