Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
.DS_Store
.idea/
.vscode/
/logos/*
docker-compose.dev.yaml
1 change: 1 addition & 0 deletions includes/i18n/ca.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Perfil",
"dashboard" => "Taulell",
"subscriptions" => "Subscripcions",
"subscriptions_count" => "{count} Subscripcions",
"stats" => "Estadístiques",
"settings" => "Configuració",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/cs.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Přehled",
"subscriptions" => "Předplatná",
"subscriptions_count" => "{count} Předplatná",
"stats" => "Statistiky",
"settings" => "Nastavení",
"admin" => "Administrace",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/da.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Dashboard",
"subscriptions" => "Abonnementer",
"subscriptions_count" => "{count} Abonnementer",
"stats" => "Statistik",
"settings" => "Indstillinger",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/de.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Dashboard",
"subscriptions" => "Abonnements",
"subscriptions_count" => "{count} Abonnements",
"stats" => "Statistiken",
"settings" => "Einstellungen",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/el.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Προφίλ",
"dashboard" => "Πίνακας",
"subscriptions" => "Συνδρομές",
"subscriptions_count" => "{count} Συνδρομές",
"stats" => "Στατιστικές",
"settings" => "Ρυθμίσεις",
"admin" => "Διαχείριση",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/en.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profile",
"dashboard" => "Dashboard",
"subscriptions" => "Subscriptions",
"subscriptions_count" => "{count} Subscriptions",
"stats" => "Statistics",
"settings" => "Settings",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/es.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Perfil",
"dashboard" => "Tablero",
"subscriptions" => "Suscripciones",
"subscriptions_count" => "{count} Suscripciones",
"stats" => "Estadísticas",
"settings" => "Configuración",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/fr.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Accueil",
"subscriptions" => "Abonnements",
"subscriptions_count" => "{count} Abonnements",
"stats" => "Statistiques",
"settings" => "Paramètres",
"admin" => "Admin",
Expand Down
16 changes: 12 additions & 4 deletions includes/i18n/getlang.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@
}
}

function translate($text, $translations)
function translate($text, $translations, $variables = [])
{
if (array_key_exists($text, $translations)) {
return $translations[$text];
$translation = $translations[$text];
} else {
require 'en.php';
if (array_key_exists($text, $i18n)) {
return $i18n[$text];
if (isset($i18n[$text])) {
$translation = $i18n[$text];
} else {
return "[i18n String Missing]";
}
}

if (!empty($variables)) {
foreach ($variables as $key => $value) {
$translation = str_replace([':' . $key, '{' . $key . '}'], $value, $translation);
}
}

return $translation;
}

?>
1 change: 1 addition & 0 deletions includes/i18n/id.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Dasbor",
"subscriptions" => "Langganan",
"subscriptions_count" => "{count} Langganan",
"stats" => "Statistik",
"settings" => "Pengaturan",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/it.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"profile" => 'Profilo',
"dashboard" => 'Dashboard',
"subscriptions" => 'Abbonamenti',
"subscriptions_count" => "{count} Abbonamenti",
"stats" => 'Statistiche',
"settings" => 'Impostazioni',
"admin" => 'Amministrazione',
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/jp.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "プロフィール",
"dashboard" => "ダッシュボード",
"subscriptions" => "定期購入",
"subscriptions_count" => "{count} 定期購入",
"stats" => "統計",
"settings" => "設定",
"admin" => "管理者",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ko.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "프로필",
"dashboard" => "대시보드",
"subscriptions" => "구독",
"subscriptions_count" => "{count} 구독",
"stats" => "통계",
"settings" => "설정",
"admin" => "관리자",
Expand Down
Empty file modified includes/i18n/languages.php
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions includes/i18n/nl.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profiel",
"dashboard" => "Dashboard",
"subscriptions" => "Abonnementen",
"subscriptions_count" => "{count} Abonnementen",
"stats" => "Statistieken",
"settings" => "Instellingen",
"admin" => "Beheer",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pl.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Panel",
"subscriptions" => "Subskrypcje",
"subscriptions_count" => "{count} Subskrypcje",
"stats" => "Statystyki",
"settings" => "Ustawienia",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Perfil",
"dashboard" => "Painel",
"subscriptions" => "Subscrições",
"subscriptions_count" => "{count} Subscrições",
"stats" => "Estatísticas",
"settings" => "Definições",
"admin" => "Administração",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt_br.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Perfil",
"dashboard" => "Painel",
"subscriptions" => "Assinaturas",
"subscriptions_count" => "{count} Assinaturas",
"stats" => "Estatísticas",
"settings" => "Configurações",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ru.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Профиль",
"dashboard" => "Панель",
"subscriptions" => "Подписки",
"subscriptions_count" => "{count} Подписки",
"stats" => "Статистика",
"settings" => "Настройки",
"admin" => "Администратор",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sl.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Panel",
"subscriptions" => "Naročnine",
"subscriptions_count" => "{count} Naročnine",
"stats" => "Statistika",
"settings" => "Nastavitve",
"admin" => "Skrbnik",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Профил",
"dashboard" => "Панел",
"subscriptions" => "Претплате",
"subscriptions_count" => "{count} Претплате",
"stats" => "Статистике",
"settings" => "Подешавања",
"admin" => "Админ",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr_lat.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Panel",
"subscriptions" => "Pretplate",
"subscriptions_count" => "{count} Pretplate",
"stats" => "Statistike",
"settings" => "Podešavanja",
"admin" => "Admin",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/tr.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Profil",
"dashboard" => "Panel",
"subscriptions" => "Abonelikler",
"subscriptions_count" => "{count} Abonelikler",
"stats" => "İstatistikler",
"settings" => "Ayarlar",
"admin" => "Yönetici",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/uk.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Профіль",
"dashboard" => "Панель",
"subscriptions" => "Підписки",
"subscriptions_count" => "{count} Підписки",
"stats" => "Статистика",
"settings" => "Налаштування",
"admin" => "Адміністратор",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/vi.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "Hồ sơ",
"dashboard" => "Bảng",
"subscriptions" => "Đăng ký",
"subscriptions_count" => "{count} Đăng ký",
"stats" => "Thống kê",
"settings" => "Cài đặt",
"admin" => "Quản trị viên",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_cn.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"profile" => "个人资料",
"dashboard" => "仪表盘",
"subscriptions" => "订阅",
"subscriptions_count" => "{count} 订阅",
"stats" => "统计",
"settings" => "设置",
"admin" => "管理员",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_tw.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"profile" => "個人檔案",
"dashboard" => "儀表板",
"subscriptions" => "訂閱服務",
"subscriptions_count" => "{count} 訂閱服務",
"stats" => "統計資訊",
"settings" => "設定",
"admin" => "管理員",
Expand Down
34 changes: 33 additions & 1 deletion includes/stats_calculations.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ function getPricePerMonth($cycle, $frequency, $price)
}
}

function getPricePerYear($cycle, $frequency, $price)
{
switch ($cycle) {
case 1:
$numberOfPaymentsPerYear = (365 / $frequency);
return $price * $numberOfPaymentsPerYear;
case 2:
$numberOfPaymentsPerYear = (52.14 / $frequency);
return $price * $numberOfPaymentsPerYear;
case 3:
$numberOfPaymentsPerYear = (12 / $frequency);
return $price * $numberOfPaymentsPerYear;
case 4:
return $price / $frequency;
}
}

function getPriceConverted($price, $currency, $database, $userId)
{
$query = "SELECT rate FROM currencies WHERE id = :currency AND user_id = :userId";
Expand Down Expand Up @@ -84,6 +101,11 @@ function getPriceConverted($price, $currency, $database, $userId)
$mostExpensiveSubscription['price'] = 0;
$amountDueThisMonth = 0;
$totalCostPerMonth = 0;
$totalCostPerYear = 0;
$monthlySubscriptions = 0;
$monthlySubscriptionsCost = 0;
$yearlySubscriptions = 0;
$yearlySubscriptionsCost = 0;
$totalSavingsPerMonth = 0;
$totalCostsInReplacementsPerMonth = 0;

Expand Down Expand Up @@ -155,10 +177,20 @@ function getPriceConverted($price, $currency, $database, $userId)
$replacementSubscriptionId = $subscription['replacement_subscription_id'];
$originalSubscriptionPrice = getPriceConverted($price, $currency, $db, $userId);
$price = getPricePerMonth($cycle, $frequency, $originalSubscriptionPrice);
$priceInYear = getPricePerYear($cycle, $frequency, $originalSubscriptionPrice);

if ($inactive == 0) {
if($cycle != 4) {
$monthlySubscriptions++;
$monthlySubscriptionsCost += $price;
}else{
$yearlySubscriptions++;
$yearlySubscriptionsCost += $priceInYear;
}

$activeSubscriptions++;
$totalCostPerMonth += $price;
$totalCostPerYear += $priceInYear;
$memberCost[$payerId]['cost'] += $price;
$categoryCost[$categoryId]['cost'] += $price;
$paymentMethodsCount[$paymentMethodId]['count'] += 1;
Expand Down Expand Up @@ -214,7 +246,7 @@ function getPriceConverted($price, $currency, $database, $userId)
$totalSavingsPerMonth -= $totalCostsInReplacementsPerMonth;

// Calculate yearly price
$totalCostPerYear = $totalCostPerMonth * 12;
// $totalCostPerYear = $totalCostPerMonth * 12;

// Calculate average subscription monthly cost
if ($activeSubscriptions > 0) {
Expand Down
27 changes: 27 additions & 0 deletions index.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class="subscription-item-logo" title="<?= $subscriptionName ?>">
</div>
</div>


<?php if (isset($totalCostPerMonth)) { ?>
<div class="subscription-item thin">
<p class="subscription-item-title"><?= translate('monthly_cost', $i18n) ?></p>
Expand All @@ -316,6 +317,32 @@ class="subscription-item-logo" title="<?= $subscriptionName ?>">
</div>
</div>
<?php } ?>


<?php if (isset($monthlySubscriptionsCost)) { ?>
<div class="subscription-item thin">
<p class="subscription-item-title"><?= translate('Monthly', $i18n) ?></p>
<div class="subscription-item-info">
<p class="subscription-item-date"><?= translate('subscriptions_count', $i18n, ['count'=>$monthlySubscriptions])?></p>
<p class="subscription-item-value">
<?= CurrencyFormatter::format($monthlySubscriptionsCost, $currencies[$userData['main_currency']]['code']) ?>
</p>
</div>
</div>
<?php } ?>

<?php if (isset($yearlySubscriptionsCost)) { ?>
<div class="subscription-item thin">
<p class="subscription-item-title"><?= translate('Yearly', $i18n) ?></p>
<div class="subscription-item-info">
<p class="subscription-item-date"><?= translate('subscriptions_count', $i18n, ['count'=>$yearlySubscriptions])?></p>
<p class="subscription-item-value">
<?= CurrencyFormatter::format($yearlySubscriptionsCost, $currencies[$userData['main_currency']]['code']) ?>
</p>
</div>
</div>
<?php } ?>

</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -2911,7 +2911,7 @@ input[type="radio"]:checked+label::after {
border-radius: 16px;
box-shadow: var(--box-shadow);
padding: 20px;
width: 155px;
width: 170px;
height: 145px;
flex: 0 0 auto;
/* prevent flex resizing */
Expand All @@ -2922,7 +2922,7 @@ input[type="radio"]:checked+label::after {
}

.dashboard-subscriptions-list>.subscription-item.thin {
height: 115px;
height: 135px;
}

.dashboard-subscriptions-list>.subscription-item .subscription-item-title {
Expand Down Expand Up @@ -3097,4 +3097,5 @@ input[type="radio"]:checked+label::after {
.spinner.ai-spinner {
margin: auto;
}
}
}

Loading