financial#46 - clean money format at form layer
[civicrm-core.git] / CRM / Contribute / Selector / Search.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
6b83d5bd 6 | Copyright CiviCRM LLC (c) 2004-2019 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
6a488035 29 * @package CRM
6b83d5bd 30 * @copyright CiviCRM LLC (c) 2004-2019
6a488035
TO
31 */
32
33/**
2e80df5b 34 * Class to render contribution search results.
6a488035
TO
35 */
36class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements CRM_Core_Selector_API {
37
38 /**
2e80df5b 39 * Array of action links.
6a488035
TO
40 *
41 * @var array
6a488035
TO
42 */
43 static $_links = NULL;
44
45 /**
100fef9d 46 * We use desc to remind us what that column is, name is used in the tpl
6a488035
TO
47 *
48 * @var array
6a488035
TO
49 */
50 static $_columnHeaders;
51
52 /**
53 * Properties of contact we're interested in displaying
54 * @var array
6a488035
TO
55 */
56 static $_properties = array(
57 'contact_id',
58 'contribution_id',
59 'contact_type',
60 'sort_name',
61 'amount_level',
62 'total_amount',
e777c2b6 63 'financial_type',
6a488035
TO
64 'contribution_source',
65 'receive_date',
66 'thankyou_date',
67 'contribution_status_id',
68 'contribution_status',
69 'cancel_date',
70 'product_name',
71 'is_test',
72 'contribution_recur_id',
73 'receipt_date',
74 'membership_id',
75 'currency',
76 'contribution_campaign_id',
36bf52ef 77 'contribution_soft_credit_name',
d4e2b978 78 'contribution_soft_credit_contact_id',
36bf52ef
DS
79 'contribution_soft_credit_amount',
80 'contribution_soft_credit_type',
6a488035
TO
81 );
82
83 /**
100fef9d 84 * Are we restricting ourselves to a single contact
6a488035 85 *
6a488035
TO
86 * @var boolean
87 */
88 protected $_single = FALSE;
89
90 /**
100fef9d 91 * Are we restricting ourselves to a single contact
6a488035 92 *
6a488035
TO
93 * @var boolean
94 */
95 protected $_limit = NULL;
96
97 /**
100fef9d 98 * What context are we being invoked from
6a488035 99 *
6a488035
TO
100 * @var string
101 */
102 protected $_context = NULL;
103
104 /**
100fef9d 105 * What component context are we being invoked from
6a488035 106 *
6a488035
TO
107 * @var string
108 */
109 protected $_compContext = NULL;
110
111 /**
100fef9d 112 * QueryParams is the array returned by exportValues called on
6a488035
TO
113 * the HTML_QuickForm_Controller for that page.
114 *
115 * @var array
6a488035
TO
116 */
117 public $_queryParams;
118
119 /**
100fef9d 120 * Represent the type of selector
6a488035
TO
121 *
122 * @var int
6a488035
TO
123 */
124 protected $_action;
125
126 /**
127 * The additional clause that we restrict the search with
128 *
129 * @var string
130 */
131 protected $_contributionClause = NULL;
132
133 /**
134 * The query object
135 *
136 * @var string
137 */
138 protected $_query;
139
36bf52ef
DS
140 protected $_includeSoftCredits = FALSE;
141
6a488035 142 /**
fe482240 143 * Class constructor.
6a488035 144 *
014c4014
TO
145 * @param array $queryParams
146 * Array of parameters for query.
da6b46f4 147 * @param \const|int $action - action of search basic or advanced.
014c4014
TO
148 * @param string $contributionClause
149 * If the caller wants to further restrict the search (used in contributions).
150 * @param bool $single
151 * Are we dealing only with one contact?.
152 * @param int $limit
153 * How many contributions do we want returned.
6a488035 154 *
da6b46f4
EM
155 * @param string $context
156 * @param null $compContext
157 *
158 * @return \CRM_Contribute_Selector_Search
6a488035 159 */
8d7a9d07 160 public function __construct(
a13f3d8c 161 &$queryParams,
874c9be7 162 $action = CRM_Core_Action::NONE,
6a488035 163 $contributionClause = NULL,
874c9be7
TO
164 $single = FALSE,
165 $limit = NULL,
166 $context = 'search',
167 $compContext = NULL
6a488035
TO
168 ) {
169
170 // submitted form values
171 $this->_queryParams = &$queryParams;
172
353ffa53
TO
173 $this->_single = $single;
174 $this->_limit = $limit;
175 $this->_context = $context;
6a488035
TO
176 $this->_compContext = $compContext;
177
178 $this->_contributionClause = $contributionClause;
179
180 // type of selector
181 $this->_action = $action;
b4bb60fc 182 $returnProperties = CRM_Contribute_BAO_Query::selectorReturnProperties($this->_queryParams);
d4e2b978 183 $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
36bf52ef
DS
184 $this->_query = new CRM_Contact_BAO_Query(
185 $this->_queryParams,
c5c270ef 186 $returnProperties,
6a488035
TO
187 NULL, FALSE, FALSE,
188 CRM_Contact_BAO_Query::MODE_CONTRIBUTE
189 );
17caeafe 190 // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this
191 // can we remove? if not why not?
3dbf477c
DS
192 if ($this->_includeSoftCredits) {
193 $this->_query->_rowCountClause = " count(civicrm_contribution.id)";
ed81a415 194 $this->_query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ";
0db6c3e1
TO
195 }
196 else {
3dbf477c
DS
197 $this->_query->_distinctComponentClause = " civicrm_contribution.id";
198 $this->_query->_groupByComponentClause = " GROUP BY civicrm_contribution.id ";
199 }
6a488035 200 }
6a488035
TO
201
202 /**
203 * This method returns the links that are given for each search row.
204 * currently the links added for each row are
205 *
206 * - View
207 * - Edit
208 *
100fef9d 209 * @param int $componentId
fd31fa4c
EM
210 * @param null $componentAction
211 * @param null $key
212 * @param null $compContext
213 *
6a488035 214 * @return array
6a488035 215 */
00be9182 216 public static function &links($componentId = NULL, $componentAction = NULL, $key = NULL, $compContext = NULL) {
6a488035
TO
217 $extraParams = NULL;
218 if ($componentId) {
219 $extraParams = "&compId={$componentId}&compAction={$componentAction}";
220 }
221 if ($compContext) {
222 $extraParams .= "&compContext={$compContext}";
223 }
224 if ($key) {
225 $extraParams .= "&key={$key}";
226 }
227
228 if (!(self::$_links)) {
229 self::$_links = array(
230 CRM_Core_Action::VIEW => array(
231 'name' => ts('View'),
232 'url' => 'civicrm/contact/view/contribution',
233 'qs' => "reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=contribute{$extraParams}",
234 'title' => ts('View Contribution'),
235 ),
236 CRM_Core_Action::UPDATE => array(
237 'name' => ts('Edit'),
238 'url' => 'civicrm/contact/view/contribution',
239 'qs' => "reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}",
240 'title' => ts('Edit Contribution'),
241 ),
242 CRM_Core_Action::DELETE => array(
243 'name' => ts('Delete'),
244 'url' => 'civicrm/contact/view/contribution',
245 'qs' => "reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}",
246 'title' => ts('Delete Contribution'),
247 ),
248 );
249 }
250 return self::$_links;
251 }
6a488035
TO
252
253 /**
100fef9d 254 * Getter for array of the parameters required for creating pager.
6a488035 255 *
da6b46f4 256 * @param $action
c490a46a 257 * @param array $params
6a488035 258 */
00be9182 259 public function getPagerParams($action, &$params) {
6a488035
TO
260 $params['status'] = ts('Contribution') . ' %%StatusMessage%%';
261 $params['csvString'] = NULL;
262 if ($this->_limit) {
263 $params['rowCount'] = $this->_limit;
264 }
265 else {
266 $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT;
267 }
268
269 $params['buttonTop'] = 'PagerTopButton';
270 $params['buttonBottom'] = 'PagerBottomButton';
271 }
6a488035
TO
272
273 /**
274 * Returns total number of rows for the query.
275 *
7fe37828 276 * @param string $action
6a488035 277 *
a6c01b45
CW
278 * @return int
279 * Total number of rows
6a488035 280 */
00be9182 281 public function getTotalCount($action) {
6a488035
TO
282 return $this->_query->searchQuery(0, 0, NULL,
283 TRUE, FALSE,
284 FALSE, FALSE,
285 FALSE,
286 $this->_contributionClause
287 );
288 }
289
290 /**
fe482240 291 * Returns all the rows in the given offset and rowCount.
6a488035 292 *
3f8d2862 293 * @param string $action
014c4014
TO
294 * The action being performed.
295 * @param int $offset
296 * The row number to start from.
297 * @param int $rowCount
298 * The number of rows to return.
299 * @param string $sort
300 * The sql string that describes the sort order.
3f8d2862 301 * @param string $output
014c4014 302 * What should the result set include (web/email/csv).
6a488035 303 *
a6c01b45
CW
304 * @return int
305 * the total number of rows for this action
6a488035 306 */
00be9182 307 public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
4f3846df
DS
308 if ($this->_includeSoftCredits) {
309 // especial sort order when rows include soft credits
8f7c2652 310 $sort = $sort->orderBy() . ", civicrm_contribution.id, civicrm_contribution_soft.id";
4f3846df 311 }
6a488035
TO
312 $result = $this->_query->searchQuery($offset, $rowCount, $sort,
313 FALSE, FALSE,
314 FALSE, FALSE,
315 FALSE,
316 $this->_contributionClause
317 );
318 // process the result of the query
319 $rows = array();
320
321 //CRM-4418 check for view/edit/delete
322 $permissions = array(CRM_Core_Permission::VIEW);
323 if (CRM_Core_Permission::check('edit contributions')) {
324 $permissions[] = CRM_Core_Permission::EDIT;
325 }
326 if (CRM_Core_Permission::check('delete in CiviContribute')) {
327 $permissions[] = CRM_Core_Permission::DELETE;
328 }
329 $mask = CRM_Core_Action::mask($permissions);
330
331 $qfKey = $this->_key;
332 $componentId = $componentContext = NULL;
333 if ($this->_context != 'contribute') {
98df3f98 334 // @todo explain the significance of context & why we do not get these i that context.
a3d827a7
CW
335 $qfKey = CRM_Utils_Request::retrieve('key', 'String');
336 $componentId = CRM_Utils_Request::retrieve('id', 'Positive');
337 $componentAction = CRM_Utils_Request::retrieve('action', 'String');
338 $componentContext = CRM_Utils_Request::retrieve('compContext', 'String');
6a488035
TO
339
340 if (!$componentContext &&
341 $this->_compContext
342 ) {
98df3f98 343 // @todo explain when this condition might occur.
6a488035
TO
344 $componentContext = $this->_compContext;
345 $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
346 }
98df3f98 347 // CRM-17628 for some reason qfKey is not always set when searching from contribution search.
348 // as a result if the edit link is opened using right-click + open in new tab
349 // then the browser is not returned to the search results on save.
350 // This is an effort to getting the qfKey without, sadly, understanding the intent of those who came before me.
351 if (empty($qfKey)) {
352 $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, NULL, FALSE, 'REQUEST');
353 }
6a488035
TO
354 }
355
356 // get all contribution status
357 $contributionStatuses = CRM_Core_OptionGroup::values('contribution_status',
358 FALSE, FALSE, FALSE, NULL, 'name', FALSE
359 );
360
361 //get all campaigns.
362 $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
363
874c9be7 364 while ($result->fetch()) {
9d5c7f14 365 $this->_query->convertToPseudoNames($result);
b501fa94
E
366 $links = self::links($componentId,
367 $componentAction,
368 $qfKey,
369 $componentContext
370 );
a964bc8e 371 $checkLineItem = FALSE;
6a488035 372 $row = array();
a964bc8e 373 // Now check for lineItems
4323dc6c
PN
374 if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
375 $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($result->id);
40c655aa 376 foreach ($lineItems as $items) {
4323dc6c
PN
377 if (!CRM_Core_Permission::check('view contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
378 $checkLineItem = TRUE;
379 break;
380 }
381 if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
382 unset($links[CRM_Core_Action::UPDATE]);
383 }
384 if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($items['financial_type_id']))) {
385 unset($links[CRM_Core_Action::DELETE]);
386 }
a964bc8e 387 }
4323dc6c
PN
388 if ($checkLineItem) {
389 continue;
390 }
391 if (!CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
2d0b158e 392 unset($links[CRM_Core_Action::UPDATE]);
48da6700 393 }
4323dc6c 394 if (!CRM_Core_Permission::check('delete contributions of type ' . CRM_Contribute_PseudoConstant::financialType($result->financial_type_id))) {
2d0b158e 395 unset($links[CRM_Core_Action::DELETE]);
48da6700 396 }
a964bc8e 397 }
6a488035
TO
398 // the columns we are interested in
399 foreach (self::$_properties as $property) {
400 if (property_exists($result, $property)) {
401 $row[$property] = $result->$property;
402 }
403 }
404
405 //carry campaign on selectors.
5deb2f24 406 // @todo - I can't find any evidence that 'carrying' the campaign on selectors actually
407 // results in it being displayed anywhere so why do we do this???
6a488035
TO
408 $row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns);
409 $row['campaign_id'] = $result->contribution_campaign_id;
410
411 // add contribution status name
412 $row['contribution_status_name'] = CRM_Utils_Array::value($row['contribution_status_id'],
413 $contributionStatuses
414 );
415
685dc433 416 $isPayLater = FALSE;
6a488035 417 if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
685dc433 418 $isPayLater = TRUE;
6a488035 419 $row['contribution_status'] .= ' (' . ts('Pay Later') . ')';
b9a90a9c 420 $links[CRM_Core_Action::ADD] = array(
421 'name' => ts('Pay with Credit Card'),
422 'url' => 'civicrm/contact/view/contribution',
423 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%&mode=live',
424 'title' => ts('Pay with Credit Card'),
425 );
6a488035
TO
426 }
427 elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') {
428 $row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')';
429 }
430
431 if ($row['is_test']) {
e777c2b6 432 $row['financial_type'] = $row['financial_type'] . ' (' . ts('test') . ')';
6a488035
TO
433 }
434
435 $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id;
436
6a488035
TO
437 $actions = array(
438 'id' => $result->contribution_id,
439 'cid' => $result->contact_id,
440 'cxt' => $this->_context,
441 );
c5c270ef 442
8e50d640
PN
443 if (in_array($row['contribution_status_name'], array('Partially paid', 'Pending refund')) || $isPayLater) {
444 $buttonName = ts('Record Payment');
445 if ($row['contribution_status_name'] == 'Pending refund') {
446 $buttonName = ts('Record Refund');
447 }
059326f3 448 elseif (CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) {
14490e83
PN
449 $links[CRM_Core_Action::BASIC] = array(
450 'name' => ts('Submit Credit Card payment'),
451 'url' => 'civicrm/payment/add',
452 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=contribution&mode=live',
453 'title' => ts('Submit Credit Card payment'),
454 );
455 }
685dc433 456 $links[CRM_Core_Action::ADD] = array(
8e50d640 457 'name' => $buttonName,
685dc433 458 'url' => 'civicrm/payment',
8e50d640
PN
459 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=contribution',
460 'title' => $buttonName,
685dc433 461 );
c5c270ef 462 }
6a488035 463
e777c2b6 464 $row['action'] = CRM_Core_Action::formLink(
b501fa94 465 $links,
87dab4a4
AH
466 $mask, $actions,
467 ts('more'),
468 FALSE,
469 'contribution.selector.row',
470 'Contribution',
471 $result->contribution_id
6a488035
TO
472 );
473
874c9be7 474 $row['contact_type'] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, $result->contact_id
6a488035
TO
475 );
476
a7488080 477 if (!empty($row['amount_level'])) {
6a488035
TO
478 CRM_Event_BAO_Participant::fixEventLevel($row['amount_level']);
479 }
480
481 $rows[] = $row;
482 }
483
484 return $rows;
485 }
486
487 /**
1054415f 488 * @inheritDoc
6a488035 489 */
6a488035
TO
490 public function getQILL() {
491 return $this->_query->qill();
492 }
493
494 /**
100fef9d 495 * Returns the column headers as an array of tuples:
6a488035
TO
496 * (name, sortName (key to the sort array))
497 *
014c4014
TO
498 * @param string $action
499 * The action being performed.
3f8d2862 500 * @param string $output
014c4014 501 * What should the result set include (web/email/csv).
6a488035 502 *
a6c01b45
CW
503 * @return array
504 * the column headers that need to be displayed
6a488035
TO
505 */
506 public function &getColumnHeaders($action = NULL, $output = NULL) {
054785dc 507 $pre = array();
36bf52ef
DS
508 self::$_columnHeaders = array(
509 array(
4f3846df 510 'name' => $this->_includeSoftCredits ? ts('Contribution Amount') : ts('Amount'),
36bf52ef
DS
511 'sort' => 'total_amount',
512 'direction' => CRM_Utils_Sort::DONTCARE,
4fb5fcf3 513 'field_name' => 'total_amount',
36bf52ef 514 ),
36bf52ef 515 );
4f3846df 516 if ($this->_includeSoftCredits) {
8d7a9d07
CB
517 self::$_columnHeaders
518 = array_merge(
fd31fa4c 519 self::$_columnHeaders,
4f3846df
DS
520 array(
521 array(
522 'name' => ts('Soft Credit Amount'),
523 'sort' => 'contribution_soft_credit_amount',
4fb5fcf3 524 'field_name' => 'contribution_soft_credit_amount',
4f3846df 525 'direction' => CRM_Utils_Sort::DONTCARE,
21dfd5f5 526 ),
4f3846df
DS
527 )
528 );
529 }
8d7a9d07
CB
530 self::$_columnHeaders
531 = array_merge(
fd31fa4c 532 self::$_columnHeaders,
4f3846df
DS
533 array(
534 array(
535 'name' => ts('Type'),
353ffa53 536 'sort' => 'financial_type',
4fb5fcf3 537 'field_name' => 'financial_type',
4f3846df
DS
538 'direction' => CRM_Utils_Sort::DONTCARE,
539 ),
540 array(
541 'name' => ts('Source'),
542 'sort' => 'contribution_source',
4fb5fcf3 543 'field_name' => 'contribution_source',
4f3846df
DS
544 'direction' => CRM_Utils_Sort::DONTCARE,
545 ),
546 array(
547 'name' => ts('Received'),
548 'sort' => 'receive_date',
4fb5fcf3 549 'field_name' => 'receive_date',
550 'type' => 'date',
4f3846df
DS
551 'direction' => CRM_Utils_Sort::DESCENDING,
552 ),
553 array(
554 'name' => ts('Thank-you Sent'),
555 'sort' => 'thankyou_date',
ca460381 556 'field_name' => 'thankyou_date',
4fb5fcf3 557 'type' => 'date',
4f3846df
DS
558 'direction' => CRM_Utils_Sort::DONTCARE,
559 ),
560 array(
561 'name' => ts('Status'),
33a5a53d 562 'sort' => 'contribution_status',
4fb5fcf3 563 'field_name' => 'contribution_status',
4f3846df
DS
564 'direction' => CRM_Utils_Sort::DONTCARE,
565 ),
566 array(
567 'name' => ts('Premium'),
568 'sort' => 'product_name',
4fb5fcf3 569 'field_name' => 'product_name',
4f3846df
DS
570 'direction' => CRM_Utils_Sort::DONTCARE,
571 ),
572 )
573 );
36bf52ef
DS
574 if (!$this->_single) {
575 $pre = array(
6a488035 576 array(
36bf52ef
DS
577 'name' => ts('Name'),
578 'sort' => 'sort_name',
6a488035
TO
579 'direction' => CRM_Utils_Sort::DONTCARE,
580 ),
6a488035 581 );
36bf52ef 582 }
d4c0653f 583 self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
36bf52ef 584 if ($this->_includeSoftCredits) {
006389de 585 self::$_columnHeaders = array_merge(
8d7a9d07
CB
586 self::$_columnHeaders,
587 array(
6a488035 588 array(
8d7a9d07
CB
589 'name' => ts('Soft Credit For'),
590 'sort' => 'contribution_soft_credit_name',
591 'direction' => CRM_Utils_Sort::DONTCARE,
592 ),
593 array(
594 'name' => ts('Soft Credit Type'),
595 'sort' => 'contribution_soft_credit_type',
596 'direction' => CRM_Utils_Sort::ASCENDING,
597 ),
598 )
599 );
6a488035 600 }
8d7a9d07
CB
601 self::$_columnHeaders
602 = array_merge(
4f3846df 603 self::$_columnHeaders, array(
4fb5fcf3 604 array('desc' => ts('Actions'), 'type' => 'actions'),
4f3846df
DS
605 )
606 );
4fb5fcf3 607 foreach (array_keys(self::$_columnHeaders) as $index) {
608 // Add weight & space it out a bit to allow headers to be inserted.
609 self::$_columnHeaders[$index]['weight'] = $index * 10;
610 }
611
c740f57b 612 CRM_Core_Smarty::singleton()->assign('softCreditColumns', $this->_includeSoftCredits);
6a488035
TO
613 return self::$_columnHeaders;
614 }
615
186c9c17
EM
616 /**
617 * @return mixed
618 */
00be9182 619 public function alphabetQuery() {
6a488035
TO
620 return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
621 }
622
186c9c17
EM
623 /**
624 * @return string
625 */
00be9182 626 public function &getQuery() {
6a488035
TO
627 return $this->_query;
628 }
629
630 /**
100fef9d 631 * Name of export file.
6a488035 632 *
014c4014
TO
633 * @param string $output
634 * Type of output.
6a488035 635 *
a6c01b45
CW
636 * @return string
637 * name of the file
6a488035 638 */
00be9182 639 public function getExportFileName($output = 'csv') {
6a488035
TO
640 return ts('CiviCRM Contribution Search');
641 }
642
186c9c17
EM
643 /**
644 * @return mixed
645 */
00be9182 646 public function getSummary() {
6a488035
TO
647 return $this->_query->summaryContribution($this->_context);
648 }
96025800 649
6a488035 650}