commit
de1303b144
@ -58,14 +58,19 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
|
||||
if (!$block->setShares($aBlock['id'], $iRoundShares))
|
||||
$strStatus = "Shares Failed";
|
||||
verbose("\t\t$strStatus\n\n");
|
||||
verbose("ID\tUsername\tValid\tInvalid\tPercentage\tPayout\t\tDonation\t\tStatus\n");
|
||||
verbose("ID\tUsername\tValid\tInvalid\tPercentage\tPayout\t\tDonation\tFee\t\tStatus\n");
|
||||
foreach ($aAccountShares as $key => $aData) {
|
||||
// Payout based on shares, PPS system
|
||||
$aData['percentage'] = number_format(round(( 100 / $iRoundShares ) * $aData['valid'], 8), 8);
|
||||
$aData['payout'] = number_format(round(( $aData['percentage'] / 100 ) * $config['reward'], 8), 8);
|
||||
// Defaults
|
||||
$aData['fee' ] = 0;
|
||||
$aData['donation'] = 0;
|
||||
|
||||
// Calculate donation amount for Donation transaction
|
||||
$aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * $aData['payout'], 8), 8);
|
||||
if ($config['fees'] > 0)
|
||||
$aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8);
|
||||
// Calculate donation amount, fees not included
|
||||
$aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8);
|
||||
|
||||
// Verbose output of this users calculations
|
||||
verbose($aData['id'] . "\t" .
|
||||
@ -74,7 +79,8 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
|
||||
$aData['invalid'] . "\t" .
|
||||
$aData['percentage'] . "\t" .
|
||||
$aData['payout'] . "\t" .
|
||||
$aData['donation'] . "\t");
|
||||
$aData['donation'] . "\t" .
|
||||
$aData['fee'] . "\t");
|
||||
|
||||
$strStatus = "OK";
|
||||
// Update user share statistics
|
||||
@ -84,11 +90,13 @@ foreach ($aAllBlocks as $iIndex => $aBlock) {
|
||||
if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit', $aBlock['id']))
|
||||
$strStatus = "Transaction Failed";
|
||||
// Add new donation debit
|
||||
if ($aData['donation'] > 0) {
|
||||
if ($aData['donation'] > 0)
|
||||
if (!$transaction->addTransaction($aData['id'], $aData['donation'], 'Donation', $aBlock['id']))
|
||||
$strStatus = "Donation Failed";
|
||||
}
|
||||
verbose("\t\t$strStatus\n");
|
||||
if ($aData['fee'] > 0 && $config['fees'] > 0)
|
||||
if (!$transaction->addTransaction($aData['id'], $aData['fee'], 'Fee', $aBlock['id']))
|
||||
$strStatus = "Fee Failed";
|
||||
verbose("\t$strStatus\n");
|
||||
}
|
||||
verbose("------------------------------------------------------------------------\n\n");
|
||||
|
||||
|
||||
@ -25,10 +25,10 @@ class Transaction {
|
||||
return $this->sError;
|
||||
}
|
||||
|
||||
public function addTransaction($account_id, $amount, $type='Credit', $block_id=NULL, $coin_address=NULL, $fee=0) {
|
||||
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, amount, block_id, type, coin_address, fee_amount) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
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("idissd", $account_id, $amount, $block_id, $type, $coin_address, $fee);
|
||||
$stmt->bind_param("idiss", $account_id, $amount, $block_id, $type, $coin_address);
|
||||
if ($stmt->execute()) {
|
||||
$this->setErrorMessage("Failed to store transaction");
|
||||
$stmt->close();
|
||||
@ -96,7 +96,7 @@ class Transaction {
|
||||
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')
|
||||
WHERE t.type IN ('Donation','Fee')
|
||||
AND b.confirmations >= ?
|
||||
AND t.account_id = ?
|
||||
) AS t3
|
||||
|
||||
@ -20,6 +20,7 @@ $aGlobal = array(
|
||||
'sharerate' => $iCurrentPoolShareRate,
|
||||
'workers' => $iCurrentActiveWorkers,
|
||||
'roundshares' => $aRoundShares,
|
||||
'fees' => $config['fees'],
|
||||
'confirmations' => $config['confirmations'],
|
||||
'reward' => $config['reward']
|
||||
);
|
||||
@ -32,6 +33,12 @@ $aGlobal['userdata']['balance'] = $transaction->getBalance($_SESSION['USERDATA']
|
||||
$aGlobal['userdata']['shares'] = $statistics->getUserShares($_SESSION['USERDATA']['id']);
|
||||
$aGlobal['userdata']['hashrate'] = $statistics->getUserHashrate($_SESSION['USERDATA']['id']);
|
||||
|
||||
// Some estimations
|
||||
$aGlobal['userdata']['est_block'] = round(( (int)$aGlobal['userdata']['shares']['valid'] / (int)$aRoundShares['valid'] ) * (int)$config['reward'], 3);
|
||||
$aGlobal['userdata']['est_donation'] = round((( $aGlobal['userdata']['donate_percent'] / 100) * $aGlobal['userdata']['est_block']), 3);
|
||||
$aGlobal['userdata']['est_fee'] = round((($config['fees'] / 100) * ($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_donation'])), 3);
|
||||
$aGlobal['userdata']['est_payout'] = round($aGlobal['userdata']['est_block'] - $aGlobal['userdata']['est_donation'] - $aGlobal['userdata']['est_fee'], 3);
|
||||
|
||||
// Make it available in Smarty
|
||||
$smarty->assign('PATH', 'site_assets/' . THEME);
|
||||
$smarty->assign('GLOBAL', $aGlobal);
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
{if (
|
||||
($TRANSACTIONS[transaction].type == 'Credit' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
||||
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
||||
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations >= $GLOBAL.confirmations)
|
||||
or $TRANSACTIONS[transaction].type == 'Debit_AP'
|
||||
or $TRANSACTIONS[transaction].type == 'Debit_MP'
|
||||
)}
|
||||
@ -57,6 +58,7 @@
|
||||
{if (
|
||||
$TRANSACTIONS[transaction].type == 'Credit' && $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations
|
||||
or ($TRANSACTIONS[transaction].type == 'Donation' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
||||
or ($TRANSACTIONS[transaction].type == 'Fee' and $TRANSACTIONS[transaction].confirmations < $GLOBAL.confirmations)
|
||||
)}
|
||||
<tr class="{cycle values="odd,even"}">
|
||||
<td>{$TRANSACTIONS[transaction].id}</td>
|
||||
|
||||
@ -34,22 +34,24 @@
|
||||
<td><b>Your Invalid</b></td>
|
||||
<td><i>{$GLOBAL.userdata.shares.invalid}</i><font size='1px'></font></td>
|
||||
</tr>
|
||||
{math assign="block" equation="round(( x / y ) * z, 3)" x=$GLOBAL.userdata.shares.valid y=$GLOBAL.roundshares.valid z=$GLOBAL.reward}
|
||||
{math assign="donation" equation="round(((d / 100) * est), 3)" d=$GLOBAL.userdata.donate_percent est=$block}
|
||||
<tr>
|
||||
<td colspan="2"><b><u>Round Estimate</u></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Block</b></td>
|
||||
<td>{$block} LTC</td>
|
||||
<td>{$GLOBAL.userdata.est_block} LTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Donation</b></td>
|
||||
<td>{$donation} LTC</td>
|
||||
<td>{$GLOBAL.userdata.est_donation} LTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Fees</b></td>
|
||||
<td>{$GLOBAL.userdata.est_fee} LTC</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b>Payout</b></td>
|
||||
<td>{math equation="block - donation" block=$block donation=$donation} LTC</td>
|
||||
<td>{$GLOBAL.userdata.est_payout} LTC</td>
|
||||
</tr>
|
||||
<tr><td colspan="2"> </td></tr>
|
||||
<tr><td colspan="2"><b><u>Account Balance</u></b></td></tr>
|
||||
|
||||
@ -146,7 +146,6 @@ CREATE TABLE IF NOT EXISTS `transactions` (
|
||||
`type` enum('Credit','Debit_MP','Debit_AP','Fee','Donation') DEFAULT NULL,
|
||||
`coin_address` varchar(255) DEFAULT NULL,
|
||||
`amount` double DEFAULT '0',
|
||||
`fee_amount` float DEFAULT '0',
|
||||
`block_id` int(255) DEFAULT NULL,
|
||||
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user