admin: rework earnings and payments totals

show number of records and query limit in table footer
set a dynamic css min height
increase a bit table limits when the query is filtered for a wallet
This commit is contained in:
Tanguy Pruvot 2016-06-03 10:09:19 +02:00
parent 5472fca192
commit 911749ae53
4 changed files with 72 additions and 66 deletions

View file

@ -6,21 +6,15 @@ if ($coin_id) {
$coin = getdbo('db_coins', $coin_id);
$this->pageTitle = 'Earnings - '.$coin->symbol;
}
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
?>
<div id='main_results'></div>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<script>
$(function()
{
main_refresh();
});
<script type="text/javascript">
var main_delay=60000;
var main_timeout;
@ -39,6 +33,8 @@ function main_error()
function main_refresh()
{
var url = '/site/earning_results?id=<?= $coin_id ?>';
var minh = $(window).height() - 150;
$('#main_results').css({'min-height': minh + 'px'});
clearTimeout(main_timeout);
$.get(url, '', main_ready).error(main_error);
@ -46,5 +42,6 @@ function main_refresh()
</script>
<?php
JavascriptReady("main_refresh();");

View file

@ -1,18 +1,18 @@
<?php
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
echo <<<end
<div align="right" style="margin-top: -14px; margin-bottom: 6px;">
<input class="search" type="search" data-column="all" style="width: 140px;" placeholder="Search..." />
</div>
<style type="text/css">
tr.ssrow.filtered { display: none; }
table.totals { margin-top: 8px; margin-right: 16px; }
.actions { width: 120px; text-align: right; }
table.dataGrid a.red { color: darkred; }
table.totals { margin-top: 8px; margin-left: 16px; display: inline-block; }
table.totals th { text-align: left; width: 100px; }
table.totals td { text-align: right; }
table.totals tr.red td { color: darkred; }
.page .footer { width: auto; }
</style>
end;
@ -48,14 +48,14 @@ echo <<<end
<th data-sorter="numeric">Block</th>
<th data-sorter="">Status</th>
<th data-sorter="numeric">Sent</th>
<th data-sorter=""></th>
<th data-sorter="" class="actions">Actions</th>
</tr>
</thead><tbody>
end;
$coin_id = getiparam('id');
$sqlFilter = $coin_id ? "AND coinid={$coin_id}": '';
$limit = $coin_id ? '' : 'LIMIT 1000';
$limit = $coin_id ? '' : 'LIMIT 1500';
$earnings = getdbolist('db_earnings', "status!=2 $sqlFilter ORDER BY create_time DESC $limit");
@ -90,10 +90,10 @@ foreach($earnings as $earning)
echo '<td data="'.$block->height.'">'."$block->category ($block->confirmations)</td>";
echo '<td data="'.$earning->create_time.'">'."$t1 $t2</td>";
echo "<td>
<a href='/site/clearearning?id=$earning->id'>[clear]</a>
<a href='/site/deleteearning?id=$earning->id'>[delete]</a>
</td>";
echo '<td class="actions">';
echo '<a href="/site/clearearning?id='.$earning->id.'">clear</a> ';
echo '<a class="red" href="/site/deleteearning?id='.$earning->id.'">delete</a>';
echo '</td>';
// echo "<td style='font-size: .7em'>$earning->tx</td>";
echo "</tr>";
@ -119,7 +119,12 @@ foreach($earnings as $earning)
}
}
echo "</tbody></table>";
echo '</tbody><tfoot>';
echo '<tr><th colspan="9">';
echo count($earnings).' records';
if (count($earnings) >= 1000) echo " ($limit)";
echo '</th></tr>';
echo '</tfoot></table>';
if ($coin_id) {
$coin = getdbo('db_coins', $coin_id);
@ -128,15 +133,26 @@ if ($coin_id) {
$feepct = yaamp_fee($coin->algo);
$totalfees = ($total / ((100 - $feepct) / 100.)) - $total;
$cleared = dboscalar("SELECT SUM(balance) FROM accounts WHERE coinid={$coin->id}");
echo '<div class="totals" align="right">';
echo '<table class="totals">';
echo '<tr><th>Immature</th><td>'.bitcoinvaluetoa($totalimmat)." $symbol</td></tr>";
echo '<tr><th>Total</th><td>'.bitcoinvaluetoa($total)." $symbol</td></tr>";
echo '<tr><th>Total owed</th><td>'.bitcoinvaluetoa($total)." $symbol</td></tr>";
//echo '<tr><th>Total BTC</th><td>'.bitcoinvaluetoa($total_btc)." BTC</td></tr>";
echo '<tr><th>Pool Fees '.round($feepct,1).'%</th><td>'.bitcoinvaluetoa($totalfees)." $symbol</td></tr>";
if ($coin->rpcencoding == 'POS')
echo '<tr><th>Stake</th><td>'.bitcoinvaluetoa($totalstake)." $symbol</td></tr>";
echo '<tr><th>Available</th><td>'.bitcoinvaluetoa($coin->balance)." $symbol</td></tr>";
echo '</tr></table>';
echo '<table class="totals">';
echo '<tr><th>Balance</th><td>'.bitcoinvaluetoa($coin->balance)." $symbol</td></tr>";
echo '<tr><th>Cleared</th><td>'.bitcoinvaluetoa($cleared)." $symbol</td></tr>";
$exchange = $total - $totalimmat;
echo '<tr><th title="Availabled = (Balance - Cleared - in exchange)">Available</th>';
echo '<td>'.bitcoinvaluetoa($coin->balance - $exchange - $cleared)." $symbol</td></tr>";
echo '</tr></table>';
echo '</div>';
}

View file

@ -6,21 +6,15 @@ if ($coin_id) {
$coin = getdbo('db_coins', $coin_id);
$this->pageTitle = 'Payments - '.$coin->symbol;
}
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
?>
<div id="main_results"></div>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br>
<script>
$(function()
{
main_refresh();
});
<script type="text/javascript">
var main_delay=60000;
var main_timeout;
@ -39,6 +33,8 @@ function main_error()
function main_refresh()
{
var url = '/site/payments_results?id=<?= $coin_id ?>';
var minh = $(window).height() - 150;
$('#main_results').css({'min-height': minh + 'px'});
clearTimeout(main_timeout);
$.get(url, '', main_ready).error(main_error);
@ -46,5 +42,6 @@ function main_refresh()
</script>
<?php
JavascriptReady("main_refresh();");

View file

@ -1,8 +1,5 @@
<?php
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
echo <<<end
<div align="right" style="margin-top: -14px; margin-bottom: 6px;">
<input class="search" type="search" data-column="all" style="width: 140px;" placeholder="Search..." />
@ -11,11 +8,12 @@ echo <<<end
tr.ssrow.filtered { display: none; }
.currency { width: 120px; max-width: 180px; text-align: right; }
.red { color: darkred; }
.actions { width: 120px; text-align: center; }
.actions { width: 120px; text-align: right; }
table.totals { margin-top: 8px; margin-right: 16px; }
table.totals th { text-align: left; width: 100px; }
table.totals td { text-align: right; }
table.totals tr.red td { color: darkred; }
.page .footer { width: auto; }
</style>
end;
@ -25,16 +23,8 @@ $saveSort = $coin_id ? 'false' : 'true';
showTableSorter('maintable', "{
tableClass: 'dataGrid',
headers: {
0:{sorter:'metadata'},
1:{sorter:'text'},
2:{sorter:'text'},
3:{sorter:'text'},
4:{sorter:'currency'},
5:{sorter:'currency'},
6:{sorter:'currency'},
7:{sorter:'currency'},
8:{sorter:false}
textExtraction: {
3: function(node, table, n) { return $(node).attr('data'); }
},
widgets: ['zebra','filter','Storage','saveSort'],
widgetOptions: {
@ -50,20 +40,21 @@ showTableSorter('maintable', "{
echo <<<end
<thead>
<tr>
<th width="20"></th>
<th>Coin</th>
<th>Address</th>
<th>Last block</th>
<th class="currency">Pool</th>
<th class="currency">Balance</th>
<th class="currency">Immature</th>
<th class="currency">Failed</th>
<th class="actions">Actions</th>
<th data-sorter="" width="20"></th>
<th data-sorter="text">Coin</th>
<th data-sorter="text">Address</th>
<th data-sorter="numeric">Last block</th>
<th data-sorter="currency" class="currency">Pool</th>
<th data-sorter="currency" class="currency">Balance</th>
<th data-sorter="currency" class="currency">Immature</th>
<th data-sorter="currency" class="currency">Failed</th>
<th data-sorter="" class="actions">Actions</th>
</tr>
</thead><tbody>
end;
$sqlFilter = $coin_id ? "AND coinid={$coin_id}" : "";
$limit = $coin_id ? '' : 'LIMIT 100';
$data = dbolist("SELECT coinid, userid, SUM(amount) AS immature FROM earnings WHERE status=0 $sqlFilter GROUP BY coinid, userid");
$immature = array();
@ -81,7 +72,7 @@ if (!empty($data)) foreach ($data as $row) {
$list = getdbolist('db_accounts', "coinid!=6 $sqlFilter AND (".
"balance > 0 OR last_earning > (UNIX_TIMESTAMP()-60*60) OR id IN (SELECT DISTINCT account_id FROM payouts WHERE tx IS NULL)".
") ORDER BY last_earning DESC limit 50");
") ORDER BY last_earning DESC $limit");
$total = 0.; $totalimmat = 0.; $totalfailed = 0.;
foreach($list as $user)
@ -92,7 +83,7 @@ foreach($list as $user)
echo '<tr class="ssrow">';
if($coin) {
$coinbalance = $coin->balance ? bitcoinvaluetoa($coin->balance) : '-';
$coinbalance = $coin->balance ? bitcoinvaluetoa($coin->balance) : '';
echo '<td><img width="16" src="'.$coin->image.'"></td>';
echo '<td><b><a href="/site/coin?id='.$coin->id.'">'.$coin->name.'</a></b>&nbsp;('.$coin->symbol_show.')</td>';
$immkey = "{$coin->id}-{$user->id}";
@ -108,18 +99,18 @@ foreach($list as $user)
echo '<td class="currency">'.$coinbalance.'</td>';
$balance = $user->balance ? bitcoinvaluetoa($user->balance) : '-';
$balance = $user->balance ? bitcoinvaluetoa($user->balance) : '';
$total += (double) $user->balance;
echo '<td class="currency">'.$balance.'</td>';
$immbalance = arraySafeVal($immature, $immkey, 0);
$totalimmat += (double) $immbalance;
$immbalance = $immbalance ? bitcoinvaluetoa($immbalance) : '-';
$immbalance = $immbalance ? bitcoinvaluetoa($immbalance) : '';
echo '<td class="currency">'.$immbalance.'</td>';
$failbalance = arraySafeVal($failed, $user->id, 0);
$totalfailed += (double) $failbalance;
$failbalance = $failbalance ? bitcoinvaluetoa($failbalance) : '-';
$failbalance = $failbalance ? bitcoinvaluetoa($failbalance) : '';
echo '<td class="currency red">'.$failbalance.'</td>';
echo '<td class="actions">';
@ -130,7 +121,12 @@ foreach($list as $user)
echo "</tr>";
}
echo "</tbody></table>";
echo '</tbody><tfoot>';
echo '<tr><th colspan="9">';
echo count($list).' users';
if (count($list) == 100) echo " ($limit)";
echo '</th></tr>';
echo '</tfoot></table>';
if ($coin_id) {
$coin = getdbo('db_coins', $coin_id);