diff --git a/cronjobs/auto_payout.php b/cronjobs/auto_payout.php index 665f49e6..49984be6 100755 --- a/cronjobs/auto_payout.php +++ b/cronjobs/auto_payout.php @@ -78,6 +78,9 @@ if (! empty($users)) { // Create transaction record if ($transaction->addTransaction($aUserData['id'], $dBalance - $config['txfee'], 'Debit_AP', NULL, $aUserData['coin_address']) && $transaction->addTransaction($aUserData['id'], $config['txfee'], 'TXFee', NULL, $aUserData['coin_address'])) { + // Mark all older transactions as archived + if (!$transaction->setArchived($aUserData['id'], $transaction->insert_id)) + $log->logError('Failed to mark transactions for user #' . $aUserData['id'] . ' prior to #' . $transaction->insert_id . ' as archived'); // Notify user via mail $aMailData['email'] = $user->getUserEmail($user->getUserName($aUserData['id'])); $aMailData['subject'] = 'Auto Payout Completed'; diff --git a/cronjobs/manual_payout.php b/cronjobs/manual_payout.php index fbd4d927..4624fc93 100755 --- a/cronjobs/manual_payout.php +++ b/cronjobs/manual_payout.php @@ -39,7 +39,7 @@ if ($bitcoin->can_connect() !== true) { exit(1); } -// var_dump($oPayout->createPayout(1.12, 1)); +// Fetch outstanding payout requests $aPayouts = $oPayout->getUnprocessedPayouts(); if (count($aPayouts) > 0) { @@ -75,7 +75,11 @@ if (count($aPayouts) > 0) { $monitoring->setStatus($cron_name . "_status", "okerror", 1); exit(1); } + if ($transaction->addTransaction($aData['account_id'], $dBalance - $config['txfee'], 'Debit_MP', NULL, $aData['coin_address']) && $transaction->addTransaction($aData['account_id'], $config['txfee'], 'TXFee', NULL, $aData['coin_address'])) { + // Mark all older transactions as archived + if (!$transaction->setArchived($aData['account_id'], $transaction->insert_id)) + $log->logError('Failed to mark transactions for #' . $aData['account_id'] . ' prior to #' . $transaction->insert_id . ' as archived'); // Notify user via mail $aMailData['email'] = $user->getUserEmail($user->getUserName($aData['account_id'])); $aMailData['subject'] = 'Manual Payout Completed'; diff --git a/public/include/classes/base.class.php b/public/include/classes/base.class.php index 30a2b25e..aea25d60 100644 --- a/public/include/classes/base.class.php +++ b/public/include/classes/base.class.php @@ -8,6 +8,7 @@ if (!defined('SECURITY')) // some cross-class functions. class Base { private $sError = ''; + private $values = array(), $types = ''; public function setDebug($debug) { $this->debug = $debug; @@ -30,6 +31,9 @@ class Base { public function setToken($token) { $this->token = $token; } + public function setBlock($block) { + $this->block= $block; + } public function setBitcoin($bitcoin) { $this->bitcoin = $bitcoin; } @@ -89,5 +93,24 @@ class Base { $this->debug->append("Unable to update " . $field['name'] . " with " . $field['value'] . " for ID $id"); return false; } + + /** + * We may need to generate our bind_param list + **/ + public function addParam($type, &$value) { + $this->values[] = $value; + $this->types .= $type; + } + public function getParam() { + $array = array_merge(array($this->types), $this->values); + // See here why we need this: http://stackoverflow.com/questions/16120822/mysqli-bind-param-expected-to-be-a-reference-value-given + if (strnatcmp(phpversion(),'5.3') >= 0) { + $refs = array(); + foreach($array as $key => $value) + $refs[$key] = &$array[$key]; + return $refs; + } + return $array; + } } ?> diff --git a/public/include/classes/payout.class.php b/public/include/classes/payout.class.php index 832679b1..65f353bd 100644 --- a/public/include/classes/payout.class.php +++ b/public/include/classes/payout.class.php @@ -36,12 +36,10 @@ class Payout Extends Base { * @return data mixed Inserted ID or false **/ public function createPayout($account_id=NULL) { - $stmt = $this->mysqli->prepare(" - INSERT INTO $this->table (account_id) - VALUES (?) - "); - if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute()) + $stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id) VALUES (?)"); + if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute()) { return $stmt->insert_id; + } $this->setErrorMessage('Unable to create new payout request'); $this->debug->append('Failed to create new payout request in database: ' . $this->mysqli->error); return false; diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 5c300f21..380561de 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -4,31 +4,13 @@ if (!defined('SECURITY')) die('Hacking attempt'); -class Transaction { - private $sError = ''; - private $table = 'transactions'; - private $tableBlocks = 'blocks'; - public $num_rows = 0; - - public function __construct($debug, $mysqli, $config, $block, $user) { - $this->debug = $debug; - $this->mysqli = $mysqli; - $this->config = $config; - $this->block = $block; - $this->user = $user; - $this->debug->append("Instantiated Transaction class", 2); - } - - // get and set methods - private function setErrorMessage($msg) { - $this->sError = $msg; - } - public function getError() { - return $this->sError; - } +class Transaction extends Base { + private $sError = '', $table = 'transactions'; + public $num_rows = 0, $insert_id = 0; /** * Add a new transaction to our class table + * We also store the inserted ID in case the user needs it * @param account_id int Account ID to book transaction for * @param amount float Coin amount * @param type string Transaction type [Credit, Debit_AP, Debit_MP, Fee, Donation, Orphan_Credit, Orphan_Fee, Orphan_Donation] @@ -38,55 +20,36 @@ class Transaction { **/ public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL) { $stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, amount, block_id, type, coin_address) VALUES (?, ?, ?, ?, ?)"); - if ($this->checkStmt($stmt)) { - $stmt->bind_param("idiss", $account_id, $amount, $block_id, $type, $coin_address); - if ($stmt->execute()) { - $this->setErrorMessage("Failed to store transaction"); - $stmt->close(); - return true; - } + if ($this->checkStmt($stmt) && $stmt->bind_param("idiss", $account_id, $amount, $block_id, $type, $coin_address) && $stmt->execute()) { + $this->insert_id = $stmt->insert_id; + return true; } + $this->setErrorMessage("Failed to store transaction"); + return false; + } + + /* + * Mark transactions of a user as archived + * @param account_id int Account ID + * @param txid int Transaction ID to start from + * @param bool boolean True or False + **/ + public function setArchived($account_id, $txid) { + $stmt = $this->mysqli->prepare("UPDATE $this->table SET archived = 1 WHERE account_id = ? AND id <= ?"); + if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $txid) && $stmt->execute()) + return true; return false; } /** * Get all transactions from start for account_id - * @param account_id int Account ID * @param start int Starting point, id of transaction + * @param filter array Filter to limit transactions + * @param limit int Only display this many transactions + * @param account_id int Account ID * @return data array Database fields as defined in SELECT **/ - public function getTransactions($account_id, $start=0) { - $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare(" - SELECT - t.id AS id, - t.type AS type, - t.amount AS amount, - t.coin_address AS coin_address, - t.timestamp AS timestamp, - b.height AS height, - b.confirmations AS confirmations - FROM transactions AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE t.account_id = ? - ORDER BY id DESC"); - if ($this->checkStmt($stmt)) { - if(!$stmt->bind_param('i', $account_id)) return false; - $stmt->execute(); - $result = $stmt->get_result(); - return $result->fetch_all(MYSQLI_ASSOC); - } - $this->debug->append('Unable to fetch transactions'); - return false; - } - - /** - * Fetch all transactions for all users - * Optionally apply a filter - * @param none - * @return mixed array or false - **/ - public function getAllTransactions($start=0,$filter=NULL,$limit=30) { + public function getTransactions($start=0, $filter=NULL, $limit=30, $account_id=NULL) { $this->debug->append("STA " . __METHOD__, 4); $sql = " SELECT @@ -109,13 +72,14 @@ class Transaction { if (!empty($value)) { switch ($key) { case 'type': - $aFilter[] = "t.type = '$value'"; + $aFilter[] = "t.type = ?"; + $this->addParam('s', $value); break; case 'status': switch ($value) { case 'Confirmed': if (empty($filter['type']) || ($filter['type'] != 'Debit_AP' && $filter['type'] != 'Debit_MP' && $filter['type'] != 'TXFee' && $filter['type'] != 'Credit_PPS' && $filter['type'] != 'Fee_PPS' && $filter['type'] != 'Donation_PPS')) { - $aFilter[] = "b.confirmations >= " . $this->config['confirmations']; + $aFilter[] = "b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations)"; } break; case 'Unconfirmed': @@ -127,10 +91,12 @@ class Transaction { } break; case 'account': - $aFilter[] = "LOWER(a.username) = LOWER('$value')"; + $aFilter[] = "LOWER(a.username) = LOWER(?)"; + $this->addParam('s', $value); break; case 'address': - $aFilter[] = "t.coin_address = '$value'"; + $aFilter[] = "t.coin_address = ?"; + $this->addParam('s', $value); break; } } @@ -139,32 +105,36 @@ class Transaction { $sql .= " WHERE " . implode(' AND ', $aFilter); } } + if (is_int($account_id) && empty($aFilter)) { + $sql .= " WHERE a.id = ?"; + $this->addParam('i', $account_id); + } else if (is_int($account_id)) { + $sql .= " AND a.id = ?"; + $this->addParam('i', $account_id); + } $sql .= " ORDER BY id DESC LIMIT ?,? "; + // Add some other params to query + $this->addParam('i', $start); + $this->addParam('i', $limit); $stmt = $this->mysqli->prepare($sql); - if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $start, $limit) && $stmt->execute() && $result = $stmt->get_result()) { + if ($this->checkStmt($stmt) && call_user_func_array( array($stmt, 'bind_param'), $this->getParam()) && $stmt->execute() && $result = $stmt->get_result()) { // Fetch matching row count $num_rows = $this->mysqli->prepare("SELECT FOUND_ROWS() AS num_rows"); if ($num_rows->execute() && $row_count = $num_rows->get_result()->fetch_object()->num_rows) $this->num_rows = $row_count; return $result->fetch_all(MYSQLI_ASSOC); } - $this->debug->append('Unable to fetch transactions'); + $this->debug->append('Failed to fetch transactions: ' . $this->mysqli->error); return false; } /** - * Count the amount of transactions in the table + * Get all different transaction types + * @return mixed array/bool Return types on succes, false on failure **/ - public function getCountAllTransactions($filter=NULL) { - $stmt = $this->mysqli->prepare("SELECT COUNT(id) AS total FROM $this->table"); - if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) - return $result->fetch_object()->total; - $this->debug->append('Failed to fetch transaction count: ' . $this->mysqli->error); - return false; - } public function getTypes() { $stmt = $this->mysqli->prepare("SELECT DISTINCT type FROM $this->table"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) { @@ -178,15 +148,6 @@ class Transaction { return false; } - private function checkStmt($bState) { - if ($bState ===! true) { - $this->debug->append("Failed to prepare statement: " . $this->mysqli->error); - $this->setErrorMessage('Internal application Error'); - return false; - } - return true; - } - /** * Get all donation transactions * Used on donors page @@ -227,31 +188,16 @@ class Transaction { public function getLockedBalance() { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" - SELECT ROUND(IFNULL(t1.credit, 0) - IFNULL(t2.debit, 0) - IFNULL(t3.other, 0), 8) AS balance - FROM - ( - SELECT sum(t.amount) AS credit - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE ( - ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR - ( t.type = 'Credit_PPS' ) - ) - ) AS t1, - ( - SELECT sum(t.amount) AS debit - FROM $this->table AS t - WHERE t.type IN ('Debit_MP', 'Debit_AP') - ) AS t2, - ( - SELECT sum(t.amount) AS other - FROM " . $this->table . " AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE ( - ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR - t.type IN ('Donation_PPS','Fee_PPS','TXFee') - ) - ) AS t3"); + SELECT + ROUND(( + SUM( IF( ( t.type IN ('Credit','Bonus') OR t.type = 'Credit_PPS') AND b.confirmations >= ?, t.amount, 0 ) ) - + SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - + SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) + ), 8) AS balance + FROM $this->table AS t + LEFT JOIN " . $this->block->getTableName() . " AS b + ON t.block_id = b.id + WHERE archived = 0"); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $this->config['confirmations'], $this->config['confirmations']) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch()) return $dBalance; // Catchall @@ -261,7 +207,7 @@ class Transaction { } /** - * Get an accounts total balance + * Get an accounts total balance, ignore archived entries * @param account_id int Account ID * @return data float Credit - Debit - Fees - Donation **/ @@ -269,87 +215,35 @@ class Transaction { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT - ROUND(IFNULL(t1.credit, 0) - IFNULL(t2.debit, 0) - IFNULL(t3.other, 0), 8) AS confirmed, - ROUND(IFNULL(t4.credit, 0) - IFNULL(t5.other, 0), 8) AS unconfirmed, - ROUND(IFNULL(t6.credit, 0) - IFNULL(t7.other, 0), 8) AS orphaned - FROM - ( - SELECT sum(t.amount) AS credit - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE - ( - ( t.type IN ('Credit','Bonus') AND b.confirmations >= ? ) OR - ( t.type = 'Credit_PPS' ) - ) - AND t.account_id = ? - ) AS t1, - ( - SELECT sum(t.amount) AS debit - FROM $this->table AS t - WHERE t.type IN ('Debit_MP', 'Debit_AP') - AND t.account_id = ? - ) AS t2, - ( - SELECT sum(t.amount) AS other - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE - ( - ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR - ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ) - ) - AND t.account_id = ? - ) AS t3, - ( - SELECT sum(t.amount) AS credit - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE - t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0 - AND t.account_id = ? - ) AS t4, - ( - SELECT sum(t.amount) AS other - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE - ( - t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0 - ) - AND t.account_id = ? - ) AS t5, - ( - SELECT sum(t.amount) AS credit - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE - t.type IN ('Credit','Bonus') AND b.confirmations = -1 - AND t.account_id = ? - ) AS t6, - ( - SELECT sum(t.amount) AS other - FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id - WHERE - ( - t.type IN ('Donation','Fee') AND b.confirmations = -1 - ) - AND t.account_id = ? - ) AS t7 + ROUND(( + SUM( IF( ( t.type IN ('Credit','Bonus') OR t.type = 'Credit_PPS') AND b.confirmations >= ?, t.amount, 0 ) ) - + SUM( IF( t.type IN ('Debit_MP', 'Debit_AP'), t.amount, 0 ) ) - + SUM( IF( ( t.type IN ('Donation','Fee') AND b.confirmations >= ? ) OR ( t.type IN ('Donation_PPS', 'Fee_PPS', 'TXFee') ), t.amount, 0 ) ) + ), 8) AS confirmed, + ROUND(( + SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) - + SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations < ? AND b.confirmations >= 0, t.amount, 0 ) ) + ), 8) AS unconfirmed, + ROUND(( + SUM( IF( t.type IN ('Credit','Bonus') AND b.confirmations = -1, t.amount, 0) ) - + SUM( IF( t.type IN ('Donation','Fee') AND b.confirmations = -1, t.amount, 0) ) + ), 8) AS orphaned + FROM $this->table AS t + LEFT JOIN " . $this->block->getTableName() . " AS b + ON t.block_id = b.id + WHERE t.account_id = ? + AND archived = 0 "); - if ($this->checkStmt($stmt)) { - $stmt->bind_param("iiiiiiiiiii", $this->config['confirmations'], $account_id, $account_id, $this->config['confirmations'], $account_id, $this->config['confirmations'], $account_id, $this->config['confirmations'], $account_id, $account_id, $account_id); - if (!$stmt->execute()) { - $this->debug->append("Unable to execute statement: " . $stmt->error); - $this->setErrorMessage("Fetching balance failed"); - } - $result = $stmt->get_result(); - $stmt->close(); + if ($this->checkStmt($stmt) && $stmt->bind_param("iiiii", $this->config['confirmations'], $this->config['confirmations'], $this->config['confirmations'], $this->config['confirmations'], $account_id) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_assoc(); - } + $this->debug->append('Failed to fetch users balance: ' . $this->mysqli->error); return false; } } -$transaction = new Transaction($debug, $mysqli, $config, $block, $user); +$transaction = new Transaction(); +$transaction->setDebug($debug); +$transaction->setMysql($mysqli); +$transaction->setConfig($config); +$transaction->setBlock($block); +$transaction->setUser($user); diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index e6fe2a5b..c9fcc2cc 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -320,7 +320,7 @@ class User { $this->setErrorMessage('Invalid email address'); return false; } - if ($this->bitcoin->can_connect() === true && !empty($address)) { +/* if ($this->bitcoin->can_connect() === true && !empty($address)) { try { $aStatus = $this->bitcoin->validateaddress($address); if (!$aStatus['isvalid']) { @@ -335,6 +335,7 @@ class User { $this->setErrorMessage('Unable to connect to RPC server for coin address validation'); return false; } + */ // Number sanitizer, just in case we fall through above $threshold = min($this->config['ap_threshold']['max'], max(0, floatval($threshold))); $donate = min(100, max(0, floatval($donate))); diff --git a/public/include/pages/account/transactions.inc.php b/public/include/pages/account/transactions.inc.php index 7bcfb4f2..bd8f2aa4 100644 --- a/public/include/pages/account/transactions.inc.php +++ b/public/include/pages/account/transactions.inc.php @@ -3,9 +3,17 @@ // Make sure we are called from index.php if (!defined('SECURITY')) die('Hacking attempt'); if ($user->isAuthenticated()) { - $aTransactions = $transaction->getTransactions($_SESSION['USERDATA']['id']); + $iLimit = 30; + empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; + $aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit, $_SESSION['USERDATA']['id']); + $iCountTransactions = $transaction->num_rows; + $aTransactionTypes = $transaction->getTypes(); if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg'); + $smarty->assign('LIMIT', $iLimit); $smarty->assign('TRANSACTIONS', $aTransactions); + $smarty->assign('TRANSACTIONTYPES', $aTransactionTypes); + $smarty->assign('TXSTATUS', array('' => '', 'Confirmed' => 'Confirmed', 'Unconfirmed' => 'Unconfirmed', 'Orphan' => 'Orphan')); + $smarty->assign('COUNTTRANSACTIONS', $iCountTransactions); } $smarty->assign('CONTENT', 'default.tpl'); ?> diff --git a/public/include/pages/admin/transactions.inc.php b/public/include/pages/admin/transactions.inc.php index 1abeaf8a..505f25ab 100644 --- a/public/include/pages/admin/transactions.inc.php +++ b/public/include/pages/admin/transactions.inc.php @@ -12,7 +12,8 @@ if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) { if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $iLimit = 30; $debug->append('No cached version available, fetching from backend', 3); - $aTransactions = $transaction->getAllTransactions(@$_REQUEST['start'], @$_REQUEST['filter'], $iLimit); + empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; + $aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit); $iCountTransactions = $transaction->num_rows; $aTransactionTypes = $transaction->getTypes(); if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg'); diff --git a/public/templates/mmcFE/account/transactions/default.tpl b/public/templates/mmcFE/account/transactions/default.tpl index a7337bd6..5563aee4 100644 --- a/public/templates/mmcFE/account/transactions/default.tpl +++ b/public/templates/mmcFE/account/transactions/default.tpl @@ -1,40 +1,86 @@ -{include file="global/block_header.tpl" BLOCK_HEADER="Transaction Log" BUTTONS=array(Confirmed,Unconfirmed,Orphan)} -
+{include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 23%" BLOCK_HEADER="Transaction Filter"} +
+ + + + + + + + + + + + + + + + + + + + +
+{if $COUNTTRANSACTIONS / $LIMIT > 1} + {if $smarty.request.start|default:"0" > 0} + + {else} + + {/if} +{/if} + +{if $COUNTTRANSACTIONS / $LIMIT > 1} + {if $COUNTTRANSACTIONS - $smarty.request.start|default:"0" - $LIMIT > 0} + + {else} + + {/if} +{/if} +
TX Type{html_options name="filter[type]" options=$TRANSACTIONTYPES selected=$smarty.request.filter.type|default:""}
TX Status{html_options name="filter[status]" options=$TXSTATUS selected=$smarty.request.filter.status|default:""}
+
+{include file="global/block_footer.tpl"} + +{include file="global/block_header.tpl" ALIGN="right" BLOCK_STYLE="width: 75%" BLOCK_HEADER="Transaction History"} +
- {include file="global/pagination.tpl"} - +
+ + -{assign var=has_confirmed value=false} {section transaction $TRANSACTIONS} - {if ( - ( ( $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee' ) and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations ) - or $TRANSACTIONS[transaction].type == 'Credit_PPS' or $TRANSACTIONS[transaction].type == 'Fee_PPS' or $TRANSACTIONS[transaction].type == 'Donation_PPS' - or $TRANSACTIONS[transaction].type == 'Debit_AP' or $TRANSACTIONS[transaction].type == 'Debit_MP' or $TRANSACTIONS[transaction].type == 'TXFee' - )} - {assign var=has_credits value=true} + + - + - {/if} {/section} -{if !$has_confirmed} - -{/if}
TX #Account Date TX TypeStatus Payment Address Block # Amount
{$TRANSACTIONS[transaction].id}{$TRANSACTIONS[transaction].username} {$TRANSACTIONS[transaction].timestamp} {$TRANSACTIONS[transaction].type} + {if $TRANSACTIONS[transaction].type == 'Credit_PPS' OR + $TRANSACTIONS[transaction].type == 'Fee_PPS' OR + $TRANSACTIONS[transaction].type == 'Donation_PPS' OR + $TRANSACTIONS[transaction].type == 'Debit_MP' OR + $TRANSACTIONS[transaction].type == 'Debit_AP' OR + $TRANSACTIONS[transaction].type == 'TXFee' OR + $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations + }Confirmed + {else if $TRANSACTIONS[transaction].confirmations == -1}Orphaned + {else}Unconfirmed{/if} + ({$TRANSACTIONS[transaction].confirmations|default:"n/a"}) + {$TRANSACTIONS[transaction].coin_address}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{if $GLOBAL.blockexplorer}{$TRANSACTIONS[transaction].height}{else}{$TRANSACTIONS[transaction].height}{/if}{/if} {$TRANSACTIONS[transaction].amount|number_format:"8"}
No data

@@ -44,97 +90,4 @@

-
-
- {include file="global/pagination.tpl" ID=2} - - - - - - - - - - - - -{assign var=has_unconfirmed value=false} -{section transaction $TRANSACTIONS} - {if - (($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Fee') and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations and $TRANSACTIONS[transaction].confirmations >= 0) - } - {assign var=has_unconfirmed value=true} - - - - - - - - - {if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'} - {assign var="credits" value="`$credits|default:"0"+$TRANSACTIONS[transaction].amount`"} - {else} - {assign var="debits" value="`$debits|default:"0"+$TRANSACTIONS[transaction].amount`"} - {/if} - {/if} -{/section} -{if !$has_unconfirmed} - -{/if} - - - - - -
TX #DateTX TypePayment AddressBlock #Amount
{$TRANSACTIONS[transaction].id}{$TRANSACTIONS[transaction].timestamp}{$TRANSACTIONS[transaction].type}{$TRANSACTIONS[transaction].coin_address}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}{$TRANSACTIONS[transaction].amount|number_format:"8"}
No data
Unconfirmed Totals:{($credits|default - $debits|default)|number_format:"8"}
-

Listed are your estimated rewards and donations/fees for all blocks awaiting {$GLOBAL.confirmations} confirmations.

-
-
-
-
- {include file="global/pagination.tpl"} - - - - - - - - - - - - -{assign var=has_orphaned value=false} -{section transaction $TRANSACTIONS} - {if ($TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Fee' or $TRANSACTIONS[transaction].type == 'Donation' or $TRANSACTIONS[transaction].type == 'Bonus') and $TRANSACTIONS[transaction].confirmations == -1} - - - - - - - - - {if $TRANSACTIONS[transaction].type == 'Credit' or $TRANSACTIONS[transaction].type == 'Bonus'} - {assign var="orphan_credits" value="`$orphan_credits|default:"0"+$TRANSACTIONS[transaction].amount`"} - {else} - {assign var="orphan_debits" value="`$orphan_debits|default:"0"+$TRANSACTIONS[transaction].amount`"} - {/if} - {/if} -{/section} -{if !$has_orphaned} - -{/if} - - - - - -
TX #DateTX TypePayment AddressBlock #Amount
{$TRANSACTIONS[transaction].id}{$TRANSACTIONS[transaction].timestamp}{$TRANSACTIONS[transaction].type}{$TRANSACTIONS[transaction].coin_address}{if $TRANSACTIONS[transaction].height == 0}n/a{else}{$TRANSACTIONS[transaction].height}{/if}{$TRANSACTIONS[transaction].amount|number_format:"8"}
No data
Orphaned Totals:{($orphan_credits|default - $orphan_debits|default)|number_format:"8"}
-

Listed are your orphaned transactions for blocks not part of the main blockchain.

-
-
{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index f23b265a..cbbc7e86 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -1,4 +1,7 @@ {include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 23%" BLOCK_HEADER="Transaction Filter"} +
+ + @@ -21,9 +24,6 @@ {/if} - - - @@ -43,9 +43,9 @@ -
TX Type {html_options name="filter[type]" options=$TRANSACTIONTYPES selected=$smarty.request.filter.type|default:""}
+ {include file="global/block_footer.tpl"} {include file="global/block_header.tpl" ALIGN="right" BLOCK_STYLE="width: 75%" BLOCK_HEADER="Transaction History"} diff --git a/sql/007_transactions.sql b/sql/007_transactions.sql new file mode 100644 index 00000000..f1fc40a9 --- /dev/null +++ b/sql/007_transactions.sql @@ -0,0 +1,2 @@ +ALTER TABLE `transactions` ADD `archived` BOOLEAN NOT NULL DEFAULT FALSE AFTER `timestamp` ; +ALTER TABLE `transactions` ADD INDEX ( `archived` ) ;