From 370b3475b993db73923082d6f69c6d9226cddccb Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 25 Jun 2013 10:57:56 +0200 Subject: [PATCH 1/2] Adding transactions admin panel * Lists all transactions for all users Addresses #251 --- public/include/classes/transaction.class.php | 25 ++++ .../include/pages/admin/transactions.inc.php | 11 ++ .../mmcFE/admin/transactions/default.tpl | 139 ++++++++++++++++++ public/templates/mmcFE/global/navigation.tpl | 1 + 4 files changed, 176 insertions(+) create mode 100644 public/include/pages/admin/transactions.inc.php create mode 100644 public/templates/mmcFE/admin/transactions/default.tpl diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 038a30c5..a9c665c6 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -108,6 +108,31 @@ class Transaction { return false; } + /** + * Fetch all transactions for all users + * @param none + * @return mixed array or false + **/ + public function getAllTransactions() { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare(" + SELECT + t.id AS id, + t.type AS type, + t.amount AS amount, + t.coin_address AS coin_address, + t.timestamp AS timestamp, + b.height AS height, + b.confirmations AS confirmations + FROM transactions AS t + LEFT JOIN blocks AS b ON t.block_id = b.id + ORDER BY id DESC"); + if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_all(MYSQLI_ASSOC); + $this->debug->append('Unable to fetch transactions'); + return false; + } + private function checkStmt($bState) { if ($bState ===! true) { $this->debug->append("Failed to prepare statement: " . $this->mysqli->error); diff --git a/public/include/pages/admin/transactions.inc.php b/public/include/pages/admin/transactions.inc.php new file mode 100644 index 00000000..93d4530d --- /dev/null +++ b/public/include/pages/admin/transactions.inc.php @@ -0,0 +1,11 @@ +isAuthenticated()) { + $aTransactions = $transaction->getAllTransactions(); + if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg'); + $smarty->assign('TRANSACTIONS', $aTransactions); + $smarty->assign('CONTENT', 'default.tpl'); +} +?> diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl new file mode 100644 index 00000000..c76e9fae --- /dev/null +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -0,0 +1,139 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Transaction Log" BUTTONS=array(Confirmed,Unconfirmed,Orphan)} +
+
+ {include file="global/pagination.tpl"} + + + + + + + + + + + + +{section transaction $TRANSACTIONS} + {if ( + (($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus')and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations) + or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations) + or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations) + or $TRANSACTIONS[transaction].type == 'Credit_PPS' + or $TRANSACTIONS[transaction].type == 'Fee_PPS' + or $TRANSACTIONS[transaction].type == 'Donation_PPS' + or $TRANSACTIONS[transaction].type == 'Debit_AP' + or $TRANSACTIONS[transaction].type == 'Debit_MP' + or $TRANSACTIONS[transaction].type == 'TXFee' + )} + + + + + + + + + {/if} +{/section} + +
TX #DateTX TypePayment AddressBlock #Amount
{$TRANSACTIONS[transaction].id}{$TRANSACTIONS[transaction].timestamp}{$TRANSACTIONS[transaction].type}{$TRANSACTIONS[transaction].coin_address}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}{$TRANSACTIONS[transaction].amount}
+

+ + Credit_AP = Auto Threshold Payment, Credit_MP = Manual Payment, Donation = Donation, Fee = Pool Fees (if applicable) + +

+
+
+
+
+ {include file="global/pagination.tpl" ID=2} + + + + + + + + + + + + +{section transaction $TRANSACTIONS} + {if ( + ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations + or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations) + or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations) + )} + + + + + + + + + {if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'} + {assign var="credits" value="`$credits+$TRANSACTIONS[transaction].amount`"} + {else} + {assign var="debits" value="`$debits+$TRANSACTIONS[transaction].amount`"} + {/if} + {/if} +{/section} + + + + + +
TX #DateTX TypePayment AddressBlock #Amount
{$TRANSACTIONS[transaction].id}{$TRANSACTIONS[transaction].timestamp}{$TRANSACTIONS[transaction].type}{$TRANSACTIONS[transaction].coin_address}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}{$TRANSACTIONS[transaction].amount}
Unconfirmed Totals:{$credits|default - $debits|default}
+

Listed are your estimated rewards and donations/fees for all blocks awaiting {$GLOBAL.confirmations} confirmations.

+
+
+
+
+ {include file="global/pagination.tpl"} + + + + + + + + + + + + +{section transaction $TRANSACTIONS} + {if ( + $TRANSACTIONS[transaction].type == 'Orphan_Credit' + or $TRANSACTIONS[transaction].type == 'Orphan_Donation' + or $TRANSACTIONS[transaction].type == 'Orphan_Fee' + or $TRANSACTIONS[transaction].type == 'Orphan_Bonus' + )} + + + + + + + + + {if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'} + {assign var="orphan_credits" value="`$orphan_credits+$TRANSACTIONS[transaction].amount`"} + {else} + {assign var="orphan_debits" value="`$orphan_debits+$TRANSACTIONS[transaction].amount`"} + {/if} + {/if} +{/section} + + + + + +
TX #DateTX TypePayment AddressBlock #Amount
{$TRANSACTIONS[transaction].id}{$TRANSACTIONS[transaction].timestamp}{$TRANSACTIONS[transaction].type}{$TRANSACTIONS[transaction].coin_address}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}{$TRANSACTIONS[transaction].amount}
Orphaned Totals:{$orphan_credits|default - $orphan_debits|default}
+

Listed are your orphaned transactions for blocks not part of the main blockchain.

+
+
+{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 960ba343..234bfda2 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -15,6 +15,7 @@ From a09bd1470ec11fd7b49a135a9e9a49318b1e8ea8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 25 Jun 2013 11:39:44 +0200 Subject: [PATCH 2/2] Adding account name to all transactions Fixes #251 --- public/include/classes/transaction.class.php | 6 ++++-- public/templates/mmcFE/admin/transactions/default.tpl | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index a9c665c6..a432b65b 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -95,7 +95,7 @@ class Transaction { b.height AS height, b.confirmations AS confirmations FROM transactions AS t - LEFT JOIN blocks AS b ON t.block_id = b.id + LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE t.account_id = ? ORDER BY id DESC"); if ($this->checkStmt($stmt)) { @@ -118,6 +118,7 @@ class Transaction { $stmt = $this->mysqli->prepare(" SELECT t.id AS id, + a.username as username, t.type AS type, t.amount AS amount, t.coin_address AS coin_address, @@ -125,7 +126,8 @@ class Transaction { b.height AS height, b.confirmations AS confirmations FROM transactions AS t - LEFT JOIN blocks AS b ON t.block_id = b.id + LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id + LEFT JOIN " . $this->user->getTableName() . " AS a ON t.account_id = a.id ORDER BY id DESC"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index c76e9fae..c6497246 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -6,6 +6,7 @@ TX # + Account Date TX Type Payment Address @@ -28,6 +29,7 @@ )} {$TRANSACTIONS[transaction].id} + {$TRANSACTIONS[transaction].username} {$TRANSACTIONS[transaction].timestamp} {$TRANSACTIONS[transaction].type} {$TRANSACTIONS[transaction].coin_address} @@ -52,6 +54,7 @@ TX # + Account Date TX Type Payment Address @@ -68,6 +71,7 @@ )} {$TRANSACTIONS[transaction].id} + {$TRANSACTIONS[transaction].username} {$TRANSACTIONS[transaction].timestamp} {$TRANSACTIONS[transaction].type} {$TRANSACTIONS[transaction].coin_address} @@ -97,6 +101,7 @@ TX # + Account Date TX Type Payment Address @@ -114,6 +119,7 @@ )} {$TRANSACTIONS[transaction].id} + {$TRANSACTIONS[transaction].username} {$TRANSACTIONS[transaction].timestamp} {$TRANSACTIONS[transaction].type} {$TRANSACTIONS[transaction].coin_address}