Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixer key error message #446

Merged
merged 2 commits into from
Jul 14, 2024
Merged
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
Empty file added a.out
Empty file.
1 change: 1 addition & 0 deletions includes/i18n/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"cancel" => "Ακύρωση",
"upload_logo" => "Φόρτωση λογότυπου",
// Statistics page
'cant_convert_currency' => "Χρησιμοποιείτε πολλαπλά νομίσματα στις συνδρομές σας. Για να έχετε έγκυρα και ακριβή στατιστικά στοιχεία, παρακαλούμε ορίστε ένα κλειδί API Fixer στη σελίδα ρυθμίσεων.",
'general_statistics' => "Γενικές στατιστικές",
'active_subscriptions' => "Ενεργές συνδρομές",
'inactive_subscriptions' => "Ανενεργές συνδρομές",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
'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',
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/jp.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"cancel" => "キャンセル",
"upload_logo" => "ロゴのアップロード",
// Statistics page
'cant_convert_currency' => "購読に複数の通貨を使用しています。有効で正確な統計を取るには、設定ページでFixer API Keyを設定してください。",
'general_statistics' => "一般統計",
'active_subscriptions' => "アクティブな定期購入",
'inactive_subscriptions' => "非アクティブなサブスクリプション",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ko.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"cancel" => "취소",
"upload_logo" => "로고 업로드",
// Statistics page
'cant_convert_currency' => "구독에서 여러 통화를 사용하고 있습니다. 유효하고 정확한 통계를 얻으려면 설정 페이지에서 Fixer API 키를 설정하세요.",
'general_statistics' => "일반 통계",
'active_subscriptions' => "활성 구독",
'inactive_subscriptions' => "비활성 구독",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt_br.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"cancel" => "Отмена",
"upload_logo" => "Загрузить логотип",
// Statistics page
'cant_convert_currency' => "Вы используете несколько валют в своих подписках. Для получения достоверной и точной статистики, пожалуйста, установите API-ключ Fixer на странице настроек.",
'general_statistics' => "Общая статистика",
'active_subscriptions' => "Активные подписки",
'inactive_subscriptions' => "Неактивные подписки",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sl.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"cancel" => "Откажи",
"upload_logo" => "Постави логотип",
// Страница са статистикама
'cant_convert_currency' => "На својим претплатама користите више валута. Да бисте имали валидну и тачну статистику, поставите Фикер АПИ кључ на страници подешавања.",
'general_statistics' => "Опште статистике",
'active_subscriptions' => "Активне претплате",
'inactive_subscriptions' => "Неактивне претплате",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr_lat.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/tr.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"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",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"upload_logo" => "上传 Logo",

// 统计页面
'cant_convert_currency' => "您在订阅中使用了多种货币。要获得有效、准确的统计数据,请在设置页面设置 Fixer API 密钥。",
'general_statistics' => "总体统计",
'active_subscriptions' => "活跃订阅",
'inactive_subscriptions' => "非活动订阅",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_tw.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"cancel" => "取消",
"upload_logo" => "上傳圖示",
// 統計頁面
'cant_convert_currency' => "您的訂閱使用多種貨幣。為了獲得有效且準確的統計數據,請在設定頁面設定 Fixer API Key。",
'general_statistics' => "整體統計",
'active_subscriptions' => "訂閱中",
'inactive_subscriptions' => "停用訂閱",
Expand Down
2 changes: 1 addition & 1 deletion includes/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$version = "v2.17.0";
$version = "v2.18.0";
?>
2 changes: 2 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -860,6 +861,7 @@ function addFixerKeyButton() {
if (data.success) {
showSuccessMessage(data.message);
document.getElementById("addFixerKey").disabled = false;
convertCurrencyCheckbox.disabled = false;
// update currency exchange rates
fetch("endpoints/currency/update_exchange.php?force=true");
} else {
Expand Down
6 changes: 4 additions & 2 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,10 @@ class="thin"><?= $settings['customCss'] ?? "" ?></textarea>
<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>
Expand Down
35 changes: 32 additions & 3 deletions stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -134,6 +133,8 @@ function getPriceConverted($price, $currency, $database, $userId)
}

$result = $stmt->execute();
$usesMultipleCurrencies = false;

if ($result) {
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$subscriptions[] = $row;
Expand All @@ -146,6 +147,9 @@ function getPriceConverted($price, $currency, $database, $userId)
$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'];
Expand Down Expand Up @@ -219,9 +223,32 @@ function getPriceConverted($price, $currency, $database, $userId)
}
}

$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>
Expand Down Expand Up @@ -272,7 +299,8 @@ function getPriceConverted($price, $currency, $database, $userId)
}
?>
<div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>">
<?= $category['name'] ?></div>
<?= $category['name'] ?>
</div>
<?php
}
?>
Expand All @@ -295,7 +323,8 @@ function getPriceConverted($price, $currency, $database, $userId)
}
?>
<div class="filter-item <?= $selectedClass ?>" data-paymentid="<?= $payment['id'] ?>">
<?= $payment['name'] ?></div>
<?= $payment['name'] ?>
</div>
<?php
}
?>
Expand Down
15 changes: 15 additions & 0 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down