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:237bb1983467d1d8ce0f3c77eacc8f93)
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',
262 'pledge_contact_id' => [
263 'name' => 'contact_id',
264 'type' => CRM_Utils_Type
::T_INT
,
265 'title' => ts('Contact ID'),
266 'description' => ts('Foreign key to civicrm_contact.id .'),
269 'where' => 'civicrm_pledge.contact_id',
271 'table_name' => 'civicrm_pledge',
272 'entity' => 'Pledge',
273 'bao' => 'CRM_Pledge_BAO_Pledge',
275 'FKClassName' => 'CRM_Contact_DAO_Contact',
277 'type' => 'EntityRef',
278 'label' => ts("Contact"),
282 'pledge_financial_type_id' => [
283 'name' => 'financial_type_id',
284 'type' => CRM_Utils_Type
::T_INT
,
285 'title' => ts('Financial Type ID'),
286 'description' => ts('FK to Financial Type'),
287 'where' => 'civicrm_pledge.financial_type_id',
288 'table_name' => 'civicrm_pledge',
289 'entity' => 'Pledge',
290 'bao' => 'CRM_Pledge_BAO_Pledge',
292 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
295 'label' => ts("Financial Type"),
297 'pseudoconstant' => [
298 'table' => 'civicrm_financial_type',
300 'labelColumn' => 'name',
304 'pledge_contribution_page_id' => [
305 'name' => 'contribution_page_id',
306 'type' => CRM_Utils_Type
::T_INT
,
307 'title' => ts('Contribution Page ID'),
308 'description' => ts('The Contribution Page which triggered this contribution'),
309 'where' => 'civicrm_pledge.contribution_page_id',
310 'table_name' => 'civicrm_pledge',
311 'entity' => 'Pledge',
312 'bao' => 'CRM_Pledge_BAO_Pledge',
314 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
316 'label' => ts("Contribution Page"),
322 'type' => CRM_Utils_Type
::T_MONEY
,
323 'title' => ts('Total Pledged'),
324 'description' => ts('Total pledged amount.'),
331 'where' => 'civicrm_pledge.amount',
333 'table_name' => 'civicrm_pledge',
334 'entity' => 'Pledge',
335 'bao' => 'CRM_Pledge_BAO_Pledge',
342 'pledge_original_installment_amount' => [
343 'name' => 'original_installment_amount',
344 'type' => CRM_Utils_Type
::T_MONEY
,
345 'title' => ts('Original Installment Amount'),
346 'description' => ts('Original amount for each of the installments.'),
352 'where' => 'civicrm_pledge.original_installment_amount',
354 'table_name' => 'civicrm_pledge',
355 'entity' => 'Pledge',
356 'bao' => 'CRM_Pledge_BAO_Pledge',
364 'name' => 'currency',
365 'type' => CRM_Utils_Type
::T_STRING
,
366 'title' => ts('Pledge Currency'),
367 'description' => ts('3 character string, value from config setting or input via user.'),
369 'size' => CRM_Utils_Type
::FOUR
,
370 'where' => 'civicrm_pledge.currency',
372 'table_name' => 'civicrm_pledge',
373 'entity' => 'Pledge',
374 'bao' => 'CRM_Pledge_BAO_Pledge',
379 'pseudoconstant' => [
380 'table' => 'civicrm_currency',
381 'keyColumn' => 'name',
382 'labelColumn' => 'full_name',
383 'nameColumn' => 'name',
384 'abbrColumn' => 'symbol',
388 'pledge_frequency_unit' => [
389 'name' => 'frequency_unit',
390 'type' => CRM_Utils_Type
::T_STRING
,
391 'title' => ts('Pledge Frequency Unit'),
392 'description' => ts('Time units for recurrence of pledge payments.'),
395 'size' => CRM_Utils_Type
::EIGHT
,
396 'where' => 'civicrm_pledge.frequency_unit',
397 'default' => 'month',
398 'table_name' => 'civicrm_pledge',
399 'entity' => 'Pledge',
400 'bao' => 'CRM_Pledge_BAO_Pledge',
405 'pseudoconstant' => [
406 'optionGroupName' => 'recur_frequency_units',
407 'keyColumn' => 'name',
408 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
412 'pledge_frequency_interval' => [
413 'name' => 'frequency_interval',
414 'type' => CRM_Utils_Type
::T_INT
,
415 'title' => ts('Pledge Frequency Interval'),
416 'description' => ts('Number of time units for recurrence of pledge payments.'),
418 'where' => 'civicrm_pledge.frequency_interval',
420 'table_name' => 'civicrm_pledge',
421 'entity' => 'Pledge',
422 'bao' => 'CRM_Pledge_BAO_Pledge',
430 'name' => 'frequency_day',
431 'type' => CRM_Utils_Type
::T_INT
,
432 'title' => ts('Pledge day'),
433 '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.'),
435 'where' => 'civicrm_pledge.frequency_day',
437 'table_name' => 'civicrm_pledge',
438 'entity' => 'Pledge',
439 'bao' => 'CRM_Pledge_BAO_Pledge',
447 'name' => 'installments',
448 'type' => CRM_Utils_Type
::T_INT
,
449 'title' => ts('Pledge Number of Installments'),
450 'description' => ts('Total number of payments to be made.'),
452 'where' => 'civicrm_pledge.installments',
455 'table_name' => 'civicrm_pledge',
456 'entity' => 'Pledge',
457 'bao' => 'CRM_Pledge_BAO_Pledge',
464 'pledge_start_date' => [
465 'name' => 'start_date',
466 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
467 'title' => ts('Pledge Start Date'),
468 'description' => ts('The date the first scheduled pledge occurs.'),
470 'where' => 'civicrm_pledge.start_date',
472 'table_name' => 'civicrm_pledge',
473 'entity' => 'Pledge',
474 'bao' => 'CRM_Pledge_BAO_Pledge',
476 'unique_title' => ts('Payments Start Date'),
478 'type' => 'Select Date',
479 'formatType' => 'activityDate',
483 'pledge_create_date' => [
484 'name' => 'create_date',
485 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
486 'title' => ts('Pledge Made'),
487 'description' => ts('When this pledge record was created.'),
490 'where' => 'civicrm_pledge.create_date',
492 'table_name' => 'civicrm_pledge',
493 'entity' => 'Pledge',
494 'bao' => 'CRM_Pledge_BAO_Pledge',
497 'type' => 'Select Date',
498 'formatType' => 'activityDate',
502 'acknowledge_date' => [
503 'name' => 'acknowledge_date',
504 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
505 'title' => ts('Pledge Acknowledged'),
506 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
507 'where' => 'civicrm_pledge.acknowledge_date',
508 'table_name' => 'civicrm_pledge',
509 'entity' => 'Pledge',
510 'bao' => 'CRM_Pledge_BAO_Pledge',
513 'type' => 'Select Date',
514 'formatType' => 'activityDate',
519 'name' => 'modified_date',
520 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
521 'title' => ts('Pledge Modified Date'),
522 'description' => ts('Last updated date for this pledge record.'),
523 'where' => 'civicrm_pledge.modified_date',
524 'table_name' => 'civicrm_pledge',
525 'entity' => 'Pledge',
526 'bao' => 'CRM_Pledge_BAO_Pledge',
531 'name' => 'cancel_date',
532 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
533 'title' => ts('Pledge Cancelled Date'),
534 'description' => ts('Date this pledge was cancelled by contributor.'),
535 'where' => 'civicrm_pledge.cancel_date',
536 'table_name' => 'civicrm_pledge',
537 'entity' => 'Pledge',
538 'bao' => 'CRM_Pledge_BAO_Pledge',
541 'type' => 'Select Date',
542 'formatType' => 'activityDate',
546 'pledge_end_date' => [
547 'name' => 'end_date',
548 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
549 'title' => ts('Pledge End Date'),
550 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
551 'where' => 'civicrm_pledge.end_date',
553 'table_name' => 'civicrm_pledge',
554 'entity' => 'Pledge',
555 'bao' => 'CRM_Pledge_BAO_Pledge',
557 'unique_title' => ts('Payments Ended Date'),
559 'type' => 'Select Date',
560 'formatType' => 'activityDate',
565 'name' => 'max_reminders',
566 'type' => CRM_Utils_Type
::T_INT
,
567 'title' => ts('Maximum Number of Reminders'),
568 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
569 'where' => 'civicrm_pledge.max_reminders',
571 'table_name' => 'civicrm_pledge',
572 'entity' => 'Pledge',
573 'bao' => 'CRM_Pledge_BAO_Pledge',
580 'initial_reminder_day' => [
581 'name' => 'initial_reminder_day',
582 'type' => CRM_Utils_Type
::T_INT
,
583 'title' => ts('Initial Reminder Day'),
584 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
585 'where' => 'civicrm_pledge.initial_reminder_day',
587 'table_name' => 'civicrm_pledge',
588 'entity' => 'Pledge',
589 'bao' => 'CRM_Pledge_BAO_Pledge',
596 'additional_reminder_day' => [
597 'name' => 'additional_reminder_day',
598 'type' => CRM_Utils_Type
::T_INT
,
599 'title' => ts('Additional Reminder Days'),
600 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
601 'where' => 'civicrm_pledge.additional_reminder_day',
603 'table_name' => 'civicrm_pledge',
604 'entity' => 'Pledge',
605 'bao' => 'CRM_Pledge_BAO_Pledge',
612 'pledge_status_id' => [
613 'name' => 'status_id',
614 'type' => CRM_Utils_Type
::T_INT
,
615 'title' => ts('Pledge Status ID'),
616 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
619 'where' => 'civicrm_pledge.status_id',
621 'table_name' => 'civicrm_pledge',
622 'entity' => 'Pledge',
623 'bao' => 'CRM_Pledge_BAO_Pledge',
628 'pseudoconstant' => [
629 'optionGroupName' => 'pledge_status',
630 'optionEditPath' => 'civicrm/admin/options/pledge_status',
634 'pledge_is_test' => [
636 'type' => CRM_Utils_Type
::T_BOOLEAN
,
637 'title' => ts('Test'),
640 'where' => 'civicrm_pledge.is_test',
643 'table_name' => 'civicrm_pledge',
644 'entity' => 'Pledge',
645 'bao' => 'CRM_Pledge_BAO_Pledge',
648 'type' => 'CheckBox',
652 'pledge_campaign_id' => [
653 'name' => 'campaign_id',
654 'type' => CRM_Utils_Type
::T_INT
,
655 'title' => ts('Campaign ID'),
656 'description' => ts('The campaign for which this pledge has been initiated.'),
658 'where' => 'civicrm_pledge.campaign_id',
660 'table_name' => 'civicrm_pledge',
661 'entity' => 'Pledge',
662 'bao' => 'CRM_Pledge_BAO_Pledge',
664 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
667 'label' => ts("Campaign"),
672 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
674 return Civi
::$statics[__CLASS__
]['fields'];
678 * Return a mapping from field-name to the corresponding key (as used in fields()).
681 * Array(string $name => string $uniqueName).
683 public static function &fieldKeys() {
684 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
685 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
687 return Civi
::$statics[__CLASS__
]['fieldKeys'];
691 * Returns the names of this table
695 public static function getTableName() {
696 return self
::$_tableName;
700 * Returns if this table needs to be logged
704 public function getLog() {
709 * Returns the list of fields that can be imported
711 * @param bool $prefix
715 public static function &import($prefix = FALSE) {
716 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
721 * Returns the list of fields that can be exported
723 * @param bool $prefix
727 public static function &export($prefix = FALSE) {
728 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
733 * Returns the list of indices
735 * @param bool $localize
739 public static function indices($localize = TRUE) {
742 'name' => 'index_status',
746 'localizable' => FALSE,
747 'sig' => 'civicrm_pledge::0::status_id',
750 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;