[UPDATE] added top inviter, some code cleanup

This commit is contained in:
iAmShorty 2014-02-24 10:39:09 +01:00
parent 00c184d45e
commit fbdd811d7f
7 changed files with 142 additions and 80 deletions

View File

@ -133,6 +133,26 @@ class User extends Base {
return $result->fetch_all(MYSQLI_ASSOC);
}
}
/**
* Fetch Top 10 Inviters
* @param none
* @return data array All users with db columns as array fields
**/
public function getTopInviters($limit=10) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("
SELECT COUNT(i.account_id) as invitationcount,a.id,a.username,a.email,
(SELECT COUNT(account_id) FROM invitations WHERE account_id = i.account_id AND is_activated = 1 GROUP BY account_id) AS activated
FROM invitations AS i
LEFT JOIN " . $this->getTableName() . " AS a
ON a.id = i.account_id
GROUP BY i.account_id
LIMIT ?");
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $limit) && $stmt->execute() && $result = $stmt->get_result()) {
return $result->fetch_all(MYSQLI_ASSOC);
}
}
/**
* Check user login

View File

@ -68,8 +68,13 @@ $smarty->assign('USER_REGISTRATIONS', $aRegistrationInfo);
$aLastRegisteredUsers = $user->getLastRegisteredUsers();
$smarty->assign("LASTREGISTEREDUSERS", $aLastRegisteredUsers);
// Fetch invitation information
// Fetching invitation Informations
if (!$setting->getValue('disable_invitations')) {
// get last 10 Inviters
$aTopInviters = $user->getTopInviters();
$smarty->assign("TOPINVITERS", $aTopInviters);
// Fetch global invitation information
$aInvitationInfo = array(
'total' => $invitation->getCount(),
'activated' => $invitation->getCountFiltered('is_activated', 1),

View File

@ -2,4 +2,7 @@
{include file="admin/dashboard/mpos.tpl"}
{include file="admin/dashboard/user.tpl"}
{include file="admin/dashboard/registrations.tpl"}
{if $GLOBAL.config.disable_invitations|default:"0" == 0}
{include file="admin/dashboard/invitation.tpl"}
{/if}
{/nocache}

View File

@ -0,0 +1,53 @@
{nocache}
<article class="module width_full">
<header><h3>Invitations</h3></header>
<article class="module width_quarter">
<header><h3>Overview</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">Total</th>
<th align="center">Activated</th>
<th align="center">Outstanding</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$INVITATION_INFO.total}</td>
<td align="center">{$INVITATION_INFO.activated}</td>
<td align="center">{$INVITATION_INFO.outstanding}</td>
</tr>
</tbody>
</table>
</article>
<article class="module width_3_quarter" style="min-height: 150px">
<header><h3>Top 10 Inviters</h3></header>
<div>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th>Username</th>
<th align="left">eMail</th>
<th align="center">Amount</th>
<th align="center">Outstanding</th>
<th align="center">Activated</th>
</tr>
</thead>
<tbody>
{section inviter $TOPINVITERS}
<tr class="{cycle values="odd,even"}">
<td align="left">{$TOPINVITERS[inviter].username|escape}</td>
<td align="left">{$TOPINVITERS[inviter].email}</td>
<td align="center">{$TOPINVITERS[inviter].invitationcount}</td>
<td align="center">{($TOPINVITERS[inviter].invitationcount - $TOPINVITERS[inviter].activated)|number_format:"0"}</td>
<td align="center">{$TOPINVITERS[inviter].activated}</td>
</tr>
{/section}
</tbody>
</table>
</article>
</article>
{/nocache}

View File

@ -25,7 +25,7 @@
</table>
</article>
<article class="module width_3_quarter" style="min-height: 350px">
<article class="module width_3_quarter" style="min-height: 150px">
<header><h3>Last 10 registered Users</h3></header>
<div>
<table class="tablesorter" cellspacing="0">
@ -46,11 +46,12 @@
<td>{$LASTREGISTEREDUSERS[user].mposuser}</td>
<td align="left">{$LASTREGISTEREDUSERS[user].email}</td>
<td align="center">{$LASTREGISTEREDUSERS[user].signup_timestamp|date_format:"%d/%m %H:%M:%S"}</td>
<td align="center">{if !$LASTREGISTEREDUSERS[user].inviter}NO{else}YES{/if}</td>
<td align="center">{$LASTREGISTEREDUSERS[user].inviter}</td>
<td align="center">{if !$LASTREGISTEREDUSERS[user].inviter}<i class="icon-cancel">{else}<i class="icon-ok">{/if}</td>
<td align="center"><a href="{$smarty.server.SCRIPT_NAME}?page=admin&action=user&do=query&filter[account]={$LASTREGISTEREDUSERS[user].inviter}">{$LASTREGISTEREDUSERS[user].inviter}</a></td>
</tr>
{/section}
</tbody>
</table>
</article>
</article>

View File

@ -1,74 +1,54 @@
{nocache}
<article class="module width_full">
<header><h3>User Informations</h3></header>
<header><h3>User Information</h3></header>
<article class="module width_quarter">
<header><h3>Users</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">Total</th>
<th align="center">Active</th>
<th align="center">Locked</th>
<th align="center">Admins</th>
<th align="center">No Fees</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$USER_INFO.total}</td>
<td align="center">{$USER_INFO.active}</td>
<td align="center">{$USER_INFO.locked}</td>
<td align="center">{$USER_INFO.admins}</td>
<td align="center">{$USER_INFO.nofees}</td>
</tr>
</tbody>
</table>
</article>
{if $GLOBAL.config.disable_invitations|default:"0" == 0}
<article class="module width_quarter">
<header><h3>Invitations</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">Total</th>
<th align="center">Activated</th>
<th align="center">Outstanding</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$INVITATION_INFO.total}</td>
<td align="center">{$INVITATION_INFO.activated}</td>
<td align="center">{$INVITATION_INFO.outstanding}</td>
</tr>
</tbody>
</table>
</article>
{/if}
<article class="module width_quarter">
<header><h3>Logins</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">24 hours</th>
<th align="center">7 days</th>
<th align="center">1 month</th>
<th align="center">6 months</th>
<th align="center">1 year</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$USER_LOGINS.24hours}</td>
<td align="center">{$USER_LOGINS.7days}</td>
<td align="center">{$USER_LOGINS.1month}</td>
<td align="center">{$USER_LOGINS.6month}</td>
<td align="center">{$USER_LOGINS.1year}</td>
</tr>
</tbody>
</table>
</article>
<article class="module width_quarter">
<header><h3>Users</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">Total</th>
<th align="center">Active</th>
<th align="center">Locked</th>
<th align="center">Admins</th>
<th align="center">No Fees</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$USER_INFO.total}</td>
<td align="center">{$USER_INFO.active}</td>
<td align="center">{$USER_INFO.locked}</td>
<td align="center">{$USER_INFO.admins}</td>
<td align="center">{$USER_INFO.nofees}</td>
</tr>
</tbody>
</table>
</article>
<article class="module width_quarter">
<header><h3>Logins</h3></header>
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th align="center">24 hours</th>
<th align="center">7 days</th>
<th align="center">1 month</th>
<th align="center">6 months</th>
<th align="center">1 year</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">{$USER_LOGINS.24hours}</td>
<td align="center">{$USER_LOGINS.7days}</td>
<td align="center">{$USER_LOGINS.1month}</td>
<td align="center">{$USER_LOGINS.6month}</td>
<td align="center">{$USER_LOGINS.1year}</td>
</tr>
</tbody>
</table>
</article>
</article>
{/nocache}

View File

@ -86,17 +86,17 @@
<th align="center">ID</th>
<th align="left">Username</th>
<th align="left">E-Mail</th>
<th align="right">Shares&nbsp;&nbsp;</th>
<th align="right">Hashrate&nbsp;&nbsp;</th>
<th align="right" style="padding-right:10px">Shares</th>
<th align="right" style="padding-right:10px">Hashrate</th>
{if $GLOBAL.config.payout_system != 'pps'}
<th align="right">Est. Donation&nbsp;&nbsp;</th>
<th align="right">Est. Payout&nbsp;&nbsp;&nbsp;</th>
<th align="right" style="padding-right:10px">Est. Donation</th>
<th align="right" style="padding-right:10px">Est. Payout</th>
{else}
<th align="right" colspan="2">Est. 24 Hours&nbsp;&nbsp;&nbsp;</th>
<th align="right" colspan="2" style="padding-right:10px">Est. 24 Hours</th>
{/if}
<th align="right">Balance&nbsp;&nbsp;&nbsp;</th>
<th align="right">Reg. Date&nbsp;&nbsp;&nbsp;</th>
<th align="right">Last Login&nbsp;&nbsp;&nbsp;</th>
<th align="right" style="padding-right:10px">Balance</th>
<th align="right" style="padding-right:10px">Reg. Date</th>
<th align="right" style="padding-right:10px">Last Login</th>
<th align="center">Admin</th>
<th align="center">Locked</th>
<th align="center">No Fees</th>