<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
'membership_id',
'currency',
'contribution_campaign_id',
+ 'contribution_soft_credit_name',
+ 'contribution_soft_credit_contact_id',
+ 'contribution_soft_credit_amount',
+ 'contribution_soft_credit_type',
);
/**
*/
protected $_query;
+ protected $_includeSoftCredits = FALSE;
+
/**
* Class constructor
*
* @param array $queryParams array of parameters for query
- * @param int $action - action of search basic or advanced.
- * @param string $contributionClause if the caller wants to further restrict the search (used in contributions)
+ * @param \const|int $action - action of search basic or advanced.
+ * @param string $contributionClause if the caller wants to further restrict the search (used in contributions)
* @param boolean $single are we dealing only with one contact?
- * @param int $limit how many contributions do we want returned
+ * @param int $limit how many contributions do we want returned
*
- * @return CRM_Contact_Selector
- * @access public
+ * @param string $context
+ * @param null $compContext
+ *
+ * @return \CRM_Contribute_Selector_Search
+ @access public
*/
function __construct(&$queryParams,
$action = CRM_Core_Action::NONE,
// type of selector
$this->_action = $action;
- $this->_query = new CRM_Contact_BAO_Query($this->_queryParams,
- CRM_Contribute_BAO_Query::defaultReturnProperties(CRM_Contact_BAO_Query::MODE_CONTRIBUTE,
+ $this->_includeSoftCredits = CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled($this->_queryParams);
+ $this->_query = new CRM_Contact_BAO_Query(
+ $this->_queryParams,
+ CRM_Contribute_BAO_Query::defaultReturnProperties(
+ CRM_Contact_BAO_Query::MODE_CONTRIBUTE,
FALSE
),
NULL, FALSE, FALSE,
CRM_Contact_BAO_Query::MODE_CONTRIBUTE
);
- $this->_query->_distinctComponentClause = " civicrm_contribution.id";
- $this->_query->_groupByComponentClause = " GROUP BY civicrm_contribution.id ";
+ if ($this->_includeSoftCredits) {
+ $this->_query->_rowCountClause = " count(civicrm_contribution.id)";
+ $this->_query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id ";
+ } else {
+ $this->_query->_distinctComponentClause = " civicrm_contribution.id";
+ $this->_query->_groupByComponentClause = " GROUP BY civicrm_contribution.id ";
+ }
}
//end of constructor
* - View
* - Edit
*
+ * @param null $componentId
+ * @param null $componentAction
+ * @param null $key
+ * @param null $compContext
+ *
* @return array
* @access public
- *
*/
static function &links($componentId = NULL, $componentAction = NULL, $key = NULL, $compContext = NULL) {
$extraParams = NULL;
/**
* getter for array of the parameters required for creating pager.
*
- * @param
+ * @param $action
+ * @param $params
+ * @internal param $
* @access public
*/
function getPagerParams($action, &$params) {
* @return int the total number of rows for this action
*/
function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
+ if ($this->_includeSoftCredits) {
+ // especial sort order when rows include soft credits
+ $sort = "civicrm_contribution.receive_date DESC, civicrm_contribution.id, civicrm_contribution_soft.id";
+ }
$result = $this->_query->searchQuery($offset, $rowCount, $sort,
FALSE, FALSE,
FALSE, FALSE,
* @access public
*/
public function &getColumnHeaders($action = NULL, $output = NULL) {
- if (!isset(self::$_columnHeaders)) {
- self::$_columnHeaders = array(
- array(
- 'name' => ts('Amount'),
- 'sort' => 'total_amount',
- 'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- array('name' => ts('Type'),
- 'sort' => 'financial_type_id',
- 'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- array(
- 'name' => ts('Source'),
- 'sort' => 'contribution_source',
- 'direction' => CRM_Utils_Sort::DONTCARE,
- ),
- array(
- 'name' => ts('Received'),
- 'sort' => 'receive_date',
- 'direction' => CRM_Utils_Sort::DESCENDING,
- ),
- array(
- 'name' => ts('Thank-you Sent'),
- 'sort' => 'thankyou_date',
- 'direction' => CRM_Utils_Sort::DONTCARE,
- ),
+ self::$_columnHeaders = array(
+ array(
+ 'name' => $this->_includeSoftCredits ? ts('Contribution Amount') : ts('Amount'),
+ 'sort' => 'total_amount',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ );
+ if ($this->_includeSoftCredits) {
+ self::$_columnHeaders =
+ array_merge(
+ self::$_columnHeaders,
+ array(
+ array(
+ 'name' => ts('Soft Credit Amount'),
+ 'sort' => 'contribution_soft_credit_amount',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ )
+ )
+ );
+ }
+ self::$_columnHeaders =
+ array_merge(
+ self::$_columnHeaders,
array(
- 'name' => ts('Status'),
- 'sort' => 'contribution_status_id',
- 'direction' => CRM_Utils_Sort::DONTCARE,
- ),
+ array(
+ 'name' => ts('Type'),
+ 'sort' => 'financial_type_id',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ array(
+ 'name' => ts('Source'),
+ 'sort' => 'contribution_source',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ array(
+ 'name' => ts('Received'),
+ 'sort' => 'receive_date',
+ 'direction' => CRM_Utils_Sort::DESCENDING,
+ ),
+ array(
+ 'name' => ts('Thank-you Sent'),
+ 'sort' => 'thankyou_date',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ array(
+ 'name' => ts('Status'),
+ 'sort' => 'contribution_status_id',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ array(
+ 'name' => ts('Premium'),
+ 'sort' => 'product_name',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ )
+ );
+ if (!$this->_single) {
+ $pre = array(
+ array('desc' => ts('Contact Type')),
array(
- 'name' => ts('Premium'),
- 'sort' => 'product_name',
+ 'name' => ts('Name'),
+ 'sort' => 'sort_name',
'direction' => CRM_Utils_Sort::DONTCARE,
),
- array('desc' => ts('Actions')),
);
-
- if (!$this->_single) {
- $pre = array(
- array('desc' => ts('Contact Type')),
+ self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
+ }
+ if ($this->_includeSoftCredits) {
+ self::$_columnHeaders =
+ array_merge(
+ self::$_columnHeaders,
array(
- 'name' => ts('Name'),
- 'sort' => 'sort_name',
- 'direction' => CRM_Utils_Sort::DONTCARE,
- ),
+ array(
+ 'name' => ts('Soft Credit For'),
+ 'sort' => 'contribution_soft_credit_name',
+ 'direction' => CRM_Utils_Sort::DONTCARE,
+ ),
+ array(
+ 'name' => ts('Soft Credit Type'),
+ 'sort' => 'contribution_soft_credit_type',
+ 'direction' => CRM_Utils_Sort::ASCENDING,
+ ),
+ )
);
- self::$_columnHeaders = array_merge($pre, self::$_columnHeaders);
- }
}
+ self::$_columnHeaders =
+ array_merge(
+ self::$_columnHeaders, array(
+ array('desc' => ts('Actions'))
+ )
+ );
return self::$_columnHeaders;
}