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:27003a5c2de79b60b4114bc92b65cc07)
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 public static function getEntityTitle() {
211 return ts('Pledges');
215 * Returns foreign keys and entity references.
218 * [CRM_Core_Reference_Interface]
220 public static function getReferenceColumns() {
221 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
222 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
223 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
224 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
225 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
226 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
227 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
229 return Civi
::$statics[__CLASS__
]['links'];
233 * Returns all the column names of this table
237 public static function &fields() {
238 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
239 Civi
::$statics[__CLASS__
]['fields'] = [
242 'type' => CRM_Utils_Type
::T_INT
,
243 'title' => ts('Pledge ID'),
244 'description' => ts('Pledge ID'),
247 'where' => 'civicrm_pledge.id',
249 'table_name' => 'civicrm_pledge',
250 'entity' => 'Pledge',
251 'bao' => 'CRM_Pledge_BAO_Pledge',
255 'pledge_contact_id' => [
256 'name' => 'contact_id',
257 'type' => CRM_Utils_Type
::T_INT
,
258 'title' => ts('Contact ID'),
259 'description' => ts('Foreign key to civicrm_contact.id .'),
262 'where' => 'civicrm_pledge.contact_id',
264 'table_name' => 'civicrm_pledge',
265 'entity' => 'Pledge',
266 'bao' => 'CRM_Pledge_BAO_Pledge',
268 'FKClassName' => 'CRM_Contact_DAO_Contact',
270 'type' => 'EntityRef',
274 'pledge_financial_type_id' => [
275 'name' => 'financial_type_id',
276 'type' => CRM_Utils_Type
::T_INT
,
277 'title' => ts('Type'),
278 'description' => ts('FK to Financial Type'),
279 'where' => 'civicrm_pledge.financial_type_id',
280 'table_name' => 'civicrm_pledge',
281 'entity' => 'Pledge',
282 'bao' => 'CRM_Pledge_BAO_Pledge',
284 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
288 'pseudoconstant' => [
289 'table' => 'civicrm_financial_type',
291 'labelColumn' => 'name',
295 'pledge_contribution_page_id' => [
296 'name' => 'contribution_page_id',
297 'type' => CRM_Utils_Type
::T_INT
,
298 'title' => ts('Pledge Contribution Page'),
299 'description' => ts('The Contribution Page which triggered this contribution'),
300 'where' => 'civicrm_pledge.contribution_page_id',
301 'table_name' => 'civicrm_pledge',
302 'entity' => 'Pledge',
303 'bao' => 'CRM_Pledge_BAO_Pledge',
305 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
310 'type' => CRM_Utils_Type
::T_MONEY
,
311 'title' => ts('Total Pledged'),
312 'description' => ts('Total pledged amount.'),
319 'where' => 'civicrm_pledge.amount',
321 'table_name' => 'civicrm_pledge',
322 'entity' => 'Pledge',
323 'bao' => 'CRM_Pledge_BAO_Pledge',
330 'pledge_original_installment_amount' => [
331 'name' => 'original_installment_amount',
332 'type' => CRM_Utils_Type
::T_MONEY
,
333 'title' => ts('Original Installment Amount'),
334 'description' => ts('Original amount for each of the installments.'),
340 'where' => 'civicrm_pledge.original_installment_amount',
342 'table_name' => 'civicrm_pledge',
343 'entity' => 'Pledge',
344 'bao' => 'CRM_Pledge_BAO_Pledge',
352 'name' => 'currency',
353 'type' => CRM_Utils_Type
::T_STRING
,
354 'title' => ts('Pledge Currency'),
355 'description' => ts('3 character string, value from config setting or input via user.'),
357 'size' => CRM_Utils_Type
::FOUR
,
358 'where' => 'civicrm_pledge.currency',
360 'table_name' => 'civicrm_pledge',
361 'entity' => 'Pledge',
362 'bao' => 'CRM_Pledge_BAO_Pledge',
367 'pseudoconstant' => [
368 'table' => 'civicrm_currency',
369 'keyColumn' => 'name',
370 'labelColumn' => 'full_name',
371 'nameColumn' => 'name',
372 'abbrColumn' => 'symbol',
376 'pledge_frequency_unit' => [
377 'name' => 'frequency_unit',
378 'type' => CRM_Utils_Type
::T_STRING
,
379 'title' => ts('Pledge Frequency Unit'),
380 'description' => ts('Time units for recurrence of pledge payments.'),
382 'size' => CRM_Utils_Type
::EIGHT
,
383 'where' => 'civicrm_pledge.frequency_unit',
384 'default' => 'month',
385 'table_name' => 'civicrm_pledge',
386 'entity' => 'Pledge',
387 'bao' => 'CRM_Pledge_BAO_Pledge',
392 'pseudoconstant' => [
393 'optionGroupName' => 'recur_frequency_units',
394 'keyColumn' => 'name',
395 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
399 'pledge_frequency_interval' => [
400 'name' => 'frequency_interval',
401 'type' => CRM_Utils_Type
::T_INT
,
402 'title' => ts('Pledge Frequency Interval'),
403 'description' => ts('Number of time units for recurrence of pledge payments.'),
405 'where' => 'civicrm_pledge.frequency_interval',
407 'table_name' => 'civicrm_pledge',
408 'entity' => 'Pledge',
409 'bao' => 'CRM_Pledge_BAO_Pledge',
417 'name' => 'frequency_day',
418 'type' => CRM_Utils_Type
::T_INT
,
419 'title' => ts('Pledge day'),
420 '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.'),
422 'where' => 'civicrm_pledge.frequency_day',
424 'table_name' => 'civicrm_pledge',
425 'entity' => 'Pledge',
426 'bao' => 'CRM_Pledge_BAO_Pledge',
434 'name' => 'installments',
435 'type' => CRM_Utils_Type
::T_INT
,
436 'title' => ts('Pledge Number of Installments'),
437 'description' => ts('Total number of payments to be made.'),
438 'where' => 'civicrm_pledge.installments',
441 'table_name' => 'civicrm_pledge',
442 'entity' => 'Pledge',
443 'bao' => 'CRM_Pledge_BAO_Pledge',
450 'pledge_start_date' => [
451 'name' => 'start_date',
452 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
453 'title' => ts('Pledge Start Date'),
454 'description' => ts('The date the first scheduled pledge occurs.'),
456 'where' => 'civicrm_pledge.start_date',
458 'table_name' => 'civicrm_pledge',
459 'entity' => 'Pledge',
460 'bao' => 'CRM_Pledge_BAO_Pledge',
462 'unique_title' => ts('Payments Start Date'),
464 'type' => 'Select Date',
465 'formatType' => 'activityDate',
469 'pledge_create_date' => [
470 'name' => 'create_date',
471 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
472 'title' => ts('Pledge Made'),
473 'description' => ts('When this pledge record was created.'),
476 'where' => 'civicrm_pledge.create_date',
478 'table_name' => 'civicrm_pledge',
479 'entity' => 'Pledge',
480 'bao' => 'CRM_Pledge_BAO_Pledge',
483 'type' => 'Select Date',
484 'formatType' => 'activityDate',
488 'acknowledge_date' => [
489 'name' => 'acknowledge_date',
490 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
491 'title' => ts('Pledge Acknowledged'),
492 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
493 'where' => 'civicrm_pledge.acknowledge_date',
494 'table_name' => 'civicrm_pledge',
495 'entity' => 'Pledge',
496 'bao' => 'CRM_Pledge_BAO_Pledge',
499 'type' => 'Select Date',
500 'formatType' => 'activityDate',
505 'name' => 'modified_date',
506 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
507 'title' => ts('Pledge Modified Date'),
508 'description' => ts('Last updated date for this pledge record.'),
509 'where' => 'civicrm_pledge.modified_date',
510 'table_name' => 'civicrm_pledge',
511 'entity' => 'Pledge',
512 'bao' => 'CRM_Pledge_BAO_Pledge',
517 'name' => 'cancel_date',
518 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
519 'title' => ts('Pledge Cancelled Date'),
520 'description' => ts('Date this pledge was cancelled by contributor.'),
521 'where' => 'civicrm_pledge.cancel_date',
522 'table_name' => 'civicrm_pledge',
523 'entity' => 'Pledge',
524 'bao' => 'CRM_Pledge_BAO_Pledge',
527 'type' => 'Select Date',
528 'formatType' => 'activityDate',
532 'pledge_end_date' => [
533 'name' => 'end_date',
534 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
535 'title' => ts('Pledge End Date'),
536 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
537 'where' => 'civicrm_pledge.end_date',
539 'table_name' => 'civicrm_pledge',
540 'entity' => 'Pledge',
541 'bao' => 'CRM_Pledge_BAO_Pledge',
543 'unique_title' => ts('Payments Ended Date'),
545 'type' => 'Select Date',
546 'formatType' => 'activityDate',
551 'name' => 'max_reminders',
552 'type' => CRM_Utils_Type
::T_INT
,
553 'title' => ts('Maximum Number of Reminders'),
554 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
555 'where' => 'civicrm_pledge.max_reminders',
557 'table_name' => 'civicrm_pledge',
558 'entity' => 'Pledge',
559 'bao' => 'CRM_Pledge_BAO_Pledge',
566 'initial_reminder_day' => [
567 'name' => 'initial_reminder_day',
568 'type' => CRM_Utils_Type
::T_INT
,
569 'title' => ts('Initial Reminder Day'),
570 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
571 'where' => 'civicrm_pledge.initial_reminder_day',
573 'table_name' => 'civicrm_pledge',
574 'entity' => 'Pledge',
575 'bao' => 'CRM_Pledge_BAO_Pledge',
582 'additional_reminder_day' => [
583 'name' => 'additional_reminder_day',
584 'type' => CRM_Utils_Type
::T_INT
,
585 'title' => ts('Additional Reminder Days'),
586 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
587 'where' => 'civicrm_pledge.additional_reminder_day',
589 'table_name' => 'civicrm_pledge',
590 'entity' => 'Pledge',
591 'bao' => 'CRM_Pledge_BAO_Pledge',
598 'pledge_status_id' => [
599 'name' => 'status_id',
600 'type' => CRM_Utils_Type
::T_INT
,
601 'title' => ts('Pledge Status Id'),
602 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
604 'where' => 'civicrm_pledge.status_id',
606 'table_name' => 'civicrm_pledge',
607 'entity' => 'Pledge',
608 'bao' => 'CRM_Pledge_BAO_Pledge',
613 'pseudoconstant' => [
614 'optionGroupName' => 'pledge_status',
615 'optionEditPath' => 'civicrm/admin/options/pledge_status',
619 'pledge_is_test' => [
621 'type' => CRM_Utils_Type
::T_BOOLEAN
,
622 'title' => ts('Test'),
624 'where' => 'civicrm_pledge.is_test',
627 'table_name' => 'civicrm_pledge',
628 'entity' => 'Pledge',
629 'bao' => 'CRM_Pledge_BAO_Pledge',
632 'type' => 'CheckBox',
636 'pledge_campaign_id' => [
637 'name' => 'campaign_id',
638 'type' => CRM_Utils_Type
::T_INT
,
639 'title' => ts('Campaign'),
640 'description' => ts('The campaign for which this pledge has been initiated.'),
642 'where' => 'civicrm_pledge.campaign_id',
644 'table_name' => 'civicrm_pledge',
645 'entity' => 'Pledge',
646 'bao' => 'CRM_Pledge_BAO_Pledge',
648 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
652 'pseudoconstant' => [
653 'table' => 'civicrm_campaign',
655 'labelColumn' => 'title',
660 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
662 return Civi
::$statics[__CLASS__
]['fields'];
666 * Return a mapping from field-name to the corresponding key (as used in fields()).
669 * Array(string $name => string $uniqueName).
671 public static function &fieldKeys() {
672 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
673 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
675 return Civi
::$statics[__CLASS__
]['fieldKeys'];
679 * Returns the names of this table
683 public static function getTableName() {
684 return self
::$_tableName;
688 * Returns if this table needs to be logged
692 public function getLog() {
697 * Returns the list of fields that can be imported
699 * @param bool $prefix
703 public static function &import($prefix = FALSE) {
704 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
709 * Returns the list of fields that can be exported
711 * @param bool $prefix
715 public static function &export($prefix = FALSE) {
716 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
721 * Returns the list of indices
723 * @param bool $localize
727 public static function indices($localize = TRUE) {
730 'name' => 'index_status',
734 'localizable' => FALSE,
735 'sig' => 'civicrm_pledge::0::status_id',
738 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;