diff options
Diffstat (limited to 'pages/money.inc')
-rw-r--r-- | pages/money.inc | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/pages/money.inc b/pages/money.inc index b297231..257b87f 100644 --- a/pages/money.inc +++ b/pages/money.inc @@ -1,5 +1,8 @@ <?php +$minimumRaindrops = 200; +$minimumCloudburst = 500; + require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; global $_PROFILE; $parts = explode("/", $_GET["_"]); @@ -70,7 +73,7 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " created a transaction to " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => $account["currency"] === "gbp" ? "£" : "€" . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "") + 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$_GET["amount"]) . " were " . ((float)$_GET["amount"] >= 0 ? "added" : "removed") . " just now" . (trim($_GET["description"]) !== "" ? ": " . $_GET["description"] : "") ] ])); @@ -96,7 +99,7 @@ if ((isset($_GET["create"]) || isset($_GET["delete"])) && isset($parts[2])) { "Title: " . (getMember($myId)["display_name"] ?? getMember($myId)["name"]) . " deleted a transaction from " . $account["name"] . " (" . ucfirst($account["owner"]) . ")\r\n" . "Tags: bits\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => $account["currency"] === "gbp" ? "£" : "€" . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"]) + 'content' => ($account["currency"] === "gbp" ? "£" : "€") . abs((float)$account["transactions"][(int)$_GET["id"]]["amount"]) . " " . ((float)$account["transactions"][(int)$_GET["id"]]["amount"] >= 0 ? "advance" : "withdrawal") . " created by " . (getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["display_name"] ?? getMemberWithoutSystem($account["transactions"][(int)$_GET["id"]]["author"])["name"]) . " " . timeAgo($account["transactions"][(int)$_GET["id"]]["date"]) ] ])); @@ -297,6 +300,30 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </a> <?php endif; endforeach; ?> </div> + + <div class="progress" style="margin-top: 20px;"> + <?php + + $part1 = 0; + $part2 = 1; + $difference = 0; + + if ($allAccounts > $minimumCloudburst) { + $part2 = ($allAccounts - $minimumCloudburst) / $allAccounts; + $part1 = 1 - $part2; + $difference = $allAccounts - $minimumCloudburst; + } else { + $part1 = 1; + $part2 = 0; + $difference = $minimumCloudburst - $allAccounts; + } + + ?> + <div class="progress-bar bg-danger" style="width:<?= $part1 * 100 ?>%"></div> + <div class="progress-bar bg-success" style="width:<?= $part2 * 100 ?>%"></div> + </div> + <p style="text-align: center; margin-top: 5px;" class="<?= $allAccounts > $minimumCloudburst ? "" : "bold text-danger" ?>">£<?= number_format($difference, 2, '.', ',') ?><?php if ($allAccounts > $minimumCloudburst): ?> (<?= round($part2 * 100, 2) ?>%)<?php endif; ?> <?= $allAccounts > $minimumCloudburst ? "over" : "under" ?> the minimum</p> + <canvas id="history-cloudburst" style="margin-top: 10px; width: 100%; height: 200px; max-height: 100%;"></canvas> <?php @@ -391,6 +418,30 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </a> <?php endif; endforeach; ?> </div> + + <div class="progress" style="margin-top: 20px;"> + <?php + + $part1 = 0; + $part2 = 1; + $difference = 0; + + if ($allAccounts > $minimumRaindrops) { + $part2 = ($allAccounts - $minimumRaindrops) / $allAccounts; + $part1 = 1 - $part2; + $difference = $allAccounts - $minimumRaindrops; + } else { + $part1 = 1; + $part2 = 0; + $difference = $minimumRaindrops - $allAccounts; + } + + ?> + <div class="progress-bar bg-danger" style="width:<?= $part1 * 100 ?>%"></div> + <div class="progress-bar bg-success" style="width:<?= $part2 * 100 ?>%"></div> + </div> + <p style="text-align: center; margin-top: 5px;" class="<?= $allAccounts > $minimumRaindrops ? "" : "bold text-danger" ?>">€<?= number_format($difference, 2, '.', ',') ?><?php if ($allAccounts > $minimumCloudburst): ?> (<?= round($part2 * 100, 2) ?>%)<?php endif; ?> <?= $allAccounts > $minimumRaindrops ? "over" : "under" ?> the minimum</p> + <canvas id="history-raindrops" style="margin-top: 10px; width: 100%; height: 200px; max-height: 100%;"></canvas> <?php |