From d4cf6d6b909a70a9dbe06311535aacc6d844fa75 Mon Sep 17 00:00:00 2001 From: elbandi Date: Sat, 28 Dec 2013 01:49:29 +0100 Subject: [PATCH] Admin: Summary table --- core.php | 5 +++++ index.php | 8 ++++++++ templates/admin.php | 26 +++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core.php b/core.php index 27150dd..02b624f 100644 --- a/core.php +++ b/core.php @@ -225,6 +225,11 @@ function fetch_row($query) return $query->fetch_row(); } +function fetch_assoc($query) +{ + return $query->fetch_assoc(); +} + function fetch_all($query, $resulttype = MYSQLI_NUM) { if (method_exists($query, 'fetch_all')) { # Compatibility layer with PHP < 5.3 diff --git a/index.php b/index.php index 0489ec6..6006e07 100644 --- a/index.php +++ b/index.php @@ -134,6 +134,14 @@ defaultlabel: if (!isset($_SESSION['isadmin'])) { $app->view()->setData('recaptcha', recaptcha_get_html($recaptchaPub)); } + + $sql = "SELECT COUNT(*) AS num_addresses, MAX(balance) AS max_balance, SUM(balance) as sum_balance, "; + $sql .= "MAX(totalbalance) as max_totalbalance, SUM(totalbalance) as sum_totalbalance "; + $sql .= "FROM balances WHERE email <> 'SERVERBALANCE'"; + $stat_query = sql_query($sql); + $statBalance = fetch_assoc($stat_query); + + $app->view()->setData('statBalance', $statBalance); $app->view()->setData('serverbalance', number_format(getserverbalance())); $app->render('admin.php', array('title' => 'Admin')); } diff --git a/templates/admin.php b/templates/admin.php index 8c7885f..32f9068 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -35,7 +35,31 @@

Home

-

blablabla

+
+ + + + + + + + + + + + + + + + + + + + + + +
Balances
Number of addresses
Max of balances
Sum of balances
Max of Total balances
Sum of Total balances
+
-- 2.1.4