Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
feat: display error message on the statistics page when the fixer key is needed but is missing
Miguel Ribeiro5f1052584b5e
diff --git a/a.out b/a.outnew file mode 100644index 0000000..e69de29diff --git a/includes/i18n/de.php b/includes/i18n/de.phpindex 36d7da9..817bea7 100644--- a/includes/i18n/de.php+++ b/includes/i18n/de.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Abbrechen","upload_logo" => "Logo hochladen",// Statistics page+ 'cant_convert_currency' => "Sie verwenden mehrere Währungen für Ihre Abonnements. Um gültige und genaue Statistiken zu erhalten, legen Sie bitte einen Fixer-API-Schlüssel auf der Einstellungsseite fest.",'general_statistics' => "Allgemeine Statistiken",'active_subscriptions' => "Aktive Abonnements",'inactive_subscriptions' => "Inaktive Abonnements",diff --git a/includes/i18n/el.php b/includes/i18n/el.phpindex 622c7fa..abd018c 100644--- a/includes/i18n/el.php+++ b/includes/i18n/el.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Ακύρωση","upload_logo" => "Φόρτωση λογότυπου",// Statistics page+ 'cant_convert_currency' => "Χρησιμοποιείτε πολλαπλά νομίσματα στις συνδρομές σας. Για να έχετε έγκυρα και ακριβή στατιστικά στοιχεία, παρακαλούμε ορίστε ένα κλειδί API Fixer στη σελίδα ρυθμίσεων.",'general_statistics' => "Γενικές στατιστικές",'active_subscriptions' => "Ενεργές συνδρομές",'inactive_subscriptions' => "Ανενεργές συνδρομές",diff --git a/includes/i18n/en.php b/includes/i18n/en.phpindex 2f07022..c29a2f8 100644--- a/includes/i18n/en.php+++ b/includes/i18n/en.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Cancel","upload_logo" => "Upload Logo",// Statistics page+ 'cant_convert_currency' => "You are using multiple currencies on your subscriptions. To have valid and accurate statistics, please set a Fixer API Key on the settings page.",'general_statistics' => "General Statistics",'active_subscriptions' => "Active Subscriptions",'inactive_subscriptions' => "Inactive Subscriptions",diff --git a/includes/i18n/es.php b/includes/i18n/es.phpindex 06ac85f..558fef8 100644--- a/includes/i18n/es.php+++ b/includes/i18n/es.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Cancelar","upload_logo" => "Cargar Logotipo",// Statistics page+ 'cant_convert_currency' => "Estás utilizando varias monedas en tus suscripciones. Para disponer de estadísticas válidas y precisas, establece una clave API Fixer en la página de configuración.",'general_statistics' => "Estadísticas Generales",'active_subscriptions' => "Suscripciones Activas",'inactive_subscriptions' => "Suscripciones inactivas",diff --git a/includes/i18n/fr.php b/includes/i18n/fr.phpindex 8b22561..99fcf0a 100644--- a/includes/i18n/fr.php+++ b/includes/i18n/fr.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Annuler","upload_logo" => "Télécharger le logo",// Page de statistiques+ 'cant_convert_currency' => "Vous utilisez plusieurs devises dans vos abonnements. Pour obtenir des statistiques valides et précises, veuillez définir une clé API Fixer sur la page des paramètres.",'general_statistics' => "Statistiques générales",'active_subscriptions' => "Abonnements actifs",'inactive_subscriptions' => "Abonnements inactifs",diff --git a/includes/i18n/it.php b/includes/i18n/it.phpindex 127729f..bc3f206 100644--- a/includes/i18n/it.php+++ b/includes/i18n/it.php@@ -95,6 +95,7 @@ $i18n = ['upload_logo' => 'Carica logo',// Statistics+ 'cant_convert_currency' => "Si stanno utilizzando più valute per gli abbonamenti. Per avere statistiche valide e precise, impostare una chiave API Fixer nella pagina delle impostazioni.",'general_statistics' => 'Statistiche generali','active_subscriptions' => 'Abbonamenti attivi','inactive_subscriptions' => 'Abbonamenti inattivi',diff --git a/includes/i18n/jp.php b/includes/i18n/jp.phpindex 02afc4a..3aad65f 100644--- a/includes/i18n/jp.php+++ b/includes/i18n/jp.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "キャンセル","upload_logo" => "ロゴのアップロード",// Statistics page+ 'cant_convert_currency' => "購読に複数の通貨を使用しています。有効で正確な統計を取るには、設定ページでFixer API Keyを設定してください。",'general_statistics' => "一般統計",'active_subscriptions' => "アクティブな定期購入",'inactive_subscriptions' => "非アクティブなサブスクリプション",diff --git a/includes/i18n/ko.php b/includes/i18n/ko.phpindex d92deef..36764c2 100644--- a/includes/i18n/ko.php+++ b/includes/i18n/ko.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "취소","upload_logo" => "로고 업로드",// Statistics page+ 'cant_convert_currency' => "구독에서 여러 통화를 사용하고 있습니다. 유효하고 정확한 통계를 얻으려면 설정 페이지에서 Fixer API 키를 설정하세요.",'general_statistics' => "일반 통계",'active_subscriptions' => "활성 구독",'inactive_subscriptions' => "비활성 구독",diff --git a/includes/i18n/pl.php b/includes/i18n/pl.phpindex e154eec..57ebfb2 100644--- a/includes/i18n/pl.php+++ b/includes/i18n/pl.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Anuluj","upload_logo" => "Prześlij logo",// Statistics page+ 'cant_convert_currency' => "Używasz wielu walut w swoich subskrypcjach. Aby uzyskać prawidłowe i dokładne statystyki, należy ustawić klucz API Fixer na stronie ustawień.",'general_statistics' => "Statystyki ogólne",'active_subscriptions' => "Aktywne subskrypcje",'inactive_subscriptions' => "Nieaktywne subskrypcje",diff --git a/includes/i18n/pt.php b/includes/i18n/pt.phpindex 4268c10..1074cb3 100644--- a/includes/i18n/pt.php+++ b/includes/i18n/pt.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Cancelar","upload_logo" => "Enviar Logo",// Statistics page+ 'cant_convert_currency' => "Está a utilizar várias moedas nas suas subscrições. Para obter estatísticas válidas e exactas, defina uma chave API do Fixer na página de definições.",'general_statistics' => "Estatísticas Gerais",'active_subscriptions' => "Subscrições Activas",'inactive_subscriptions' => "Subscrições inactivas",diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.phpindex a5e7feb..6bcd5e6 100644--- a/includes/i18n/pt_br.php+++ b/includes/i18n/pt_br.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Cancelar","upload_logo" => "Enviar Logo",// Statistics page+ 'cant_convert_currency' => "Você está usando várias moedas em suas assinaturas. Para obter estatísticas válidas e precisas, defina uma chave de API do Fixer na página de configurações.",'general_statistics' => "Estatísticas gerais",'active_subscriptions' => "Assinaturas ativas",'inactive_subscriptions' => "Assinaturas inativas",diff --git a/includes/i18n/ru.php b/includes/i18n/ru.phpindex 73ce6a6..99a7e61 100644--- a/includes/i18n/ru.php+++ b/includes/i18n/ru.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Отмена","upload_logo" => "Загрузить логотип",// Statistics page+ 'cant_convert_currency' => "Вы используете несколько валют в своих подписках. Для получения достоверной и точной статистики, пожалуйста, установите API-ключ Fixer на странице настроек.",'general_statistics' => "Общая статистика",'active_subscriptions' => "Активные подписки",'inactive_subscriptions' => "Неактивные подписки",diff --git a/includes/i18n/sl.php b/includes/i18n/sl.phpindex 5a63a6d..6989cff 100644--- a/includes/i18n/sl.php+++ b/includes/i18n/sl.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Prekliči","upload_logo" => "Naloži logotip",// Statistics page+ 'cant_convert_currency' => "Pri naročninah uporabljate več valut. Če želite imeti veljavne in točne statistične podatke, na strani z nastavitvami nastavite ključ API Fixer.",'general_statistics' => "Splošna statistika",'active_subscriptions' => "Aktivne naročnine",'inactive_subscriptions' => "Neaktivne naročnine",diff --git a/includes/i18n/sr.php b/includes/i18n/sr.phpindex 1166039..c051a89 100644--- a/includes/i18n/sr.php+++ b/includes/i18n/sr.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Откажи","upload_logo" => "Постави логотип",// Страница са статистикама+ 'cant_convert_currency' => "На својим претплатама користите више валута. Да бисте имали валидну и тачну статистику, поставите Фикер АПИ кључ на страници подешавања.",'general_statistics' => "Опште статистике",'active_subscriptions' => "Активне претплате",'inactive_subscriptions' => "Неактивне претплате",diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.phpindex 6eef424..0ec7244 100644--- a/includes/i18n/sr_lat.php+++ b/includes/i18n/sr_lat.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "Otkaži","upload_logo" => "Učitaj logo",// Stranica sa statistikama+ 'cant_convert_currency' => "Na svojim pretplatama koristite više valuta. Da biste imali validnu i tačnu statistiku, postavite Fiker API ključ na stranici podešavanja.",'general_statistics' => "Opšte statistike",'active_subscriptions' => "Aktivne pretplate",'inactive_subscriptions' => "Neaktivne pretplate",diff --git a/includes/i18n/tr.php b/includes/i18n/tr.phpindex f1d3f3c..959ec79 100644--- a/includes/i18n/tr.php+++ b/includes/i18n/tr.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "İptal","upload_logo" => "Logo Yükle",// Statistics page+ 'cant_convert_currency' => "Aboneliklerinizde birden fazla para birimi kullanıyorsunuz. Geçerli ve doğru istatistiklere sahip olmak için lütfen ayarlar sayfasında bir Fixer API Anahtarı ayarlayın.",'general_statistics' => "Genel İstatistikler",'active_subscriptions' => "Aktif Abonelikler",'inactive_subscriptions' => "Aktif Olmayan Abonelikler",diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.phpindex abb4aaa..e3bd8ac 100644--- a/includes/i18n/zh_cn.php+++ b/includes/i18n/zh_cn.php@@ -95,6 +95,7 @@ $i18n = ["upload_logo" => "上传 Logo",// 统计页面+ 'cant_convert_currency' => "您在订阅中使用了多种货币。要获得有效、准确的统计数据,请在设置页面设置 Fixer API 密钥。",'general_statistics' => "总体统计",'active_subscriptions' => "活跃订阅",'inactive_subscriptions' => "非活动订阅",diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.phpindex 3c7cee7..9a88dfe 100644--- a/includes/i18n/zh_tw.php+++ b/includes/i18n/zh_tw.php@@ -89,6 +89,7 @@ $i18n = ["cancel" => "取消","upload_logo" => "上傳圖示",// 統計頁面+ 'cant_convert_currency' => "您的訂閱使用多種貨幣。為了獲得有效且準確的統計數據,請在設定頁面設定 Fixer API Key。",'general_statistics' => "整體統計",'active_subscriptions' => "訂閱中",'inactive_subscriptions' => "停用訂閱",diff --git a/includes/version.php b/includes/version.phpindex e7940d9..7f8a24f 100644--- a/includes/version.php+++ b/includes/version.php@@ -1,3 +1,3 @@<?php-$version = "v2.17.0";+$version = "v2.18.0";?>\ No newline at end of filediff --git a/scripts/settings.js b/scripts/settings.jsindex 350c2ed..ea6d71f 100644--- a/scripts/settings.js+++ b/scripts/settings.js@@ -848,6 +848,7 @@ function addFixerKeyButton() {const apiKeyInput = document.querySelector("#fixerKey");apiKey = apiKeyInput.value.trim();const provider = document.querySelector("#fixerProvider").value;+ const convertCurrencyCheckbox = document.querySelector("#convertcurrency");fetch("endpoints/currency/fixer_api_key.php", {method: "POST",headers: {@@ -860,6 +861,7 @@ function addFixerKeyButton() {if (data.success) {showSuccessMessage(data.message);document.getElementById("addFixerKey").disabled = false;+ convertCurrencyCheckbox.disabled = false;// update currency exchange ratesfetch("endpoints/currency/update_exchange.php?force=true");} else {diff --git a/settings.php b/settings.phpindex e9ce63a..635141d 100644--- a/settings.php+++ b/settings.php@@ -1215,8 +1215,10 @@ require_once 'includes/header.php';<div><div class="form-group-inline"><input type="checkbox" id="convertcurrency" name="convertcurrency" onChange="setConvertCurrency()"- <?php if ($settings['convert_currency'])- echo 'checked'; ?>>+ <?php+ if ($settings['convert_currency']) echo ' checked';+ if ($apiKey == "") echo ' disabled';+ ?>><label for="convertcurrency"><?= translate('convert_prices', $i18n) ?></label></div></div>diff --git a/stats.php b/stats.phpindex 1fea28d..66195ec 100644--- a/stats.php+++ b/stats.php@@ -19,7 +19,6 @@ function getPricePerMonth($cycle, $frequency, $price)}}-function getPriceConverted($price, $currency, $database, $userId){$query = "SELECT rate FROM currencies WHERE id = :currency AND user_id = :userId";@@ -134,6 +133,8 @@ foreach ($params as $key => $value) {}$result = $stmt->execute();+$usesMultipleCurrencies = false;+if ($result) {while ($row = $result->fetchArray(SQLITE3_ASSOC)) {$subscriptions[] = $row;@@ -146,6 +147,9 @@ if ($result) {$frequency = $subscription['frequency'];$cycle = $subscription['cycle'];$currency = $subscription['currency_id'];+ if ($currency != $userData['main_currency']) {+ $usesMultipleCurrencies = true;+ }$next_payment = $subscription['next_payment'];$payerId = $subscription['payer_user_id'];$categoryId = $subscription['category_id'];@@ -219,9 +223,32 @@ if (isset($userData['budget']) && $userData['budget'] > 0) {}}+$showCantConverErrorMessage = false;+if ($usesMultipleCurrencies) {+ $query = "SELECT api_key FROM fixer WHERE user_id = :userId";+ $stmt = $db->prepare($query);+ $stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);+ $result = $stmt->execute();+ if ($result->fetchArray(SQLITE3_ASSOC) === false) {+ $showCantConverErrorMessage = true;+ }+}+$numberOfElements = 6;?><section class="contain">+ <?php+ if ($showCantConverErrorMessage) {+ ?>+ <div class="error-box">+ <div class="error-message">+ <i class="fa-solid fa-exclamation-circle"></i>+ <?= translate('cant_convert_currency', $i18n) ?>+ </div>+ </div>+ <?php+ }+ ?><div class="split-header"><h2><?= translate('general_statistics', $i18n) ?> <span class="header-subtitle"><?= $statsSubtitle ?></span>@@ -272,7 +299,8 @@ $numberOfElements = 6;}?><div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>">- <?= $category['name'] ?></div>+ <?= $category['name'] ?>+ </div><?php}?>@@ -295,7 +323,8 @@ $numberOfElements = 6;}?><div class="filter-item <?= $selectedClass ?>" data-paymentid="<?= $payment['id'] ?>">- <?= $payment['name'] ?></div>+ <?= $payment['name'] ?>+ </div><?php}?>diff --git a/styles/styles.css b/styles/styles.cssindex 4fa5889..4d40c62 100644--- a/styles/styles.css+++ b/styles/styles.css@@ -12,6 +12,7 @@ body.no-scroll {input, button, select, textarea {font-family: Barlow, 'Helvetica Neue', Helvetica, sans-serif;+ font-weight: 400;}@media (max-width: 768px) {@@ -35,6 +36,20 @@ h2, h3 {box-sizing: border-box;}+.error-box {+ padding: 20px 16px;+ background-color: rgba(var(--error-color-rgb), 0.3);+ border: 1px solid var(--error-color);+ border-radius: 8px;+ margin-bottom: 20px;+ font-size: 16px;+}++.error-box .error-message i {+ color: var(--error-color);+ margin-right: 10px;+}+.split-header {display: flex;flex-direction: row;