diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 38e1b429..038a30c5 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -9,11 +9,12 @@ class Transaction { private $table = 'transactions'; private $tableBlocks = 'blocks'; - public function __construct($debug, $mysqli, $config, $block) { + 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); } @@ -116,6 +117,36 @@ class Transaction { return true; } + /** + * Get all donation transactions + * Used on donors page + * return data array Donors and amounts + **/ + public function getDonations() { + $this->debug->append("STA " . __METHOD__, 4); + $stmt = $this->mysqli->prepare(" + SELECT + SUM(t.amount) AS donation, + a.username AS username, + a.donate_percent AS donate_percent + FROM $this->table AS t + LEFT JOIN " . $this->user->getTableName() . " AS a + ON t.account_id = a.id + LEFT JOIN blocks AS b + ON t.block_id = b.id + WHERE + ( + ( t.type = 'Donation' AND b.confirmations >= " . $this->config['confirmations'] . " ) OR + t.type = 'Donation_PPS' + ) + GROUP BY a.username + "); + if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_all(MYSQLI_ASSOC); + $this->debug->append("Failed to fetch website donors: " . $this->mysqli->error); + return false; + } + /** * Get total balance for all users locked in wallet * This includes any outstanding unconfirmed transactions! @@ -231,4 +262,4 @@ class Transaction { } } -$transaction = new Transaction($debug, $mysqli, $config, $block); +$transaction = new Transaction($debug, $mysqli, $config, $block, $user); diff --git a/public/include/pages/about/donors.inc.php b/public/include/pages/about/donors.inc.php new file mode 100644 index 00000000..e4ff8753 --- /dev/null +++ b/public/include/pages/about/donors.inc.php @@ -0,0 +1,11 @@ +getDonations(); + +// Tempalte specifics +$smarty->assign("DONORS", $aDonors); +$smarty->assign("CONTENT", "default.tpl"); +?> diff --git a/public/templates/mmcFE/about/donors/default.tpl b/public/templates/mmcFE/about/donors/default.tpl new file mode 100644 index 00000000..366ffbd3 --- /dev/null +++ b/public/templates/mmcFE/about/donors/default.tpl @@ -0,0 +1,27 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Pool Donors"} +
+{include file="global/pagination.tpl"} + + + + + + + + + +{section name=donor loop=$DONORS} + + + + + +{sectionelse} + + + +{/section} + +
Name%{$GLOBAL.config.currency} Total
{$DONORS[donor].username}{$DONORS[donor].donate_percent}{$DONORS[donor].donation|number_format:"2"}
No donors yet! Be the first one to donate!
+
+{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 407d5c6b..09901679 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -31,6 +31,7 @@
  • About
  • {if $smarty.session.AUTHENTICATED|default == 1}
  • Logout
  • {else}
  • Register
  • {/if}