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:0df66b3d12c2b147e5f8b5b03f2148a8)
13 * Database access object for the Pledge entity.
15 class CRM_Pledge_DAO_Pledge
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_pledge';
25 * Icon associated with this entity.
29 public static $_icon = 'fa-paper-plane';
32 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 public static $_log = TRUE;
46 * Foreign key to civicrm_contact.id .
53 * FK to Financial Type
57 public $financial_type_id;
60 * The Contribution Page which triggered this contribution
64 public $contribution_page_id;
67 * Total pledged amount.
74 * Original amount for each of the installments.
78 public $original_installment_amount;
81 * 3 character string, value from config setting or input via user.
88 * Time units for recurrence of pledge payments.
92 public $frequency_unit;
95 * Number of time units for recurrence of pledge payments.
99 public $frequency_interval;
102 * 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.
106 public $frequency_day;
109 * Total number of payments to be made.
113 public $installments;
116 * The date the first scheduled pledge occurs.
123 * When this pledge record was created.
130 * When a pledge acknowledgement message was sent to the contributor.
134 public $acknowledge_date;
137 * Last updated date for this pledge record.
141 public $modified_date;
144 * Date this pledge was cancelled by contributor.
151 * Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).
158 * The maximum number of payment reminders to send for any given payment.
162 public $max_reminders;
165 * Send initial reminder this many days prior to the payment due date.
169 public $initial_reminder_day;
172 * Send additional reminder this many days after last one sent, up to maximum number of reminders.
176 public $additional_reminder_day;
179 * Implicit foreign key to civicrm_option_values in the pledge_status option group.
191 * The campaign for which this pledge has been initiated.
200 public function __construct() {
201 $this->__table
= 'civicrm_pledge';
202 parent
::__construct();
206 * Returns localized title of this entity.
208 public static function getEntityTitle() {
209 return ts('Pledges');
213 * Returns foreign keys and entity references.
216 * [CRM_Core_Reference_Interface]
218 public static function getReferenceColumns() {
219 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
220 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
221 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
222 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
223 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
224 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
225 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
227 return Civi
::$statics[__CLASS__
]['links'];
231 * Returns all the column names of this table
235 public static function &fields() {
236 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
237 Civi
::$statics[__CLASS__
]['fields'] = [
240 'type' => CRM_Utils_Type
::T_INT
,
241 'title' => ts('Pledge ID'),
242 'description' => ts('Pledge ID'),
245 'where' => 'civicrm_pledge.id',
247 'table_name' => 'civicrm_pledge',
248 'entity' => 'Pledge',
249 'bao' => 'CRM_Pledge_BAO_Pledge',
253 'pledge_contact_id' => [
254 'name' => 'contact_id',
255 'type' => CRM_Utils_Type
::T_INT
,
256 'title' => ts('Contact ID'),
257 'description' => ts('Foreign key to civicrm_contact.id .'),
260 'where' => 'civicrm_pledge.contact_id',
262 'table_name' => 'civicrm_pledge',
263 'entity' => 'Pledge',
264 'bao' => 'CRM_Pledge_BAO_Pledge',
266 'FKClassName' => 'CRM_Contact_DAO_Contact',
268 'type' => 'EntityRef',
272 'pledge_financial_type_id' => [
273 'name' => 'financial_type_id',
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Type'),
276 'description' => ts('FK to Financial Type'),
277 'where' => 'civicrm_pledge.financial_type_id',
278 'table_name' => 'civicrm_pledge',
279 'entity' => 'Pledge',
280 'bao' => 'CRM_Pledge_BAO_Pledge',
282 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
286 'pseudoconstant' => [
287 'table' => 'civicrm_financial_type',
289 'labelColumn' => 'name',
293 'pledge_contribution_page_id' => [
294 'name' => 'contribution_page_id',
295 'type' => CRM_Utils_Type
::T_INT
,
296 'title' => ts('Pledge Contribution Page'),
297 'description' => ts('The Contribution Page which triggered this contribution'),
298 'where' => 'civicrm_pledge.contribution_page_id',
299 'table_name' => 'civicrm_pledge',
300 'entity' => 'Pledge',
301 'bao' => 'CRM_Pledge_BAO_Pledge',
303 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
308 'type' => CRM_Utils_Type
::T_MONEY
,
309 'title' => ts('Total Pledged'),
310 'description' => ts('Total pledged amount.'),
317 'where' => 'civicrm_pledge.amount',
319 'table_name' => 'civicrm_pledge',
320 'entity' => 'Pledge',
321 'bao' => 'CRM_Pledge_BAO_Pledge',
328 'pledge_original_installment_amount' => [
329 'name' => 'original_installment_amount',
330 'type' => CRM_Utils_Type
::T_MONEY
,
331 'title' => ts('Original Installment Amount'),
332 'description' => ts('Original amount for each of the installments.'),
338 'where' => 'civicrm_pledge.original_installment_amount',
340 'table_name' => 'civicrm_pledge',
341 'entity' => 'Pledge',
342 'bao' => 'CRM_Pledge_BAO_Pledge',
350 'name' => 'currency',
351 'type' => CRM_Utils_Type
::T_STRING
,
352 'title' => ts('Pledge Currency'),
353 'description' => ts('3 character string, value from config setting or input via user.'),
355 'size' => CRM_Utils_Type
::FOUR
,
356 'where' => 'civicrm_pledge.currency',
358 'table_name' => 'civicrm_pledge',
359 'entity' => 'Pledge',
360 'bao' => 'CRM_Pledge_BAO_Pledge',
365 'pseudoconstant' => [
366 'table' => 'civicrm_currency',
367 'keyColumn' => 'name',
368 'labelColumn' => 'full_name',
369 'nameColumn' => 'name',
370 'abbrColumn' => 'symbol',
374 'pledge_frequency_unit' => [
375 'name' => 'frequency_unit',
376 'type' => CRM_Utils_Type
::T_STRING
,
377 'title' => ts('Pledge Frequency Unit'),
378 'description' => ts('Time units for recurrence of pledge payments.'),
380 'size' => CRM_Utils_Type
::EIGHT
,
381 'where' => 'civicrm_pledge.frequency_unit',
382 'default' => 'month',
383 'table_name' => 'civicrm_pledge',
384 'entity' => 'Pledge',
385 'bao' => 'CRM_Pledge_BAO_Pledge',
390 'pseudoconstant' => [
391 'optionGroupName' => 'recur_frequency_units',
392 'keyColumn' => 'name',
393 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
397 'pledge_frequency_interval' => [
398 'name' => 'frequency_interval',
399 'type' => CRM_Utils_Type
::T_INT
,
400 'title' => ts('Pledge Frequency Interval'),
401 'description' => ts('Number of time units for recurrence of pledge payments.'),
403 'where' => 'civicrm_pledge.frequency_interval',
405 'table_name' => 'civicrm_pledge',
406 'entity' => 'Pledge',
407 'bao' => 'CRM_Pledge_BAO_Pledge',
415 'name' => 'frequency_day',
416 'type' => CRM_Utils_Type
::T_INT
,
417 'title' => ts('Pledge day'),
418 '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.'),
420 'where' => 'civicrm_pledge.frequency_day',
422 'table_name' => 'civicrm_pledge',
423 'entity' => 'Pledge',
424 'bao' => 'CRM_Pledge_BAO_Pledge',
432 'name' => 'installments',
433 'type' => CRM_Utils_Type
::T_INT
,
434 'title' => ts('Pledge Number of Installments'),
435 'description' => ts('Total number of payments to be made.'),
436 'where' => 'civicrm_pledge.installments',
439 'table_name' => 'civicrm_pledge',
440 'entity' => 'Pledge',
441 'bao' => 'CRM_Pledge_BAO_Pledge',
448 'pledge_start_date' => [
449 'name' => 'start_date',
450 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
451 'title' => ts('Pledge Start Date'),
452 'description' => ts('The date the first scheduled pledge occurs.'),
454 'where' => 'civicrm_pledge.start_date',
456 'table_name' => 'civicrm_pledge',
457 'entity' => 'Pledge',
458 'bao' => 'CRM_Pledge_BAO_Pledge',
460 'unique_title' => ts('Payments Start Date'),
462 'type' => 'Select Date',
466 'pledge_create_date' => [
467 'name' => 'create_date',
468 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
469 'title' => ts('Pledge Made'),
470 'description' => ts('When this pledge record was created.'),
473 'where' => 'civicrm_pledge.create_date',
475 'table_name' => 'civicrm_pledge',
476 'entity' => 'Pledge',
477 'bao' => 'CRM_Pledge_BAO_Pledge',
480 'type' => 'Select Date',
484 'acknowledge_date' => [
485 'name' => 'acknowledge_date',
486 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
487 'title' => ts('Pledge Acknowledged'),
488 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
489 'where' => 'civicrm_pledge.acknowledge_date',
490 'table_name' => 'civicrm_pledge',
491 'entity' => 'Pledge',
492 'bao' => 'CRM_Pledge_BAO_Pledge',
495 'type' => 'Select Date',
500 'name' => 'modified_date',
501 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
502 'title' => ts('Pledge Modified Date'),
503 'description' => ts('Last updated date for this pledge record.'),
504 'where' => 'civicrm_pledge.modified_date',
505 'table_name' => 'civicrm_pledge',
506 'entity' => 'Pledge',
507 'bao' => 'CRM_Pledge_BAO_Pledge',
512 'name' => 'cancel_date',
513 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
514 'title' => ts('Pledge Cancelled Date'),
515 'description' => ts('Date this pledge was cancelled by contributor.'),
516 'where' => 'civicrm_pledge.cancel_date',
517 'table_name' => 'civicrm_pledge',
518 'entity' => 'Pledge',
519 'bao' => 'CRM_Pledge_BAO_Pledge',
522 'type' => 'Select Date',
526 'pledge_end_date' => [
527 'name' => 'end_date',
528 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
529 'title' => ts('Pledge End Date'),
530 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
531 'where' => 'civicrm_pledge.end_date',
533 'table_name' => 'civicrm_pledge',
534 'entity' => 'Pledge',
535 'bao' => 'CRM_Pledge_BAO_Pledge',
537 'unique_title' => ts('Payments Ended Date'),
539 'type' => 'Select Date',
544 'name' => 'max_reminders',
545 'type' => CRM_Utils_Type
::T_INT
,
546 'title' => ts('Maximum Number of Reminders'),
547 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
548 'where' => 'civicrm_pledge.max_reminders',
550 'table_name' => 'civicrm_pledge',
551 'entity' => 'Pledge',
552 'bao' => 'CRM_Pledge_BAO_Pledge',
559 'initial_reminder_day' => [
560 'name' => 'initial_reminder_day',
561 'type' => CRM_Utils_Type
::T_INT
,
562 'title' => ts('Initial Reminder Day'),
563 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
564 'where' => 'civicrm_pledge.initial_reminder_day',
566 'table_name' => 'civicrm_pledge',
567 'entity' => 'Pledge',
568 'bao' => 'CRM_Pledge_BAO_Pledge',
575 'additional_reminder_day' => [
576 'name' => 'additional_reminder_day',
577 'type' => CRM_Utils_Type
::T_INT
,
578 'title' => ts('Additional Reminder Days'),
579 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
580 'where' => 'civicrm_pledge.additional_reminder_day',
582 'table_name' => 'civicrm_pledge',
583 'entity' => 'Pledge',
584 'bao' => 'CRM_Pledge_BAO_Pledge',
591 'pledge_status_id' => [
592 'name' => 'status_id',
593 'type' => CRM_Utils_Type
::T_INT
,
594 'title' => ts('Pledge Status Id'),
595 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
597 'where' => 'civicrm_pledge.status_id',
599 'table_name' => 'civicrm_pledge',
600 'entity' => 'Pledge',
601 'bao' => 'CRM_Pledge_BAO_Pledge',
606 'pseudoconstant' => [
607 'optionGroupName' => 'pledge_status',
608 'optionEditPath' => 'civicrm/admin/options/pledge_status',
612 'pledge_is_test' => [
614 'type' => CRM_Utils_Type
::T_BOOLEAN
,
615 'title' => ts('Test'),
617 'where' => 'civicrm_pledge.is_test',
620 'table_name' => 'civicrm_pledge',
621 'entity' => 'Pledge',
622 'bao' => 'CRM_Pledge_BAO_Pledge',
625 'type' => 'CheckBox',
629 'pledge_campaign_id' => [
630 'name' => 'campaign_id',
631 'type' => CRM_Utils_Type
::T_INT
,
632 'title' => ts('Campaign'),
633 'description' => ts('The campaign for which this pledge has been initiated.'),
635 'where' => 'civicrm_pledge.campaign_id',
637 'table_name' => 'civicrm_pledge',
638 'entity' => 'Pledge',
639 'bao' => 'CRM_Pledge_BAO_Pledge',
641 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
645 'pseudoconstant' => [
646 'table' => 'civicrm_campaign',
648 'labelColumn' => 'title',
653 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
655 return Civi
::$statics[__CLASS__
]['fields'];
659 * Return a mapping from field-name to the corresponding key (as used in fields()).
662 * Array(string $name => string $uniqueName).
664 public static function &fieldKeys() {
665 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
666 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
668 return Civi
::$statics[__CLASS__
]['fieldKeys'];
672 * Returns the names of this table
676 public static function getTableName() {
677 return self
::$_tableName;
681 * Returns if this table needs to be logged
685 public function getLog() {
690 * Returns the list of fields that can be imported
692 * @param bool $prefix
696 public static function &import($prefix = FALSE) {
697 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
702 * Returns the list of fields that can be exported
704 * @param bool $prefix
708 public static function &export($prefix = FALSE) {
709 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
714 * Returns the list of indices
716 * @param bool $localize
720 public static function indices($localize = TRUE) {
723 'name' => 'index_status',
727 'localizable' => FALSE,
728 'sig' => 'civicrm_pledge::0::status_id',
731 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;