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 * @param bool $checkPermission
41 public static function &getFields($checkPermission = TRUE) {
42 $fields = CRM_Pledge_BAO_Pledge
::exportableFields($checkPermission);
47 * Build select for Pledge.
51 public static function select(&$query) {
52 $statusId = implode(',', array_keys(CRM_Core_PseudoConstant
::accountOptionValues("contribution_status", NULL, " AND v.name IN ('Pending', 'Overdue')")));
53 if (($query->_mode
& CRM_Contact_BAO_Query
::MODE_PLEDGE
) ||
!empty($query->_returnProperties
['pledge_id'])) {
54 $query->_select
['pledge_id'] = 'civicrm_pledge.id as pledge_id';
55 $query->_element
['pledge_id'] = 1;
56 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
60 if (!empty($query->_returnProperties
['pledge_amount'])) {
61 $query->_select
['pledge_amount'] = 'civicrm_pledge.amount as pledge_amount';
62 $query->_element
['pledge_amount'] = 1;
63 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
66 if (!empty($query->_returnProperties
['pledge_create_date'])) {
67 $query->_select
['pledge_create_date'] = 'civicrm_pledge.create_date as pledge_create_date';
68 $query->_element
['pledge_create_date'] = 1;
69 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
72 if (!empty($query->_returnProperties
['pledge_start_date'])) {
73 $query->_select
['pledge_start_date'] = 'civicrm_pledge.start_date as pledge_start_date';
74 $query->_element
['pledge_start_date'] = 1;
75 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
78 if (!empty($query->_returnProperties
['pledge_status_id'])) {
79 $query->_select
['pledge_status_id'] = 'pledge_status.value as pledge_status_id';
80 $query->_element
['pledge_status'] = 1;
81 $query->_tables
['pledge_status'] = $query->_whereTables
['pledge_status'] = 1;
82 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
85 if (!empty($query->_returnProperties
['pledge_status'])) {
86 $query->_select
['pledge_status'] = 'pledge_status.label as pledge_status';
87 $query->_element
['pledge_status'] = 1;
88 $query->_tables
['pledge_status'] = $query->_whereTables
['pledge_status'] = 1;
89 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
92 if (!empty($query->_returnProperties
['pledge_total_paid'])) {
93 $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';
94 $query->_element
['pledge_total_paid'] = 1;
97 if (!empty($query->_returnProperties
['pledge_next_pay_date'])) {
98 $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";
99 $query->_element
['pledge_next_pay_date'] = 1;
102 if (!empty($query->_returnProperties
['pledge_next_pay_amount'])) {
103 $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";
104 $query->_element
['pledge_next_pay_amount'] = 1;
106 $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";
107 $query->_element
['pledge_outstanding_amount'] = 1;
110 if (!empty($query->_returnProperties
['pledge_financial_type'])) {
111 $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";
112 $query->_element
['pledge_financial_type'] = 1;
113 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
116 if (!empty($query->_returnProperties
['pledge_contribution_page_id'])) {
117 $query->_select
['pledge_contribution_page_id'] = 'civicrm_pledge.contribution_page_id as pledge_contribution_page_id';
118 $query->_element
['pledge_contribution_page_id'] = 1;
119 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
122 if (!empty($query->_returnProperties
['pledge_payment_id'])) {
123 $query->_select
['pledge_payment_id'] = 'civicrm_pledge_payment.id as pledge_payment_id';
124 $query->_element
['pledge_payment_id'] = 1;
125 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
128 if (!empty($query->_returnProperties
['pledge_payment_scheduled_amount'])) {
129 $query->_select
['pledge_payment_scheduled_amount'] = 'civicrm_pledge_payment.scheduled_amount as pledge_payment_scheduled_amount';
130 $query->_element
['pledge_payment_scheduled_amount'] = 1;
131 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
134 if (!empty($query->_returnProperties
['pledge_payment_scheduled_date'])) {
135 $query->_select
['pledge_payment_scheduled_date'] = 'civicrm_pledge_payment.scheduled_date as pledge_payment_scheduled_date';
136 $query->_element
['pledge_payment_scheduled_date'] = 1;
137 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
140 if (!empty($query->_returnProperties
['pledge_payment_paid_amount'])) {
141 $query->_select
['pledge_payment_paid_amount'] = 'civicrm_pledge_payment.actual_amount as pledge_payment_paid_amount';
142 $query->_element
['pledge_payment_paid_amount'] = 1;
143 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
146 if (!empty($query->_returnProperties
['pledge_payment_paid_date'])) {
147 $query->_select
['pledge_payment_paid_date'] = 'payment_contribution.receive_date as pledge_payment_paid_date';
148 $query->_element
['pledge_payment_paid_date'] = 1;
149 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
150 $query->_tables
['payment_contribution'] = $query->_whereTables
['payment_contribution'] = 1;
153 if (!empty($query->_returnProperties
['pledge_payment_reminder_date'])) {
154 $query->_select
['pledge_payment_reminder_date'] = 'civicrm_pledge_payment.reminder_date as pledge_payment_reminder_date';
155 $query->_element
['pledge_payment_reminder_date'] = 1;
156 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
159 if (!empty($query->_returnProperties
['pledge_payment_reminder_count'])) {
160 $query->_select
['pledge_payment_reminder_count'] = 'civicrm_pledge_payment.reminder_count as pledge_payment_reminder_count';
161 $query->_element
['pledge_payment_reminder_count'] = 1;
162 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
165 if (!empty($query->_returnProperties
['pledge_payment_status_id'])) {
166 $query->_select
['pledge_payment_status_id'] = 'payment_status.name as pledge_payment_status_id';
167 $query->_element
['pledge_payment_status_id'] = 1;
168 $query->_tables
['payment_status'] = $query->_whereTables
['payment_status'] = 1;
169 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
172 if (!empty($query->_returnProperties
['pledge_payment_status'])) {
173 $query->_select
['pledge_payment_status'] = 'payment_status.label as pledge_payment_status';
174 $query->_element
['pledge_payment_status'] = 1;
175 $query->_tables
['payment_status'] = $query->_whereTables
['payment_status'] = 1;
176 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
179 if (!empty($query->_returnProperties
['pledge_frequency_interval'])) {
180 $query->_select
['pledge_frequency_interval'] = 'civicrm_pledge.frequency_interval as pledge_frequency_interval';
181 $query->_element
['pledge_frequency_interval'] = 1;
182 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
185 if (!empty($query->_returnProperties
['pledge_frequency_unit'])) {
186 $query->_select
['pledge_frequency_unit'] = 'civicrm_pledge.frequency_unit as pledge_frequency_unit';
187 $query->_element
['pledge_frequency_unit'] = 1;
188 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
191 if (!empty($query->_returnProperties
['pledge_is_test'])) {
192 $query->_select
['pledge_is_test'] = 'civicrm_pledge.is_test as pledge_is_test';
193 $query->_element
['pledge_is_test'] = 1;
194 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
196 if (!empty($query->_returnProperties
['pledge_campaign_id'])) {
197 $query->_select
['pledge_campaign_id'] = 'civicrm_pledge.campaign_id as pledge_campaign_id';
198 $query->_element
['pledge_campaign_id'] = 1;
199 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
202 if (!empty($query->_returnProperties
['pledge_currency'])) {
203 $query->_select
['pledge_currency'] = 'civicrm_pledge.currency as pledge_currency';
204 $query->_element
['pledge_currency'] = 1;
205 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
212 public static function where(&$query) {
214 foreach (array_keys($query->_params
) as $id) {
215 if (empty($query->_params
[$id][0])) {
218 if (substr($query->_params
[$id][0], 0, 7) == 'pledge_') {
219 if ($query->_mode
== CRM_Contact_BAO_QUERY
::MODE_CONTACTS
) {
220 $query->_useDistinct
= TRUE;
222 $grouping = $query->_params
[$id][3];
223 self
::whereClauseSingle($query->_params
[$id], $query);
232 public static function whereClauseSingle(&$values, &$query) {
233 list($name, $op, $value, $grouping, $wildcard) = $values;
236 case 'pledge_create_date_low':
237 case 'pledge_create_date_high':
238 // process to / from date
239 $query->dateQueryBuilder($values,
240 'civicrm_pledge', 'pledge_create_date', 'create_date', 'Pledge Made'
242 case 'pledge_start_date_low':
243 case 'pledge_start_date_high':
244 // process to / from date
245 $query->dateQueryBuilder($values,
246 'civicrm_pledge', 'pledge_start_date', 'start_date', 'Pledge Start Date'
250 case 'pledge_end_date_low':
251 case 'pledge_end_date_high':
252 // process to / from date
253 $query->dateQueryBuilder($values,
254 'civicrm_pledge', 'pledge_end_date', 'end_date', 'Pledge End Date'
258 case 'pledge_payment_date_low':
259 case 'pledge_payment_date_high':
260 // process to / from date
261 $query->dateQueryBuilder($values,
262 'civicrm_pledge_payment', 'pledge_payment_date', 'scheduled_date', 'Payment Scheduled'
266 case 'pledge_amount':
267 case 'pledge_amount_low':
268 case 'pledge_amount_high':
269 // process min/max amount
270 $query->numberRangeBuilder($values,
271 'civicrm_pledge', 'pledge_amount', 'amount', 'Pledge Amount'
275 case 'pledge_payment_status_id':
276 case 'pledge_status_id':
277 if ($name == 'pledge_status_id') {
278 $tableName = 'civicrm_pledge';
279 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
280 $label = "Pledge Status";
283 $tableName = 'civicrm_pledge_payment';
284 $query->_tables
['civicrm_pledge_payment'] = $query->_whereTables
['civicrm_pledge_payment'] = 1;
285 $label = "Pledge Payment Status";
288 if (!empty($value) && is_array($value) && !in_array(key($value), CRM_Core_DAO
::acceptedSQLOperators(), TRUE)) {
289 $value = array('IN' => $value);
292 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("$tableName.$name",
297 list($qillop, $qillVal) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', 'contribution_status_id', $value, $op);
298 $query->_qill
[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $qillop, 3 => $qillVal));
302 case 'pledge_is_test':
303 // We dont want to include all tests for sql OR CRM-7827
304 if (!$value ||
$query->getOperator() != 'OR') {
305 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause('civicrm_pledge.is_test',
311 $query->_qill
[$grouping][] = ts('Pledge is a Test');
313 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
317 case 'pledge_financial_type_id':
318 $type = CRM_Contribute_PseudoConstant
::financialType($value);
319 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause('civicrm_pledge.financial_type_id',
324 $query->_qill
[$grouping][] = ts('Financial Type - %1', array(1 => $type));
325 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
328 case 'pledge_contribution_page_id':
329 $page = CRM_Contribute_PseudoConstant
::contributionPage($value);
330 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause('civicrm_pledge.contribution_page_id',
335 $query->_qill
[$grouping][] = ts('Financial Page - %1', array(1 => $page));
336 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
340 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("civicrm_pledge.id",
345 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
348 case 'pledge_frequency_interval':
349 $query->_where
[$grouping][] = "civicrm_pledge.frequency_interval $op $value";
350 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
353 case 'pledge_frequency_unit':
354 $query->_where
[$grouping][] = "civicrm_pledge.frequency_unit $op $value";
355 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
358 case 'pledge_contact_id':
359 case 'pledge_campaign_id':
360 $name = str_replace('pledge_', '', $name);
361 $query->_where
[$grouping][] = CRM_Contact_BAO_Query
::buildClause("civicrm_pledge.$name", $op, $value, 'Integer');
362 list($op, $value) = CRM_Contact_BAO_Query
::buildQillForFieldValue('CRM_Pledge_DAO_Pledge', $name, $value, $op);
363 $label = ($name == 'campaign_id') ?
'Campaign' : 'Contact ID';
364 $query->_qill
[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $op, 3 => $value));
365 $query->_tables
['civicrm_pledge'] = $query->_whereTables
['civicrm_pledge'] = 1;
373 * @param string $name
374 * @param string $mode
375 * @param string $side
377 * @return null|string
379 public static function from($name, $mode, $side) {
383 case 'civicrm_pledge':
384 $from = " $side JOIN civicrm_pledge ON civicrm_pledge.contact_id = contact_a.id ";
387 case 'pledge_status':
388 $from .= " $side JOIN civicrm_option_group option_group_pledge_status ON (option_group_pledge_status.name = 'contribution_status')";
389 $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 ) ";
392 case 'pledge_financial_type':
393 $from .= " $side JOIN civicrm_financial_type ON civicrm_pledge.financial_type_id = civicrm_financial_type.id ";
396 case 'civicrm_pledge_payment':
397 $from .= " $side JOIN civicrm_pledge_payment ON civicrm_pledge_payment.pledge_id = civicrm_pledge.id ";
400 case 'payment_contribution':
401 $from .= " $side JOIN civicrm_contribution payment_contribution ON civicrm_pledge_payment.contribution_id = payment_contribution.id ";
404 case 'payment_status':
405 $from .= " $side JOIN civicrm_option_group option_group_payment_status ON (option_group_payment_status.name = 'contribution_status')";
406 $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 ) ";
414 * Getter for the qill object.
418 public function qill() {
419 return (isset($this->_qill
)) ?
$this->_qill
: "";
423 * Ideally this function should include fields that are displayed in the selector.
426 * @param bool $includeCustomFields
430 public static function defaultReturnProperties(
432 $includeCustomFields = TRUE
436 if ($mode & CRM_Contact_BAO_Query
::MODE_PLEDGE
) {
439 'contact_sub_type' => 1,
443 'pledge_amount' => 1,
444 'pledge_total_paid' => 1,
445 'pledge_create_date' => 1,
446 'pledge_start_date' => 1,
447 'pledge_next_pay_date' => 1,
448 'pledge_next_pay_amount' => 1,
449 'pledge_status' => 1,
450 'pledge_status_id' => 1,
451 'pledge_is_test' => 1,
452 'pledge_contribution_page_id' => 1,
453 'pledge_financial_type' => 1,
454 'pledge_frequency_interval' => 1,
455 'pledge_frequency_unit' => 1,
456 'pledge_currency' => 1,
457 'pledge_campaign_id' => 1,
464 * This includes any extra fields that might need for export etc.
466 * @param string $mode
470 public static function extraReturnProperties($mode) {
473 if ($mode & CRM_Contact_BAO_Query
::MODE_PLEDGE
) {
475 'pledge_balance_amount' => 1,
476 'pledge_payment_id' => 1,
477 'pledge_payment_scheduled_amount' => 1,
478 'pledge_payment_scheduled_date' => 1,
479 'pledge_payment_paid_amount' => 1,
480 'pledge_payment_paid_date' => 1,
481 'pledge_payment_reminder_date' => 1,
482 'pledge_payment_reminder_count' => 1,
483 'pledge_payment_status_id' => 1,
484 'pledge_payment_status' => 1,
487 // also get all the custom pledge properties
488 $fields = CRM_Core_BAO_CustomField
::getFieldsForImport('Pledge');
489 if (!empty($fields)) {
490 foreach ($fields as $name => $dontCare) {
491 $properties[$name] = 1;
499 * @param CRM_Core_Form $form
501 public static function buildSearchForm(&$form) {
502 // pledge related dates
503 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_start_date', 1, '_low', '_high', ts('From'), FALSE);
504 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_end_date', 1, '_low', '_high', ts('From'), FALSE);
505 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_create_date', 1, '_low', '_high', ts('From'), FALSE);
507 // pledge payment related dates
508 CRM_Core_Form_Date
::buildDateRange($form, 'pledge_payment_date', 1, '_low', '_high', ts('From'), FALSE);
510 $form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE);
511 $form->add('text', 'pledge_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8));
512 $form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money
::format('9.99', ' '))), 'money');
514 $form->add('text', 'pledge_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8));
515 $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money
::format('99.99', ' '))), 'money');
517 $statusValues = CRM_Contribute_PseudoConstant
::contributionStatus();
519 // Remove status values that are only used for recurring contributions for now (Failed and In Progress).
520 unset($statusValues['4']);
522 $form->add('select', 'pledge_status_id',
523 ts('Pledge Status'), $statusValues,
524 FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
527 // unset in progress for payment
528 unset($statusValues['5']);
530 $form->add('select', 'pledge_payment_status_id',
531 ts('Pledge Payment Status'), $statusValues,
532 FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple')
535 $form->add('select', 'pledge_financial_type_id',
536 ts('Financial Type'),
537 array('' => ts('- select -')) + CRM_Contribute_PseudoConstant
::financialType(),
538 FALSE, array('class' => 'crm-select2')
541 $form->add('select', 'pledge_contribution_page_id',
542 ts('Contribution Page'),
543 array('' => ts('- any -')) + CRM_Contribute_PseudoConstant
::contributionPage(),
544 FALSE, array('class' => 'crm-select2')
547 // add fields for pledge frequency
548 $form->add('text', 'pledge_frequency_interval', ts('Every'), array('size' => 8, 'maxlength' => 8));
549 $form->addRule('pledge_frequency_interval', ts('Please enter valid Pledge Frequency Interval'), 'integer');
550 $frequencies = CRM_Core_OptionGroup
::values('recur_frequency_units');
551 foreach ($frequencies as $val => $label) {
552 $freqUnitsDisplay["'{$val}'"] = ts('%1(s)', array(1 => $label));
555 $form->add('select', 'pledge_frequency_unit',
556 ts('Pledge Frequency'),
557 array('' => ts('- any -')) +
$freqUnitsDisplay
560 // add all the custom searchable fields
561 $pledge = array('Pledge');
562 $groupDetails = CRM_Core_BAO_CustomGroup
::getGroupDetail(NULL, TRUE, $pledge);
564 $form->assign('pledgeGroupTree', $groupDetails);
565 foreach ($groupDetails as $group) {
566 foreach ($group['fields'] as $field) {
567 $fieldId = $field['id'];
568 $elementName = 'custom_' . $fieldId;
569 CRM_Core_BAO_CustomField
::addQuickFormElement($form,
578 CRM_Campaign_BAO_Campaign
::addCampaignInComponentSearch($form, 'pledge_campaign_id');
580 $form->assign('validCiviPledge', TRUE);
581 $form->setDefaults(array('pledge_test' => 0));
588 public static function searchAction(&$row, $id) {
594 public static function tableNames(&$tables) {
596 if (!empty($tables['pledge_status']) ||
!empty($tables['civicrm_pledge_payment'])) {
597 $tables = array_merge(array('civicrm_pledge' => 1), $tables);