public $_columnHeaders = array();
public $_orderBy = NULL;
public $_groupBy = NULL;
+
+ /**
+ * Variable to hold the currency alias
+ */
+ protected $_currencyColumn = NULL;
/**
*
// add / modify display columns, filters ..etc
CRM_Utils_Hook::alterReportVar('columns', $this->_columns, $this);
+
+ //assign currencyColumn variable to tpl
+ $this->assign('currencyColumn', $this->_currencyColumn);
}
function preProcessCommon() {
),
'payment_instrument_id' => array('title' => ts('Payment Type'),
),
+ 'currency' =>
+ array('required' => TRUE,
+ 'no_display' => TRUE,
+ ),
'trxn_id' => NULL,
'receive_date' => array('default' => TRUE),
'receipt_date' => NULL,
array(
'receive_date' =>
array('operatorType' => CRM_Report_Form::OP_DATE),
+ 'currency' =>
+ array('title' => 'Currency',
+ 'operatorType' => CRM_Utils_Type::T_STRING,
+ ),
'financial_type_id' =>
array( 'title' => ts( 'Financial Type' ),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
);
$this->_columns['civicrm_contribution']['order_bys']['campaign_id'] = array('title' => ts('Campaign'));
}
+
+ $this->_currencyColumn = 'civicrm_contribution_currency';
parent::__construct();
}
function statistics(&$rows) {
$statistics = parent::statistics($rows);
+ $totalAmount = $average = array();
+ $count = 0;
$select = "
SELECT COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as count,
SUM( {$this->_aliases['civicrm_contribution']}.total_amount ) as amount,
- ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as avg
+ ROUND(AVG({$this->_aliases['civicrm_contribution']}.total_amount), 2) as avg,
+ {$this->_aliases['civicrm_contribution']}.currency as currency
";
- $sql = "{$select} {$this->_from} {$this->_where}";
+ $group = "\nGROUP BY {$this->_aliases['civicrm_contribution']}.currency";
+ $sql = "{$select} {$this->_from} {$this->_where} {$group}";
$dao = CRM_Core_DAO::executeQuery($sql);
- if ($dao->fetch()) {
- $statistics['counts']['amount'] = array(
- 'value' => $dao->amount,
- 'title' => 'Total Amount',
- 'type' => CRM_Utils_Type::T_MONEY,
- );
- $statistics['counts']['avg'] = array(
- 'value' => $dao->avg,
- 'title' => 'Average',
- 'type' => CRM_Utils_Type::T_MONEY,
- );
+ while ($dao->fetch()) {
+ $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)."(".$dao->count.")";
+ $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency);
+ $count += $dao->count;
}
+ $statistics['counts']['amount'] = array(
+ 'title' => ts('Total Amount (Donations)'),
+ 'value' => implode(', ', $totalAmount),
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $statistics['counts']['count'] = array(
+ 'title' => ts('Total Donations'),
+ 'value' => $count,
+ );
+ $statistics['counts']['avg'] = array(
+ 'title' => ts('Average'),
+ 'value' => implode(', ', $average),
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
return $statistics;
}
'avg' => ts('Average'),
),
),
+ 'currency' =>
+ array('required' => TRUE,
+ 'no_display' => TRUE,
+ ),
),
'filters' =>
array(
'default' => 'this.year',
'operatorType' => CRM_Report_Form::OP_DATE,
),
+ 'currency' =>
+ array('title' => ts('Currency'),
+ 'default' => NULL,
+ 'type' => CRM_Utils_Type::T_STRING,
+ ),
'total_range' =>
array('title' => ts('Show no. of Top Donors'),
'type' => CRM_Utils_Type::T_INT,
);
$this->_tagFilter = TRUE;
+ $this->_currencyColumn = 'civicrm_contribution_currency';
parent::__construct();
}
}
function groupBy() {
- $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id ";
+ $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contact']}.id, {$this->_aliases['civicrm_contribution']}.currency";
}
function postProcess() {
$rows[$rowNum]['civicrm_donor_rank'] = $rank++;
// convert display name to links
if (array_key_exists('civicrm_contact_display_name', $row) &&
- array_key_exists('civicrm_contact_id', $row)
+ array_key_exists('civicrm_contact_id', $row) &&
+ CRM_Utils_Array::value('civicrm_contribution_currency', $row)
) {
$url = CRM_Report_Utils_Report::getNextUrl('contribute/detail',
- 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'],
+ 'reset=1&force=1&id_op=eq&id_value=' . $row['civicrm_contact_id'] . "¤cy_value=" . $row['civicrm_contribution_currency'],
$this->_absoluteUrl, $this->_id, $this->_drilldownReport
);
$rows[$rowNum]['civicrm_contact_display_name_link'] = $url;
'required' => TRUE,
'type' => CRM_Utils_Type::T_MONEY,
),
+ 'currency' =>
+ array(
+ 'required' => TRUE,
+ 'no_display' => TRUE,
+ ),
'frequency_unit' =>
array('title' => ts('Frequency Unit'),
),
array('title' => ts('Pledged Amount'),
'operatorType' => CRM_Report_Form::OP_INT,
),
+ 'currency' =>
+ array('title' => 'Currency',
+ 'default' => NULL,
+ 'type' => CRM_Utils_Type::T_STRING,
+ ),
'sid' =>
array(
'name' => 'status_id',
function groupBy() {
parent::groupBy();
if (empty($this->_groupBy) && $this->_totalPaid) {
- $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_pledge']}.id " ;
+ $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_pledge']}.id, {$this->_aliases['civicrm_pledge']}.currency" ;
}
}
function from() {
$statistics = parent::statistics($rows);
if (!$this->_having) {
+ $totalAmount = $average = array();
+ $count = 0;
$select = "
SELECT COUNT({$this->_aliases['civicrm_pledge']}.amount ) as count,
SUM({$this->_aliases['civicrm_pledge']}.amount ) as amount,
- ROUND(AVG({$this->_aliases['civicrm_pledge']}.amount), 2) as avg
+ ROUND(AVG({$this->_aliases['civicrm_pledge']}.amount), 2) as avg,
+ {$this->_aliases['civicrm_pledge']}.currency as currency
";
- $sql = "{$select} {$this->_from} {$this->_where}";
+ $group = "\nGROUP BY {$this->_aliases['civicrm_pledge']}.currency";
+ $sql = "{$select} {$this->_from} {$this->_where} {$group}";
$dao = CRM_Core_DAO::executeQuery($sql);
- if ($dao->fetch()) {
- $statistics['counts']['amount'] = array(
- 'value' => $dao->amount,
- 'title' => 'Total Pledged',
- 'type' => CRM_Utils_Type::T_MONEY,
- );
- $statistics['counts']['count '] = array(
- 'value' => $dao->count,
- 'title' => 'Total No Pledges',
- );
- $statistics['counts']['avg '] = array(
- 'value' => $dao->avg,
- 'title' => 'Average',
- 'type' => CRM_Utils_Type::T_MONEY,
- );
+ while ($dao->fetch()) {
+ $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency)."(".$dao->count.")";
+ $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency);
+ $count += $dao->count;
}
+
+ $statistics['counts']['amount'] = array(
+ 'title' => ts('Total Pledged (Number of Pledge)'),
+ 'value' => implode(', ', $totalAmount),
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
+ $statistics['counts']['count'] = array(
+ 'title' => ts('Total No Pledges'),
+ 'value' => $count,
+ );
+ $statistics['counts']['avg'] = array(
+ 'title' => ts('Average'),
+ 'value' => implode(', ', $average),
+ 'type' => CRM_Utils_Type::T_STRING,
+ );
}
return $statistics;
}
'required' => TRUE,
'type' => CRM_Utils_Type::T_MONEY,
),
+ 'currency' =>
+ array(
+ 'required' => TRUE,
+ 'no_display' => TRUE,
+ ),
'status_id' =>
array('title' => ts('Status'),
),
array(
'title' => 'Pledge Made',
'operatorType' => CRM_Report_Form::OP_DATE,
+ ),
+ 'currency' =>
+ array('title' => 'Currency',
+ 'default' => NULL,
+ 'type' => CRM_Utils_Type::T_STRING,
),
'financial_type_id' =>
array( 'title' => ts('Financial Type'),
);
$this->_tagFilter = TRUE;
+ $this->_currencyColumn = 'civicrm_pledge_currency';
parent::__construct();
}
function groupBy() {
$this->_groupBy = "
GROUP BY {$this->_aliases['civicrm_pledge']}.contact_id,
- {$this->_aliases['civicrm_pledge']}.id";
+ {$this->_aliases['civicrm_pledge']}.id,
+ {$this->_aliases['civicrm_pledge']}.currency";
}
function orderBy() {
{/if}
{/if}
{elseif $header.type eq 1024}
- <span class="nowrap">{$row.$field|crmMoney}</span>
+ {if $currencyColumn}
+ <span class="nowrap">{$row.$field|crmMoney:$row.$currencyColumn}</span>
+ {else}
+ <span class="nowrap">{$row.$field|crmMoney}</span>
+ {/if}
{else}
{$row.$field}
{/if}
<td>
{if $row.type eq 1024}
{$row.value|crmMoney}
+ {elseif $row.type eq 2}
+ {$row.value}
{else}
{$row.value|crmNumberFormat}
{/if}
</tr>
{/foreach}
</table>
-{/if}
\ No newline at end of file
+{/if}