X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContribute%2FSelector%2FSearch.php;h=95adc2f4ea95dcab39a2a1561f566606377f2835;hb=da6b46f4a1c9a3dfd1502637efad4fa003eee61a;hp=5836363533b67e016068ac5f35031a7fcf36b38d;hpb=bd6d55934fb8cec290b612b6c2d3d028800744ad;p=civicrm-core.git diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index 5836363533..95adc2f4ea 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -1,9 +1,9 @@ _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 @@ -201,9 +218,13 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C * - 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; @@ -246,7 +267,9 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C /** * getter for array of the parameters required for creating pager. * - * @param + * @param $action + * @param $params + * @internal param $ * @access public */ function getPagerParams($action, &$params) { @@ -293,6 +316,10 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C * @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, @@ -424,57 +451,97 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C * @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; }