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:8a17ba664d9a2c65860be67652def7f5)
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 foreign keys and entity references.
222 * [CRM_Core_Reference_Interface]
224 public static function getReferenceColumns() {
225 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
226 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
227 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
228 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
229 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
230 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
231 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
233 return Civi
::$statics[__CLASS__
]['links'];
237 * Returns all the column names of this table
241 public static function &fields() {
242 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
243 Civi
::$statics[__CLASS__
]['fields'] = [
246 'type' => CRM_Utils_Type
::T_INT
,
247 'title' => ts('Pledge ID'),
248 'description' => ts('Pledge ID'),
251 'where' => 'civicrm_pledge.id',
253 'table_name' => 'civicrm_pledge',
254 'entity' => 'Pledge',
255 'bao' => 'CRM_Pledge_BAO_Pledge',
259 'pledge_contact_id' => [
260 'name' => 'contact_id',
261 'type' => CRM_Utils_Type
::T_INT
,
262 'title' => ts('Contact ID'),
263 'description' => ts('Foreign key to civicrm_contact.id .'),
266 'where' => 'civicrm_pledge.contact_id',
268 'table_name' => 'civicrm_pledge',
269 'entity' => 'Pledge',
270 'bao' => 'CRM_Pledge_BAO_Pledge',
272 'FKClassName' => 'CRM_Contact_DAO_Contact',
274 'type' => 'EntityRef',
278 'pledge_financial_type_id' => [
279 'name' => 'financial_type_id',
280 'type' => CRM_Utils_Type
::T_INT
,
281 'title' => ts('Type'),
282 'description' => ts('FK to Financial Type'),
283 'where' => 'civicrm_pledge.financial_type_id',
284 'table_name' => 'civicrm_pledge',
285 'entity' => 'Pledge',
286 'bao' => 'CRM_Pledge_BAO_Pledge',
288 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
292 'pseudoconstant' => [
293 'table' => 'civicrm_financial_type',
295 'labelColumn' => 'name',
299 'pledge_contribution_page_id' => [
300 'name' => 'contribution_page_id',
301 'type' => CRM_Utils_Type
::T_INT
,
302 'title' => ts('Pledge Contribution Page'),
303 'description' => ts('The Contribution Page which triggered this contribution'),
304 'where' => 'civicrm_pledge.contribution_page_id',
305 'table_name' => 'civicrm_pledge',
306 'entity' => 'Pledge',
307 'bao' => 'CRM_Pledge_BAO_Pledge',
309 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
314 'type' => CRM_Utils_Type
::T_MONEY
,
315 'title' => ts('Total Pledged'),
316 'description' => ts('Total pledged amount.'),
323 'where' => 'civicrm_pledge.amount',
325 'table_name' => 'civicrm_pledge',
326 'entity' => 'Pledge',
327 'bao' => 'CRM_Pledge_BAO_Pledge',
334 'pledge_original_installment_amount' => [
335 'name' => 'original_installment_amount',
336 'type' => CRM_Utils_Type
::T_MONEY
,
337 'title' => ts('Original Installment Amount'),
338 'description' => ts('Original amount for each of the installments.'),
344 'where' => 'civicrm_pledge.original_installment_amount',
346 'table_name' => 'civicrm_pledge',
347 'entity' => 'Pledge',
348 'bao' => 'CRM_Pledge_BAO_Pledge',
356 'name' => 'currency',
357 'type' => CRM_Utils_Type
::T_STRING
,
358 'title' => ts('Pledge Currency'),
359 'description' => ts('3 character string, value from config setting or input via user.'),
361 'size' => CRM_Utils_Type
::FOUR
,
362 'where' => 'civicrm_pledge.currency',
364 'table_name' => 'civicrm_pledge',
365 'entity' => 'Pledge',
366 'bao' => 'CRM_Pledge_BAO_Pledge',
371 'pseudoconstant' => [
372 'table' => 'civicrm_currency',
373 'keyColumn' => 'name',
374 'labelColumn' => 'full_name',
375 'nameColumn' => 'name',
376 'abbrColumn' => 'symbol',
380 'pledge_frequency_unit' => [
381 'name' => 'frequency_unit',
382 'type' => CRM_Utils_Type
::T_STRING
,
383 'title' => ts('Pledge Frequency Unit'),
384 'description' => ts('Time units for recurrence of pledge payments.'),
387 'size' => CRM_Utils_Type
::EIGHT
,
388 'where' => 'civicrm_pledge.frequency_unit',
389 'default' => 'month',
390 'table_name' => 'civicrm_pledge',
391 'entity' => 'Pledge',
392 'bao' => 'CRM_Pledge_BAO_Pledge',
397 'pseudoconstant' => [
398 'optionGroupName' => 'recur_frequency_units',
399 'keyColumn' => 'name',
400 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
404 'pledge_frequency_interval' => [
405 'name' => 'frequency_interval',
406 'type' => CRM_Utils_Type
::T_INT
,
407 'title' => ts('Pledge Frequency Interval'),
408 'description' => ts('Number of time units for recurrence of pledge payments.'),
410 'where' => 'civicrm_pledge.frequency_interval',
412 'table_name' => 'civicrm_pledge',
413 'entity' => 'Pledge',
414 'bao' => 'CRM_Pledge_BAO_Pledge',
422 'name' => 'frequency_day',
423 'type' => CRM_Utils_Type
::T_INT
,
424 'title' => ts('Pledge day'),
425 '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.'),
427 'where' => 'civicrm_pledge.frequency_day',
429 'table_name' => 'civicrm_pledge',
430 'entity' => 'Pledge',
431 'bao' => 'CRM_Pledge_BAO_Pledge',
439 'name' => 'installments',
440 'type' => CRM_Utils_Type
::T_INT
,
441 'title' => ts('Pledge Number of Installments'),
442 'description' => ts('Total number of payments to be made.'),
444 'where' => 'civicrm_pledge.installments',
447 'table_name' => 'civicrm_pledge',
448 'entity' => 'Pledge',
449 'bao' => 'CRM_Pledge_BAO_Pledge',
456 'pledge_start_date' => [
457 'name' => 'start_date',
458 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
459 'title' => ts('Pledge Start Date'),
460 'description' => ts('The date the first scheduled pledge occurs.'),
462 'where' => 'civicrm_pledge.start_date',
464 'table_name' => 'civicrm_pledge',
465 'entity' => 'Pledge',
466 'bao' => 'CRM_Pledge_BAO_Pledge',
468 'unique_title' => ts('Payments Start Date'),
470 'type' => 'Select Date',
471 'formatType' => 'activityDate',
475 'pledge_create_date' => [
476 'name' => 'create_date',
477 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
478 'title' => ts('Pledge Made'),
479 'description' => ts('When this pledge record was created.'),
482 'where' => 'civicrm_pledge.create_date',
484 'table_name' => 'civicrm_pledge',
485 'entity' => 'Pledge',
486 'bao' => 'CRM_Pledge_BAO_Pledge',
489 'type' => 'Select Date',
490 'formatType' => 'activityDate',
494 'acknowledge_date' => [
495 'name' => 'acknowledge_date',
496 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
497 'title' => ts('Pledge Acknowledged'),
498 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
499 'where' => 'civicrm_pledge.acknowledge_date',
500 'table_name' => 'civicrm_pledge',
501 'entity' => 'Pledge',
502 'bao' => 'CRM_Pledge_BAO_Pledge',
505 'type' => 'Select Date',
506 'formatType' => 'activityDate',
511 'name' => 'modified_date',
512 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
513 'title' => ts('Pledge Modified Date'),
514 'description' => ts('Last updated date for this pledge record.'),
515 'where' => 'civicrm_pledge.modified_date',
516 'table_name' => 'civicrm_pledge',
517 'entity' => 'Pledge',
518 'bao' => 'CRM_Pledge_BAO_Pledge',
523 'name' => 'cancel_date',
524 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
525 'title' => ts('Pledge Cancelled Date'),
526 'description' => ts('Date this pledge was cancelled by contributor.'),
527 'where' => 'civicrm_pledge.cancel_date',
528 'table_name' => 'civicrm_pledge',
529 'entity' => 'Pledge',
530 'bao' => 'CRM_Pledge_BAO_Pledge',
533 'type' => 'Select Date',
534 'formatType' => 'activityDate',
538 'pledge_end_date' => [
539 'name' => 'end_date',
540 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
541 'title' => ts('Pledge End Date'),
542 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
543 'where' => 'civicrm_pledge.end_date',
545 'table_name' => 'civicrm_pledge',
546 'entity' => 'Pledge',
547 'bao' => 'CRM_Pledge_BAO_Pledge',
549 'unique_title' => ts('Payments Ended Date'),
551 'type' => 'Select Date',
552 'formatType' => 'activityDate',
557 'name' => 'max_reminders',
558 'type' => CRM_Utils_Type
::T_INT
,
559 'title' => ts('Maximum Number of Reminders'),
560 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
561 'where' => 'civicrm_pledge.max_reminders',
563 'table_name' => 'civicrm_pledge',
564 'entity' => 'Pledge',
565 'bao' => 'CRM_Pledge_BAO_Pledge',
572 'initial_reminder_day' => [
573 'name' => 'initial_reminder_day',
574 'type' => CRM_Utils_Type
::T_INT
,
575 'title' => ts('Initial Reminder Day'),
576 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
577 'where' => 'civicrm_pledge.initial_reminder_day',
579 'table_name' => 'civicrm_pledge',
580 'entity' => 'Pledge',
581 'bao' => 'CRM_Pledge_BAO_Pledge',
588 'additional_reminder_day' => [
589 'name' => 'additional_reminder_day',
590 'type' => CRM_Utils_Type
::T_INT
,
591 'title' => ts('Additional Reminder Days'),
592 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
593 'where' => 'civicrm_pledge.additional_reminder_day',
595 'table_name' => 'civicrm_pledge',
596 'entity' => 'Pledge',
597 'bao' => 'CRM_Pledge_BAO_Pledge',
604 'pledge_status_id' => [
605 'name' => 'status_id',
606 'type' => CRM_Utils_Type
::T_INT
,
607 'title' => ts('Pledge Status Id'),
608 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
611 'where' => 'civicrm_pledge.status_id',
613 'table_name' => 'civicrm_pledge',
614 'entity' => 'Pledge',
615 'bao' => 'CRM_Pledge_BAO_Pledge',
620 'pseudoconstant' => [
621 'optionGroupName' => 'pledge_status',
622 'optionEditPath' => 'civicrm/admin/options/pledge_status',
626 'pledge_is_test' => [
628 'type' => CRM_Utils_Type
::T_BOOLEAN
,
629 'title' => ts('Test'),
632 'where' => 'civicrm_pledge.is_test',
635 'table_name' => 'civicrm_pledge',
636 'entity' => 'Pledge',
637 'bao' => 'CRM_Pledge_BAO_Pledge',
640 'type' => 'CheckBox',
644 'pledge_campaign_id' => [
645 'name' => 'campaign_id',
646 'type' => CRM_Utils_Type
::T_INT
,
647 'title' => ts('Campaign'),
648 'description' => ts('The campaign for which this pledge has been initiated.'),
650 'where' => 'civicrm_pledge.campaign_id',
652 'table_name' => 'civicrm_pledge',
653 'entity' => 'Pledge',
654 'bao' => 'CRM_Pledge_BAO_Pledge',
656 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
660 'pseudoconstant' => [
661 'table' => 'civicrm_campaign',
663 'labelColumn' => 'title',
668 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
670 return Civi
::$statics[__CLASS__
]['fields'];
674 * Return a mapping from field-name to the corresponding key (as used in fields()).
677 * Array(string $name => string $uniqueName).
679 public static function &fieldKeys() {
680 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
681 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
683 return Civi
::$statics[__CLASS__
]['fieldKeys'];
687 * Returns the names of this table
691 public static function getTableName() {
692 return self
::$_tableName;
696 * Returns if this table needs to be logged
700 public function getLog() {
705 * Returns the list of fields that can be imported
707 * @param bool $prefix
711 public static function &import($prefix = FALSE) {
712 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
717 * Returns the list of fields that can be exported
719 * @param bool $prefix
723 public static function &export($prefix = FALSE) {
724 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
729 * Returns the list of indices
731 * @param bool $localize
735 public static function indices($localize = TRUE) {
738 'name' => 'index_status',
742 'localizable' => FALSE,
743 'sig' => 'civicrm_pledge::0::status_id',
746 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;