5 * @copyright CiviCRM LLC (c) 2004-2018
7 * Generated from xml/schema/CRM/Pledge/Pledge.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0e2129564a1877226e6dfce2840ce831)
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 static $_tableName = 'civicrm_pledge';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
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' => 'Pledge ID',
231 'where' => 'civicrm_pledge.id',
232 'headerPattern' => '',
235 'table_name' => 'civicrm_pledge',
236 'entity' => 'Pledge',
237 'bao' => 'CRM_Pledge_BAO_Pledge',
240 'pledge_contact_id' => [
241 'name' => 'contact_id',
242 'type' => CRM_Utils_Type
::T_INT
,
243 'title' => ts('Contact ID'),
244 'description' => 'Foreign key to civicrm_contact.id .',
247 'where' => 'civicrm_pledge.contact_id',
248 'headerPattern' => '',
251 'table_name' => 'civicrm_pledge',
252 'entity' => 'Pledge',
253 'bao' => 'CRM_Pledge_BAO_Pledge',
255 'FKClassName' => 'CRM_Contact_DAO_Contact',
257 'type' => 'EntityRef',
260 'pledge_financial_type_id' => [
261 'name' => 'financial_type_id',
262 'type' => CRM_Utils_Type
::T_INT
,
263 'title' => ts('Type'),
264 'description' => 'FK to Financial Type',
265 'table_name' => 'civicrm_pledge',
266 'entity' => 'Pledge',
267 'bao' => 'CRM_Pledge_BAO_Pledge',
269 'FKClassName' => 'CRM_Financial_DAO_FinancialType',
273 'pseudoconstant' => [
274 'table' => 'civicrm_financial_type',
276 'labelColumn' => 'name',
279 'pledge_contribution_page_id' => [
280 'name' => 'contribution_page_id',
281 'type' => CRM_Utils_Type
::T_INT
,
282 'title' => ts('Pledge Contribution Page'),
283 'description' => 'The Contribution Page which triggered this contribution',
284 'table_name' => 'civicrm_pledge',
285 'entity' => 'Pledge',
286 'bao' => 'CRM_Pledge_BAO_Pledge',
288 'FKClassName' => 'CRM_Contribute_DAO_ContributionPage',
292 'type' => CRM_Utils_Type
::T_MONEY
,
293 'title' => ts('Total Pledged'),
294 'description' => 'Total pledged amount.',
301 'where' => 'civicrm_pledge.amount',
302 'headerPattern' => '',
305 'table_name' => 'civicrm_pledge',
306 'entity' => 'Pledge',
307 'bao' => 'CRM_Pledge_BAO_Pledge',
313 'pledge_original_installment_amount' => [
314 'name' => 'original_installment_amount',
315 'type' => CRM_Utils_Type
::T_MONEY
,
316 'title' => ts('Original Installment Amount'),
317 'description' => 'Original amount for each of the installments.',
324 'where' => 'civicrm_pledge.original_installment_amount',
325 'headerPattern' => '',
327 'table_name' => 'civicrm_pledge',
328 'entity' => 'Pledge',
329 'bao' => 'CRM_Pledge_BAO_Pledge',
336 'name' => 'currency',
337 'type' => CRM_Utils_Type
::T_STRING
,
338 'title' => ts('Pledge Currency'),
339 'description' => '3 character string, value from config setting or input via user.',
341 'size' => CRM_Utils_Type
::FOUR
,
343 'table_name' => 'civicrm_pledge',
344 'entity' => 'Pledge',
345 'bao' => 'CRM_Pledge_BAO_Pledge',
350 'pseudoconstant' => [
351 'table' => 'civicrm_currency',
352 'keyColumn' => 'name',
353 'labelColumn' => 'full_name',
354 'nameColumn' => 'name',
357 'pledge_frequency_unit' => [
358 'name' => 'frequency_unit',
359 'type' => CRM_Utils_Type
::T_STRING
,
360 'title' => ts('Pledge Frequency Unit'),
361 'description' => 'Time units for recurrence of pledge payments.',
363 'size' => CRM_Utils_Type
::EIGHT
,
364 'default' => 'month',
365 'table_name' => 'civicrm_pledge',
366 'entity' => 'Pledge',
367 'bao' => 'CRM_Pledge_BAO_Pledge',
372 'pseudoconstant' => [
373 'optionGroupName' => 'recur_frequency_units',
374 'keyColumn' => 'name',
375 'optionEditPath' => 'civicrm/admin/options/recur_frequency_units',
378 'pledge_frequency_interval' => [
379 'name' => 'frequency_interval',
380 'type' => CRM_Utils_Type
::T_INT
,
381 'title' => ts('Pledge Frequency Interval'),
382 'description' => 'Number of time units for recurrence of pledge payments.',
385 'table_name' => 'civicrm_pledge',
386 'entity' => 'Pledge',
387 'bao' => 'CRM_Pledge_BAO_Pledge',
394 'name' => 'frequency_day',
395 'type' => CRM_Utils_Type
::T_INT
,
396 'title' => ts('Pledge day'),
397 'description' => '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.',
400 'table_name' => 'civicrm_pledge',
401 'entity' => 'Pledge',
402 'bao' => 'CRM_Pledge_BAO_Pledge',
409 'name' => 'installments',
410 'type' => CRM_Utils_Type
::T_INT
,
411 'title' => ts('Pledge Number of Installments'),
412 'description' => 'Total number of payments to be made.',
414 'where' => 'civicrm_pledge.installments',
415 'headerPattern' => '',
418 'table_name' => 'civicrm_pledge',
419 'entity' => 'Pledge',
420 'bao' => 'CRM_Pledge_BAO_Pledge',
427 'name' => 'start_date',
428 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
429 'title' => ts('Pledge Start Date'),
430 'description' => 'The date the first scheduled pledge occurs.',
432 'table_name' => 'civicrm_pledge',
433 'entity' => 'Pledge',
434 'bao' => 'CRM_Pledge_BAO_Pledge',
437 'type' => 'Select Date',
440 'pledge_create_date' => [
441 'name' => 'create_date',
442 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
443 'title' => ts('Pledge Made'),
444 'description' => 'When this pledge record was created.',
447 'where' => 'civicrm_pledge.create_date',
448 'headerPattern' => '',
451 'table_name' => 'civicrm_pledge',
452 'entity' => 'Pledge',
453 'bao' => 'CRM_Pledge_BAO_Pledge',
456 'type' => 'Select Date',
459 'acknowledge_date' => [
460 'name' => 'acknowledge_date',
461 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
462 'title' => ts('Pledge Acknowledged'),
463 'description' => 'When a pledge acknowledgement message was sent to the contributor.',
464 'table_name' => 'civicrm_pledge',
465 'entity' => 'Pledge',
466 'bao' => 'CRM_Pledge_BAO_Pledge',
469 'type' => 'Select Date',
473 'name' => 'modified_date',
474 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
475 'title' => ts('Pledge Modified Date'),
476 'description' => 'Last updated date for this pledge record.',
477 'table_name' => 'civicrm_pledge',
478 'entity' => 'Pledge',
479 'bao' => 'CRM_Pledge_BAO_Pledge',
483 'name' => 'cancel_date',
484 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
485 'title' => ts('Pledge Cancelled Date'),
486 'description' => 'Date this pledge was cancelled by contributor.',
487 'table_name' => 'civicrm_pledge',
488 'entity' => 'Pledge',
489 'bao' => 'CRM_Pledge_BAO_Pledge',
492 'type' => 'Select Date',
496 'name' => 'end_date',
497 'type' => CRM_Utils_Type
::T_DATE + CRM_Utils_Type
::T_TIME
,
498 'title' => ts('Pledge End Date'),
499 'description' => 'Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).',
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' => 'The maximum number of payment reminders to send for any given payment.',
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' => 'Send initial reminder this many days prior to the payment due date.',
528 'table_name' => 'civicrm_pledge',
529 'entity' => 'Pledge',
530 'bao' => 'CRM_Pledge_BAO_Pledge',
536 'additional_reminder_day' => [
537 'name' => 'additional_reminder_day',
538 'type' => CRM_Utils_Type
::T_INT
,
539 'title' => ts('Additional Reminder Days'),
540 'description' => 'Send additional reminder this many days after last one sent, up to maximum number of reminders.',
542 'table_name' => 'civicrm_pledge',
543 'entity' => 'Pledge',
544 'bao' => 'CRM_Pledge_BAO_Pledge',
550 'pledge_status_id' => [
551 'name' => 'status_id',
552 'type' => CRM_Utils_Type
::T_INT
,
553 'title' => ts('Pledge Status Id'),
554 'description' => 'Implicit foreign key to civicrm_option_values in the pledge_status option group.',
556 'where' => 'civicrm_pledge.status_id',
557 'headerPattern' => '',
560 'table_name' => 'civicrm_pledge',
561 'entity' => 'Pledge',
562 'bao' => 'CRM_Pledge_BAO_Pledge',
564 'pseudoconstant' => [
565 'optionGroupName' => 'pledge_status',
566 'optionEditPath' => 'civicrm/admin/options/pledge_status',
569 'pledge_is_test' => [
571 'type' => CRM_Utils_Type
::T_BOOLEAN
,
572 'title' => ts('Test'),
574 'where' => 'civicrm_pledge.is_test',
575 'headerPattern' => '',
578 'table_name' => 'civicrm_pledge',
579 'entity' => 'Pledge',
580 'bao' => 'CRM_Pledge_BAO_Pledge',
583 'type' => 'CheckBox',
586 'pledge_campaign_id' => [
587 'name' => 'campaign_id',
588 'type' => CRM_Utils_Type
::T_INT
,
589 'title' => ts('Campaign'),
590 'description' => 'The campaign for which this pledge has been initiated.',
592 'where' => 'civicrm_pledge.campaign_id',
593 'headerPattern' => '',
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;