5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Pledge/Pledge.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:117f63c183c68fcf5bd882f3fc40173e)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
39 * Foreign key to civicrm_contact.id .
46 * FK to Financial Type
50 public $financial_type_id;
53 * The Contribution Page which triggered this contribution
57 public $contribution_page_id;
60 * Total pledged amount.
67 * Original amount for each of the installments.
71 public $original_installment_amount;
74 * 3 character string, value from config setting or input via user.
81 * Time units for recurrence of pledge payments.
85 public $frequency_unit;
88 * Number of time units for recurrence of pledge payments.
92 public $frequency_interval;
95 * 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.
99 public $frequency_day;
102 * Total number of payments to be made.
106 public $installments;
109 * The date the first scheduled pledge occurs.
116 * When this pledge record was created.
123 * When a pledge acknowledgement message was sent to the contributor.
127 public $acknowledge_date;
130 * Last updated date for this pledge record.
134 public $modified_date;
137 * Date this pledge was cancelled by contributor.
144 * Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).
151 * The maximum number of payment reminders to send for any given payment.
155 public $max_reminders;
158 * Send initial reminder this many days prior to the payment due date.
162 public $initial_reminder_day;
165 * Send additional reminder this many days after last one sent, up to maximum number of reminders.
169 public $additional_reminder_day;
172 * Implicit foreign key to civicrm_option_values in the pledge_status option group.
184 * The campaign for which this pledge has been initiated.
193 public function __construct() {
194 $this->__table
= 'civicrm_pledge';
195 parent
::__construct();
199 * Returns foreign keys and entity references.
202 * [CRM_Core_Reference_Interface]
204 public static function getReferenceColumns() {
205 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
206 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
207 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
208 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id');
209 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id');
210 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
211 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
213 return Civi
::$statics[__CLASS__
]['links'];
217 * Returns all the column names of this table
221 public static function &fields() {
222 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
223 Civi
::$statics[__CLASS__
]['fields'] = [
226 'type' => CRM_Utils_Type
::T_INT
,
227 'title' => ts('Pledge ID'),
228 'description' => ts('Pledge ID'),
231 'where' => 'civicrm_pledge.id',
233 'table_name' => 'civicrm_pledge',
234 'entity' => 'Pledge',
235 'bao' => 'CRM_Pledge_BAO_Pledge',
238 'pledge_contact_id' => [
239 'name' => 'contact_id',
240 'type' => CRM_Utils_Type
::T_INT
,
241 'title' => ts('Contact ID'),
242 'description' => ts('Foreign key to civicrm_contact.id .'),
245 'where' => 'civicrm_pledge.contact_id',
247 'table_name' => 'civicrm_pledge',
248 'entity' => 'Pledge',
249 'bao' => 'CRM_Pledge_BAO_Pledge',
251 'FKClassName' => 'CRM_Contact_DAO_Contact',
253 'type' => 'EntityRef',
256 'pledge_financial_type_id' => [
257 'name' => 'financial_type_id',
258 'type' => CRM_Utils_Type
::T_INT
,
259 'title' => ts('Type'),
260 'description' => ts('FK to Financial Type'),
261 'where' => 'civicrm_pledge.financial_type_id',
262 'table_name' => 'civicrm_pledge',
263 'entity' => 'Pledge',
264 'bao' => 'CRM_Pledge_BAO_Pledge',
266 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
270 'pseudoconstant' => [
271 'table' => 'civicrm_financial_type',
273 'labelColumn' => 'name',
276 'pledge_contribution_page_id' => [
277 'name' => 'contribution_page_id',
278 'type' => CRM_Utils_Type
::T_INT
,
279 'title' => ts('Pledge Contribution Page'),
280 'description' => ts('The Contribution Page which triggered this contribution'),
281 'where' => 'civicrm_pledge.contribution_page_id',
282 'table_name' => 'civicrm_pledge',
283 'entity' => 'Pledge',
284 'bao' => 'CRM_Pledge_BAO_Pledge',
286 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
290 'type' => CRM_Utils_Type
::T_MONEY
,
291 'title' => ts('Total Pledged'),
292 'description' => ts('Total pledged amount.'),
299 'where' => 'civicrm_pledge.amount',
301 'table_name' => 'civicrm_pledge',
302 'entity' => 'Pledge',
303 'bao' => 'CRM_Pledge_BAO_Pledge',
309 'pledge_original_installment_amount' => [
310 'name' => 'original_installment_amount',
311 'type' => CRM_Utils_Type
::T_MONEY
,
312 'title' => ts('Original Installment Amount'),
313 'description' => ts('Original amount for each of the installments.'),
319 'where' => 'civicrm_pledge.original_installment_amount',
321 'table_name' => 'civicrm_pledge',
322 'entity' => 'Pledge',
323 'bao' => 'CRM_Pledge_BAO_Pledge',
330 'name' => 'currency',
331 'type' => CRM_Utils_Type
::T_STRING
,
332 'title' => ts('Pledge Currency'),
333 'description' => ts('3 character string, value from config setting or input via user.'),
335 'size' => CRM_Utils_Type
::FOUR
,
336 'where' => 'civicrm_pledge.currency',
338 'table_name' => 'civicrm_pledge',
339 'entity' => 'Pledge',
340 'bao' => 'CRM_Pledge_BAO_Pledge',
345 'pseudoconstant' => [
346 'table' => 'civicrm_currency',
347 'keyColumn' => 'name',
348 'labelColumn' => 'full_name',
349 'nameColumn' => 'name',
352 'pledge_frequency_unit' => [
353 'name' => 'frequency_unit',
354 'type' => CRM_Utils_Type
::T_STRING
,
355 'title' => ts('Pledge Frequency Unit'),
356 'description' => ts('Time units for recurrence of pledge payments.'),
358 'size' => CRM_Utils_Type
::EIGHT
,
359 'where' => 'civicrm_pledge.frequency_unit',
360 'default' => 'month',
361 'table_name' => 'civicrm_pledge',
362 'entity' => 'Pledge',
363 'bao' => 'CRM_Pledge_BAO_Pledge',
368 'pseudoconstant' => [
369 'optionGroupName' => 'recur_frequency_units',
370 'keyColumn' => 'name',
371 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
374 'pledge_frequency_interval' => [
375 'name' => 'frequency_interval',
376 'type' => CRM_Utils_Type
::T_INT
,
377 'title' => ts('Pledge Frequency Interval'),
378 'description' => ts('Number of time units for recurrence of pledge payments.'),
380 'where' => 'civicrm_pledge.frequency_interval',
382 'table_name' => 'civicrm_pledge',
383 'entity' => 'Pledge',
384 'bao' => 'CRM_Pledge_BAO_Pledge',
391 'name' => 'frequency_day',
392 'type' => CRM_Utils_Type
::T_INT
,
393 'title' => ts('Pledge day'),
394 '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.'),
396 'where' => 'civicrm_pledge.frequency_day',
398 'table_name' => 'civicrm_pledge',
399 'entity' => 'Pledge',
400 'bao' => 'CRM_Pledge_BAO_Pledge',
407 'name' => 'installments',
408 'type' => CRM_Utils_Type
::T_INT
,
409 'title' => ts('Pledge Number of Installments'),
410 'description' => ts('Total number of payments to be made.'),
411 'where' => 'civicrm_pledge.installments',
414 'table_name' => 'civicrm_pledge',
415 'entity' => 'Pledge',
416 'bao' => 'CRM_Pledge_BAO_Pledge',
423 'name' => 'start_date',
424 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
425 'title' => ts('Pledge Start Date'),
426 'description' => ts('The date the first scheduled pledge occurs.'),
428 'where' => 'civicrm_pledge.start_date',
429 'table_name' => 'civicrm_pledge',
430 'entity' => 'Pledge',
431 'bao' => 'CRM_Pledge_BAO_Pledge',
434 'type' => 'Select Date',
437 'pledge_create_date' => [
438 'name' => 'create_date',
439 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
440 'title' => ts('Pledge Made'),
441 'description' => ts('When this pledge record was created.'),
444 'where' => 'civicrm_pledge.create_date',
446 'table_name' => 'civicrm_pledge',
447 'entity' => 'Pledge',
448 'bao' => 'CRM_Pledge_BAO_Pledge',
451 'type' => 'Select Date',
454 'acknowledge_date' => [
455 'name' => 'acknowledge_date',
456 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
457 'title' => ts('Pledge Acknowledged'),
458 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
459 'where' => 'civicrm_pledge.acknowledge_date',
460 'table_name' => 'civicrm_pledge',
461 'entity' => 'Pledge',
462 'bao' => 'CRM_Pledge_BAO_Pledge',
465 'type' => 'Select Date',
469 'name' => 'modified_date',
470 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
471 'title' => ts('Pledge Modified Date'),
472 'description' => ts('Last updated date for this pledge record.'),
473 'where' => 'civicrm_pledge.modified_date',
474 'table_name' => 'civicrm_pledge',
475 'entity' => 'Pledge',
476 'bao' => 'CRM_Pledge_BAO_Pledge',
480 'name' => 'cancel_date',
481 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
482 'title' => ts('Pledge Cancelled Date'),
483 'description' => ts('Date this pledge was cancelled by contributor.'),
484 'where' => 'civicrm_pledge.cancel_date',
485 'table_name' => 'civicrm_pledge',
486 'entity' => 'Pledge',
487 'bao' => 'CRM_Pledge_BAO_Pledge',
490 'type' => 'Select Date',
494 'name' => 'end_date',
495 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
496 'title' => ts('Pledge End Date'),
497 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
498 'where' => 'civicrm_pledge.end_date',
499 'table_name' => 'civicrm_pledge',
500 'entity' => 'Pledge',
501 'bao' => 'CRM_Pledge_BAO_Pledge',
504 'type' => 'Select Date',
508 'name' => 'max_reminders',
509 'type' => CRM_Utils_Type
::T_INT
,
510 'title' => ts('Maximum Number of Reminders'),
511 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
512 'where' => 'civicrm_pledge.max_reminders',
514 'table_name' => 'civicrm_pledge',
515 'entity' => 'Pledge',
516 'bao' => 'CRM_Pledge_BAO_Pledge',
522 'initial_reminder_day' => [
523 'name' => 'initial_reminder_day',
524 'type' => CRM_Utils_Type
::T_INT
,
525 'title' => ts('Initial Reminder Day'),
526 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
527 'where' => 'civicrm_pledge.initial_reminder_day',
529 'table_name' => 'civicrm_pledge',
530 'entity' => 'Pledge',
531 'bao' => 'CRM_Pledge_BAO_Pledge',
537 'additional_reminder_day' => [
538 'name' => 'additional_reminder_day',
539 'type' => CRM_Utils_Type
::T_INT
,
540 'title' => ts('Additional Reminder Days'),
541 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
542 'where' => 'civicrm_pledge.additional_reminder_day',
544 'table_name' => 'civicrm_pledge',
545 'entity' => 'Pledge',
546 'bao' => 'CRM_Pledge_BAO_Pledge',
552 'pledge_status_id' => [
553 'name' => 'status_id',
554 'type' => CRM_Utils_Type
::T_INT
,
555 'title' => ts('Pledge Status Id'),
556 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
558 'where' => 'civicrm_pledge.status_id',
560 'table_name' => 'civicrm_pledge',
561 'entity' => 'Pledge',
562 'bao' => 'CRM_Pledge_BAO_Pledge',
567 'pseudoconstant' => [
568 'optionGroupName' => 'pledge_status',
569 'optionEditPath' => 'civicrm/admin/options/pledge_status',
572 'pledge_is_test' => [
574 'type' => CRM_Utils_Type
::T_BOOLEAN
,
575 'title' => ts('Test'),
577 'where' => 'civicrm_pledge.is_test',
580 'table_name' => 'civicrm_pledge',
581 'entity' => 'Pledge',
582 'bao' => 'CRM_Pledge_BAO_Pledge',
585 'type' => 'CheckBox',
588 'pledge_campaign_id' => [
589 'name' => 'campaign_id',
590 'type' => CRM_Utils_Type
::T_INT
,
591 'title' => ts('Campaign'),
592 'description' => ts('The campaign for which this pledge has been initiated.'),
594 'where' => 'civicrm_pledge.campaign_id',
596 'table_name' => 'civicrm_pledge',
597 'entity' => 'Pledge',
598 'bao' => 'CRM_Pledge_BAO_Pledge',
600 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
604 'pseudoconstant' => [
605 'table' => 'civicrm_campaign',
607 'labelColumn' => 'title',
611 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
613 return Civi
::$statics[__CLASS__
]['fields'];
617 * Return a mapping from field-name to the corresponding key (as used in fields()).
620 * Array(string $name => string $uniqueName).
622 public static function &fieldKeys() {
623 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
624 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
626 return Civi
::$statics[__CLASS__
]['fieldKeys'];
630 * Returns the names of this table
634 public static function getTableName() {
635 return self
::$_tableName;
639 * Returns if this table needs to be logged
643 public function getLog() {
648 * Returns the list of fields that can be imported
650 * @param bool $prefix
654 public static function &import($prefix = FALSE) {
655 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
660 * Returns the list of fields that can be exported
662 * @param bool $prefix
666 public static function &export($prefix = FALSE) {
667 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
672 * Returns the list of indices
674 * @param bool $localize
678 public static function indices($localize = TRUE) {
681 'name' => 'index_status',
685 'localizable' => FALSE,
686 'sig' => 'civicrm_pledge::0::status_id',
689 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;