From 20305026e890c626b5e2fd7607311de3fe3e7f13 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 12 Jan 2014 09:05:59 +0100 Subject: [PATCH] [ADDED] User login overview to admin dashboard Fixes #1374 once merged --- public/include/classes/base.class.php | 4 +-- public/include/pages/admin/dashboard.inc.php | 10 ++++++++ .../mpos/admin/dashboard/default.tpl | 1 + .../templates/mpos/admin/dashboard/logins.tpl | 25 +++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 public/templates/mpos/admin/dashboard/logins.tpl diff --git a/public/include/classes/base.class.php b/public/include/classes/base.class.php index a2f8c7e1..85b43d57 100644 --- a/public/include/classes/base.class.php +++ b/public/include/classes/base.class.php @@ -133,9 +133,9 @@ class Base { * @param none * @param data mixed Count or false **/ - public function getCountFiltered($column='id', $value=NULL, $type='i') { + public function getCountFiltered($column='id', $value=NULL, $type='i', $operator = '=') { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare("SELECT COUNT(id) AS count FROM $this->table WHERE $column = ?"); + $stmt = $this->mysqli->prepare("SELECT COUNT(id) AS count FROM $this->table WHERE $column $operator ?"); if ($this->checkStmt($stmt) && $stmt->bind_param($type, $value) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->count; return $this->sqlError(); diff --git a/public/include/pages/admin/dashboard.inc.php b/public/include/pages/admin/dashboard.inc.php index 35121969..85e7f35f 100644 --- a/public/include/pages/admin/dashboard.inc.php +++ b/public/include/pages/admin/dashboard.inc.php @@ -46,6 +46,16 @@ $aUserInfo = array( ); $smarty->assign('USER_INFO', $aUserInfo); +// Fetch login information +$aLoginInfo = array( + '24hours' => $user->getCountFiltered('last_login', time() - 3600, 'i', '>='), + '7days' => $user->getCountFiltered('last_login', (time() - (3600 * 7)), 'i', '>='), + '1month' => $user->getCountFiltered('last_login', (time() - (3600 * 7 * 4)), 'i', '>='), + '6month' => $user->getCountFiltered('last_login', (time() - (3600 * 7 * 4 * 6)), 'i', '>='), + '1year' => $user->getCountFiltered('last_login', (time() - (3600 * 365)), 'i', '>=') +); +$smarty->assign('USER_LOGINS', $aLoginInfo); + // Fetch invitation information if (!$setting->getValue('disable_invitations')) { $aInvitationInfo = array( diff --git a/public/templates/mpos/admin/dashboard/default.tpl b/public/templates/mpos/admin/dashboard/default.tpl index 89237007..36bfa757 100644 --- a/public/templates/mpos/admin/dashboard/default.tpl +++ b/public/templates/mpos/admin/dashboard/default.tpl @@ -3,4 +3,5 @@ {include file="admin/dashboard/users.tpl"} {include file="admin/dashboard/status.tpl"} {if $GLOBAL.config.disable_invitations|default:"0" == 0}{include file="admin/dashboard/invitations.tpl"}{/if} +{include file="admin/dashboard/logins.tpl"} {/nocache} diff --git a/public/templates/mpos/admin/dashboard/logins.tpl b/public/templates/mpos/admin/dashboard/logins.tpl new file mode 100644 index 00000000..85c5a469 --- /dev/null +++ b/public/templates/mpos/admin/dashboard/logins.tpl @@ -0,0 +1,25 @@ +{nocache} +
+

Logins

+ + + + + + + + + + + + + + + + + + + +
24 hours7 days1 month6 months1 year
{$USER_LOGINS.24hours}{$USER_LOGINS.7days}{$USER_LOGINS.1month}{$USER_LOGINS.6month}{$USER_LOGINS.1year}
+
+{/nocache}