mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-09-23 20:00:42 +00:00
wallet: link filtered earnings and payments views
This commit is contained in:
parent
9976490e5c
commit
3b74cc6a89
6 changed files with 134 additions and 41 deletions
|
@ -8,6 +8,8 @@ if (!$coin) {
|
|||
$this->goback();
|
||||
}
|
||||
|
||||
$this->pageTitle = 'Wallet - '.$coin->symbol;
|
||||
|
||||
if (!empty($coin->algo) && $coin->algo != 'PoS')
|
||||
user()->setState('yaamp-algo', $coin->algo);
|
||||
|
||||
|
|
|
@ -7,24 +7,29 @@ $PoS = ($coin->algo == 'PoS'); // or if 'stake' key is present in 'getinfo' meth
|
|||
|
||||
$remote = new Bitcoin($coin->rpcuser, $coin->rpcpasswd, $coin->rpchost, $coin->rpcport);
|
||||
|
||||
$reserved1 = dboscalar("select sum(balance) from accounts where coinid=$coin->id");
|
||||
$reserved2 = dboscalar("select sum(amount*price) from earnings
|
||||
where status!=2 and userid in (select id from accounts where coinid=$coin->id)");
|
||||
|
||||
$reserved1 = dboscalar("SELECT SUM(balance) FROM accounts WHERE coinid={$coin->id}");
|
||||
$reserved1 = altcoinvaluetoa($reserved1);
|
||||
$reserved2 = bitcoinvaluetoa($reserved2);
|
||||
$balance = altcoinvaluetoa($coin->balance);
|
||||
|
||||
$owed = dboscalar("select sum(amount) from earnings where status!=2 and coinid=$coin->id");
|
||||
$owed_btc = $owed? bitcoinvaluetoa($owed*$coin->price): '';
|
||||
$owed = $owed? altcoinvaluetoa($owed): '';
|
||||
$owed = dboscalar("SELECT SUM(E.amount) AS owed FROM earnings E ".
|
||||
"LEFT JOIN blocks B ON E.blockid = B.id ".
|
||||
"WHERE E.status!=2 AND E.coinid={$coin->id} "//."AND B.category NOT IN ('stake','generated')"
|
||||
);
|
||||
$owed_btc = bitcoinvaluetoa($owed*$coin->price);
|
||||
$owed = altcoinvaluetoa($owed);
|
||||
|
||||
$symbol = $coin->symbol;
|
||||
if (!empty($coin->symbol2)) $symbol = $coin->symbol2;
|
||||
|
||||
echo "<br/>";
|
||||
echo "Earnings $reserved2 BTC, balance (db) $balance $symbol";
|
||||
if ($owed) echo ", owed $owed $symbol ($owed_btc BTC)";
|
||||
echo ", $reserved1 $symbol cleared<br/><br/>";
|
||||
if (YAAMP_ALLOW_EXCHANGE) {
|
||||
$reserved2 = bitcoinvaluetoa(dboscalar("SELECT SUM(amount*price) FROM earnings
|
||||
WHERE status!=2 AND userid IN (SELECT id FROM accounts WHERE coinid={$coin->id})"));
|
||||
echo "Earnings $reserved2 BTC, ";
|
||||
}
|
||||
echo "Balance (db) $balance $symbol";
|
||||
echo ", Owed ".CHtml::link($owed, "/site/earning?id=".$coin->id)." $symbol ($owed_btc BTC)";
|
||||
echo ", ".CHtml::link($reserved1, "/site/payments?id=".$coin->id)." $symbol cleared<br/><br/>";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
<?php
|
||||
echo getAdminSideBarLinks();
|
||||
|
||||
$coin_id = getiparam('id');
|
||||
if ($coin_id) {
|
||||
$coin = getdbo('db_coins', $coin_id);
|
||||
$this->pageTitle = 'Earnings - '.$coin->symbol;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id='main_results'></div>
|
||||
|
@ -32,7 +38,7 @@ function main_error()
|
|||
|
||||
function main_refresh()
|
||||
{
|
||||
var url = "/site/earning_results";
|
||||
var url = '/site/earning_results?id=<?= $coin_id ?>';
|
||||
|
||||
clearTimeout(main_timeout);
|
||||
$.get(url, '', main_ready).error(main_error);
|
||||
|
|
|
@ -9,9 +9,17 @@ echo <<<end
|
|||
</div>
|
||||
<style type="text/css">
|
||||
tr.ssrow.filtered { display: none; }
|
||||
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; }
|
||||
</style>
|
||||
end;
|
||||
|
||||
$coin_id = getiparam('id');
|
||||
|
||||
$saveSort = $coin_id ? 'false' : 'true';
|
||||
|
||||
showTableSorter('maintable', "{
|
||||
tableClass: 'dataGrid',
|
||||
headers: {
|
||||
|
@ -19,15 +27,16 @@ showTableSorter('maintable', "{
|
|||
1:{sorter:'text'},
|
||||
2:{sorter:'text'},
|
||||
3:{sorter:'currency'},
|
||||
4:{sorter:'numeric'},
|
||||
5:{sorter:'metadata'},
|
||||
4:{sorter:'currency'},
|
||||
5:{sorter:'numeric'},
|
||||
6:{sorter:'metadata'},
|
||||
7:{sorter:false}
|
||||
7:{sorter:'metadata'},
|
||||
8:{sorter:false}
|
||||
},
|
||||
widgets: ['zebra','filter','Storage','saveSort'],
|
||||
widgetOptions: {
|
||||
saveSort: true,
|
||||
filter_saveFilters: true,
|
||||
saveSort: {$saveSort},
|
||||
filter_saveFilters: {$saveSort},
|
||||
filter_external: '.search',
|
||||
filter_columnFilters: false,
|
||||
filter_childRows : true,
|
||||
|
@ -35,22 +44,28 @@ showTableSorter('maintable', "{
|
|||
}
|
||||
}");
|
||||
|
||||
echo "<thead>";
|
||||
echo "<tr>";
|
||||
echo "<th width=20></th>";
|
||||
echo "<th>Coin</th>";
|
||||
echo "<th>Wallet</th>";
|
||||
//echo "<th>Status</th>";
|
||||
//echo "<th>Amount</th>";
|
||||
echo "<th>Quantity</th>";
|
||||
echo "<th>Block</th>";
|
||||
echo "<th>Status</th>";
|
||||
echo "<th>Sent</th>";
|
||||
echo "<th></th>";
|
||||
echo "</tr>";
|
||||
echo "</thead><tbody>";
|
||||
echo <<<end
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20"></th>
|
||||
<th>Coin</th>
|
||||
<th>Address</th>
|
||||
<th class="currency">Quantity</th>
|
||||
<th class="currency">BTC</th>
|
||||
<th>Block</th>
|
||||
<th>Status</th>
|
||||
<th>Sent</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
end;
|
||||
|
||||
$earnings = getdbolist('db_earnings', "status!=2 ORDER BY create_time DESC LIMIT 500");
|
||||
$coin_id = getiparam('id');
|
||||
$sqlFilter = $coin_id ? "AND coinid={$coin_id}": '';
|
||||
|
||||
$earnings = getdbolist('db_earnings', "status!=2 $sqlFilter ORDER BY create_time DESC LIMIT 1000");
|
||||
|
||||
$total = 0.; $total_btc = 0.; $totalimmat = 0.; $totalfees = 0.; $totalstake = 0.;
|
||||
|
||||
foreach($earnings as $earning)
|
||||
{
|
||||
|
@ -76,6 +91,7 @@ foreach($earnings as $earning)
|
|||
echo "<td><b>$coinlink</b> ($coin->symbol_show)</td>";
|
||||
echo '<td><b><a href="/?address='.$user->username.'">'.$user->username.'</a></b></td>';
|
||||
echo '<td>'.bitcoinvaluetoa($earning->amount).'</td>';
|
||||
echo '<td>'.bitcoinvaluetoa($earning->amount * $earning->price).'</td>';
|
||||
echo "<td>$block->height</td>";
|
||||
echo "<td>$block->category ($block->confirmations)</td>";
|
||||
echo '<td data="'.$earning->create_time.'">'."$t1 $t2</td>";
|
||||
|
@ -94,8 +110,39 @@ foreach($earnings as $earning)
|
|||
// $earning->mature_time = time()-100*60;
|
||||
// $earning->save();
|
||||
// }
|
||||
|
||||
if($block->category == 'immature') {
|
||||
$total += (double) $earning->amount;
|
||||
$total_btc += (double) $earning->amount * $earning->price;
|
||||
$totalimmat += (double) $earning->amount;
|
||||
}
|
||||
if($block->category == 'generate') {
|
||||
$total += (double) $earning->amount; // "Exchange" state
|
||||
$total_btc += (double) $earning->amount * $earning->price;
|
||||
}
|
||||
else if($block->category == 'stake' || $block->category == 'generated') {
|
||||
$totalstake += (double) $earning->amount;
|
||||
}
|
||||
}
|
||||
|
||||
echo "</tbody></table>";
|
||||
|
||||
if ($coin_id) {
|
||||
$coin = getdbo('db_coins', $coin_id);
|
||||
if (!$coin) exit;
|
||||
$symbol = $coin->symbol;
|
||||
$feepct = yaamp_fee($coin->algo);
|
||||
$totalfees = ($total / ((100 - $feepct) / 100.)) - $total;
|
||||
|
||||
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 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 '</div>';
|
||||
}
|
|
@ -1,8 +1,14 @@
|
|||
<?php
|
||||
echo getAdminSideBarLinks();
|
||||
|
||||
$coin_id = getiparam('id');
|
||||
if ($coin_id) {
|
||||
$coin = getdbo('db_coins', $coin_id);
|
||||
$this->pageTitle = 'Payments - '.$coin->symbol;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id='main_results'></div>
|
||||
<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>
|
||||
|
@ -32,7 +38,7 @@ function main_error()
|
|||
|
||||
function main_refresh()
|
||||
{
|
||||
var url = "/site/payments_results";
|
||||
var url = '/site/payments_results?id=<?= $coin_id ?>';
|
||||
|
||||
clearTimeout(main_timeout);
|
||||
$.get(url, '', main_ready).error(main_error);
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
|
||||
// PS: account last_login is not related to user logins... its the last backend payment loop, todo: rename it..
|
||||
|
||||
$list = getdbolist('db_accounts', "coinid!=6 AND (".
|
||||
"balance > 0 OR last_login > (UNIX_TIMESTAMP()-60*60) OR id IN (SELECT DISTINCT account_id FROM payouts WHERE tx IS NULL)".
|
||||
") ORDER BY last_login DESC limit 50");
|
||||
|
||||
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
|
||||
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
|
||||
|
||||
|
@ -18,9 +14,17 @@ tr.ssrow.filtered { display: none; }
|
|||
.currency { width: 120px; max-width: 180px; text-align: right; }
|
||||
.red { color: darkred; }
|
||||
.actions { width: 120px; text-align: center; }
|
||||
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; }
|
||||
</style>
|
||||
end;
|
||||
|
||||
$coin_id = getiparam('id');
|
||||
|
||||
$saveSort = $coin_id ? 'false' : 'true';
|
||||
|
||||
showTableSorter('maintable', "{
|
||||
tableClass: 'dataGrid',
|
||||
headers: {
|
||||
|
@ -36,8 +40,8 @@ showTableSorter('maintable', "{
|
|||
},
|
||||
widgets: ['zebra','filter','Storage','saveSort'],
|
||||
widgetOptions: {
|
||||
saveSort: true,
|
||||
filter_saveFilters: true,
|
||||
saveSort: {$saveSort},
|
||||
filter_saveFilters: {$saveSort},
|
||||
filter_external: '.search',
|
||||
filter_columnFilters: false,
|
||||
filter_childRows : true,
|
||||
|
@ -61,7 +65,9 @@ echo <<<end
|
|||
</thead><tbody>
|
||||
end;
|
||||
|
||||
$data = dbolist("SELECT coinid, userid, SUM(amount) AS immature FROM earnings WHERE status=0 GROUP BY coinid, userid");
|
||||
$sqlFilter = $coin_id ? "AND coinid={$coin_id}" : "";
|
||||
|
||||
$data = dbolist("SELECT coinid, userid, SUM(amount) AS immature FROM earnings WHERE status=0 $sqlFilter GROUP BY coinid, userid");
|
||||
$immature = array();
|
||||
if (!empty($data)) foreach ($data as $row) {
|
||||
$immkey = $row['coinid']."-".$row['userid'];
|
||||
|
@ -75,6 +81,11 @@ if (!empty($data)) foreach ($data as $row) {
|
|||
$failed[$uid] = $row['failed'];
|
||||
}
|
||||
|
||||
$list = getdbolist('db_accounts', "coinid!=6 $sqlFilter AND (".
|
||||
"balance > 0 OR last_login > (UNIX_TIMESTAMP()-60*60) OR id IN (SELECT DISTINCT account_id FROM payouts WHERE tx IS NULL)".
|
||||
") ORDER BY last_login DESC limit 50");
|
||||
|
||||
$total = 0.; $totalimmat = 0.; $totalfailed = 0.;
|
||||
foreach($list as $user)
|
||||
{
|
||||
$coin = getdbo('db_coins', $user->coinid);
|
||||
|
@ -100,13 +111,16 @@ foreach($list as $user)
|
|||
echo '<td class="currency">'.$coinbalance.'</td>';
|
||||
|
||||
$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) : '-';
|
||||
echo '<td class="currency">'.$immbalance.'</td>';
|
||||
|
||||
$failbalance = arraySafeVal($failed, $user->id, 0);
|
||||
$totalfailed += (double) $failbalance;
|
||||
$failbalance = $failbalance ? bitcoinvaluetoa($failbalance) : '-';
|
||||
echo '<td class="currency red">'.$failbalance.'</td>';
|
||||
|
||||
|
@ -119,3 +133,16 @@ foreach($list as $user)
|
|||
}
|
||||
|
||||
echo "</tbody></table>";
|
||||
|
||||
if ($coin_id) {
|
||||
$coin = getdbo('db_coins', $coin_id);
|
||||
$symbol = $coin->symbol;
|
||||
echo '<div class="totals" align="right">';
|
||||
echo '<table class="totals">';
|
||||
echo '<tr><th>Balances</th><td>'.bitcoinvaluetoa($total)." $symbol</td></tr>";
|
||||
echo '<tr><th>Immature</th><td>'.bitcoinvaluetoa($totalimmat)." $symbol</td></tr>";
|
||||
if ($totalfailed)
|
||||
echo '<tr class="red"><th>Failed</th><td>'.bitcoinvaluetoa($totalfailed)." $symbol</td></tr>";
|
||||
echo '</tr></table>';
|
||||
echo '</div>';
|
||||
}
|
Loading…
Add table
Reference in a new issue