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:7beeffe02aa5aa08578f40547b3c61bd)
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',
252 'pledge_contact_id' => [
253 'name' => 'contact_id',
254 'type' => CRM_Utils_Type
::T_INT
,
255 'title' => ts('Contact ID'),
256 'description' => ts('Foreign key to civicrm_contact.id .'),
259 'where' => 'civicrm_pledge.contact_id',
261 'table_name' => 'civicrm_pledge',
262 'entity' => 'Pledge',
263 'bao' => 'CRM_Pledge_BAO_Pledge',
265 'FKClassName' => 'CRM_Contact_DAO_Contact',
267 'type' => 'EntityRef',
270 'pledge_financial_type_id' => [
271 'name' => 'financial_type_id',
272 'type' => CRM_Utils_Type
::T_INT
,
273 'title' => ts('Type'),
274 'description' => ts('FK to Financial Type'),
275 'where' => 'civicrm_pledge.financial_type_id',
276 'table_name' => 'civicrm_pledge',
277 'entity' => 'Pledge',
278 'bao' => 'CRM_Pledge_BAO_Pledge',
280 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
284 'pseudoconstant' => [
285 'table' => 'civicrm_financial_type',
287 'labelColumn' => 'name',
290 'pledge_contribution_page_id' => [
291 'name' => 'contribution_page_id',
292 'type' => CRM_Utils_Type
::T_INT
,
293 'title' => ts('Pledge Contribution Page'),
294 'description' => ts('The Contribution Page which triggered this contribution'),
295 'where' => 'civicrm_pledge.contribution_page_id',
296 'table_name' => 'civicrm_pledge',
297 'entity' => 'Pledge',
298 'bao' => 'CRM_Pledge_BAO_Pledge',
300 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
304 'type' => CRM_Utils_Type
::T_MONEY
,
305 'title' => ts('Total Pledged'),
306 'description' => ts('Total pledged amount.'),
313 'where' => 'civicrm_pledge.amount',
315 'table_name' => 'civicrm_pledge',
316 'entity' => 'Pledge',
317 'bao' => 'CRM_Pledge_BAO_Pledge',
323 'pledge_original_installment_amount' => [
324 'name' => 'original_installment_amount',
325 'type' => CRM_Utils_Type
::T_MONEY
,
326 'title' => ts('Original Installment Amount'),
327 'description' => ts('Original amount for each of the installments.'),
333 'where' => 'civicrm_pledge.original_installment_amount',
335 'table_name' => 'civicrm_pledge',
336 'entity' => 'Pledge',
337 'bao' => 'CRM_Pledge_BAO_Pledge',
344 'name' => 'currency',
345 'type' => CRM_Utils_Type
::T_STRING
,
346 'title' => ts('Pledge Currency'),
347 'description' => ts('3 character string, value from config setting or input via user.'),
349 'size' => CRM_Utils_Type
::FOUR
,
350 'where' => 'civicrm_pledge.currency',
352 'table_name' => 'civicrm_pledge',
353 'entity' => 'Pledge',
354 'bao' => 'CRM_Pledge_BAO_Pledge',
359 'pseudoconstant' => [
360 'table' => 'civicrm_currency',
361 'keyColumn' => 'name',
362 'labelColumn' => 'full_name',
363 'nameColumn' => 'name',
364 'abbrColumn' => 'symbol',
367 'pledge_frequency_unit' => [
368 'name' => 'frequency_unit',
369 'type' => CRM_Utils_Type
::T_STRING
,
370 'title' => ts('Pledge Frequency Unit'),
371 'description' => ts('Time units for recurrence of pledge payments.'),
373 'size' => CRM_Utils_Type
::EIGHT
,
374 'where' => 'civicrm_pledge.frequency_unit',
375 'default' => 'month',
376 'table_name' => 'civicrm_pledge',
377 'entity' => 'Pledge',
378 'bao' => 'CRM_Pledge_BAO_Pledge',
383 'pseudoconstant' => [
384 'optionGroupName' => 'recur_frequency_units',
385 'keyColumn' => 'name',
386 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
389 'pledge_frequency_interval' => [
390 'name' => 'frequency_interval',
391 'type' => CRM_Utils_Type
::T_INT
,
392 'title' => ts('Pledge Frequency Interval'),
393 'description' => ts('Number of time units for recurrence of pledge payments.'),
395 'where' => 'civicrm_pledge.frequency_interval',
397 'table_name' => 'civicrm_pledge',
398 'entity' => 'Pledge',
399 'bao' => 'CRM_Pledge_BAO_Pledge',
406 'name' => 'frequency_day',
407 'type' => CRM_Utils_Type
::T_INT
,
408 'title' => ts('Pledge day'),
409 '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.'),
411 'where' => 'civicrm_pledge.frequency_day',
413 'table_name' => 'civicrm_pledge',
414 'entity' => 'Pledge',
415 'bao' => 'CRM_Pledge_BAO_Pledge',
422 'name' => 'installments',
423 'type' => CRM_Utils_Type
::T_INT
,
424 'title' => ts('Pledge Number of Installments'),
425 'description' => ts('Total number of payments to be made.'),
426 'where' => 'civicrm_pledge.installments',
429 'table_name' => 'civicrm_pledge',
430 'entity' => 'Pledge',
431 'bao' => 'CRM_Pledge_BAO_Pledge',
437 'pledge_start_date' => [
438 'name' => 'start_date',
439 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
440 'title' => ts('Pledge Start Date'),
441 'description' => ts('The date the first scheduled pledge occurs.'),
443 'where' => 'civicrm_pledge.start_date',
445 'table_name' => 'civicrm_pledge',
446 'entity' => 'Pledge',
447 'bao' => 'CRM_Pledge_BAO_Pledge',
449 'unique_title' => ts('Payments Start Date'),
451 'type' => 'Select Date',
454 'pledge_create_date' => [
455 'name' => 'create_date',
456 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
457 'title' => ts('Pledge Made'),
458 'description' => ts('When this pledge record was created.'),
461 'where' => 'civicrm_pledge.create_date',
463 'table_name' => 'civicrm_pledge',
464 'entity' => 'Pledge',
465 'bao' => 'CRM_Pledge_BAO_Pledge',
468 'type' => 'Select Date',
471 'acknowledge_date' => [
472 'name' => 'acknowledge_date',
473 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
474 'title' => ts('Pledge Acknowledged'),
475 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
476 'where' => 'civicrm_pledge.acknowledge_date',
477 'table_name' => 'civicrm_pledge',
478 'entity' => 'Pledge',
479 'bao' => 'CRM_Pledge_BAO_Pledge',
482 'type' => 'Select Date',
486 'name' => 'modified_date',
487 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
488 'title' => ts('Pledge Modified Date'),
489 'description' => ts('Last updated date for this pledge record.'),
490 'where' => 'civicrm_pledge.modified_date',
491 'table_name' => 'civicrm_pledge',
492 'entity' => 'Pledge',
493 'bao' => 'CRM_Pledge_BAO_Pledge',
497 'name' => 'cancel_date',
498 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
499 'title' => ts('Pledge Cancelled Date'),
500 'description' => ts('Date this pledge was cancelled by contributor.'),
501 'where' => 'civicrm_pledge.cancel_date',
502 'table_name' => 'civicrm_pledge',
503 'entity' => 'Pledge',
504 'bao' => 'CRM_Pledge_BAO_Pledge',
507 'type' => 'Select Date',
510 'pledge_end_date' => [
511 'name' => 'end_date',
512 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
513 'title' => ts('Pledge End Date'),
514 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
515 'where' => 'civicrm_pledge.end_date',
517 'table_name' => 'civicrm_pledge',
518 'entity' => 'Pledge',
519 'bao' => 'CRM_Pledge_BAO_Pledge',
521 'unique_title' => ts('Payments Ended Date'),
523 'type' => 'Select Date',
527 'name' => 'max_reminders',
528 'type' => CRM_Utils_Type
::T_INT
,
529 'title' => ts('Maximum Number of Reminders'),
530 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
531 'where' => 'civicrm_pledge.max_reminders',
533 'table_name' => 'civicrm_pledge',
534 'entity' => 'Pledge',
535 'bao' => 'CRM_Pledge_BAO_Pledge',
541 'initial_reminder_day' => [
542 'name' => 'initial_reminder_day',
543 'type' => CRM_Utils_Type
::T_INT
,
544 'title' => ts('Initial Reminder Day'),
545 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
546 'where' => 'civicrm_pledge.initial_reminder_day',
548 'table_name' => 'civicrm_pledge',
549 'entity' => 'Pledge',
550 'bao' => 'CRM_Pledge_BAO_Pledge',
556 'additional_reminder_day' => [
557 'name' => 'additional_reminder_day',
558 'type' => CRM_Utils_Type
::T_INT
,
559 'title' => ts('Additional Reminder Days'),
560 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
561 'where' => 'civicrm_pledge.additional_reminder_day',
563 'table_name' => 'civicrm_pledge',
564 'entity' => 'Pledge',
565 'bao' => 'CRM_Pledge_BAO_Pledge',
571 'pledge_status_id' => [
572 'name' => 'status_id',
573 'type' => CRM_Utils_Type
::T_INT
,
574 'title' => ts('Pledge Status Id'),
575 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
577 'where' => 'civicrm_pledge.status_id',
579 'table_name' => 'civicrm_pledge',
580 'entity' => 'Pledge',
581 'bao' => 'CRM_Pledge_BAO_Pledge',
586 'pseudoconstant' => [
587 'optionGroupName' => 'pledge_status',
588 'optionEditPath' => 'civicrm/admin/options/pledge_status',
591 'pledge_is_test' => [
593 'type' => CRM_Utils_Type
::T_BOOLEAN
,
594 'title' => ts('Test'),
596 'where' => 'civicrm_pledge.is_test',
599 'table_name' => 'civicrm_pledge',
600 'entity' => 'Pledge',
601 'bao' => 'CRM_Pledge_BAO_Pledge',
604 'type' => 'CheckBox',
607 'pledge_campaign_id' => [
608 'name' => 'campaign_id',
609 'type' => CRM_Utils_Type
::T_INT
,
610 'title' => ts('Campaign'),
611 'description' => ts('The campaign for which this pledge has been initiated.'),
613 'where' => 'civicrm_pledge.campaign_id',
615 'table_name' => 'civicrm_pledge',
616 'entity' => 'Pledge',
617 'bao' => 'CRM_Pledge_BAO_Pledge',
619 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
623 'pseudoconstant' => [
624 'table' => 'civicrm_campaign',
626 'labelColumn' => 'title',
630 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
632 return Civi
::$statics[__CLASS__
]['fields'];
636 * Return a mapping from field-name to the corresponding key (as used in fields()).
639 * Array(string $name => string $uniqueName).
641 public static function &fieldKeys() {
642 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
643 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
645 return Civi
::$statics[__CLASS__
]['fieldKeys'];
649 * Returns the names of this table
653 public static function getTableName() {
654 return self
::$_tableName;
658 * Returns if this table needs to be logged
662 public function getLog() {
667 * Returns the list of fields that can be imported
669 * @param bool $prefix
673 public static function &import($prefix = FALSE) {
674 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
679 * Returns the list of fields that can be exported
681 * @param bool $prefix
685 public static function &export($prefix = FALSE) {
686 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
691 * Returns the list of indices
693 * @param bool $localize
697 public static function indices($localize = TRUE) {
700 'name' => 'index_status',
704 'localizable' => FALSE,
705 'sig' => 'civicrm_pledge::0::status_id',
708 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;