Skip to content
Snippets Groups Projects
Verified Commit 62079bb7 authored by Kevin Cristiano's avatar Kevin Cristiano :earth_americas:
Browse files

Fix Fatal errors in 5.63+ update version

parent a31cb6e9
No related branches found
No related tags found
No related merge requests found
......@@ -457,7 +457,7 @@ class CRM_Additionalreports_Form_Report_BookkeepingExtra extends CRM_Report_Form
ON fitem.id = {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id
LEFT JOIN civicrm_financial_account {$this->_aliases['civicrm_financial_account']}_credit_2
ON fitem.financial_account_id = {$this->_aliases['civicrm_financial_account']}_credit_2.id
LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
LEFT JOIN civicrm_address {$this->_aliases['civicrm_address']}
ON {$this->_aliases['civicrm_address']}.contact_id = {$this->_aliases['civicrm_contact']}.id AND {$this->_aliases['civicrm_address']}.is_primary = 1
LEFT JOIN civicrm_line_item {$this->_aliases['civicrm_line_item']}
ON fitem.entity_id = {$this->_aliases['civicrm_line_item']}.id AND fitem.entity_table = 'civicrm_line_item' ";
......@@ -563,50 +563,49 @@ class CRM_Additionalreports_Form_Report_BookkeepingExtra extends CRM_Report_Form
*/
public function statistics(&$rows) {
$statistics = parent::statistics($rows);
$tempTableName = CRM_Core_DAO::createTempTableName('civicrm_contribution');
$financialSelect = "CASE WHEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.entity_id IS NOT NULL
THEN {$this->_aliases['civicrm_entity_financial_trxn']}_item.amount
ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount
END as amount";
$this->_selectClauses = array(
$this->_selectClauses = [
"{$this->_aliases['civicrm_contribution']}.id",
"{$this->_aliases['civicrm_entity_financial_trxn']}.id as trxnID",
"{$this->_aliases['civicrm_contribution']}.currency",
$financialSelect,
);
];
$select = "SELECT " . implode(', ', $this->_selectClauses);
$this->groupBy();
$tempQuery = "CREATE TEMPORARY TABLE {$tempTableName} CHARACTER SET utf8 COLLATE utf8_unicode_ci AS
{$select} {$this->_from} {$this->_where} {$this->_groupBy} ";
CRM_Core_DAO::executeQuery($tempQuery);
$tempTableName = $this->createTemporaryTable('tempTable', "
{$select} {$this->_from} {$this->_where} {$this->_groupBy} ");
$sql = "SELECT COUNT(trxnID) as count, SUM(amount) as amount, currency
FROM {$tempTableName}
GROUP BY currency";
$dao = CRM_Core_DAO::executeQuery($sql);
$amount = $avg = array();
$amount = $avg = [];
while ($dao->fetch()) {
$amount[] = CRM_Utils_Money::format($dao->amount, $dao->currency);
$avg[] = CRM_Utils_Money::format(round(($dao->amount /
$dao->count), 2), $dao->currency);
}
$statistics['counts']['amount'] = array(
$statistics['counts']['amount'] = [
'value' => implode(', ', $amount),
'title' => ts('Total Amount'),
'type' => CRM_Utils_Type::T_STRING,
);
$statistics['counts']['avg'] = array(
];
$statistics['counts']['avg'] = [
'value' => implode(', ', $avg),
'title' => ts('Average'),
'type' => CRM_Utils_Type::T_STRING,
);
];
return $statistics;
}
/**
* Alter display of rows.
*
......
......@@ -15,12 +15,12 @@
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2016-11-02</releaseDate>
<version>1.0</version>
<version>1.0.1</version>
<develStage>beta</develStage>
<compatibility>
<ver>4.7</ver>
<ver>5.63</ver>
</compatibility>
<comments>This is a new module</comments>
<comments>Additional Fields for the bookkeeping Report</comments>
<civix>
<namespace>CRM/Additionalreports</namespace>
</civix>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment