Merge pull request #288 from TheSerapher/issue-267
Adding SQL based pagination to admin transactions
This commit is contained in:
commit
6e62eff59b
@ -113,7 +113,7 @@ class Transaction {
|
||||
* @param none
|
||||
* @return mixed array or false
|
||||
**/
|
||||
public function getAllTransactions() {
|
||||
public function getAllTransactions($start=0) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
@ -128,8 +128,9 @@ class Transaction {
|
||||
FROM transactions AS t
|
||||
LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id
|
||||
LEFT JOIN " . $this->user->getTableName() . " AS a ON t.account_id = a.id
|
||||
ORDER BY id DESC");
|
||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
|
||||
ORDER BY id DESC
|
||||
LIMIT ?,30");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $start) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $result->fetch_all(MYSQLI_ASSOC);
|
||||
$this->debug->append('Unable to fetch transactions');
|
||||
return false;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
if ($user->isAuthenticated()) {
|
||||
$aTransactions = $transaction->getAllTransactions();
|
||||
$aTransactions = $transaction->getAllTransactions(@$_REQUEST['start']);
|
||||
if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg');
|
||||
$smarty->assign('TRANSACTIONS', $aTransactions);
|
||||
$smarty->assign('CONTENT', 'default.tpl');
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
{include file="global/block_header.tpl" BLOCK_HEADER="Transaction Log" BUTTONS=array(Confirmed,Unconfirmed,Orphan)}
|
||||
<center>
|
||||
<a href="{$smart.server.PHP_SELF}?page=admin&action=transactions&start={$smarty.request.start|default:"0" - 30}"><img src="{$PATH}/images/prev.png" /></a>
|
||||
<a href="{$smart.server.PHP_SELF}?page=admin&action=transactions&start={$smarty.request.start|default:"0" + 30}"><img src="{$PATH}/images/next.png" /></a>
|
||||
</center>
|
||||
<div class="block_content tab_content" id="Confirmed" style="clear:;">
|
||||
<center>
|
||||
{include file="global/pagination.tpl"}
|
||||
<table cellpadding="1" cellspacing="1" width="98%" class="pagesort">
|
||||
<thead style="font-size:13px;">
|
||||
<tr>
|
||||
<th class="header" style="cursor: pointer;">TX #</th>
|
||||
<th class="header" style="cursor: pointer;">Account<th>
|
||||
<th class="header" style="cursor: pointer;">Account</th>
|
||||
<th class="header" style="cursor: pointer;">Date</th>
|
||||
<th class="header" style="cursor: pointer;">TX Type</th>
|
||||
<th class="header" style="cursor: pointer;">Payment Address</th>
|
||||
@ -27,6 +30,7 @@
|
||||
or $TRANSACTIONS[transaction].type == 'Debit_MP'
|
||||
or $TRANSACTIONS[transaction].type == 'TXFee'
|
||||
)}
|
||||
{assign var=confirmed value=1}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
<td>{$TRANSACTIONS[transaction].username}</td>
|
||||
@ -34,10 +38,15 @@
|
||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Credit_PPS' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Credit_PPS' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount|number_format:"8"}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
{/section}
|
||||
{if $confirmed != 1}
|
||||
<tr>
|
||||
<td class="center" colspan="7">No confirmed transactions</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
@ -49,12 +58,11 @@
|
||||
</div>
|
||||
<div class="block_content tab_content" id="Unconfirmed" style="">
|
||||
<center>
|
||||
{include file="global/pagination.tpl" ID=2}
|
||||
<table cellpadding="1" cellspacing="1" width="98%" class="pagesort2">
|
||||
<thead style="font-size:13px;">
|
||||
<tr>
|
||||
<th class="header" style="cursor: pointer;">TX #</th>
|
||||
<th class="header" style="cursor: pointer;">Account<th>
|
||||
<th class="header" style="cursor: pointer;">Account</th>
|
||||
<th class="header" style="cursor: pointer;">Date</th>
|
||||
<th class="header" style="cursor: pointer;">TX Type</th>
|
||||
<th class="header" style="cursor: pointer;">Payment Address</th>
|
||||
@ -69,6 +77,7 @@
|
||||
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
||||
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
||||
)}
|
||||
{assign var=unconfirmed value=1}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
<td>{$TRANSACTIONS[transaction].username}</td>
|
||||
@ -76,19 +85,15 @@
|
||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount|number_format:"8"}</td>
|
||||
</tr>
|
||||
{if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'}
|
||||
{assign var="credits" value="`$credits+$TRANSACTIONS[transaction].amount`"}
|
||||
{else}
|
||||
{assign var="debits" value="`$debits+$TRANSACTIONS[transaction].amount`"}
|
||||
{/if}
|
||||
{/if}
|
||||
{/section}
|
||||
{if $unconfirmed != 1}
|
||||
<tr>
|
||||
<td colspan="5"><b>Unconfirmed Totals:</b></td>
|
||||
<td><b>{$credits|default - $debits|default}</b></td>
|
||||
<td colspan="7">No unconfirmed transactions</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
<p><font color="" sizeze="1">Listed are your estimated rewards and donations/fees for all blocks awaiting {$GLOBAL.confirmations} confirmations.</font></p>
|
||||
@ -96,12 +101,11 @@
|
||||
</div>
|
||||
<div class="block_content tab_content" id="Orphan" style="">
|
||||
<center>
|
||||
{include file="global/pagination.tpl"}
|
||||
<table cellpadding="1" cellspacing="1" width="98%" class="pagesort3">
|
||||
<thead style="font-size:13px;">
|
||||
<tr>
|
||||
<th class="header" style="cursor: pointer;">TX #</th>
|
||||
<th class="header" style="cursor: pointer;">Account<th>
|
||||
<th class="header" style="cursor: pointer;">Account</th>
|
||||
<th class="header" style="cursor: pointer;">Date</th>
|
||||
<th class="header" style="cursor: pointer;">TX Type</th>
|
||||
<th class="header" style="cursor: pointer;">Payment Address</th>
|
||||
@ -117,6 +121,7 @@
|
||||
or $TRANSACTIONS[transaction].type == 'Orphan_Fee'
|
||||
or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'
|
||||
)}
|
||||
{assign var=orphaned value=1}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
<td>{$TRANSACTIONS[transaction].username}</td>
|
||||
@ -124,19 +129,15 @@
|
||||
<td>{$TRANSACTIONS[transaction].type}</td>
|
||||
<td>{$TRANSACTIONS[transaction].coin_address}</td>
|
||||
<td>{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount}</td>
|
||||
<td><font color="{if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'}green{else}red{/if}">{$TRANSACTIONS[transaction].amount|number_format:"8"}</td>
|
||||
</tr>
|
||||
{if $TRANSACTIONS[transaction].type == 'Orphan_Credit' or $TRANSACTIONS[transaction].type == 'Orphan_Bonus'}
|
||||
{assign var="orphan_credits" value="`$orphan_credits+$TRANSACTIONS[transaction].amount`"}
|
||||
{else}
|
||||
{assign var="orphan_debits" value="`$orphan_debits+$TRANSACTIONS[transaction].amount`"}
|
||||
{/if}
|
||||
{/if}
|
||||
{/section}
|
||||
{if $orphaned != 1}
|
||||
<tr>
|
||||
<td colspan="5"><b>Orphaned Totals:</b></td>
|
||||
<td><b>{$orphan_credits|default - $orphan_debits|default}</b></td>
|
||||
<td class="center" colspan="7">No orphan transactions</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
<p><font color="" sizeze="1">Listed are your orphaned transactions for blocks not part of the main blockchain.</font></p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user