From ecd4d80f4371c1148850358fff23d8aa697ff7ba Mon Sep 17 00:00:00 2001 From: Jamie McClelland Date: Tue, 3 Dec 2013 10:51:05 -0500 Subject: [PATCH] CRM-13898 - Contribute - Add summary to PCP report --- CRM/Report/Form/Contribute/PCP.php | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index be1b0016bf..a051910bd7 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -271,6 +271,38 @@ LEFT JOIN civicrm_contribution_page {$this->_aliases['civicrm_contribution_page' } } + function statistics(&$rows) { + $statistics = parent::statistics($rows); + + $select = "SELECT SUM({$this->_aliases['civicrm_pcp']}.goal_amount) as goal_total, ". + "SUM({$this->_aliases['civicrm_contribution_soft']}.amount) as committed_total, ". + "COUNT({$this->_aliases['civicrm_contribution_soft']}.id) as donors_total, ". + "SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount)) AS received_total "; + $sql = "{$select} {$this->_from} {$this->_where}"; + $dao = CRM_Core_DAO::executeQuery($sql); + $dao->fetch(); + $statistics['counts']['goal_total'] = array( + 'title' => ts('Goal Total'), + 'value' => $dao->goal_total, + 'type' => CRM_Utils_Type::T_MONEY + ); + $statistics['counts']['committed_total'] = array( + 'title' => ts('Total Committed'), + 'value' => $dao->committed_total, + 'type' => CRM_Utils_Type::T_MONEY + ); + $statistics['counts']['received_total'] = array( + 'title' => ts('Total Received'), + 'value' => $dao->received_total, + 'type' => CRM_Utils_Type::T_MONEY + ); + $statistics['counts']['donors_total'] = array( + 'title' => ts('Total Donors'), + 'value' => $dao->donors_total, + 'type' => CRM_Utils_Type::T_INT + ); + return $statistics; + } function alterDisplay(&$rows) { // custom code to alter rows $entryFound = FALSE; -- 2.25.1