3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
33 class CRM_Pledge_BAO_Query
{
37 public static function &getFields() {
38 $fields = CRM_Pledge_BAO_Pledge
::exportableFields();
43 * Build select for Pledge.
47 public static function select(&$query) {
48 $statusId = implode(',', array_keys(CRM_Core_PseudoConstant
::accountOptionValues("contribution_status", NULL, " AND v.name IN ('Pending', 'Overdue')")));
49 if (($query->_mode
& CRM_Contact_BAO_Query
::MODE_PLEDGE
) ||
!empty($query->_returnProperties
['pledge_id'])) {
50 $query->_select
['pledge_id'] = 'civicrm_pledge.id as pledge_id';
51 $query->_element
['pledge_id'] = 1;
52 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
56 if (!empty($query->_returnProperties
['pledge_amount'])) {
57 $query->_select
['pledge_amount'] = 'civicrm_pledge.amount as pledge_amount';
58 $query->_element
['pledge_amount'] = 1;
59 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
62 if (!empty($query->_returnProperties
['pledge_create_date'])) {
63 $query->_select
['pledge_create_date'] = 'civicrm_pledge.create_date as pledge_create_date';
64 $query->_element
['pledge_create_date'] = 1;
65 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
68 if (!empty($query->_returnProperties
['pledge_start_date'])) {
69 $query->_select
['pledge_start_date'] = 'civicrm_pledge.start_date as pledge_start_date';
70 $query->_element
['pledge_start_date'] = 1;
71 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
74 if (!empty($query->_returnProperties
['pledge_status_id'])) {
75 $query->_select
['pledge_status_id'] = 'pledge_status.value as pledge_status_id';
76 $query->_element
['pledge_status'] = 1;
77 $query->_tables
['pledge_status'] = $query->_whereTables
['pledge_status'] = 1;
78 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
81 if (!empty($query->_returnProperties
['pledge_status'])) {
82 $query->_select
['pledge_status'] = 'pledge_status.label as pledge_status';
83 $query->_element
['pledge_status'] = 1;
84 $query->_tables
['pledge_status'] = $query->_whereTables
['pledge_status'] = 1;
85 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
88 if (!empty($query->_returnProperties
['pledge_total_paid'])) {
89 $query->_select
['pledge_total_paid'] = ' (SELECT sum(civicrm_pledge_payment.actual_amount) FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id = 1 ) as pledge_total_paid';
90 $query->_element
['pledge_total_paid'] = 1;
93 if (!empty($query->_returnProperties
['pledge_next_pay_date'])) {
94 $query->_select
['pledge_next_pay_date'] = " (SELECT civicrm_pledge_payment.scheduled_date FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id IN ({$statusId}) ORDER BY civicrm_pledge_payment.scheduled_date ASC LIMIT 0, 1) as pledge_next_pay_date";
95 $query->_element
['pledge_next_pay_date'] = 1;
98 if (!empty($query->_returnProperties
['pledge_next_pay_amount'])) {
99 $query->_select
['pledge_next_pay_amount'] = " (SELECT civicrm_pledge_payment.scheduled_amount FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id IN ({$statusId}) ORDER BY civicrm_pledge_payment.scheduled_date ASC LIMIT 0, 1) as pledge_next_pay_amount";
100 $query->_element
['pledge_next_pay_amount'] = 1;
102 $query->_select
['pledge_outstanding_amount'] = " (SELECT sum(civicrm_pledge_payment.scheduled_amount) FROM civicrm_pledge_payment WHERE civicrm_pledge_payment.pledge_id = civicrm_pledge.id AND civicrm_pledge_payment.status_id = 6 ) as pledge_outstanding_amount";
103 $query->_element
['pledge_outstanding_amount'] = 1;
106 if (!empty($query->_returnProperties
['pledge_financial_type'])) {
107 $query->_select
['pledge_financial_type'] = "(SELECT civicrm_financial_type.name FROM civicrm_financial_type WHERE civicrm_financial_type.id = civicrm_pledge.financial_type_id) as pledge_financial_type";
108 $query->_element
['pledge_financial_type'] = 1;
109 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
112 if (!empty($query->_returnProperties
['pledge_contribution_page_id'])) {
113 $query->_select
['pledge_contribution_page_id'] = 'civicrm_pledge.contribution_page_id as pledge_contribution_page_id';
114 $query->_element
['pledge_contribution_page_id'] = 1;
115 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
118 if (!empty($query->_returnProperties
['pledge_payment_id'])) {
119 $query->_select
['pledge_payment_id'] = 'civicrm_pledge_payment.id as pledge_payment_id';
120 $query->_element
['pledge_payment_id'] = 1;
121 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
124 if (!empty($query->_returnProperties
['pledge_payment_scheduled_amount'])) {
125 $query->_select
['pledge_payment_scheduled_amount'] = 'civicrm_pledge_payment.scheduled_amount as pledge_payment_scheduled_amount';
126 $query->_element
['pledge_payment_scheduled_amount'] = 1;
127 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
130 if (!empty($query->_returnProperties
['pledge_payment_scheduled_date'])) {
131 $query->_select
['pledge_payment_scheduled_date'] = 'civicrm_pledge_payment.scheduled_date as pledge_payment_scheduled_date';
132 $query->_element
['pledge_payment_scheduled_date'] = 1;
133 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
136 if (!empty($query->_returnProperties
['pledge_payment_paid_amount'])) {
137 $query->_select
['pledge_payment_paid_amount'] = 'civicrm_pledge_payment.actual_amount as pledge_payment_paid_amount';
138 $query->_element
['pledge_payment_paid_amount'] = 1;
139 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
142 if (!empty($query->_returnProperties
['pledge_payment_paid_date'])) {
143 $query->_select
['pledge_payment_paid_date'] = 'payment_contribution.receive_date as pledge_payment_paid_date';
144 $query->_element
['pledge_payment_paid_date'] = 1;
145 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
146 $query->_tables
['payment_contribution'] = $query->_whereTables
['payment_contribution'] = 1;
149 if (!empty($query->_returnProperties
['pledge_payment_reminder_date'])) {
150 $query->_select
['pledge_payment_reminder_date'] = 'civicrm_pledge_payment.reminder_date as pledge_payment_reminder_date';
151 $query->_element
['pledge_payment_reminder_date'] = 1;
152 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
155 if (!empty($query->_returnProperties
['pledge_payment_reminder_count'])) {
156 $query->_select
['pledge_payment_reminder_count'] = 'civicrm_pledge_payment.reminder_count as pledge_payment_reminder_count';
157 $query->_element
['pledge_payment_reminder_count'] = 1;
158 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
161 if (!empty($query->_returnProperties
['pledge_payment_status_id'])) {
162 $query->_select
['pledge_payment_status_id'] = 'payment_status.name as pledge_payment_status_id';
163 $query->_element
['pledge_payment_status_id'] = 1;
164 $query->_tables
['payment_status'] = $query->_whereTables
['payment_status'] = 1;
165 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
168 if (!empty($query->_returnProperties
['pledge_payment_status'])) {
169 $query->_select
['pledge_payment_status'] = 'payment_status.label as pledge_payment_status';
170 $query->_element
['pledge_payment_status'] = 1;
171 $query->_tables
['payment_status'] = $query->_whereTables
['payment_status'] = 1;
172 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
175 if (!empty($query->_returnProperties
['pledge_frequency_interval'])) {
176 $query->_select
['pledge_frequency_interval'] = 'civicrm_pledge.frequency_interval as pledge_frequency_interval';
177 $query->_element
['pledge_frequency_interval'] = 1;
178 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
181 if (!empty($query->_returnProperties
['pledge_frequency_unit'])) {
182 $query->_select
['pledge_frequency_unit'] = 'civicrm_pledge.frequency_unit as pledge_frequency_unit';
183 $query->_element
['pledge_frequency_unit'] = 1;
184 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
187 if (!empty($query->_returnProperties
['pledge_is_test'])) {
188 $query->_select
['pledge_is_test'] = 'civicrm_pledge.is_test as pledge_is_test';
189 $query->_element
['pledge_is_test'] = 1;
190 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
192 if (!empty($query->_returnProperties
['pledge_campaign_id'])) {
193 $query->_select
['pledge_campaign_id'] = 'civicrm_pledge.campaign_id as pledge_campaign_id';
194 $query->_element
['pledge_campaign_id'] = 1;
195 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
198 if (!empty($query->_returnProperties
['pledge_currency'])) {
199 $query->_select
['pledge_currency'] = 'civicrm_pledge.currency as pledge_currency';
200 $query->_element
['pledge_currency'] = 1;
201 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
208 public static function where(&$query) {
210 foreach (array_keys($query->_params
) as $id) {
211 if (empty($query->_params
[$id][0])) {
214 if (substr($query->_params
[$id][0], 0, 7) == 'pledge_') {
215 if ($query->_mode
== CRM_Contact_BAO_QUERY
::MODE_CONTACTS
) {
216 $query->_useDistinct
= TRUE;
218 $grouping = $query->_params
[$id][3];
219 self
::whereClauseSingle($query->_params
[$id], $query);
228 public static function whereClauseSingle(&$values, &$query) {
229 list($name, $op, $value, $grouping, $wildcard) = $values;
232 case 'pledge_create_date_low':
233 case 'pledge_create_date_high':
234 // process to / from date
235 $query->dateQueryBuilder($values,
236 'civicrm_pledge', 'pledge_create_date', 'create_date', 'Pledge Made'
238 case 'pledge_start_date_low':
239 case 'pledge_start_date_high':
240 // process to / from date
241 $query->dateQueryBuilder($values,
242 'civicrm_pledge', 'pledge_start_date', 'start_date', 'Pledge Start Date'
246 case 'pledge_end_date_low':
247 case 'pledge_end_date_high':
248 // process to / from date
249 $query->dateQueryBuilder($values,
250 'civicrm_pledge', 'pledge_end_date', 'end_date', 'Pledge End Date'
254 case 'pledge_payment_date_low':
255 case 'pledge_payment_date_high':
256 // process to / from date
257 $query->dateQueryBuilder($values,
258 'civicrm_pledge_payment', 'pledge_payment_date', 'scheduled_date', 'Payment Scheduled'
262 case 'pledge_amount':
263 case 'pledge_amount_low':
264 case 'pledge_amount_high':
265 // process min/max amount
266 $query->numberRangeBuilder($values,
267 'civicrm_pledge', 'pledge_amount', 'amount', 'Pledge Amount'
271 case 'pledge_payment_status_id':
272 case 'pledge_status_id':
273 if ($name == 'pledge_status_id') {
274 $tableName = 'civicrm_pledge';
275 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
276 $label = "Pledge Status";
279 $tableName = 'civicrm_pledge_payment';
280 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
281 $label = "Pledge Payment Status";
284 if (!empty($value) && is_array($value) && !in_array(key($value), CRM_Core_DAO
::acceptedSQLOperators(), TRUE)) {
285 $value = array('IN' => $value);
288 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("$tableName.$name",
293 list($qillop, $qillVal) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', 'contribution_status_id', $value, $op);
294 $query->_qill
[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $qillop, 3 => $qillVal));
298 case 'pledge_is_test':
299 // We dont want to include all tests for sql OR CRM-7827
300 if (!$value ||
$query->getOperator() != 'OR') {
301 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause('civicrm_pledge.is_test',
307 $query->_qill
[$grouping][] = ts('Pledge is a Test');
309 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
313 case 'pledge_financial_type_id':
314 $type = CRM_Contribute_PseudoConstant
::financialType($value);
315 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause('civicrm_pledge.financial_type_id',
320 $query->_qill
[$grouping][] = ts('Financial Type - %1', array(1 => $type));
321 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
324 case 'pledge_contribution_page_id':
325 $page = CRM_Contribute_PseudoConstant
::contributionPage($value);
326 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause('civicrm_pledge.contribution_page_id',
331 $query->_qill
[$grouping][] = ts('Financial Page - %1', array(1 => $page));
332 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
336 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("civicrm_pledge.id",
341 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
344 case 'pledge_frequency_interval':
345 $query->_where
[$grouping][] = "civicrm_pledge.frequency_interval $op $value";
346 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
349 case 'pledge_frequency_unit':
350 $query->_where
[$grouping][] = "civicrm_pledge.frequency_unit $op $value";
351 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
354 case 'pledge_contact_id':
355 case 'pledge_campaign_id':
356 $name = str_replace('pledge_', '', $name);
357 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("civicrm_pledge.$name", $op, $value, 'Integer');
358 list($op, $value) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Pledge_DAO_Pledge', $name, $value, $op);
359 $label = ($name == 'campaign_id') ?
'Campaign' : 'Contact ID';
360 $query->_qill
[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $op, 3 => $value));
361 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
369 * @param string $name
370 * @param string $mode
371 * @param string $side
373 * @return null|string
375 public static function from($name, $mode, $side) {
379 case 'civicrm_pledge':
380 $from = " $side JOIN civicrm_pledge ON civicrm_pledge.contact_id = contact_a.id ";
383 case 'pledge_status':
384 $from .= " $side JOIN civicrm_option_group option_group_pledge_status ON (option_group_pledge_status.name = 'contribution_status')";
385 $from .= " $side JOIN civicrm_option_value pledge_status ON (civicrm_pledge.status_id = pledge_status.value AND option_group_pledge_status.id = pledge_status.option_group_id ) ";
388 case 'pledge_financial_type':
389 $from .= " $side JOIN civicrm_financial_type ON civicrm_pledge.financial_type_id = civicrm_financial_type.id ";
392 case 'civicrm_pledge_payment':
393 $from .= " $side JOIN civicrm_pledge_payment ON civicrm_pledge_payment.pledge_id = civicrm_pledge.id ";
396 case 'payment_contribution':
397 $from .= " $side JOIN civicrm_contribution payment_contribution ON civicrm_pledge_payment.contribution_id = payment_contribution.id ";
400 case 'payment_status':
401 $from .= " $side JOIN civicrm_option_group option_group_payment_status ON (option_group_payment_status.name = 'contribution_status')";
402 $from .= " $side JOIN civicrm_option_value payment_status ON (civicrm_pledge_payment.status_id = payment_status.value AND option_group_payment_status.id = payment_status.option_group_id ) ";
410 * Getter for the qill object.
414 public function qill() {
415 return (isset($this->_qill
)) ?
$this->_qill
: "";
419 * Ideally this function should include fields that are displayed in the selector.
422 * @param bool $includeCustomFields
426 public static function defaultReturnProperties(
428 $includeCustomFields = TRUE
432 if ($mode & CRM_Contact_BAO_Query
::MODE_PLEDGE
) {
435 'contact_sub_type' => 1,
439 'pledge_amount' => 1,
440 'pledge_total_paid' => 1,
441 'pledge_create_date' => 1,
442 'pledge_start_date' => 1,
443 'pledge_next_pay_date' => 1,
444 'pledge_next_pay_amount' => 1,
445 'pledge_status' => 1,
446 'pledge_status_id' => 1,
447 'pledge_is_test' => 1,
448 'pledge_contribution_page_id' => 1,
449 'pledge_financial_type' => 1,
450 'pledge_frequency_interval' => 1,
451 'pledge_frequency_unit' => 1,
452 'pledge_currency' => 1,
453 'pledge_campaign_id' => 1,
460 * This includes any extra fields that might need for export etc.
462 * @param string $mode
466 public static function extraReturnProperties($mode) {
469 if ($mode & CRM_Contact_BAO_Query
::MODE_PLEDGE
) {
471 'pledge_balance_amount' => 1,
472 'pledge_payment_id' => 1,
473 'pledge_payment_scheduled_amount' => 1,
474 'pledge_payment_scheduled_date' => 1,
475 'pledge_payment_paid_amount' => 1,
476 'pledge_payment_paid_date' => 1,
477 'pledge_payment_reminder_date' => 1,
478 'pledge_payment_reminder_count' => 1,
479 'pledge_payment_status_id' => 1,
480 'pledge_payment_status' => 1,
483 // also get all the custom pledge properties
484 $fields = CRM_Core_BAO_CustomField
::getFieldsForImport('Pledge');
485 if (!empty($fields)) {
486 foreach ($fields as $name => $dontCare) {
487 $properties[$name] = 1;
495 * @param CRM_Core_Form $form
497 public static function buildSearchForm(&$form) {
498 // pledge related dates
499 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_start_date', 1, '_low', '_high', ts('From'), FALSE);
500 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_end_date', 1, '_low', '_high', ts('From'), FALSE);
501 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_create_date', 1, '_low', '_high', ts('From'), FALSE);
503 // pledge payment related dates
504 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_payment_date', 1, '_low', '_high', ts('From'), FALSE);
506 $form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE);
507 $form->add('text', 'pledge_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
508 $form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money
::format('9.99', ' '))), 'money');
510 $form->add('text', 'pledge_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
511 $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money
::format('99.99', ' '))), 'money');
513 $statusValues = CRM_Contribute_PseudoConstant
::contributionStatus();
515 // Remove status values that are only used for recurring contributions for now (Failed and In Progress).
516 unset($statusValues['4']);
518 $form->add('select', 'pledge_status_id',
519 ts('Pledge Status'), $statusValues,
520 FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
523 // unset in progress for payment
524 unset($statusValues['5']);
526 $form->add('select', 'pledge_payment_status_id',
527 ts('Pledge Payment Status'), $statusValues,
528 FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
531 $form->add('select', 'pledge_financial_type_id',
532 ts('Financial Type'),
533 array('' => ts('- select -')) + CRM_Contribute_PseudoConstant
::financialType(),
534 FALSE, array('class' => 'crm-select2')
537 $form->add('select', 'pledge_contribution_page_id',
538 ts('Contribution Page'),
539 array('' => ts('- any -')) + CRM_Contribute_PseudoConstant
::contributionPage(),
540 FALSE, array('class' => 'crm-select2')
543 // add fields for pledge frequency
544 $form->add('text', 'pledge_frequency_interval', ts('Every'), array('size' => 8, 'maxlength' => 8));
545 $form->addRule('pledge_frequency_interval', ts('Please enter valid Pledge Frequency Interval'), 'integer');
546 $frequencies = CRM_Core_OptionGroup
::values('recur_frequency_units');
547 foreach ($frequencies as $val => $label) {
548 $freqUnitsDisplay["'{$val}'"] = ts('%1(s)', array(1 => $label));
551 $form->add('select', 'pledge_frequency_unit',
552 ts('Pledge Frequency'),
553 array('' => ts('- any -')) +
$freqUnitsDisplay
556 // add all the custom searchable fields
557 $pledge = array('Pledge');
558 $groupDetails = CRM_Core_BAO_CustomGroup
::getGroupDetail(NULL, TRUE, $pledge);
560 $form->assign('pledgeGroupTree', $groupDetails);
561 foreach ($groupDetails as $group) {
562 foreach ($group['fields'] as $field) {
563 $fieldId = $field['id'];
564 $elementName = 'custom_' . $fieldId;
565 CRM_Core_BAO_CustomField
::addQuickFormElement($form,
574 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($form, 'pledge_campaign_id');
576 $form->assign('validCiviPledge', TRUE);
577 $form->setDefaults(array('pledge_test' => 0));
584 public static function searchAction(&$row, $id) {
590 public static function tableNames(&$tables) {
592 if (!empty($tables['pledge_status']) ||
!empty($tables['civicrm_pledge_payment'])) {
593 $tables = array_merge(array('civicrm_pledge' => 1), $tables);