[UPDATE] total user earnings, icons in invitations
This commit is contained in:
parent
8751610ed8
commit
6705f879b1
@ -100,6 +100,47 @@ class Transaction extends Base {
|
||||
return $this->sqlError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a transaction summary by user with total amounts
|
||||
* @param account_id int Account ID, NULL for all
|
||||
* @return data array type and total
|
||||
**/
|
||||
public function getTransactionSummarybyTime($account_id=NULL) {
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||
$sql = "
|
||||
SELECT
|
||||
SUM(t.amount) AS total,
|
||||
t.type AS type
|
||||
FROM transactions AS t
|
||||
LEFT OUTER JOIN blocks AS b
|
||||
ON b.id = t.block_id
|
||||
WHERE ( b.confirmations > 0 OR b.id IS NULL )";
|
||||
if (!empty($account_id)) {
|
||||
$sql .= " AND t.account_id = ? ";
|
||||
$this->addParam('i', $account_id);
|
||||
}
|
||||
$sql .= " GROUP BY t.type";
|
||||
$stmt = $this->mysqli->prepare($sql);
|
||||
if (!empty($account_id)) {
|
||||
if (!($this->checkStmt($stmt) && call_user_func_array( array($stmt, 'bind_param'), $this->getParam()) && $stmt->execute()))
|
||||
return false;
|
||||
$result = $stmt->get_result();
|
||||
} else {
|
||||
if (!($this->checkStmt($stmt) && $stmt->execute()))
|
||||
return false;
|
||||
$result = $stmt->get_result();
|
||||
}
|
||||
if ($result) {
|
||||
$aData = NULL;
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$aData[$row['type']] = $row['total'];
|
||||
}
|
||||
// Cache data for a while, query takes long on many rows
|
||||
return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData, 60);
|
||||
}
|
||||
return $this->sqlError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all transactions from start for account_id
|
||||
* @param start int Starting point, id of transaction
|
||||
|
||||
22
public/include/pages/account/earnings.inc.php
Normal file
22
public/include/pages/account/earnings.inc.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
|
||||
// Check user to ensure they are admin
|
||||
if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
|
||||
header("HTTP/1.1 404 Page not found");
|
||||
die("404 Page not found");
|
||||
}
|
||||
|
||||
if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
||||
$iLimit = 30;
|
||||
$debug->append('No cached version available, fetching from backend', 3);
|
||||
if (!$setting->getValue('disable_transactionsummary')) {
|
||||
$aTransactionSummary = $transaction->getTransactionSummarybyTime($_SESSION['USERDATA']['id']);
|
||||
$smarty->assign('SUMMARY', $aTransactionSummary);
|
||||
}
|
||||
} else {
|
||||
$debug->append('Using cached page', 3);
|
||||
}
|
||||
|
||||
$smarty->assign('CONTENT', 'default.tpl');
|
||||
?>
|
||||
31
public/templates/bootstrap/account/earnings/default.tpl
Executable file
31
public/templates/bootstrap/account/earnings/default.tpl
Executable file
@ -0,0 +1,31 @@
|
||||
{if $DISABLE_TRANSACTIONSUMMARY|default:"0" != 1}
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<i class="fa fa-money fa-fw"></i> Total Earning Stats
|
||||
</div>
|
||||
<div class="panel-body no-padding">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
{foreach $SUMMARY as $type=>$total}
|
||||
<th>{$type}</th>
|
||||
{/foreach}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
{foreach $SUMMARY as $type=>$total}
|
||||
<td class="right">{$total|number_format:"8"}</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@ -1,9 +1,6 @@
|
||||
{nocache}
|
||||
|
||||
{include file="admin/dashboard/mpos.tpl"}
|
||||
|
||||
{include file="admin/dashboard/user.tpl"}
|
||||
|
||||
<div class="row">
|
||||
{include file="admin/dashboard/registrations.tpl"}
|
||||
{if $GLOBAL.config.disable_invitations|default:"0" == 0}
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
<td>{$LASTREGISTEREDUSERS[user].mposuser}</td>
|
||||
<td>{$LASTREGISTEREDUSERS[user].email}</td>
|
||||
<td>{$LASTREGISTEREDUSERS[user].signup_timestamp|date_format:"%d/%m %H:%M:%S"}</td>
|
||||
<td>{if !$LASTREGISTEREDUSERS[user].inviter}<i class="icon-cancel">{else}<i class="icon-ok">{/if}</td>
|
||||
<td align="center">{if !$LASTREGISTEREDUSERS[user].inviter}<i class="fa fa-times fa-fw">{else}<i class="fa fa-check fa-fw">{/if}</td>
|
||||
<td><a href="{$smarty.server.SCRIPT_NAME}?page=admin&action=user&do=query&filter[account]={$LASTREGISTEREDUSERS[user].inviter}">{$LASTREGISTEREDUSERS[user].inviter}</a></td>
|
||||
</tr>
|
||||
{/section}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=edit"><i class="fa fa-edit fa-fw"></i> Edit Account</a></li>
|
||||
<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=workers"><i class="fa fa-desktop fa-fw"></i> My Workers</a></li>
|
||||
<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=transactions"><i class="fa fa-credit-card fa-fw"></i> Transactions</a></li>
|
||||
<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=earnings"><i class="fa fa-money fa-fw"></i> Earnings</a></li>
|
||||
{if !$GLOBAL.config.disable_notifications}<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=notifications"><i class="fa fa-bullhorn fa-fw"></i> Notifications</a></li>{/if}
|
||||
{if !$GLOBAL.config.disable_invitations}<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=invitations"><i class="fa fa-users fa-fw"></i> Invitations</a></li>{/if}
|
||||
<li><a href="{$smarty.server.SCRIPT_NAME}?page=account&action=qrcode"><i class="fa fa-qrcode fa-fw"></i> QR Codes</a></li>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user