diff --git a/system/pages/admin/dashboard.php b/system/pages/admin/dashboard.php index 10e8dbe8..ec86249e 100644 --- a/system/pages/admin/dashboard.php +++ b/system/pages/admin/dashboard.php @@ -62,18 +62,6 @@ $query = $db->query('SELECT count(*) as `how_much` FROM `houses`;'); $query = $query->fetch(); $total_houses = $query['how_much']; -if ($db->hasColumn('accounts', 'premium_points')) { - $points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;'); -} else { - $points = 0; -} - -if ($db->hasColumn('accounts', 'coins')) { - $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); -} else { - $coins = 0; -} - $twig->display('admin.statistics.html.twig', array( 'total_accounts' => $total_accounts, 'total_players' => $total_players, @@ -86,9 +74,23 @@ $twig->display('admin.dashboard.html.twig', array( 'closed_message' => $closed_message, 'status' => $status, 'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'), - 'points' => $points, - 'coins' => $coins, + )); + +echo '<div class="row">'; +$config['modules'] = "lastlogin,points,coins"; +if(isset($config['modules'])) + $config['modules'] = explode(",", $config['modules']); + +$twig_loader->prependPath(__DIR__ . '/modules/templates'); +foreach($config['modules'] as $box) { + $file = __DIR__ . '/modules/' . $box . '.php'; + if(file_exists($file)) { + include($file); + } +} +echo '</div>'; + function clearCache() { global $template_name; diff --git a/system/pages/admin/modules/coins.php b/system/pages/admin/modules/coins.php new file mode 100644 index 00000000..3dbc19c8 --- /dev/null +++ b/system/pages/admin/modules/coins.php @@ -0,0 +1,11 @@ +<?php + +if ($db->hasColumn('accounts', 'coins')) { + $coins = $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;'); +} else { + $coins = 0; +} + +$twig->display('coins.html.twig', array( + 'coins' => $coins +)); \ No newline at end of file diff --git a/system/pages/admin/modules/lastlogin.php b/system/pages/admin/modules/lastlogin.php new file mode 100644 index 00000000..d8d5ed52 --- /dev/null +++ b/system/pages/admin/modules/lastlogin.php @@ -0,0 +1,11 @@ +<?php + +if ($db->hasColumn('players', 'lastlogin')) { + $players = $db->query('SELECT `id`, `name`,`level`,`lastlogin` FROM `players` ORDER BY `lastlogin` DESC LIMIT 10;'); +} else { + $players = 0; +} + +$twig->display('lastlogin.html.twig', array( + 'players' => $players, +)); \ No newline at end of file diff --git a/system/pages/admin/modules/points.php b/system/pages/admin/modules/points.php new file mode 100644 index 00000000..e5040f53 --- /dev/null +++ b/system/pages/admin/modules/points.php @@ -0,0 +1,10 @@ +<?php +if ($db->hasColumn('accounts', 'premium_points')) { + $points = $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;'); +} else { + $points = 0; +} + +$twig->display('points.html.twig', array( + 'points' => $points, +)); \ No newline at end of file diff --git a/system/pages/admin/modules/templates/coins.html.twig b/system/pages/admin/modules/templates/coins.html.twig new file mode 100644 index 00000000..e5183443 --- /dev/null +++ b/system/pages/admin/modules/templates/coins.html.twig @@ -0,0 +1,29 @@ +{% if coins is iterable %} + <div class="col-md-3"> + <div class="box"> + <div class="box-header"> + <h3 class="box-title">Top 10 - Most coins</h3> + </div> + <div class="box-body no-padding"> + <table class="table table-condensed"> + <tbody> + <tr> + <th>#</th> + <th>Account {{ account_type }}</th> + <th>Tibia coins</th> + </tr> + {% set i = 0 %} + {% for result in coins %} + {% set i = i + 1 %} + <tr> + <td>{{ i }}</td> + <td>{{ result.name }}</td> + <td>{{ result.coins }}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + </div> +{% endif %} \ No newline at end of file diff --git a/system/pages/admin/modules/templates/lastlogin.html.twig b/system/pages/admin/modules/templates/lastlogin.html.twig new file mode 100644 index 00000000..62d6fbc5 --- /dev/null +++ b/system/pages/admin/modules/templates/lastlogin.html.twig @@ -0,0 +1,29 @@ +{% if players is iterable %} + <div class="col-md-3"> + <div class="box"> + <div class="box-header"> + <h3 class="box-title">Last 10 Logins</h3> + </div> + <div class="box-body no-padding"> + <table class="table table-condensed"> + <tbody> + <tr> + <th>#</th> + <th>Player</th> + <th>Login Date</th> + </tr> + {% set i = 0 %} + {% for result in players %} + {% set i = i + 1 %} + <tr> + <td>{{ i }}</td> + <td>{{ result.name }}</td> + <td>{{ result.lastlogin|date("M d Y, H:i:s") }}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + </div> +{% endif %} \ No newline at end of file diff --git a/system/pages/admin/modules/templates/points.html.twig b/system/pages/admin/modules/templates/points.html.twig new file mode 100644 index 00000000..acdcd390 --- /dev/null +++ b/system/pages/admin/modules/templates/points.html.twig @@ -0,0 +1,29 @@ +{% if points is iterable %} + <div class="col-md-3"> + <div class="box"> + <div class="box-header"> + <h3 class="box-title">Top 10 - Most premium points</h3> + </div> + <div class="box-body no-padding"> + <table class="table table-condensed"> + <tbody> + <tr> + <th>#</th> + <th>Account {{ account_type }}</th> + <th>Premium points</th> + </tr> + {% set i = 0 %} + {% for result in points %} + {% set i = i + 1 %} + <tr> + <td>{{ i }}</td> + <td>{{ result.name }}</td> + <td>{{ result.premium_points }}</td> + </tr> + {% endfor %} + </tbody> + </table> + </div> + </div> + </div> +{% endif %} \ No newline at end of file