From 1d180c3e3d075436b47a90616349519e8edf9ac7 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 27 Oct 2013 02:18:49 +0100 Subject: [PATCH] [FIX] Do not include orphans in transaction summary --- public/include/classes/transaction.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 53d111e3..48e1d921 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -53,9 +53,17 @@ class Transaction extends Base { * @return data array type and total **/ public function getTransactionSummary($account_id=NULL) { - $sql = "SELECT SUM(t.amount) AS total, t.type AS type FROM $this->table AS t"; + $sql = " + SELECT + SUM(t.amount) AS total, t.type AS type + FROM transactions AS t + LEFT OUTER JOIN blocks AS b + ON b.id = t.block_id + WHERE b.confirmations > 0 + OR b.id IS NULL + "; if (!empty($account_id)) { - $sql .= " WHERE t.account_id = ? "; + $sql .= " AND t.account_id = ? "; $this->addParam('i', $account_id); } $sql .= " GROUP BY t.type";