X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FReport%2FForm%2FContribute%2FSummary.php;h=3479ec3a5f05191cf4c35553007e61e8ae00b8da;hb=776ff7a00ca98cd3f668e43e4419c62791b1110f;hp=4fc51f6ec300782e2d9f202341c991a30efcd83a;hpb=17d83a01db1059f95af45e3bd8898e353e52c02c;p=civicrm-core.git diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 4fc51f6ec3..3479ec3a5f 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -45,8 +45,6 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); - /** - */ /** */ public function __construct() { @@ -61,186 +59,186 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { } $this->_columns = array( - 'civicrm_contact' => array( - 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( - 'title' => ts('Contact Name'), - 'no_repeat' => TRUE, - ), - 'postal_greeting_display' => array('title' => ts('Postal Greeting')), - 'id' => array( - 'no_display' => TRUE, - 'required' => TRUE, - ), - 'contact_type' => array( - 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( - 'title' => ts('Contact Subtype'), - ), + 'civicrm_contact' => array( + 'dao' => 'CRM_Contact_DAO_Contact', + 'fields' => array( + 'sort_name' => array( + 'title' => ts('Contact Name'), + 'no_repeat' => TRUE, ), - 'grouping' => 'contact-fields', - 'group_bys' => array( - 'id' => array('title' => ts('Contact ID')), - 'sort_name' => array( - 'title' => ts('Contact Name'), - ), + 'postal_greeting_display' => array('title' => ts('Postal Greeting')), + 'id' => array( + 'no_display' => TRUE, + 'required' => TRUE, + ), + 'contact_type' => array( + 'title' => ts('Contact Type'), + ), + 'contact_sub_type' => array( + 'title' => ts('Contact Subtype'), ), ), - 'civicrm_email' => array( - 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( - 'title' => ts('Email'), - 'no_repeat' => TRUE, - ), + 'grouping' => 'contact-fields', + 'group_bys' => array( + 'id' => array('title' => ts('Contact ID')), + 'sort_name' => array( + 'title' => ts('Contact Name'), ), - 'grouping' => 'contact-fields', ), - 'civicrm_phone' => array( - 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( - 'title' => ts('Phone'), - 'no_repeat' => TRUE, - ), + ), + 'civicrm_email' => array( + 'dao' => 'CRM_Core_DAO_Email', + 'fields' => array( + 'email' => array( + 'title' => ts('Email'), + 'no_repeat' => TRUE, ), - 'grouping' => 'contact-fields', ), - 'civicrm_financial_type' => array( - 'dao' => 'CRM_Financial_DAO_FinancialType', - 'fields' => array('financial_type' => NULL), - 'grouping' => 'contri-fields', - 'group_bys' => array( - 'financial_type' => array('title' => ts('Financial Type')), + 'grouping' => 'contact-fields', + ), + 'civicrm_phone' => array( + 'dao' => 'CRM_Core_DAO_Phone', + 'fields' => array( + 'phone' => array( + 'title' => ts('Phone'), + 'no_repeat' => TRUE, ), ), - 'civicrm_contribution' => array( - 'dao' => 'CRM_Contribute_DAO_Contribution', + 'grouping' => 'contact-fields', + ), + 'civicrm_financial_type' => array( + 'dao' => 'CRM_Financial_DAO_FinancialType', + 'fields' => array('financial_type' => NULL), + 'grouping' => 'contri-fields', + 'group_bys' => array( + 'financial_type' => array('title' => ts('Financial Type')), + ), + ), + 'civicrm_contribution' => array( + 'dao' => 'CRM_Contribute_DAO_Contribution', //'bao' => 'CRM_Contribute_BAO_Contribution', - 'fields' => array( - 'contribution_source' => array('title' => ts('Source')), - 'currency' => array( - 'required' => TRUE, - 'no_display' => TRUE, - ), - 'total_amount' => array( - 'title' => ts('Contribution Amount Stats'), - 'default' => TRUE, - 'statistics' => array( - 'sum' => ts('Contribution Aggregate'), - 'count' => ts('Contributions'), - 'avg' => ts('Contribution Avg'), - ), - ), + 'fields' => array( + 'contribution_source' => array('title' => ts('Source')), + 'currency' => array( + 'required' => TRUE, + 'no_display' => TRUE, ), - 'grouping' => 'contri-fields', - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_status_id' => array( - 'title' => ts('Contribution Status'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - 'type' => CRM_Utils_Type::T_INT, - ), - 'currency' => array( - 'title' => 'Currency', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'financial_type_id' => array( - 'title' => ts('Financial Type'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::financialType(), - 'type' => CRM_Utils_Type::T_INT, - ), - 'contribution_page_id' => array( - 'title' => ts('Contribution Page'), - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Contribute_PseudoConstant::contributionPage(), - 'type' => CRM_Utils_Type::T_INT, - ), - 'total_amount' => array( - 'title' => ts('Contribution Amount'), - ), - 'total_sum' => array( - 'title' => ts('Contribution Aggregate'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_sum', - 'having' => TRUE, - ), - 'total_count' => array( - 'title' => ts('Contribution Count'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_count', - 'having' => TRUE, - ), - 'total_avg' => array( - 'title' => ts('Contribution Avg'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_total_amount_avg', - 'having' => TRUE, + 'total_amount' => array( + 'title' => ts('Contribution Amount Stats'), + 'default' => TRUE, + 'statistics' => array( + 'sum' => ts('Contribution Aggregate'), + 'count' => ts('Contributions'), + 'avg' => ts('Contribution Avg'), ), ), - 'group_bys' => array( - 'receive_date' => array( - 'frequency' => TRUE, - 'default' => TRUE, - 'chart' => TRUE, - ), - 'contribution_source' => NULL, + ), + 'grouping' => 'contri-fields', + 'filters' => array( + 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), + 'contribution_status_id' => array( + 'title' => ts('Contribution Status'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), + 'default' => array(1), + 'type' => CRM_Utils_Type::T_INT, + ), + 'currency' => array( + 'title' => 'Currency', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'financial_type_id' => array( + 'title' => ts('Financial Type'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::financialType(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'contribution_page_id' => array( + 'title' => ts('Contribution Page'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_PseudoConstant::contributionPage(), + 'type' => CRM_Utils_Type::T_INT, + ), + 'total_amount' => array( + 'title' => ts('Contribution Amount'), + ), + 'total_sum' => array( + 'title' => ts('Contribution Aggregate'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_sum', + 'having' => TRUE, + ), + 'total_count' => array( + 'title' => ts('Contribution Count'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_count', + 'having' => TRUE, + ), + 'total_avg' => array( + 'title' => ts('Contribution Avg'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_total_amount_avg', + 'having' => TRUE, ), ), - 'civicrm_contribution_soft' => array( - 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => array( - 'soft_amount' => array( - 'title' => ts('Soft Credit Amount Stats'), - 'name' => 'amount', - 'statistics' => array( - 'sum' => ts('Soft Credit Aggregate'), - 'count' => ts('Soft Credits'), - 'avg' => ts('Soft Credit Avg'), - ), - ), + 'group_bys' => array( + 'receive_date' => array( + 'frequency' => TRUE, + 'default' => TRUE, + 'chart' => TRUE, ), - 'grouping' => 'contri-fields', - 'filters' => array( - 'amount' => array( - 'title' => ts('Soft Credit Amount'), - ), - 'soft_credit_type_id' => array( - 'title' => 'Soft Credit Type', - 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), - 'default' => NULL, - 'type' => CRM_Utils_Type::T_STRING, - ), - 'soft_sum' => array( - 'title' => ts('Soft Credit Aggregate'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum', - 'having' => TRUE, - ), - 'soft_count' => array( - 'title' => ts('Soft Credits Count'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count', - 'having' => TRUE, - ), - 'soft_avg' => array( - 'title' => ts('Soft Credit Avg'), - 'type' => CRM_Report_Form::OP_INT, - 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg', - 'having' => TRUE, + 'contribution_source' => NULL, + ), + ), + 'civicrm_contribution_soft' => array( + 'dao' => 'CRM_Contribute_DAO_ContributionSoft', + 'fields' => array( + 'soft_amount' => array( + 'title' => ts('Soft Credit Amount Stats'), + 'name' => 'amount', + 'statistics' => array( + 'sum' => ts('Soft Credit Aggregate'), + 'count' => ts('Soft Credits'), + 'avg' => ts('Soft Credit Avg'), ), ), ), - ) + $this->addAddressFields(); + 'grouping' => 'contri-fields', + 'filters' => array( + 'amount' => array( + 'title' => ts('Soft Credit Amount'), + ), + 'soft_credit_type_id' => array( + 'title' => 'Soft Credit Type', + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_STRING, + ), + 'soft_sum' => array( + 'title' => ts('Soft Credit Aggregate'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_soft_soft_amount_sum', + 'having' => TRUE, + ), + 'soft_count' => array( + 'title' => ts('Soft Credits Count'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_soft_soft_amount_count', + 'having' => TRUE, + ), + 'soft_avg' => array( + 'title' => ts('Soft Credit Avg'), + 'type' => CRM_Report_Form::OP_INT, + 'dbAlias' => 'civicrm_contribution_soft_soft_amount_avg', + 'having' => TRUE, + ), + ), + ), + ) + $this->addAddressFields(); // If we have a campaign, build out the relevant elements if ($campaignEnabled && !empty($this->activeCampaigns)) { @@ -316,8 +314,7 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form { } if (!empty($this->_params['group_bys_freq'][$fieldName])) { $this->_interval = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = - $field['title'] . ' Beginning'; + $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['title'] = $field['title'] . ' Beginning'; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['type'] = $field['type']; $this->_columnHeaders["{$tableName}_{$fieldName}_start"]['group_by'] = $this->_params['group_bys_freq'][$fieldName]; @@ -546,15 +543,15 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ $totalAmount = $average = $softTotalAmount = $softAverage = array(); $count = $softCount = 0; while ($dao->fetch()) { - $totalAmount[] = - CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->currency) . + $totalAmount[] + = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->currency) . " (" . $dao->civicrm_contribution_total_amount_count . ")"; $average[] = CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_avg, $dao->currency); $count += $dao->civicrm_contribution_total_amount_count; if ($softCredit) { - $softTotalAmount[] = - CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_sum, $dao->currency) . + $softTotalAmount[] + = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_sum, $dao->currency) . " (" . $dao->civicrm_contribution_soft_soft_amount_count . ")"; $softAverage[] = CRM_Utils_Money::format($dao->civicrm_contribution_soft_soft_amount_avg, $dao->currency); $softCount += $dao->civicrm_contribution_soft_soft_amount_count; @@ -653,10 +650,15 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ } /** - * @param $rows + * Alter display of rows. + * + * Iterate through the rows retrieved via SQL and make changes for display purposes, + * such as rendering contacts as links. + * + * @param array $rows + * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { - // custom code to alter rows $entryFound = FALSE; foreach ($rows as $rowNum => $row) { @@ -747,4 +749,5 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_ } } } + }