Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

feat: option to show progress of subscription cycle

Miguel Ribeiroff13fcb6547e
diff --git a/api/admin/get_admin_settings.php b/api/admin/get_admin_settings.php
index a2e3bb2..b7cd423 100644
--- a/api/admin/get_admin_settings.php
+++ b/api/admin/get_admin_settings.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/categories/get_categories.php b/api/categories/get_categories.php
index 34541d1..185f9ac 100644
--- a/api/categories/get_categories.php
+++ b/api/categories/get_categories.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/currencies/get_currencies.php b/api/currencies/get_currencies.php
index 22b9a63..832a144 100644
--- a/api/currencies/get_currencies.php
+++ b/api/currencies/get_currencies.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/household/get_household.php b/api/household/get_household.php
index 232fbfa..9a0f3ef 100644
--- a/api/household/get_household.php
+++ b/api/household/get_household.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/payment_methods/get_payment_methods.php b/api/payment_methods/get_payment_methods.php
index 75b3323..79c5f15 100644
--- a/api/payment_methods/get_payment_methods.php
+++ b/api/payment_methods/get_payment_methods.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/settings/get_settings.php b/api/settings/get_settings.php
index 1ff920d..d37d940 100644
--- a/api/settings/get_settings.php
+++ b/api/settings/get_settings.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/status/version.php b/api/status/version.php
new file mode 100644
index 0000000..1accfab
--- /dev/null
+++ b/api/status/version.php
@@ -0,0 +1,81 @@
+<?php
+/*
+This API Endpoint accepts both POST and GET requests.
+It receives the following parameters:
+- api_key: the API key of the user.
+
+It returns a JSON object with the following properties:
+- success: whether the request was successful (boolean).
+- title: the title of the response (string).
+- version: a string containing the version matching the github package version.
+- version_number: a string containing the version number.
+- notes: warning messages or additional information (array).
+
+Example response:
+{
+ "success": true,
+ "title": "version",
+ "version": "v2.42.1",
+ "version_number": "2.42.1",
+ "notes": []
+}
+*/
+
+require_once '../../includes/connect_endpoint.php';
+require_once '../../includes/version.php';
+
+header('Content-Type: application/json, charset=UTF-8');
+
+if ($_SERVER["REQUEST_METHOD"] === "POST" || $_SERVER["REQUEST_METHOD"] === "GET") {
+ // if the parameters are not set, return an error
+
+ if (!isset($_REQUEST['api_key'])) {
+ $response = [
+ "success" => false,
+ "title" => "Missing parameters"
+ ];
+ echo json_encode($response);
+ exit;
+ }
+
+ $apiKey = $_REQUEST['api_key'];
+
+ // Get user from API key
+ $sql = "SELECT * FROM user WHERE api_key = :apiKey";
+ $stmt = $db->prepare($sql);
+ $stmt->bindValue(':apiKey', $apiKey);
+ $result = $stmt->execute();
+ $user = $result->fetchArray(SQLITE3_ASSOC);
+
+ // If the user is not found, return an error
+ if (!$user) {
+ $response = [
+ "success" => false,
+ "title" => "Invalid API key"
+ ];
+ echo json_encode($response);
+ exit;
+ }
+
+ $version_number = substr($version, 1);
+
+ $response = [
+ "success" => true,
+ "title" => "version",
+ "version" => $version,
+ "version_number" => $version_number,
+ "notes" => []
+ ];
+
+ echo json_encode($response);
+
+} else {
+ $response = [
+ "success" => false,
+ "title" => "Invalid request method"
+ ];
+ echo json_encode($response);
+ exit;
+}
+
+?>
\ No newline at end of file
diff --git a/api/subscriptions/get_ical_feed.php b/api/subscriptions/get_ical_feed.php
index 4f77670..27634cc 100644
--- a/api/subscriptions/get_ical_feed.php
+++ b/api/subscriptions/get_ical_feed.php
@@ -3,7 +3,7 @@
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
- convert_currency: whether to convert to the main currency (boolean) default false.
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a downloadable VCAL file with the active subscriptions
*/
diff --git a/api/subscriptions/get_monthly_cost.php b/api/subscriptions/get_monthly_cost.php
index fcd72bf..4bca50f 100644
--- a/api/subscriptions/get_monthly_cost.php
+++ b/api/subscriptions/get_monthly_cost.php
@@ -4,7 +4,7 @@ This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
- month: the month for which the cost is to be calculated (integer).
- year: the year for which the cost is to be calculated (integer).
-- apiKey: the API key of the user (string).
+- api_key: the API key of the user (string).
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/subscriptions/get_subscriptions.php b/api/subscriptions/get_subscriptions.php
index 2ecf698..880cb2d 100644
--- a/api/subscriptions/get_subscriptions.php
+++ b/api/subscriptions/get_subscriptions.php
@@ -9,7 +9,7 @@ It receives the following parameters:
- disabled_to_bottom: whether to sort the inactive subscriptions to the bottom (boolean) default false.
- sort: the sorting method (string) default next_payment ['name', 'id', 'next_payment', 'price', 'payer_user_id', 'category_id', 'payment_method_id', 'inactive', 'alphanumeric'].
- convert_currency: whether to convert to the main currency (boolean) default false.
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/api/users/get_user.php b/api/users/get_user.php
index c6a691a..7582595 100644
--- a/api/users/get_user.php
+++ b/api/users/get_user.php
@@ -2,7 +2,7 @@
/*
This API Endpoint accepts both POST and GET requests.
It receives the following parameters:
-- apiKey: the API key of the user.
+- api_key: the API key of the user.
It returns a JSON object with the following properties:
- success: whether the request was successful (boolean).
diff --git a/endpoints/settings/subscription_progress.php b/endpoints/settings/subscription_progress.php
new file mode 100644
index 0000000..373afd2
--- /dev/null
+++ b/endpoints/settings/subscription_progress.php
@@ -0,0 +1,34 @@
+<?php
+require_once '../../includes/connect_endpoint.php';
+
+if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
+ die(json_encode([
+ "success" => false,
+ "message" => translate('session_expired', $i18n)
+ ]));
+}
+
+if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ $postData = file_get_contents("php://input");
+ $data = json_decode($postData, true);
+
+ $show_subscription_progress = $data['value'];
+
+ $stmt = $db->prepare('UPDATE settings SET show_subscription_progress = :show_subscription_progress WHERE user_id = :userId');
+ $stmt->bindParam(':show_subscription_progress', $show_subscription_progress, SQLITE3_INTEGER);
+ $stmt->bindParam(':userId', $userId, SQLITE3_INTEGER);
+
+ if ($stmt->execute()) {
+ die(json_encode([
+ "success" => true,
+ "message" => translate("success", $i18n)
+ ]));
+ } else {
+ die(json_encode([
+ "success" => false,
+ "message" => translate("error", $i18n)
+ ]));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/endpoints/subscriptions/get.php b/endpoints/subscriptions/get.php
index 9a9cfba..36821b1 100644
--- a/endpoints/subscriptions/get.php
+++ b/endpoints/subscriptions/get.php
@@ -164,6 +164,7 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
$print[$id]['category_id'] = $subscription['category_id'];
$print[$id]['payer_user_id'] = $subscription['payer_user_id'];
$print[$id]['price'] = floatval($subscription['price']);
+ $print[$id]['progress'] = getSubscriptionProgress($cycle, $frequency, $subscription['next_payment']);
$print[$id]['inactive'] = $subscription['inactive'];
$print[$id]['url'] = $subscription['url'] ?? "";
$print[$id]['notes'] = $subscription['notes'] ?? "";
@@ -194,7 +195,7 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {
}
if (isset($print)) {
- printSubscriptions($print, $sort, $categories, $members, $i18n, $colorTheme, "../../", $settings['disabledToBottom'], $settings['mobileNavigation']);
+ printSubscriptions($print, $sort, $categories, $members, $i18n, $colorTheme, "../../", $settings['disabledToBottom'], $settings['mobileNavigation'], $settings['showSubscriptionProgress']);
}
if (count($subscriptions) == 0) {
diff --git a/includes/getsettings.php b/includes/getsettings.php
index 5bcf5df..0f73c61 100644
--- a/includes/getsettings.php
+++ b/includes/getsettings.php
@@ -28,6 +28,7 @@ if ($settings) {
$settings['disabledToBottom'] = $settings['disabled_to_bottom'] ? 'true': 'false';
$settings['showOriginalPrice'] = $settings['show_original_price'] ? 'true': 'false';
$settings['mobileNavigation'] = $settings['mobile_nav'] ? 'true': 'false';
+ $settings['showSubscriptionProgress'] = $settings['show_subscription_progress'] ? 'true': 'false';
}
$query = "SELECT * FROM custom_colors WHERE user_id = :userId";
diff --git a/includes/i18n/de.php b/includes/i18n/de.php
index b612a6a..7143055 100644
--- a/includes/i18n/de.php
+++ b/includes/i18n/de.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Berechne und zeige monatlichen Preis für alle Abonnements an",
"convert_prices" => "Preise immer in meine Hauptwährung umrechnen und darin anzeigen (langsamer)",
"show_original_price" => "Originalpreis anzeigen, wenn Umrechnungen oder Berechnungen durchgeführt werden",
+ "experience" => "Erfahrung",
+ "show_subscription_progress" => "Abonnementfortschritt anzeigen",
"disabled_subscriptions" => "Deaktivierte Abonnements",
"hide_disabled_subscriptions" => "Deaktivierte Abonnements verstecken",
"show_disabled_subscriptions_at_the_bottom" => "Deaktivierte Abonnements am Ende anzeigen",
diff --git a/includes/i18n/el.php b/includes/i18n/el.php
index 4d4916e..3ef529c 100644
--- a/includes/i18n/el.php
+++ b/includes/i18n/el.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Υπολογισμός και εμφάνιση της μηνιαίας τιμής για όλες τις συνδρομές",
"convert_prices" => "Πάντα να μετατρέπει και να εμφανίζει τις τιμές στο κύριο νόμισμά μου (πιο αργό)",
"show_original_price" => "Εμφάνιση της αρχικής τιμής όταν γίνονται μετατροπές ή υπολογισμοί",
+ "experience" => "Εμπειρία",
+ "show_subscription_progress" => "Εμφάνιση προόδου συνδρομής",
"disabled_subscriptions" => "Απενεργοποιημένες συνδρομές",
"hide_disabled_subscriptions" => "Απόκρυψη απενεργοποιημένων συνδρομών",
"show_disabled_subscriptions_at_the_bottom" => "Εμφάνιση απενεργοποιημένων συνδρομών στο τέλος",
diff --git a/includes/i18n/en.php b/includes/i18n/en.php
index e97f921..969510f 100644
--- a/includes/i18n/en.php
+++ b/includes/i18n/en.php
@@ -224,6 +224,8 @@ $i18n = [
"calculate_monthly_price" => "Calculate and show monthly price for all subscriptions",
"convert_prices" => "Always convert and show prices on my main currency (slower)",
"show_original_price" => "Also show original price when conversions or calculations are made",
+ "experience" => "Experience",
+ "show_subscription_progress" => "Show subscription progress",
"disabled_subscriptions" => "Disabled Subscriptions",
"hide_disabled_subscriptions" => "Hide disabled subscriptions",
"show_disabled_subscriptions_at_the_bottom" => "Show disabled subscriptions at the bottom",
diff --git a/includes/i18n/es.php b/includes/i18n/es.php
index c372391..4c5b3a0 100644
--- a/includes/i18n/es.php
+++ b/includes/i18n/es.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Calcular y mostrar el precio mensual de todas las suscripciones",
"convert_prices" => "Convertir y mostrar siempre los precios en mi moneda principal (más lento)",
"show_original_price" => "Mostrar también el precio original cuando se realicen conversiones o cálculos",
+ "experience" => "Experiencia",
+ "show_subscription_progress" => "Mostrar el progreso de la suscripción",
"disabled_subscriptions" => "Suscripciones Desactivadas",
"hide_disabled_subscriptions" => "Ocultar suscripciones desactivadas",
"show_disabled_subscriptions_at_the_bottom" => "Mostrar suscripciones desactivadas al final",
diff --git a/includes/i18n/fr.php b/includes/i18n/fr.php
index de02131..09cc02d 100644
--- a/includes/i18n/fr.php
+++ b/includes/i18n/fr.php
@@ -224,6 +224,8 @@ $i18n = [
"calculate_monthly_price" => "Calculer et afficher le prix mensuel pour tous les abonnements",
"convert_prices" => "Convertir toujours et afficher les prix dans ma devise principale (plus lent)",
"show_original_price" => "Afficher également le prix original lorsque des conversions ou des calculs sont effectués",
+ "experience" => "Expérience",
+ "show_subscription_progress" => "Afficher la progression de l'abonnement",
"disabled_subscriptions" => "Abonnements désactivés",
"hide_disabled_subscriptions" => "Masquer les abonnements désactivés",
"show_disabled_subscriptions_at_the_bottom" => "Afficher les abonnements désactivés en bas",
diff --git a/includes/i18n/it.php b/includes/i18n/it.php
index ce40ca5..1c4346b 100644
--- a/includes/i18n/it.php
+++ b/includes/i18n/it.php
@@ -230,6 +230,8 @@ $i18n = [
"calculate_monthly_price" => 'Calcola e mostra il prezzo mensile per tutti gli abbonamenti',
"convert_prices" => 'Converti sempre e mostra i prezzi nella mia valuta principale (più lento)',
"show_original_price" => "Mostra anche il prezzo originale quando vengono effettuate conversioni o calcoli",
+ "experience" => 'Esperienza',
+ "show_subscription_progress" => 'Mostra il progresso dell\'abbonamento',
"disabled_subscriptions" => 'Abbonamenti disattivati',
"hide_disabled_subscriptions" => 'Nascondi gli abbonamenti disattivati',
"show_disabled_subscriptions_at_the_bottom" => 'Mostra gli abbonamenti disattivati in fondo',
diff --git a/includes/i18n/jp.php b/includes/i18n/jp.php
index 12be4fb..35e66ab 100644
--- a/includes/i18n/jp.php
+++ b/includes/i18n/jp.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "すべての定期購入の月額料金を計算して表示する",
"convert_prices" => "常にメイン通貨で価格を換算して表示する (遅い)",
"show_original_price" => "変換や計算が行われるときに元の価格も表示する",
+ "experience" => "体験",
+ "show_subscription_progress" => "定期購入の進捗を表示する",
"disabled_subscriptions" => "無効な定期購入",
"hide_disabled_subscriptions" => "無効な定期購入を非表示にする",
"show_disabled_subscriptions_at_the_bottom" => "無効な定期購入を一番下に表示する",
diff --git a/includes/i18n/ko.php b/includes/i18n/ko.php
index 41e29f7..989ff83 100644
--- a/includes/i18n/ko.php
+++ b/includes/i18n/ko.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "모든 구독에 대한 월별 요금을 계산하고 표시",
"convert_prices" => "항상 기본 통화로 가격을 환산하고 표시 (느림)",
"show_original_price" => "변환이나 계산이 이루어질 때 원래 가격도 표시",
+ "experience" => "경험",
+ "show_subscription_progress" => "구독 진행률 표시",
"disabled_subscriptions" => "비활성화된 구독",
"hide_disabled_subscriptions" => "비활성화된 구독 숨기기",
"show_disabled_subscriptions_at_the_bottom" => "비활성화된 구독을 하단에 표시",
diff --git a/includes/i18n/nl.php b/includes/i18n/nl.php
index 8ca3828..cc53dd0 100644
--- a/includes/i18n/nl.php
+++ b/includes/i18n/nl.php
@@ -224,6 +224,8 @@ $i18n = [
"calculate_monthly_price" => "Bereken en toon maandelijkse prijs voor alle abonnementen",
"convert_prices" => "Converteer en toon prijzen altijd in mijn basisvaluta (langzamer)",
"show_original_price" => "Toon ook originele prijs bij conversies of berekeningen",
+ "experience" => "Ervaring",
+ "show_subscription_progress" => "Toon abonnementsvoortgang",
"disabled_subscriptions" => "Uitgeschakelde abonnementen",
"hide_disabled_subscriptions" => "Verberg uitgeschakelde abonnementen",
"show_disabled_subscriptions_at_the_bottom" => "Toon uitgeschakelde abonnementen onderaan",
diff --git a/includes/i18n/pl.php b/includes/i18n/pl.php
index 3d6bd9e..16906b9 100644
--- a/includes/i18n/pl.php
+++ b/includes/i18n/pl.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Oblicz i pokaż miesięczną cenę wszystkich subskrypcji",
"convert_prices" => "Zawsze przeliczaj i pokazuj ceny w mojej głównej walucie (wolniej)",
"show_original_price" => "Pokaż również oryginalną cenę, gdy dokonywane są przeliczenia lub obliczenia",
+ "experience" => "Doświadczenie",
+ "show_subscription_progress" => "Pokaż postęp subskrypcji",
"disabled_subscriptions" => "Wyłączone subskrypcje",
"hide_disabled_subscriptions" => "Ukryj wyłączone subskrypcje",
"show_disabled_subscriptions_at_the_bottom" => "Pokaż wyłączone subskrypcje na dole",
diff --git a/includes/i18n/pt.php b/includes/i18n/pt.php
index f2a8d8c..5258152 100644
--- a/includes/i18n/pt.php
+++ b/includes/i18n/pt.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Calcular e mostrar preço mensal para todas as subscrições",
"convert_prices" => "Converter e mostrar todas as subscrições na moeda principal (mais lento)",
"show_original_price" => "Também mostrar o preço original quando são feitas conversões ou cálculos",
+ "experience" => "Experiência",
+ "show_subscription_progress" => "Mostrar progresso da subscrição",
"disabled_subscriptions" => "Subscrições Desactivadas",
"hide_disabled_subscriptions" => "Esconder subscrições desactivadas",
"show_disabled_subscriptions_at_the_bottom" => "Mostrar subscrições desactivadas no fundo da lista",
diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.php
index ba5f852..75c88af 100644
--- a/includes/i18n/pt_br.php
+++ b/includes/i18n/pt_br.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Calcular e exibir o custo mensal para todas as assinaturas",
"convert_prices" => "Sempre converter e exibir preços na moeda principal (mais lento)",
"show_original_price" => "Também mostrar o preço original quando conversões ou cálculos são feitos",
+ "experience" => "Experiência",
+ "show_subscription_progress" => "Mostrar progresso da assinatura",
"disabled_subscriptions" => "Assinaturas desativadas",
"hide_disabled_subscriptions" => "Ocultar assinaturas desativadas",
"show_disabled_subscriptions_at_the_bottom" => "Mostre as assinaturas desativadas no final da lista",
diff --git a/includes/i18n/ru.php b/includes/i18n/ru.php
index 6e74ccc..6ae08e6 100644
--- a/includes/i18n/ru.php
+++ b/includes/i18n/ru.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Рассчитать и показать ежемесячную цену для всех подписок",
"convert_prices" => "Всегда конвертировать и показывать цены в моей основной валюте (медленнее)",
"show_original_price" => "Также показывать оригинальную цену при выполнении конверсий или расчетов",
+ "experience" => "Опыт",
+ "show_subscription_progress" => "Показать прогресс подписки",
"disabled_subscriptions" => "Отключенные подписки",
"hide_disabled_subscriptions" => "Скрыть отключенные подписки",
"show_disabled_subscriptions_at_the_bottom" => "Показать отключенные подписки внизу списка",
diff --git a/includes/i18n/sl.php b/includes/i18n/sl.php
index 7e22968..f75e11e 100644
--- a/includes/i18n/sl.php
+++ b/includes/i18n/sl.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Izračunaj in prikaži mesečno ceno za vse naročnine",
"convert_prices" => "Vedno pretvori in prikaži cene v moji glavni valuti (počasneje)",
"show_original_price" => "Prikaži tudi originalno ceno, ko se izvajajo pretvorbe ali izračuni",
+ "experience" => "Izkušnja",
+ "show_subscription_progress" => "Prikaži napredek naročnine",
"disabled_subscriptions" => "Onemogočene naročnine",
"hide_disabled_subscriptions" => "Skrij onemogočene naročnine",
"show_disabled_subscriptions_at_the_bottom" => "Prikaži onemogočene naročnine na dnu seznama",
diff --git a/includes/i18n/sr.php b/includes/i18n/sr.php
index 4017495..1b34629 100644
--- a/includes/i18n/sr.php
+++ b/includes/i18n/sr.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Израчунајте и прикажите месечну цену за све претплате",
"convert_prices" => "Увек конвертујте и прикажите цене на мојој главној валути (спорије)",
"show_original_price" => "Прикажи и оригиналну цену када се врше конверзије или прорачуни",
+ "experience" => "Искуство",
+ "show_subscription_progress" => "Прикажи прогрес претплате",
"disabled_subscriptions" => "Онемогућене претплате",
"hide_disabled_subscriptions" => "Сакриј онемогућене претплате",
"show_disabled_subscriptions_at_the_bottom" => "Прикажи онемогућене претплате на дну",
diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.php
index 39f8b86..4b94815 100644
--- a/includes/i18n/sr_lat.php
+++ b/includes/i18n/sr_lat.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Izračunaj i prikaži mesečnu cenu za sve pretplate",
"convert_prices" => "Uvek konvertuj i prikaži cene u mojoj glavnoj valuti (sporije)",
"show_original_price" => "Prikaži i originalnu cenu kada se vrše konverzije ili proračuni",
+ "experience" => "Iskustvo",
+ "show_subscription_progress" => "Prikaži napredak pretplate",
"disabled_subscriptions" => "Onemogućene pretplate",
"hide_disabled_subscriptions" => "Sakrij onemogućene pretplate",
"show_disabled_subscriptions_at_the_bottom" => "Prikaži onemogućene pretplate na dnu",
diff --git a/includes/i18n/tr.php b/includes/i18n/tr.php
index a7f5525..b210f01 100644
--- a/includes/i18n/tr.php
+++ b/includes/i18n/tr.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "Tüm aboneliklerin aylık fiyatını hesaplayın ve gösterin",
"convert_prices" => "Fiyatları her zaman ana para birimimde dönüştürün ve gösterin (daha yavaş)",
"show_original_price" => "Dönüşümler veya hesaplamalar yapıldığında orijinal fiyatı da göster",
+ "experience" => "Deneyim",
+ "show_subscription_progress" => "Aboneliklerin ilerlemesini göster",
"disabled_subscriptions" => "Devre Dışı Bırakılan Abonelikler",
"hide_disabled_subscriptions" => "Devre dışı bırakılan abonelikleri gizle",
"show_disabled_subscriptions_at_the_bottom" => "Devre dışı bırakılan abonelikleri altta göster",
diff --git a/includes/i18n/vi.php b/includes/i18n/vi.php
index 239b271..7ecfc09 100644
--- a/includes/i18n/vi.php
+++ b/includes/i18n/vi.php
@@ -224,6 +224,8 @@ $i18n = [
"calculate_monthly_price" => "Tính toán và hiển thị giá hàng tháng cho tất cả các đăng ký",
"convert_prices" => "Luôn chuyển đổi và hiển thị giá theo tiền tệ chính của tôi (chậm hơn)",
"show_original_price" => "Cũng hiển thị giá gốc khi thực hiện chuyển đổi hoặc tính toán",
+ "experience" => "Trải nghiệm",
+ "show_subscription_progress" => "Hiển thị tiến độ đăng ký",
"disabled_subscriptions" => "Các đăng ký đã vô hiệu hóa",
"hide_disabled_subscriptions" => "Ẩn các đăng ký đã vô hiệu hóa",
"show_disabled_subscriptions_at_the_bottom" => "Hiển thị các đăng ký đã vô hiệu hóa ở cuối",
diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.php
index a8e4c11..1b8f9a5 100644
--- a/includes/i18n/zh_cn.php
+++ b/includes/i18n/zh_cn.php
@@ -231,6 +231,8 @@ $i18n = [
"calculate_monthly_price" => "计算并显示所有订阅的月价格",
"convert_prices" => "始终按我的主要货币转换和显示价格(较慢)",
"show_original_price" => "当进行转换或计算时,也显示原始价格",
+ "experience" => "体验",
+ "show_subscription_progress" => "显示订阅进度",
"disabled_subscriptions" => "已停用的订阅",
"hide_disabled_subscriptions" => "隐藏已停用的订阅",
"show_disabled_subscriptions_at_the_bottom" => "在订阅列表底部显示已停用的订阅",
diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.php
index 7265a05..fb2dc71 100644
--- a/includes/i18n/zh_tw.php
+++ b/includes/i18n/zh_tw.php
@@ -223,6 +223,8 @@ $i18n = [
"calculate_monthly_price" => "計算並顯示所有訂閱的每月價格",
"convert_prices" => "始終按照我的主要貨幣單位轉換和顯示價格(較慢)",
"show_original_price" => "當進行轉換或計算時,也顯示原始價格",
+ "experience" => "體驗",
+ "show_subscription_progress" => "顯示訂閱進度",
"disabled_subscriptions" => "停用的訂閱",
"hide_disabled_subscriptions" => "隱藏已停用的訂閱",
"show_disabled_subscriptions_at_the_bottom" => "將已停用的訂閱顯示在底部",
diff --git a/includes/list_subscriptions.php b/includes/list_subscriptions.php
index daa4862..d9b7a94 100644
--- a/includes/list_subscriptions.php
+++ b/includes/list_subscriptions.php
@@ -16,6 +16,35 @@ function getBillingCycle($cycle, $frequency, $i18n)
}
}
+function getSubscriptionProgress($cycle, $frequency, $next_payment) {
+ $nextPaymentDate = new DateTime($next_payment);
+ $currentDate = new DateTime('now');
+
+ $paymentCycleDays = 30; // Default to monthly
+ if ($cycle === 1) {
+ $paymentCycleDays = 1 * $frequency;
+ } else if ($cycle === 2) {
+ $paymentCycleDays = 7 * $frequency;
+ } else if ($cycle === 3) {
+ $paymentCycleDays = 30 * $frequency;
+ } else if ($cycle === 4) {
+ $paymentCycleDays = 365 * $frequency;
+ }
+
+ $lastPaymentDate = clone $nextPaymentDate;
+ $lastPaymentDate->modify("-$paymentCycleDays days");
+
+ $totalCycleDays = $lastPaymentDate->diff($nextPaymentDate)->days;
+ $daysSinceLastPayment = $lastPaymentDate->diff($currentDate)->days;
+
+ $subscriptionProgress = 0;
+ if ($totalCycleDays > 0) {
+ $subscriptionProgress = ($daysSinceLastPayment / $totalCycleDays) * 100;
+ }
+
+ return floor($subscriptionProgress);
+}
+
function getPricePerMonth($cycle, $frequency, $price)
{
switch ($cycle) {
@@ -51,7 +80,7 @@ function getPriceConverted($price, $currency, $database)
}
}
-function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n, $colorTheme, $imagePath, $disabledToBottom, $mobileNavigation)
+function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n, $colorTheme, $imagePath, $disabledToBottom, $mobileNavigation, $showSubscriptionProgress)
{
if ($sort === "price") {
usort($subscriptions, function ($a, $b) {
@@ -258,6 +287,13 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,
}
?>
</div>
+ <?php
+ if ($showSubscriptionProgress === 'true') {
+ ?>
+ <span class="subscription-progress" style="width: <?= $subscription['progress'] ?>%;"></span>
+ <?php
+ }
+ ?>
</div>
<?php
}
diff --git a/includes/version.php b/includes/version.php
index 3f88bfd..6804fa6 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
-$version = "v2.42.2";
+$version = "v2.43.0";
?>
\ No newline at end of file
diff --git a/index.php b/index.php
index 37e3cb2..9f73eab 100644
--- a/index.php
+++ b/index.php
@@ -367,6 +367,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden
$print[$id]['category_id'] = $subscription['category_id'];
$print[$id]['payer_user_id'] = $subscription['payer_user_id'];
$print[$id]['price'] = floatval($subscription['price']);
+ $print[$id]['progress'] = getSubscriptionProgress($cycle, $frequency, $subscription['next_payment']);
$print[$id]['inactive'] = $subscription['inactive'];
$print[$id]['url'] = $subscription['url'];
$print[$id]['notes'] = $subscription['notes'];
@@ -397,7 +398,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden
}
if (isset($print)) {
- printSubscriptions($print, $sort, $categories, $members, $i18n, $colorTheme, "", $settings['disabledToBottom'], $settings['mobileNavigation']);
+ printSubscriptions($print, $sort, $categories, $members, $i18n, $colorTheme, "", $settings['disabledToBottom'], $settings['mobileNavigation'], $settings['showSubscriptionProgress']);
}
$db->close();
diff --git a/migrations/000033.php b/migrations/000033.php
new file mode 100644
index 0000000..cf9f192
--- /dev/null
+++ b/migrations/000033.php
@@ -0,0 +1,11 @@
+<?php
+// This migration adds a "show_subscription_progress" column to the settings table and sets to false as default.
+
+/** @noinspection PhpUndefinedVariableInspection */
+$columnQuery = $db->query("SELECT * FROM pragma_table_info('settings') where name='show_subscription_progress'");
+$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
+
+if ($columnRequired) {
+ $db->exec("ALTER TABLE settings ADD COLUMN show_subscription_progress BOOLEAN DEFAULT 0");
+ $db->exec('UPDATE settings SET `show_subscription_progress` = 0');
+}
\ No newline at end of file
diff --git a/scripts/settings.js b/scripts/settings.js
index bb42344..fb64352 100644
--- a/scripts/settings.js
+++ b/scripts/settings.js
@@ -843,6 +843,13 @@ function setMobileNavigation() {
storeSettingsOnDB('mobile_navigation', value);
}
+function setShowSubscriptionProgress() {
+ const showSubscriptionProgressCheckbox = document.querySelector("#showsubscriptionprogress");
+ const value = showSubscriptionProgressCheckbox.checked;
+
+ storeSettingsOnDB('subscription_progress', value);
+}
+
function saveCategorySorting() {
const categories = document.getElementById('categories');
const categoryIds = Array.from(categories.children).map(category => category.dataset.categoryid);
diff --git a/settings.php b/settings.php
index 1b11eca..f946088 100644
--- a/settings.php
+++ b/settings.php
@@ -10,7 +10,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$currencyId = $row['id'];
$currencies[$currencyId] = $row;
}
-$userData['currency_symbol'] = "€";
+$userData['currency_symbol'] = $currencies[$main_currency]['symbol'];
?>
@@ -1170,6 +1170,25 @@ $userData['currency_symbol'] = "€";
<label for="showoriginalprice"><?= translate('show_original_price', $i18n) ?></label>
</div>
</div>
+ <h3><?= translate('experience', $i18n) ?></h3>
+ <div>
+ <div class="form-group-inline">
+ <input type="checkbox" id="mobilenavigation" name="mobilenavigation"
+ onChange="setMobileNavigation()" <?php if ($settings['mobile_nav'])
+ echo 'checked'; ?>>
+ <label for="mobilenavigation"><?= translate('use_mobile_navigation_bar', $i18n) ?></label>
+ </div>
+ <div class="mobile-nav-image">
+ </div>
+ </div>
+ <div>
+ <div class="form-group-inline">
+ <input type="checkbox" id="showsubscriptionprogress" name="showsubscriptionprogress"
+ onChange="setShowSubscriptionProgress()" <?php if ($settings['show_subscription_progress'])
+ echo 'checked'; ?>>
+ <label for="showsubscriptionprogress"><?= translate('show_subscription_progress', $i18n) ?></label>
+ </div>
+ </div>
<h3><?= translate('disabled_subscriptions', $i18n) ?></h3>
<div>
<div class="form-group-inline">
@@ -1203,16 +1222,6 @@ $userData['currency_symbol'] = "€";
<label for="removebackground"><?= translate('remove_background', $i18n) ?></label>
</div>
</div>
- <div>
- <div class="form-group-inline">
- <input type="checkbox" id="mobilenavigation" name="mobilenavigation"
- onChange="setMobileNavigation()" <?php if ($settings['mobile_nav'])
- echo 'checked'; ?>>
- <label for="mobilenavigation"><?= translate('use_mobile_navigation_bar', $i18n) ?></label>
- </div>
- <div class="mobile-nav-image">
- </div>
- </div>
</div>
<div class="settings-notes">
<p>
diff --git a/styles/styles.css b/styles/styles.css
index 69ecaba..8fc0f31 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -345,6 +345,7 @@ button:hover svg .main-color {
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
border-radius: 16px;
background-color: #FFFFFF;
+ overflow: hidden;
}
.subscription-container>.mobile-actions {
@@ -414,6 +415,16 @@ button.mobile-action-renew {
display: none;
}
+.subscription-container>.subscription-progress {
+ width: 36%;
+ height: 3px;
+ background-color: var(--accent-color);
+ display: block;
+ position: absolute;
+ bottom: 0px;
+ z-index: 1;
+}
+
.subscription.inactive {
background-color: #FFF;
color: rgba(100, 100, 100, 0.6);