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:0447b8be2ab956b77d0d6be123e0bdb4)
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';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_pledge';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-paper-plane';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
48 * Foreign key to civicrm_contact.id .
55 * FK to Financial Type
59 public $financial_type_id;
62 * The Contribution Page which triggered this contribution
66 public $contribution_page_id;
69 * Total pledged amount.
76 * Original amount for each of the installments.
80 public $original_installment_amount;
83 * 3 character string, value from config setting or input via user.
90 * Time units for recurrence of pledge payments.
94 public $frequency_unit;
97 * Number of time units for recurrence of pledge payments.
101 public $frequency_interval;
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.
108 public $frequency_day;
111 * Total number of payments to be made.
115 public $installments;
118 * The date the first scheduled pledge occurs.
125 * When this pledge record was created.
132 * When a pledge acknowledgement message was sent to the contributor.
136 public $acknowledge_date;
139 * Last updated date for this pledge record.
143 public $modified_date;
146 * Date this pledge was cancelled by contributor.
153 * Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).
160 * The maximum number of payment reminders to send for any given payment.
164 public $max_reminders;
167 * Send initial reminder this many days prior to the payment due date.
171 public $initial_reminder_day;
174 * Send additional reminder this many days after last one sent, up to maximum number of reminders.
178 public $additional_reminder_day;
181 * Implicit foreign key to civicrm_option_values in the pledge_status option group.
193 * The campaign for which this pledge has been initiated.
202 public function __construct() {
203 $this->__table
= 'civicrm_pledge';
204 parent
::__construct();
208 * Returns localized title of this entity.
210 * @param bool $plural
211 * Whether to return the plural version of the title.
213 public static function getEntityTitle($plural = FALSE) {
214 return $plural ?
ts('Pledges') : ts('Pledge');
218 * Returns foreign keys and entity references.
221 * [CRM_Core_Reference_Interface]
223 public static function getReferenceColumns() {
224 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
225 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
226 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
227 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
228 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
229 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
230 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
232 return Civi
::$statics[__CLASS__
]['links'];
236 * Returns all the column names of this table
240 public static function &fields() {
241 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
242 Civi
::$statics[__CLASS__
]['fields'] = [
245 'type' => CRM_Utils_Type
::T_INT
,
246 'title' => ts('Pledge ID'),
247 'description' => ts('Pledge ID'),
250 'where' => 'civicrm_pledge.id',
252 'table_name' => 'civicrm_pledge',
253 'entity' => 'Pledge',
254 'bao' => 'CRM_Pledge_BAO_Pledge',
258 'pledge_contact_id' => [
259 'name' => 'contact_id',
260 'type' => CRM_Utils_Type
::T_INT
,
261 'title' => ts('Contact ID'),
262 'description' => ts('Foreign key to civicrm_contact.id .'),
265 'where' => 'civicrm_pledge.contact_id',
267 'table_name' => 'civicrm_pledge',
268 'entity' => 'Pledge',
269 'bao' => 'CRM_Pledge_BAO_Pledge',
271 'FKClassName' => 'CRM_Contact_DAO_Contact',
273 'type' => 'EntityRef',
277 'pledge_financial_type_id' => [
278 'name' => 'financial_type_id',
279 'type' => CRM_Utils_Type
::T_INT
,
280 'title' => ts('Type'),
281 'description' => ts('FK to Financial Type'),
282 'where' => 'civicrm_pledge.financial_type_id',
283 'table_name' => 'civicrm_pledge',
284 'entity' => 'Pledge',
285 'bao' => 'CRM_Pledge_BAO_Pledge',
287 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
291 'pseudoconstant' => [
292 'table' => 'civicrm_financial_type',
294 'labelColumn' => 'name',
298 'pledge_contribution_page_id' => [
299 'name' => 'contribution_page_id',
300 'type' => CRM_Utils_Type
::T_INT
,
301 'title' => ts('Pledge Contribution Page'),
302 'description' => ts('The Contribution Page which triggered this contribution'),
303 'where' => 'civicrm_pledge.contribution_page_id',
304 'table_name' => 'civicrm_pledge',
305 'entity' => 'Pledge',
306 'bao' => 'CRM_Pledge_BAO_Pledge',
308 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
313 'type' => CRM_Utils_Type
::T_MONEY
,
314 'title' => ts('Total Pledged'),
315 'description' => ts('Total pledged amount.'),
322 'where' => 'civicrm_pledge.amount',
324 'table_name' => 'civicrm_pledge',
325 'entity' => 'Pledge',
326 'bao' => 'CRM_Pledge_BAO_Pledge',
333 'pledge_original_installment_amount' => [
334 'name' => 'original_installment_amount',
335 'type' => CRM_Utils_Type
::T_MONEY
,
336 'title' => ts('Original Installment Amount'),
337 'description' => ts('Original amount for each of the installments.'),
343 'where' => 'civicrm_pledge.original_installment_amount',
345 'table_name' => 'civicrm_pledge',
346 'entity' => 'Pledge',
347 'bao' => 'CRM_Pledge_BAO_Pledge',
355 'name' => 'currency',
356 'type' => CRM_Utils_Type
::T_STRING
,
357 'title' => ts('Pledge Currency'),
358 'description' => ts('3 character string, value from config setting or input via user.'),
360 'size' => CRM_Utils_Type
::FOUR
,
361 'where' => 'civicrm_pledge.currency',
363 'table_name' => 'civicrm_pledge',
364 'entity' => 'Pledge',
365 'bao' => 'CRM_Pledge_BAO_Pledge',
370 'pseudoconstant' => [
371 'table' => 'civicrm_currency',
372 'keyColumn' => 'name',
373 'labelColumn' => 'full_name',
374 'nameColumn' => 'name',
375 'abbrColumn' => 'symbol',
379 'pledge_frequency_unit' => [
380 'name' => 'frequency_unit',
381 'type' => CRM_Utils_Type
::T_STRING
,
382 'title' => ts('Pledge Frequency Unit'),
383 'description' => ts('Time units for recurrence of pledge payments.'),
385 'size' => CRM_Utils_Type
::EIGHT
,
386 'where' => 'civicrm_pledge.frequency_unit',
387 'default' => 'month',
388 'table_name' => 'civicrm_pledge',
389 'entity' => 'Pledge',
390 'bao' => 'CRM_Pledge_BAO_Pledge',
395 'pseudoconstant' => [
396 'optionGroupName' => 'recur_frequency_units',
397 'keyColumn' => 'name',
398 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
402 'pledge_frequency_interval' => [
403 'name' => 'frequency_interval',
404 'type' => CRM_Utils_Type
::T_INT
,
405 'title' => ts('Pledge Frequency Interval'),
406 'description' => ts('Number of time units for recurrence of pledge payments.'),
408 'where' => 'civicrm_pledge.frequency_interval',
410 'table_name' => 'civicrm_pledge',
411 'entity' => 'Pledge',
412 'bao' => 'CRM_Pledge_BAO_Pledge',
420 'name' => 'frequency_day',
421 'type' => CRM_Utils_Type
::T_INT
,
422 'title' => ts('Pledge day'),
423 '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.'),
425 'where' => 'civicrm_pledge.frequency_day',
427 'table_name' => 'civicrm_pledge',
428 'entity' => 'Pledge',
429 'bao' => 'CRM_Pledge_BAO_Pledge',
437 'name' => 'installments',
438 'type' => CRM_Utils_Type
::T_INT
,
439 'title' => ts('Pledge Number of Installments'),
440 'description' => ts('Total number of payments to be made.'),
441 'where' => 'civicrm_pledge.installments',
444 'table_name' => 'civicrm_pledge',
445 'entity' => 'Pledge',
446 'bao' => 'CRM_Pledge_BAO_Pledge',
453 'pledge_start_date' => [
454 'name' => 'start_date',
455 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
456 'title' => ts('Pledge Start Date'),
457 'description' => ts('The date the first scheduled pledge occurs.'),
459 'where' => 'civicrm_pledge.start_date',
461 'table_name' => 'civicrm_pledge',
462 'entity' => 'Pledge',
463 'bao' => 'CRM_Pledge_BAO_Pledge',
465 'unique_title' => ts('Payments Start Date'),
467 'type' => 'Select Date',
468 'formatType' => 'activityDate',
472 'pledge_create_date' => [
473 'name' => 'create_date',
474 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
475 'title' => ts('Pledge Made'),
476 'description' => ts('When this pledge record was created.'),
479 'where' => 'civicrm_pledge.create_date',
481 'table_name' => 'civicrm_pledge',
482 'entity' => 'Pledge',
483 'bao' => 'CRM_Pledge_BAO_Pledge',
486 'type' => 'Select Date',
487 'formatType' => 'activityDate',
491 'acknowledge_date' => [
492 'name' => 'acknowledge_date',
493 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
494 'title' => ts('Pledge Acknowledged'),
495 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
496 'where' => 'civicrm_pledge.acknowledge_date',
497 'table_name' => 'civicrm_pledge',
498 'entity' => 'Pledge',
499 'bao' => 'CRM_Pledge_BAO_Pledge',
502 'type' => 'Select Date',
503 'formatType' => 'activityDate',
508 'name' => 'modified_date',
509 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
510 'title' => ts('Pledge Modified Date'),
511 'description' => ts('Last updated date for this pledge record.'),
512 'where' => 'civicrm_pledge.modified_date',
513 'table_name' => 'civicrm_pledge',
514 'entity' => 'Pledge',
515 'bao' => 'CRM_Pledge_BAO_Pledge',
520 'name' => 'cancel_date',
521 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
522 'title' => ts('Pledge Cancelled Date'),
523 'description' => ts('Date this pledge was cancelled by contributor.'),
524 'where' => 'civicrm_pledge.cancel_date',
525 'table_name' => 'civicrm_pledge',
526 'entity' => 'Pledge',
527 'bao' => 'CRM_Pledge_BAO_Pledge',
530 'type' => 'Select Date',
531 'formatType' => 'activityDate',
535 'pledge_end_date' => [
536 'name' => 'end_date',
537 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
538 'title' => ts('Pledge End Date'),
539 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
540 'where' => 'civicrm_pledge.end_date',
542 'table_name' => 'civicrm_pledge',
543 'entity' => 'Pledge',
544 'bao' => 'CRM_Pledge_BAO_Pledge',
546 'unique_title' => ts('Payments Ended Date'),
548 'type' => 'Select Date',
549 'formatType' => 'activityDate',
554 'name' => 'max_reminders',
555 'type' => CRM_Utils_Type
::T_INT
,
556 'title' => ts('Maximum Number of Reminders'),
557 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
558 'where' => 'civicrm_pledge.max_reminders',
560 'table_name' => 'civicrm_pledge',
561 'entity' => 'Pledge',
562 'bao' => 'CRM_Pledge_BAO_Pledge',
569 'initial_reminder_day' => [
570 'name' => 'initial_reminder_day',
571 'type' => CRM_Utils_Type
::T_INT
,
572 'title' => ts('Initial Reminder Day'),
573 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
574 'where' => 'civicrm_pledge.initial_reminder_day',
576 'table_name' => 'civicrm_pledge',
577 'entity' => 'Pledge',
578 'bao' => 'CRM_Pledge_BAO_Pledge',
585 'additional_reminder_day' => [
586 'name' => 'additional_reminder_day',
587 'type' => CRM_Utils_Type
::T_INT
,
588 'title' => ts('Additional Reminder Days'),
589 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
590 'where' => 'civicrm_pledge.additional_reminder_day',
592 'table_name' => 'civicrm_pledge',
593 'entity' => 'Pledge',
594 'bao' => 'CRM_Pledge_BAO_Pledge',
601 'pledge_status_id' => [
602 'name' => 'status_id',
603 'type' => CRM_Utils_Type
::T_INT
,
604 'title' => ts('Pledge Status Id'),
605 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
607 'where' => 'civicrm_pledge.status_id',
609 'table_name' => 'civicrm_pledge',
610 'entity' => 'Pledge',
611 'bao' => 'CRM_Pledge_BAO_Pledge',
616 'pseudoconstant' => [
617 'optionGroupName' => 'pledge_status',
618 'optionEditPath' => 'civicrm/admin/options/pledge_status',
622 'pledge_is_test' => [
624 'type' => CRM_Utils_Type
::T_BOOLEAN
,
625 'title' => ts('Test'),
627 'where' => 'civicrm_pledge.is_test',
630 'table_name' => 'civicrm_pledge',
631 'entity' => 'Pledge',
632 'bao' => 'CRM_Pledge_BAO_Pledge',
635 'type' => 'CheckBox',
639 'pledge_campaign_id' => [
640 'name' => 'campaign_id',
641 'type' => CRM_Utils_Type
::T_INT
,
642 'title' => ts('Campaign'),
643 'description' => ts('The campaign for which this pledge has been initiated.'),
645 'where' => 'civicrm_pledge.campaign_id',
647 'table_name' => 'civicrm_pledge',
648 'entity' => 'Pledge',
649 'bao' => 'CRM_Pledge_BAO_Pledge',
651 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
655 'pseudoconstant' => [
656 'table' => 'civicrm_campaign',
658 'labelColumn' => 'title',
663 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
665 return Civi
::$statics[__CLASS__
]['fields'];
669 * Return a mapping from field-name to the corresponding key (as used in fields()).
672 * Array(string $name => string $uniqueName).
674 public static function &fieldKeys() {
675 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
676 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
678 return Civi
::$statics[__CLASS__
]['fieldKeys'];
682 * Returns the names of this table
686 public static function getTableName() {
687 return self
::$_tableName;
691 * Returns if this table needs to be logged
695 public function getLog() {
700 * Returns the list of fields that can be imported
702 * @param bool $prefix
706 public static function &import($prefix = FALSE) {
707 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
712 * Returns the list of fields that can be exported
714 * @param bool $prefix
718 public static function &export($prefix = FALSE) {
719 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
724 * Returns the list of indices
726 * @param bool $localize
730 public static function indices($localize = TRUE) {
733 'name' => 'index_status',
737 'localizable' => FALSE,
738 'sig' => 'civicrm_pledge::0::status_id',
741 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;