From 549477a7ad30c3c05c87cb176cbb9efc7f72b426 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 7 Jan 2014 10:32:34 +0100 Subject: [PATCH] [ADDED] User overview in admin dashboard * Total users * Locked users * Admin users * No Fees users Thanks @daygle for the suggestion! Fixes #1277 once merged --- public/include/classes/base.class.php | 26 +++++++++++++++++++ public/include/pages/admin/dashboard.inc.php | 9 +++++++ .../mpos/admin/dashboard/default.tpl | 23 ++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/public/include/classes/base.class.php b/public/include/classes/base.class.php index 3afba032..9d6bdf48 100644 --- a/public/include/classes/base.class.php +++ b/public/include/classes/base.class.php @@ -115,6 +115,32 @@ class Base { } } + /** + * Fetch count of all entries in table + * @param none + * @param data mixed Count or false + **/ + public function getCount() { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare("SELECT COUNT(id) AS count FROM $this->table"); + if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_object()->count; + return $this->sqlError(); + } + + /** + * Fetch count of all entries in table filtered by a column/value + * @param none + * @param data mixed Count or false + **/ + public function getCountFiltered($column='id', $value=NULL, $type='i') { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare("SELECT COUNT(id) AS count FROM $this->table WHERE $column = ?"); + if ($this->checkStmt($stmt) && $stmt->bind_param($type, $value) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_object()->count; + return $this->sqlError(); + } + /** * Fetch all entries as an assoc array from a table * This should, in general, not be used but sometimes it's just easier diff --git a/public/include/pages/admin/dashboard.inc.php b/public/include/pages/admin/dashboard.inc.php index af32639a..53284c1c 100644 --- a/public/include/pages/admin/dashboard.inc.php +++ b/public/include/pages/admin/dashboard.inc.php @@ -36,6 +36,15 @@ foreach ($aCrons as $strCron) { $smarty->assign('CRON_ERROR', $cron_errors); $smarty->assign('CRON_DISABLED', $cron_disabled); +// Fetch user information +$aUserInfo = array( + 'total' => $user->getCount(), + 'locked' => $user->getCountFiltered('is_locked', 1), + 'admins' => $user->getCountFiltered('is_admin', 1), + 'nofees' => $user->getCountFiltered('no_fees', 1) +); +$smarty->assign('USER_INFO', $aUserInfo); + // Wallet status $smarty->assign('WALLET_ERROR', $aGetInfo['errors']); diff --git a/public/templates/mpos/admin/dashboard/default.tpl b/public/templates/mpos/admin/dashboard/default.tpl index 2ac4b0a4..dc216a57 100644 --- a/public/templates/mpos/admin/dashboard/default.tpl +++ b/public/templates/mpos/admin/dashboard/default.tpl @@ -34,6 +34,29 @@ + +
+

Users

+ + + + + + + + + + + + + + + + + +
TotalLockedAdminsNo Fees
{$USER_INFO.total}{$USER_INFO.locked}{$USER_INFO.admins}{$USER_INFO.nofees}
+
+

MPOS Status