feat: show name of most expensive subscription on statistics (#194)
This commit is contained in:
parent
45b0a3b41d
commit
ede08b1f6a
29
stats.php
29
stats.php
@ -84,13 +84,14 @@ $code = $row['code'];
|
|||||||
$activeSubscriptions = 0;
|
$activeSubscriptions = 0;
|
||||||
$inactiveSubscriptions = 0;
|
$inactiveSubscriptions = 0;
|
||||||
// Calculate total monthly price
|
// Calculate total monthly price
|
||||||
$mostExpensiveSubscription = 0;
|
$mostExpensiveSubscription = array();
|
||||||
|
$mostExpensiveSubscription['price'] = 0;
|
||||||
$amountDueThisMonth = 0;
|
$amountDueThisMonth = 0;
|
||||||
$totalCostPerMonth = 0;
|
$totalCostPerMonth = 0;
|
||||||
$totalSavingsPerMonth = 0;
|
$totalSavingsPerMonth = 0;
|
||||||
|
|
||||||
$statsSubtitleParts = [];
|
$statsSubtitleParts = [];
|
||||||
$query = "SELECT name, price, frequency, cycle, currency_id, next_payment, payer_user_id, category_id, payment_method_id, inactive FROM subscriptions";
|
$query = "SELECT name, price, logo, frequency, cycle, currency_id, next_payment, payer_user_id, category_id, payment_method_id, inactive FROM subscriptions";
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
@ -132,6 +133,7 @@ if ($result) {
|
|||||||
foreach ($subscriptions as $subscription) {
|
foreach ($subscriptions as $subscription) {
|
||||||
$name = $subscription['name'];
|
$name = $subscription['name'];
|
||||||
$price = $subscription['price'];
|
$price = $subscription['price'];
|
||||||
|
$logo = $subscription['logo'];
|
||||||
$frequency = $subscription['frequency'];
|
$frequency = $subscription['frequency'];
|
||||||
$cycle = $subscription['cycle'];
|
$cycle = $subscription['cycle'];
|
||||||
$currency = $subscription['currency_id'];
|
$currency = $subscription['currency_id'];
|
||||||
@ -149,8 +151,10 @@ if ($result) {
|
|||||||
$memberCost[$payerId]['cost'] += $price;
|
$memberCost[$payerId]['cost'] += $price;
|
||||||
$categoryCost[$categoryId]['cost'] += $price;
|
$categoryCost[$categoryId]['cost'] += $price;
|
||||||
$paymentMethodCount[$paymentMethodId]['count'] += 1;
|
$paymentMethodCount[$paymentMethodId]['count'] += 1;
|
||||||
if ($price > $mostExpensiveSubscription) {
|
if ($price > $mostExpensiveSubscription['price']) {
|
||||||
$mostExpensiveSubscription = $price;
|
$mostExpensiveSubscription['price'] = $price;
|
||||||
|
$mostExpensiveSubscription['name'] = $name;
|
||||||
|
$mostExpensiveSubscription['logo'] = $logo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate ammount due this month
|
// Calculate ammount due this month
|
||||||
@ -301,9 +305,22 @@ $numberOfElements = 6;
|
|||||||
<span><?= CurrencyFormatter::format($averageSubscriptionCost, $code) ?></span>
|
<span><?= CurrencyFormatter::format($averageSubscriptionCost, $code) ?></span>
|
||||||
<div class="title"><?= translate('average_monthly', $i18n) ?></div>
|
<div class="title"><?= translate('average_monthly', $i18n) ?></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="statistic">
|
<div class="statistic short">
|
||||||
<span><?= CurrencyFormatter::format($mostExpensiveSubscription, $code) ?></span>
|
<span><?= CurrencyFormatter::format($mostExpensiveSubscription['price'], $code) ?></span>
|
||||||
<div class="title"><?= translate('most_expensive', $i18n) ?></div>
|
<div class="title"><?= translate('most_expensive', $i18n) ?></div>
|
||||||
|
<?php
|
||||||
|
if ($mostExpensiveSubscription['logo']) {
|
||||||
|
?>
|
||||||
|
<div class="subtitle">
|
||||||
|
<img src="images/uploads/logos/<?= $mostExpensiveSubscription['logo'] ?>" alt="<?= $mostExpensiveSubscription['name'] ?>" title="<?= $mostExpensiveSubscription['name'] ?>" />
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
|
<div class="subtitle"><?= $mostExpensiveSubscription['name'] ?></div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="statistic">
|
<div class="statistic">
|
||||||
<span><?= CurrencyFormatter::format($amountDueThisMonth, $code) ?></span>
|
<span><?= CurrencyFormatter::format($amountDueThisMonth, $code) ?></span>
|
||||||
|
|||||||
@ -1247,6 +1247,10 @@ input[type="checkbox"] {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.statistic.short {
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.statistic.empty {
|
.statistic.empty {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
@ -1269,9 +1273,21 @@ input[type="checkbox"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.statistic > .title {
|
.statistic > .title {
|
||||||
|
margin-top: 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.statistic > .subtitle {
|
||||||
|
font-size: 25px;
|
||||||
|
color: #8FBFFA;
|
||||||
|
margin-top: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.statistic > .subtitle > img {
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
.graphs {
|
.graphs {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user