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:5e5bb725caa46ae10f0c5d039a03c675)
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',
350 'abbrColumn' => 'symbol',
353 'pledge_frequency_unit' => [
354 'name' => 'frequency_unit',
355 'type' => CRM_Utils_Type
::T_STRING
,
356 'title' => ts('Pledge Frequency Unit'),
357 'description' => ts('Time units for recurrence of pledge payments.'),
359 'size' => CRM_Utils_Type
::EIGHT
,
360 'where' => 'civicrm_pledge.frequency_unit',
361 'default' => 'month',
362 'table_name' => 'civicrm_pledge',
363 'entity' => 'Pledge',
364 'bao' => 'CRM_Pledge_BAO_Pledge',
369 'pseudoconstant' => [
370 'optionGroupName' => 'recur_frequency_units',
371 'keyColumn' => 'name',
372 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
375 'pledge_frequency_interval' => [
376 'name' => 'frequency_interval',
377 'type' => CRM_Utils_Type
::T_INT
,
378 'title' => ts('Pledge Frequency Interval'),
379 'description' => ts('Number of time units for recurrence of pledge payments.'),
381 'where' => 'civicrm_pledge.frequency_interval',
383 'table_name' => 'civicrm_pledge',
384 'entity' => 'Pledge',
385 'bao' => 'CRM_Pledge_BAO_Pledge',
392 'name' => 'frequency_day',
393 'type' => CRM_Utils_Type
::T_INT
,
394 'title' => ts('Pledge day'),
395 '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.'),
397 'where' => 'civicrm_pledge.frequency_day',
399 'table_name' => 'civicrm_pledge',
400 'entity' => 'Pledge',
401 'bao' => 'CRM_Pledge_BAO_Pledge',
408 'name' => 'installments',
409 'type' => CRM_Utils_Type
::T_INT
,
410 'title' => ts('Pledge Number of Installments'),
411 'description' => ts('Total number of payments to be made.'),
412 'where' => 'civicrm_pledge.installments',
415 'table_name' => 'civicrm_pledge',
416 'entity' => 'Pledge',
417 'bao' => 'CRM_Pledge_BAO_Pledge',
424 'name' => 'start_date',
425 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
426 'title' => ts('Pledge Start Date'),
427 'description' => ts('The date the first scheduled pledge occurs.'),
429 'where' => 'civicrm_pledge.start_date',
430 'table_name' => 'civicrm_pledge',
431 'entity' => 'Pledge',
432 'bao' => 'CRM_Pledge_BAO_Pledge',
435 'type' => 'Select Date',
438 'pledge_create_date' => [
439 'name' => 'create_date',
440 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
441 'title' => ts('Pledge Made'),
442 'description' => ts('When this pledge record was created.'),
445 'where' => 'civicrm_pledge.create_date',
447 'table_name' => 'civicrm_pledge',
448 'entity' => 'Pledge',
449 'bao' => 'CRM_Pledge_BAO_Pledge',
452 'type' => 'Select Date',
455 'acknowledge_date' => [
456 'name' => 'acknowledge_date',
457 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
458 'title' => ts('Pledge Acknowledged'),
459 'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
460 'where' => 'civicrm_pledge.acknowledge_date',
461 'table_name' => 'civicrm_pledge',
462 'entity' => 'Pledge',
463 'bao' => 'CRM_Pledge_BAO_Pledge',
466 'type' => 'Select Date',
470 'name' => 'modified_date',
471 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
472 'title' => ts('Pledge Modified Date'),
473 'description' => ts('Last updated date for this pledge record.'),
474 'where' => 'civicrm_pledge.modified_date',
475 'table_name' => 'civicrm_pledge',
476 'entity' => 'Pledge',
477 'bao' => 'CRM_Pledge_BAO_Pledge',
481 'name' => 'cancel_date',
482 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
483 'title' => ts('Pledge Cancelled Date'),
484 'description' => ts('Date this pledge was cancelled by contributor.'),
485 'where' => 'civicrm_pledge.cancel_date',
486 'table_name' => 'civicrm_pledge',
487 'entity' => 'Pledge',
488 'bao' => 'CRM_Pledge_BAO_Pledge',
491 'type' => 'Select Date',
495 'name' => 'end_date',
496 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
497 'title' => ts('Pledge End Date'),
498 'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
499 'where' => 'civicrm_pledge.end_date',
500 'table_name' => 'civicrm_pledge',
501 'entity' => 'Pledge',
502 'bao' => 'CRM_Pledge_BAO_Pledge',
505 'type' => 'Select Date',
509 'name' => 'max_reminders',
510 'type' => CRM_Utils_Type
::T_INT
,
511 'title' => ts('Maximum Number of Reminders'),
512 'description' => ts('The maximum number of payment reminders to send for any given payment.'),
513 'where' => 'civicrm_pledge.max_reminders',
515 'table_name' => 'civicrm_pledge',
516 'entity' => 'Pledge',
517 'bao' => 'CRM_Pledge_BAO_Pledge',
523 'initial_reminder_day' => [
524 'name' => 'initial_reminder_day',
525 'type' => CRM_Utils_Type
::T_INT
,
526 'title' => ts('Initial Reminder Day'),
527 'description' => ts('Send initial reminder this many days prior to the payment due date.'),
528 'where' => 'civicrm_pledge.initial_reminder_day',
530 'table_name' => 'civicrm_pledge',
531 'entity' => 'Pledge',
532 'bao' => 'CRM_Pledge_BAO_Pledge',
538 'additional_reminder_day' => [
539 'name' => 'additional_reminder_day',
540 'type' => CRM_Utils_Type
::T_INT
,
541 'title' => ts('Additional Reminder Days'),
542 'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
543 'where' => 'civicrm_pledge.additional_reminder_day',
545 'table_name' => 'civicrm_pledge',
546 'entity' => 'Pledge',
547 'bao' => 'CRM_Pledge_BAO_Pledge',
553 'pledge_status_id' => [
554 'name' => 'status_id',
555 'type' => CRM_Utils_Type
::T_INT
,
556 'title' => ts('Pledge Status Id'),
557 'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
559 'where' => 'civicrm_pledge.status_id',
561 'table_name' => 'civicrm_pledge',
562 'entity' => 'Pledge',
563 'bao' => 'CRM_Pledge_BAO_Pledge',
568 'pseudoconstant' => [
569 'optionGroupName' => 'pledge_status',
570 'optionEditPath' => 'civicrm/admin/options/pledge_status',
573 'pledge_is_test' => [
575 'type' => CRM_Utils_Type
::T_BOOLEAN
,
576 'title' => ts('Test'),
578 'where' => 'civicrm_pledge.is_test',
581 'table_name' => 'civicrm_pledge',
582 'entity' => 'Pledge',
583 'bao' => 'CRM_Pledge_BAO_Pledge',
586 'type' => 'CheckBox',
589 'pledge_campaign_id' => [
590 'name' => 'campaign_id',
591 'type' => CRM_Utils_Type
::T_INT
,
592 'title' => ts('Campaign'),
593 'description' => ts('The campaign for which this pledge has been initiated.'),
595 'where' => 'civicrm_pledge.campaign_id',
597 'table_name' => 'civicrm_pledge',
598 'entity' => 'Pledge',
599 'bao' => 'CRM_Pledge_BAO_Pledge',
601 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
605 'pseudoconstant' => [
606 'table' => 'civicrm_campaign',
608 'labelColumn' => 'title',
612 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
614 return Civi
::$statics[__CLASS__
]['fields'];
618 * Return a mapping from field-name to the corresponding key (as used in fields()).
621 * Array(string $name => string $uniqueName).
623 public static function &fieldKeys() {
624 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
625 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
627 return Civi
::$statics[__CLASS__
]['fieldKeys'];
631 * Returns the names of this table
635 public static function getTableName() {
636 return self
::$_tableName;
640 * Returns if this table needs to be logged
644 public function getLog() {
649 * Returns the list of fields that can be imported
651 * @param bool $prefix
655 public static function &import($prefix = FALSE) {
656 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'pledge', $prefix, []);
661 * Returns the list of fields that can be exported
663 * @param bool $prefix
667 public static function &export($prefix = FALSE) {
668 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'pledge', $prefix, []);
673 * Returns the list of indices
675 * @param bool $localize
679 public static function indices($localize = TRUE) {
682 'name' => 'index_status',
686 'localizable' => FALSE,
687 'sig' => 'civicrm_pledge::0::status_id',
690 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;