Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
fix: null array on empty subscription list
Miguel Ribeiro0fef9597ef9e
diff --git a/.gitignore b/.gitignoreindex 9143a9f..60c1b97 100644--- a/.gitignore+++ b/.gitignore@@ -5,3 +5,4 @@.DS_Store.idea/.vscode/+AGENTS.mddiff --git a/about.php b/about.phpindex f12c0ff..6353bc3 100644--- a/about.php+++ b/about.php@@ -83,16 +83,6 @@ if (!is_null($settings['latest_version'])) {<h2><?= translate("credits", $i18n) ?></h2></header><div class="credits-list">- <div>- <h3><?= translate('icons', $i18n) ?></h3>- <span>- https://www.streamlinehq.com/freebies/plump-flat-free- <a href="https://www.streamlinehq.com/freebies/plump-flat-free" target="_blank"- title="<?= translate('external_url', $i18n) ?>" rel="noreferrer">- <i class="fa-solid fa-arrow-up-right-from-square"></i>- </a>- </span>- </div><div><h3><?= translate('payment_icons', $i18n) ?></h3><span>diff --git a/admin.php b/admin.phpindex eae1ce6..4fd5540 100644--- a/admin.php+++ b/admin.php@@ -140,7 +140,7 @@ $loginDisabledAllowed = $userCount == 1 && $settings['registrations_open'] == 0;<div class="user-list"><?phpforeach ($users as $user) {- $userIcon = $user['id'] == 1 ? 'fa-user-tie' : 'fa-id-badge';+ $userIcon = $user['id'] == 1 ? 'fa-user-shield' : 'fa-user';?><div class="form-group-inline" data-userid="<?= $user['id'] ?>"><div class="user-list-row">@@ -152,7 +152,7 @@ $loginDisabledAllowed = $userCount == 1 && $settings['registrations_open'] == 0;</div><div title="<?= translate('email', $i18n) ?>"><div class="user-list-icon">- <i class="fa-solid fa-envelope"></i>+ <i class="fa-solid fa-at"></i></div><a href="mailto:<?= htmlspecialchars($user['email']) ?>"><?= htmlspecialchars($user['email']) ?></a></div>@@ -163,14 +163,14 @@ $loginDisabledAllowed = $userCount == 1 && $settings['registrations_open'] == 0;?><button class="image-button medium" onClick="removeUser(<?= $user['id'] ?>)"title="<?= translate('delete_user', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php} else {?><button class="image-button medium disabled" disabledtitle="<?= translate('delete_user', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php}diff --git a/calendar.php b/calendar.phpindex 74b090c..d45e721 100644--- a/calendar.php+++ b/calendar.php@@ -199,9 +199,21 @@ $yearsToLoad = $calendarYear - $currentYear + 1;<?phpforeach ($subscriptions as $subscription) {$nextPaymentDate = strtotime($subscription['next_payment']);- $cycle = $subscription['cycle']; // Integer from 1 to 4+ $cycle = $subscription['cycle'];$frequency = $subscription['frequency'];+ if ($cycle == 5) {+ // One-time purchase: only show on its exact payment date+ if (date('Y-m', $nextPaymentDate) == $calendarYear . '-' . str_pad($calendarMonth, 2, '0', STR_PAD_LEFT) && date('d', $nextPaymentDate) == $day) {+ ?>+ <div class="calendar-subscription-title" onClick="openSubscriptionModal(<?= $subscription['id'] ?>)">+ <?= htmlspecialchars($subscription['name']) ?>+ </div>+ <?php+ }+ continue;+ }+$endDate = strtotime("+" . $yearsToLoad . " years", $nextPaymentDate);// Determine the strtotime increment string based on cycle@@ -219,7 +231,7 @@ $yearsToLoad = $calendarYear - $currentYear + 1;$incrementString = "+{$frequency} years";break;default:- $incrementString = "+{$frequency} months"; // Default case, if needed+ $incrementString = "+{$frequency} months";}// Calculate the start of the month@@ -272,9 +284,21 @@ $yearsToLoad = $calendarYear - $currentYear + 1;<?phpforeach ($subscriptions as $subscription) {$nextPaymentDate = strtotime($subscription['next_payment']);- $cycle = $subscription['cycle']; // Integer from 1 to 4+ $cycle = $subscription['cycle'];$frequency = $subscription['frequency'];+ if ($cycle == 5) {+ // One-time purchase: only show on its exact payment date+ if (date('Y-m', $nextPaymentDate) == $calendarYear . '-' . str_pad($calendarMonth, 2, '0', STR_PAD_LEFT) && date('d', $nextPaymentDate) == $day) {+ ?>+ <div class="calendar-subscription-title" onClick="openSubscriptionModal(<?= $subscription['id'] ?>)">+ <?= htmlspecialchars($subscription['name']) ?>+ </div>+ <?php+ }+ continue;+ }+$endDate = strtotime("+" . $yearsToLoad . " years", $nextPaymentDate);// Determine the strtotime increment string based on cycle@@ -292,7 +316,7 @@ $yearsToLoad = $calendarYear - $currentYear + 1;$incrementString = "+{$frequency} years";break;default:- $incrementString = "+{$frequency} months"; // Default case, if needed+ $incrementString = "+{$frequency} months";}// Calculate the start of the month@@ -314,7 +338,7 @@ $yearsToLoad = $calendarYear - $currentYear + 1;}?><div class="calendar-subscription-title" onClick="openSubscriptionModal(<?= $subscription['id'] ?>)">- <?= $subscription['name'] ?>+ <?= htmlspecialchars($subscription['name']) ?></div><?php}diff --git a/endpoints/cronjobs/createdatabase.php b/endpoints/cronjobs/createdatabase.phpindex d659832..449f050 100644--- a/endpoints/cronjobs/createdatabase.php+++ b/endpoints/cronjobs/createdatabase.php@@ -126,7 +126,8 @@ if (!file_exists($databaseFile)) {(1, 1, 'Daily'),(2, 7, 'Weekly'),(3, 30, 'Monthly'),- (4, 365, 'Yearly')");+ (4, 365, 'Yearly'),+ (5, 0, 'One-time')");$db->exec("INSERT INTO frequencies (id, name) VALUES(1, 1),diff --git a/endpoints/cronjobs/generaterecommendations.php b/endpoints/cronjobs/generaterecommendations.phpindex 26dc7fd..12add1d 100644--- a/endpoints/cronjobs/generaterecommendations.php+++ b/endpoints/cronjobs/generaterecommendations.php@@ -40,12 +40,16 @@ function getPricePerMonth($cycle, $frequency, $price)case 2: return $price * (4.35 / $frequency);case 3: return $price / $frequency;case 4: return $price / (12 * $frequency);+ case 5: return 0;default: return $price;}}function describeFrequency($cycle, $frequency){+ if ($cycle === 5) {+ return 'One-time purchase (lifetime)';+ }$unit = match ($cycle) {1 => 'day',2 => 'week',@@ -174,7 +178,7 @@ You are a helpful assistant designed to help users save money on digital subscriThe user has shared a list of their active subscriptions across household members. For each subscription, you are given:- Name of the service- Price (in original currency)-- Payment frequency (e.g., every month, every year, etc.)+- Payment frequency (e.g., every month, every year, etc.) — entries marked "One-time purchase (lifetime)" are perpetual licenses already paid for, not recurring costs- Category- Payer (which household member pays for it)@@ -191,6 +195,7 @@ Follow these guidelines:- Recommend switching from monthly to yearly plans only if it provides clear savings and the user is likely to keep the service long-term.- Suggest looking for promo or new customer deals if a service appears overpriced.- Only recommend cancelling rarely used services if they do not provide unique value.+- Do NOT suggest cancelling or changing one-time purchases (lifetime licenses) — they are already paid for and have no ongoing cost.Return the result as a JSON array. Each item in the array should have:- "title": a short summary of the suggestiondiff --git a/endpoints/cronjobs/sendnotifications.php b/endpoints/cronjobs/sendnotifications.phpindex 221e43e..c9e91eb 100644--- a/endpoints/cronjobs/sendnotifications.php+++ b/endpoints/cronjobs/sendnotifications.php@@ -765,7 +765,8 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {curl_setopt($ch, CURLOPT_URL, $ntfyHost . '/' . $ntfyTopic);curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $message);- curl_setopt($ch, CURLOPT_HTTPHEADER, $customheaders);+ $ntfyHeaders = array_merge(['Content-Type: text/plain; charset=utf-8'], $customheaders);+ curl_setopt($ch, CURLOPT_HTTPHEADER, $ntfyHeaders);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);if ($ntfy['ignore_ssl']) {diff --git a/endpoints/db/migrate.php b/endpoints/db/migrate.phpindex 0e5b989..3819f41 100644--- a/endpoints/db/migrate.php+++ b/endpoints/db/migrate.php@@ -20,7 +20,7 @@ try {$completedMigrations = [];$migrationTableExists = $db- ->query('SELECT name FROM sqlite_master WHERE type="table" AND name="migrations"')+ ->query("SELECT name FROM sqlite_master WHERE type='table' AND name='migrations'")->fetchArray(SQLITE3_ASSOC) !== false;if ($migrationTableExists) {diff --git a/endpoints/subscription/renew.php b/endpoints/subscription/renew.phpindex f35d377..e3954b3 100644--- a/endpoints/subscription/renew.php+++ b/endpoints/subscription/renew.php@@ -17,7 +17,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {}$subscriptionId = $data["id"];-$query = "SELECT * FROM subscriptions WHERE id = :id AND user_id = :user_id AND auto_renew = 0";+$query = "SELECT * FROM subscriptions WHERE id = :id AND user_id = :user_id AND auto_renew = 0 AND cycle != 5";$stmt = $db->prepare($query);$stmt->bindValue(':id', $subscriptionId, SQLITE3_INTEGER);$stmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);diff --git a/endpoints/subscriptions/get.php b/endpoints/subscriptions/get.phpindex 0980d92..bdf1f9a 100644--- a/endpoints/subscriptions/get.php+++ b/endpoints/subscriptions/get.php@@ -88,8 +88,29 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {}if (isset($_GET['renewalType']) && $_GET['renewalType'] != "") {- $sql .= " AND auto_renew = :auto_renew";- $params[':auto_renew'] = $_GET['renewalType'];+ if ($_GET['renewalType'] === 'onetime') {+ $sql .= " AND cycle = 5";+ } else {+ $sql .= " AND auto_renew = :auto_renew AND cycle != 5";+ $params[':auto_renew'] = $_GET['renewalType'];+ }+ }++ if (isset($_GET['notifications']) && $_GET['notifications'] !== "") {+ $notifTypes = array_filter(explode(',', $_GET['notifications']), fn($t) => in_array($t, ['reminder', 'cancellation', 'none']));+ $notifConditions = [];+ foreach ($notifTypes as $type) {+ if ($type === 'reminder') {+ $notifConditions[] = "notify = 1";+ } elseif ($type === 'cancellation') {+ $notifConditions[] = "(cancellation_date IS NOT NULL AND cancellation_date != '')";+ } elseif ($type === 'none') {+ $notifConditions[] = "(notify = 0 AND (cancellation_date IS NULL OR cancellation_date = ''))";+ }+ }+ if (!empty($notifConditions)) {+ $sql .= " AND (" . implode(' OR ', $notifConditions) . ")";+ }}if (isset($_COOKIE['sortOrder']) && $_COOKIE['sortOrder'] != "") {@@ -161,6 +182,7 @@ if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] === true) {$cycle = $subscription['cycle'];$frequency = $subscription['frequency'];$print[$id]['billing_cycle'] = getBillingCycle($cycle, $frequency, $i18n);+ $print[$id]['one_time'] = ($cycle == 5);$paymentMethodId = $subscription['payment_method_id'];$print[$id]['currency_code'] = $currencies[$subscription['currency_id']]['code'];$currencyId = $subscription['currency_id'];diff --git a/includes/filters_menu.php b/includes/filters_menu.phpindex 123ae28..0d4338a 100644--- a/includes/filters_menu.php+++ b/includes/filters_menu.php@@ -110,6 +110,16 @@<div class="filtermenu-submenu-content" id="filter-renewal_type"><div class="filter-item capitalize" data-renewaltype="1"><?= translate("auto_renewal", $i18n) ?></div><div class="filter-item capitalize" data-renewaltype="0"><?= translate("manual_renewal", $i18n) ?></div>+ <div class="filter-item capitalize" data-renewaltype="onetime"><?= translate("One-time", $i18n) ?></div>+ </div>+ </div>++ <div class="filtermenu-submenu">+ <div class="filter-title" onClick="toggleSubMenu('notification')"><?= translate("notifications", $i18n) ?></div>+ <div class="filtermenu-submenu-content" id="filter-notification">+ <div class="filter-item capitalize" data-notificationtype="reminder"><?= translate("reminder", $i18n) ?></div>+ <div class="filter-item capitalize" data-notificationtype="cancellation"><?= translate("cancellation", $i18n) ?></div>+ <div class="filter-item capitalize" data-notificationtype="none"><?= translate("none", $i18n) ?></div></div></div>diff --git a/includes/i18n/ca.php b/includes/i18n/ca.phpindex b53715a..043fac2 100644--- a/includes/i18n/ca.php+++ b/includes/i18n/ca.php@@ -72,7 +72,9 @@ $i18n = ["start_date" => "Data d'Inici","inactive" => "Desactivar Subscripció","replaced_with" => "Reemplaçada amb",- "none" => "Cap",+ "none" => "Cap",+ "reminder" => "Recordatori",+ "cancellation" => "Cancel·lació","member" => "Membre","category" => "Categoria","payment_method" => "Mètode de Pagament",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Setmanal","Monthly" => "Mensual","Yearly" => "Anual",+ "One-time" => "Únic",+ "lifetime_purchases" => "Compres de per vida","daily" => "Dia / Dies","weekly" => "Setmana / Setmanes","monthly" => "Mes / Mesos","yearly" => "Any / Anys",+ "one-time" => "Únic",+ "payment_date" => "Data de pagament","days" => "dies","weeks" => "setmanes","months" => "mesos",diff --git a/includes/i18n/cs.php b/includes/i18n/cs.phpindex 78e4af3..16eda8c 100644--- a/includes/i18n/cs.php+++ b/includes/i18n/cs.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Zakázat předplatné","replaced_with" => "Nahrazeno","none" => "Nic",+ "reminder" => "Připomínka",+ "cancellation" => "Zrušení","member" => "Člen","category" => "Kategorie","payment_method" => "Platební metoda",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Týdně","Monthly" => "Měsíčně","Yearly" => "Ročně",+ "One-time" => "Jednorázový",+ "lifetime_purchases" => "Doživotní nákupy","daily" => "dní","weekly" => "týdnů","monthly" => "měsíců","yearly" => "roků",+ "one-time" => "Jednorázový",+ "payment_date" => "Datum platby","days" => "dní","weeks" => "týdnů","months" => "měsíců",diff --git a/includes/i18n/da.php b/includes/i18n/da.phpindex 821ee85..ea47e21 100644--- a/includes/i18n/da.php+++ b/includes/i18n/da.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Deaktiver abonnement","replaced_with" => "Erstattet med","none" => "Ingen",+ "reminder" => "Påmindelse",+ "cancellation" => "Annullering","member" => "Medlem","category" => "Kategori","payment_method" => "Betalingsmetode",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Ugentligt","Monthly" => "Månedligt","Yearly" => "Årligt",+ "One-time" => "Engangskøb",+ "lifetime_purchases" => "Livstidskøb","daily" => "Dag(e)","weekly" => "Uge(r)","monthly" => "Måned(er)","yearly" => "År",+ "one-time" => "Engangskøb",+ "payment_date" => "Betalingsdato","days" => "dage","weeks" => "uger","months" => "måneder",diff --git a/includes/i18n/de.php b/includes/i18n/de.phpindex ea6cd6a..5904ecb 100644--- a/includes/i18n/de.php+++ b/includes/i18n/de.php@@ -72,7 +72,9 @@ $i18n = ["start_date" => "Startdatum","inactive" => "Abonnement deaktivieren","replaced_with" => "Ersetzt durch",- "none" => "Keine",+ "none" => "Keine",+ "reminder" => "Erinnerung",+ "cancellation" => "Kündigung","member" => "Mitglied","category" => "Kategorie","payment_method" => "Zahlungsmethode",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Wöchentlich","Monthly" => "Monatlich","Yearly" => "Jährlich",+ "One-time" => "Einmalig",+ "lifetime_purchases" => "Lebenslange Käufe","dayly" => "Tag(e)","weekly" => "Woche(n)","monthly" => "Monat(e)","yearly" => "Jahr(e)",+ "one-time" => "Einmalig",+ "payment_date" => "Zahlungsdatum","days" => "Tage","weeks" => "Wochen","months" => "Monate",diff --git a/includes/i18n/el.php b/includes/i18n/el.phpindex b713e67..9e00f5c 100644--- a/includes/i18n/el.php+++ b/includes/i18n/el.php@@ -80,10 +80,14 @@ $i18n = ["Weekly" => "Εβδομαδιαία","Monthly" => "Μηνιαία","Yearly" => "Ετήσια",+ "One-time" => "Εφάπαξ",+ "lifetime_purchases" => "Αγορές δια βίου","dayly" => "Ημέρα(ες)","weekly" => "Εβδομάδα","monthly" => "Μήνας(ες)","yearly" => "Χρόνος(ια)",+ "one-time" => "Εφάπαξ",+ "payment_date" => "Ημερομηνία πληρωμής","days" => "ημέρες","weeks" => "εβδομάδες","months" => "μήνες",diff --git a/includes/i18n/en.php b/includes/i18n/en.phpindex c4ba827..6404f40 100644--- a/includes/i18n/en.php+++ b/includes/i18n/en.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Disable Subscription","replaced_with" => "Replaced with","none" => "None",+ "reminder" => "Reminder",+ "cancellation" => "Cancellation","member" => "Member","category" => "Category","payment_method" => "Payment Method",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Weekly","Monthly" => "Monthly","Yearly" => "Yearly",+ "One-time" => "One-time",+ "lifetime_purchases" => "Lifetime Purchases","daily" => "Day(s)","weekly" => "Week(s)","monthly" => "Month(s)","yearly" => "Year(s)",+ "one-time" => "One-time",+ "payment_date" => "Payment Date","days" => "days","weeks" => "weeks","months" => "months",diff --git a/includes/i18n/es.php b/includes/i18n/es.phpindex 6d63077..314e652 100644--- a/includes/i18n/es.php+++ b/includes/i18n/es.php@@ -72,7 +72,9 @@ $i18n = ["start_date" => "Fecha de Inicio","inactive" => "Desactivar Suscripción","replaced_with" => "Reemplazada con",- "none" => "Ninguna",+ "none" => "Ninguna",+ "reminder" => "Recordatorio",+ "cancellation" => "Cancelación","member" => "Miembro","category" => "Categoría","payment_method" => "Método de Pago",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Semanal","Monthly" => "Mensual","Yearly" => "Anual",+ "One-time" => "Único",+ "lifetime_purchases" => "Compras de por vida","daily" => "Día(s)","weekly" => "Semana(s)","monthly" => "Mes(es)","yearly" => "Año(s)",+ "one-time" => "Único",+ "payment_date" => "Fecha de pago","days" => "días","weeks" => "semanas","months" => "meses",diff --git a/includes/i18n/fr.php b/includes/i18n/fr.phpindex b743332..d053491 100644--- a/includes/i18n/fr.php+++ b/includes/i18n/fr.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Désactiver l'abonnement","replaced_with" => "Remplacé par","none" => "Aucun",+ "reminder" => "Rappel",+ "cancellation" => "Annulation","member" => "Membre","category" => "Catégorie","payment_method" => "Méthode de paiement",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Hebdomadaire","Monthly" => "Mensuel","Yearly" => "Annuel",+ "One-time" => "Unique",+ "lifetime_purchases" => "Achats à vie","daily" => "Jour(s)","weekly" => "Semaine(s)","monthly" => "Mois","yearly" => "Année(s)",+ "one-time" => "Unique",+ "payment_date" => "Date de paiement","days" => "jours","weeks" => "semaines","months" => "mois",diff --git a/includes/i18n/id.php b/includes/i18n/id.phpindex 7982ac7..fce8c3e 100644--- a/includes/i18n/id.php+++ b/includes/i18n/id.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Nonaktifkan Langganan","replaced_with" => "Diganti dengan","none" => "Tidak ada",+ "reminder" => "Pengingat",+ "cancellation" => "Pembatalan","member" => "Anggota","category" => "Kategori","payment_method" => "Metode Pembayaran",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Mingguan","Monthly" => "Bulanan","Yearly" => "Tahunan",+ "One-time" => "Sekali bayar",+ "lifetime_purchases" => "Pembelian seumur hidup","daily" => "Hari","weekly" => "Minggu","monthly" => "Bulan","yearly" => "Tahun",+ "one-time" => "Sekali bayar",+ "payment_date" => "Tanggal pembayaran","days" => "hari","weeks" => "minggu","months" => "bulan",diff --git a/includes/i18n/it.php b/includes/i18n/it.phpindex 8308d76..c332a7c 100644--- a/includes/i18n/it.php+++ b/includes/i18n/it.php@@ -85,10 +85,14 @@ $i18n = ["Weekly" => 'Settimanale',"Monthly" => 'Mensile',"Yearly" => 'Annuale',+ "One-time" => "Una tantum",+ "lifetime_purchases" => "Acquisti a vita","daily" => 'Giorno/i',"weekly" => 'Settimana/e',"monthly" => 'Mese/i',"yearly" => 'Anno/i',+ "one-time" => "Una tantum",+ "payment_date" => "Data di pagamento","days" => 'giorni',"weeks" => 'settimane',"months" => 'mesi',diff --git a/includes/i18n/ja.php b/includes/i18n/ja.phpindex 3836189..1611f35 100644--- a/includes/i18n/ja.php+++ b/includes/i18n/ja.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "サブスクリプションを無効にする","replaced_with" => "置き換えられた","none" => "なし",+ "reminder" => "リマインダー",+ "cancellation" => "キャンセル","member" => "メンバー","category" => "カテゴリ","payment_method" => "支払い方法",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "毎週","Monthly" => "毎月","Yearly" => "毎年",+ "One-time" => "買い切り",+ "lifetime_purchases" => "買い切り購入","daily" => "日","weekly" => "週","monthly" => "月","yearly" => "年",+ "one-time" => "買い切り",+ "payment_date" => "支払日","days" => "日毎","weeks" => "週毎","months" => "月毎",diff --git a/includes/i18n/ko.php b/includes/i18n/ko.phpindex 58a9f83..5b38d19 100644--- a/includes/i18n/ko.php+++ b/includes/i18n/ko.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "구독 비활성화","replaced_with" => "다음 구독으로 대체됨","none" => "없음",+ "reminder" => "알림",+ "cancellation" => "취소","member" => "구성원","category" => "카테고리","payment_method" => "지불 수단",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "주간 결제","Monthly" => "월간 결제","Yearly" => "연간 결제",+ "One-time" => "일회성",+ "lifetime_purchases" => "영구 구매","daily" => "일","weekly" => "주","monthly" => "월","yearly" => "년",+ "one-time" => "일회성",+ "payment_date" => "결제일","days" => "매일","weeks" => "매주","months" => "매월",diff --git a/includes/i18n/nl.php b/includes/i18n/nl.phpindex 5f43f0c..09abf23 100644--- a/includes/i18n/nl.php+++ b/includes/i18n/nl.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Abonnement uitschakelen","replaced_with" => "Vervangen door","none" => "Geen",+ "reminder" => "Herinnering",+ "cancellation" => "Annulering","member" => "Lid","category" => "Categorie","payment_method" => "Betaalmethode",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Wekelijks","Monthly" => "Maandelijks","Yearly" => "Jaarlijks",+ "One-time" => "Eenmalig",+ "lifetime_purchases" => "Levenslange aankopen","daily" => "Dagen","weekly" => "Weken","monthly" => "Maanden","yearly" => "Jaren",+ "one-time" => "Eenmalig",+ "payment_date" => "Betaaldatum","days" => "dagen","weeks" => "weken","months" => "maanden",diff --git a/includes/i18n/pl.php b/includes/i18n/pl.phpindex 5f4bb1c..409005c 100644--- a/includes/i18n/pl.php+++ b/includes/i18n/pl.php@@ -72,7 +72,9 @@ $i18n = ["start_date" => "Data rozpoczęcia","inactive" => "Wyłącz subskrypcję","replaced_with" => "Zastąpione przez",- "none" => "Brak",+ "none" => "Brak",+ "reminder" => "Przypomnienie",+ "cancellation" => "Anulowanie","member" => "Użytkownik","category" => "Kategoria","payment_method" => "Metoda płatności",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Co tydzień","Monthly" => "Miesięcznie","Yearly" => "Rocznie",+ "One-time" => "Jednorazowy",+ "lifetime_purchases" => "Zakupy dożywotnie","daily" => "Dzień/Dni","weekly" => "Tydzień/Tygodni","monthly" => "Miesiąc/Miesięcy","yearly" => "Rok/Lat",+ "one-time" => "Jednorazowy",+ "payment_date" => "Data płatności","days" => "dni","weeks" => "tygodnie","months" => "miesiące",diff --git a/includes/i18n/pt.php b/includes/i18n/pt.phpindex d7654bf..8c865a9 100644--- a/includes/i18n/pt.php+++ b/includes/i18n/pt.php@@ -72,7 +72,9 @@ $i18n = ["start_date" => "Data de Início","inactive" => "Desactivar Subscrição","replaced_with" => "Substituída por",- "none" => "Nenhuma",+ "none" => "Nenhuma",+ "reminder" => "Lembrete",+ "cancellation" => "Cancelamento","member" => "Membro","category" => "Categoria","payment_method" => "Metodo de Pagamento",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Semanal","Monthly" => "Mensal","Yearly" => "Anual",+ "One-time" => "Único",+ "lifetime_purchases" => "Compras vitalícias","daily" => "Dia(s)","weekly" => "Semana(s)","monthly" => "Mês(es)","yearly" => "Ano(s)",+ "one-time" => "Único",+ "payment_date" => "Data de pagamento","days" => "dias","weeks" => "semanas","months" => "meses",diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.phpindex dfc6ae8..815f451 100644--- a/includes/i18n/pt_br.php+++ b/includes/i18n/pt_br.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Assinatura inativa","replaced_with" => "Substituída por","none" => "Nenhuma",+ "reminder" => "Lembrete",+ "cancellation" => "Cancelamento","member" => "Membro","category" => "Categoria","payment_method" => "Método de Pagamento",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Semanal","Monthly" => "Mensal","Yearly" => "Anual",+ "One-time" => "Único",+ "lifetime_purchases" => "Compras vitalícias","daily" => "Dia(s)","weekly" => "Semana(s)","monthly" => "Mês(es)","yearly" => "Ano(s)",+ "one-time" => "Único",+ "payment_date" => "Data de pagamento","days" => "dias","weeks" => "semanas","months" => "meses",diff --git a/includes/i18n/ro.php b/includes/i18n/ro.phpindex 929c801..bafcc1f 100644--- a/includes/i18n/ro.php+++ b/includes/i18n/ro.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Dezactivează abonament","replaced_with" => "Înlocuit cu","none" => "Niciunul",+ "reminder" => "Reminder",+ "cancellation" => "Anulare","member" => "Membru","category" => "Categorie","payment_method" => "Metodă de plată",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Săptămânal","Monthly" => "Lunar","Yearly" => "Anual",+ "One-time" => "O singură dată",+ "lifetime_purchases" => "Achiziții pe viață","daily" => "Zile","weekly" => "Săptămâni","monthly" => "Luni","yearly" => "Ani",+ "one-time" => "O singură dată",+ "payment_date" => "Data plății","days" => "zile","weeks" => "săptămâni","months" => "luni",diff --git a/includes/i18n/ru.php b/includes/i18n/ru.phpindex 6130741..33fbc97 100644--- a/includes/i18n/ru.php+++ b/includes/i18n/ru.php@@ -72,7 +72,9 @@ $i18n = ["start_date" => "Дата начала","inactive" => "Отключить подписку","replaced_with" => "Заменена на",- "none" => "Нет",+ "none" => "Нет",+ "reminder" => "Напоминание",+ "cancellation" => "Отмена","member" => "Член семьи","category" => "Категория","payment_method" => "Способ оплаты",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Неделя","Monthly" => "Месяц","Yearly" => "Год",+ "One-time" => "Единовременный",+ "lifetime_purchases" => "Бессрочные покупки","daily" => "День","weekly" => "Неделя","monthly" => "Месяц","yearly" => "Год",+ "one-time" => "Единовременный",+ "payment_date" => "Дата платежа","days" => "дней","weeks" => "недель","months" => "месяцев",diff --git a/includes/i18n/sl.php b/includes/i18n/sl.phpindex 2a5be0b..e40673e 100644--- a/includes/i18n/sl.php+++ b/includes/i18n/sl.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Onemogoči naročnino","replaced_with" => "Zamenjano z","none" => "brez",+ "reminder" => "Opomnik",+ "cancellation" => "Preklic","member" => "Član","category" => "Kategorija","payment_method" => "Način plačila",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Tedensko","Monthly" => "Mesečno","Yearly" => "Letno",+ "One-time" => "Enkratno",+ "lifetime_purchases" => "Doživljenjski nakupi","daily" => "Dan (dni)","weekly" => "Teden (tednov)","monthly" => "Mesec (mesecev)","yearly" => "Leto (leta)",+ "one-time" => "Enkratno",+ "payment_date" => "Datum plačila","days" => "dnevi","weeks" => "tedni","months" => "meseci",diff --git a/includes/i18n/sr.php b/includes/i18n/sr.phpindex 5c0dd95..7c79c8a 100644--- a/includes/i18n/sr.php+++ b/includes/i18n/sr.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Онемогући претплату","replaced_with" => "Замењено са","none" => "Ништа",+ "reminder" => "Подсетник",+ "cancellation" => "Отказивање","member" => "Члан","category" => "Категорија","payment_method" => "Начин плаћања",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Недељно","Monthly" => "Месечно","Yearly" => "Годишње",+ "One-time" => "Једнократно",+ "lifetime_purchases" => "Доживотне куповине","daily" => "дана","weekly" => "недеља","monthly" => "месеци","yearly" => "година",+ "one-time" => "Једнократно",+ "payment_date" => "Датум плаћања","days" => "дана","weeks" => "недеља","months" => "месеци",diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.phpindex 6640172..aca68b1 100644--- a/includes/i18n/sr_lat.php+++ b/includes/i18n/sr_lat.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Onemogući pretplatu","replaced_with" => "Zamenjeno sa","none" => "Nijedna",+ "reminder" => "Podsetnik",+ "cancellation" => "Otkazivanje","member" => "Član","category" => "Kategorija","payment_method" => "Način plaćanja",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Nedeljno","Monthly" => "Mesečno","Yearly" => "Godišnje",+ "One-time" => "Jednokratno",+ "lifetime_purchases" => "Doživotne kupovine","daily" => "dana","weekly" => "nedelja","monthly" => "meseci","yearly" => "godina",+ "one-time" => "Jednokratno",+ "payment_date" => "Datum plaćanja","days" => "dana","weeks" => "nedelja","months" => "meseci",diff --git a/includes/i18n/tr.php b/includes/i18n/tr.phpindex f63de9b..114ecb5 100644--- a/includes/i18n/tr.php+++ b/includes/i18n/tr.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Aboneliği Devre Dışı Bırak","replaced_with" => "Şununla değiştirildi","none" => "Yok",+ "reminder" => "Hatırlatıcı",+ "cancellation" => "İptal","member" => "Üye","category" => "Kategori","payment_method" => "Ödeme Yöntemi",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Haftalık","Monthly" => "Aylık","Yearly" => "Yıllık",+ "One-time" => "Tek seferlik",+ "lifetime_purchases" => "Ömür boyu satın almalar","daily" => "Gün(ler)","weekly" => "Hafta(lar)","monthly" => "Ay(lar)","yearly" => "Yıl(lar)",+ "one-time" => "Tek seferlik",+ "payment_date" => "Ödeme tarihi","days" => "günler","weeks" => "haftalar","months" => "aylar",diff --git a/includes/i18n/uk.php b/includes/i18n/uk.phpindex 077ac7e..3431685 100644--- a/includes/i18n/uk.php+++ b/includes/i18n/uk.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Відключити підписку","replaced_with" => "Замінена на","none" => "Немає",+ "reminder" => "Нагадування",+ "cancellation" => "Скасування","member" => "Член сім'ї","category" => "Категорія","payment_method" => "Спосіб оплати",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Тиждень","Monthly" => "Місяць","Yearly" => "Рік",+ "One-time" => "Одноразовий",+ "lifetime_purchases" => "Безстрокові покупки","daily" => "День","weekly" => "Тиждень","monthly" => "Місяць","yearly" => "Рік",+ "one-time" => "Одноразовий",+ "payment_date" => "Дата платежу","days" => "днів","weeks" => "тижнів","months" => "місяців",diff --git a/includes/i18n/vi.php b/includes/i18n/vi.phpindex 9e4b323..3f5079b 100644--- a/includes/i18n/vi.php+++ b/includes/i18n/vi.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "Vô hiệu hóa đăng ký","replaced_with" => "Thay thế bằng","none" => "Không",+ "reminder" => "Nhắc nhở",+ "cancellation" => "Hủy bỏ","member" => "Thành viên","category" => "Danh mục","payment_method" => "Phương thức thanh toán",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "Hàng tuần","Monthly" => "Hàng tháng","Yearly" => "Hàng năm",+ "One-time" => "Một lần",+ "lifetime_purchases" => "Mua trọn đời","daily" => "Ngày","weekly" => "Tuần","monthly" => "Tháng","yearly" => "Năm",+ "one-time" => "Một lần",+ "payment_date" => "Ngày thanh toán","days" => "ngày","weeks" => "tuần","months" => "tháng",diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.phpindex cf42f2c..fe767fd 100644--- a/includes/i18n/zh_cn.php+++ b/includes/i18n/zh_cn.php@@ -78,6 +78,8 @@ $i18n = ["inactive" => "停用订阅","replaced_with" => "替换为","none" => "无",+ "reminder" => "提醒",+ "cancellation" => "取消","member" => "成员","category" => "分类","payment_method" => "支付方式",@@ -85,10 +87,14 @@ $i18n = ["Weekly" => "每周","Monthly" => "每月","Yearly" => "每年",+ "One-time" => "买断",+ "lifetime_purchases" => "买断购买","daily" => "日","weekly" => "周","monthly" => "月","yearly" => "年",+ "one-time" => "买断",+ "payment_date" => "付款日期","days" => "天","weeks" => "周","months" => "月",diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.phpindex b15e9e3..07b9c3d 100644--- a/includes/i18n/zh_tw.php+++ b/includes/i18n/zh_tw.php@@ -73,6 +73,8 @@ $i18n = ["inactive" => "停用訂閱","replaced_with" => "取代為","none" => "無",+ "reminder" => "提醒",+ "cancellation" => "取消","member" => "成員","category" => "分類","payment_method" => "付款方式",@@ -80,10 +82,14 @@ $i18n = ["Weekly" => "每週","Monthly" => "每月","Yearly" => "每年",+ "One-time" => "買斷",+ "lifetime_purchases" => "買斷購買","daily" => "天","weekly" => "週","monthly" => "月","yearly" => "年",+ "one-time" => "買斷",+ "payment_date" => "付款日期","days" => "天","weeks" => "週","months" => "月",diff --git a/includes/list_subscriptions.php b/includes/list_subscriptions.phpindex 99d91db..d8ef7d4 100644--- a/includes/list_subscriptions.php+++ b/includes/list_subscriptions.php@@ -13,11 +13,17 @@ function getBillingCycle($cycle, $frequency, $i18n)return $frequency == 1 ? translate('Monthly', $i18n) : $frequency . " " . translate('months', $i18n);case 4:return $frequency == 1 ? translate('Yearly', $i18n) : $frequency . " " . translate('years', $i18n);+ case 5:+ return translate('One-time', $i18n);}}function getSubscriptionProgress($cycle, $frequency, $next_payment){+ if ($cycle === 5) {+ return 0;+ }+$nextPaymentDate = new DateTime($next_payment);$currentDate = new DateTime('now');@@ -61,6 +67,8 @@ function getPricePerMonth($cycle, $frequency, $price)case 4:$numberOfMonths = (12 * $frequency);return $price / $numberOfMonths;+ case 5:+ return 0;}}@@ -155,10 +163,22 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,}}+ // One-time purchases always go to the bottom regardless of sort order+ usort($subscriptions, fn($a, $b) => ($a['one_time'] ? 1 : 0) - ($b['one_time'] ? 1 : 0));+$currentCategory = 0;$currentPayerUserId = 0;$currentPaymentMethodId = 0;+ $oneTimeSectionShown = false;foreach ($subscriptions as $subscription) {+ if ($subscription['one_time'] && !$oneTimeSectionShown) {+ ?>+ <div class="subscription-list-title">+ <?= translate('lifetime_purchases', $i18n) ?>+ </div>+ <?php+ $oneTimeSectionShown = true;+ }if ($sort == "category_id" && $subscription['category_id'] != $currentCategory) {?><div class="subscription-list-title">@@ -205,7 +225,7 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,Delete</button><?php- if ($subscription['auto_renew'] != 1) {+ if ($subscription['auto_renew'] != 1 && !$subscription['one_time']) {?><button class="mobile-action-renew" onClick="renewSubscription(event, <?= $subscription['id'] ?>)"><?php include $imagePath . "images/siteicons/svg/mobile-menu/renew.php"; ?>@@ -254,12 +274,14 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,</span><span class="name <?= $hasLogo ? 'hideOnMobile' : '' ?>"><?= $subscription['name'] ?></span><span class="cycle"- title="<?= $subscription['auto_renew'] ? translate("automatically_renews", $i18n) : translate("manual_renewal", $i18n) ?>">+ title="<?= $subscription['one_time'] ? $subscription['billing_cycle'] : ($subscription['auto_renew'] ? translate("automatically_renews", $i18n) : translate("manual_renewal", $i18n)) ?>"><?php- if ($subscription['auto_renew']) {- include $imagePath . "images/siteicons/svg/automatic.php";- } else {- include $imagePath . "images/siteicons/svg/manual.php";+ if (!$subscription['one_time']) {+ if ($subscription['auto_renew']) {+ include $imagePath . "images/siteicons/svg/automatic.php";+ } else {+ include $imagePath . "images/siteicons/svg/manual.php";+ }}?><?= $subscription['billing_cycle'] ?>@@ -297,25 +319,25 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,<ul class="actions"><li class="edit" title="<?= translate('edit_subscription', $i18n) ?>"onClick="openEditSubscription(event, <?= $subscription['id'] ?>)">- <?php include $imagePath . "images/siteicons/svg/edit.php"; ?>+ <i class="fa-solid fa-pen-to-square"></i><?= translate('edit_subscription', $i18n) ?></li><li class="delete" title="<?= translate('delete', $i18n) ?>"onClick="deleteSubscription(event, <?= $subscription['id'] ?>)">- <?php include $imagePath . "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i><?= translate('delete', $i18n) ?></li><li class="clone" title="<?= translate('clone', $i18n) ?>"onClick="cloneSubscription(event, <?= $subscription['id'] ?>)">- <?php include $imagePath . "images/siteicons/svg/clone.php"; ?>+ <i class="fa-solid fa-copy"></i><?= translate('clone', $i18n) ?></li><?php- if ($subscription['auto_renew'] != 1) {+ if ($subscription['auto_renew'] != 1 && !$subscription['one_time']) {?><li class="renew" title="<?= translate('renew', $i18n) ?>"onClick="renewSubscription(event, <?= $subscription['id'] ?>)">- <?php include $imagePath . "images/siteicons/svg/renew.php"; ?>+ <i class="fa-solid fa-rotate-right"></i><?= translate('renew', $i18n) ?></li><?php@@ -325,11 +347,11 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,</div><div class="subscription-secondary"><span- class="name"><?php include $imagePath . "images/siteicons/svg/subscription.php"; ?><?= $subscription['name'] ?></span>+ class="name"><i class="fa-solid fa-tag"></i><?= $subscription['name'] ?></span><span class="payer_user"- title="<?= translate('paid_by', $i18n) ?>"><?php include $imagePath . "images/siteicons/svg/payment.php"; ?><?= $members[$subscription['payer_user_id']]['name'] ?></span>+ title="<?= translate('paid_by', $i18n) ?>"><i class="fa-solid fa-wallet"></i><?= $members[$subscription['payer_user_id']]['name'] ?></span><span class="category"- title="<?= translate('category', $i18n) ?>"><?php include $imagePath . "images/siteicons/svg/category.php"; ?><?= $categories[$subscription['category_id']]['name'] ?></span>+ title="<?= translate('category', $i18n) ?>"><i class="fa-solid fa-layer-group"></i><?= $categories[$subscription['category_id']]['name'] ?></span><?phpif ($subscription['url'] != "") {$url = $subscription['url'];@@ -338,7 +360,7 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,}?><span class="url" title="<?= translate('external_url', $i18n) ?>"><a href="<?= $url ?>" target="_blank"- rel="noreferrer"><?php include $imagePath . "images/siteicons/svg/web.php"; ?></a></span>+ rel="noreferrer"><i class="fa-solid fa-globe"></i></a></span><?php}?>@@ -348,7 +370,7 @@ function printSubscriptions($subscriptions, $sort, $categories, $members, $i18n,?><div class="subscription-notes"><span class="notes">- <?php include $imagePath . "images/siteicons/svg/notes.php"; ?>+ <i class="fa-solid fa-note-sticky"></i><?= $subscription['notes'] ?></span></div>diff --git a/includes/stats_calculations.php b/includes/stats_calculations.phpindex c93776a..2589978 100644--- a/includes/stats_calculations.php+++ b/includes/stats_calculations.php@@ -15,6 +15,8 @@ function getPricePerMonth($cycle, $frequency, $price)case 4:$numberOfMonths = (12 * $frequency);return $price / $numberOfMonths;+ case 5:+ return 0;}}@@ -77,6 +79,31 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {$memberCost[$memberId]['name'] = $row['name'];}+// Unfiltered counts for filter menu display (so non-selected items remain visible when a filter is active)+$stmt = $db->prepare("SELECT category_id, COUNT(*) as cnt FROM subscriptions WHERE user_id = :userId GROUP BY category_id");+$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);+$r = $stmt->execute();+$menuCategoryCounts = [];+while ($row = $r->fetchArray(SQLITE3_ASSOC)) {+ $menuCategoryCounts[$row['category_id']] = $row['cnt'];+}++$stmt = $db->prepare("SELECT payer_user_id, COUNT(*) as cnt FROM subscriptions WHERE user_id = :userId GROUP BY payer_user_id");+$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);+$r = $stmt->execute();+$menuMemberCounts = [];+while ($row = $r->fetchArray(SQLITE3_ASSOC)) {+ $menuMemberCounts[$row['payer_user_id']] = $row['cnt'];+}++$stmt = $db->prepare("SELECT payment_method_id, COUNT(*) as cnt FROM subscriptions WHERE user_id = :userId AND inactive = 0 GROUP BY payment_method_id");+$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);+$r = $stmt->execute();+$menuPaymentCounts = [];+while ($row = $r->fetchArray(SQLITE3_ASSOC)) {+ $menuPaymentCounts[$row['payment_method_id']] = $row['cnt'];+}+$activeSubscriptions = 0;$inactiveSubscriptions = 0;// Calculate total monthly price@@ -92,22 +119,34 @@ $query = "SELECT name, price, logo, frequency, cycle, currency_id, next_payment,$conditions = [];$params = [];-if (isset($_GET['member'])) {- $conditions[] = "payer_user_id = :member";- $params[':member'] = $_GET['member'];- $statsSubtitleParts[] = $members[$_GET['member']]['name'];+if (isset($_GET['member']) && $_GET['member'] !== '') {+ $memberIds = array_map('intval', explode(',', $_GET['member']));+ $conditions[] = "payer_user_id IN (" . implode(',', $memberIds) . ")";+ foreach ($memberIds as $mid) {+ if (isset($members[$mid])) {+ $statsSubtitleParts[] = $members[$mid]['name'];+ }+ }}-if (isset($_GET['category'])) {- $conditions[] = "category_id = :category";- $params[':category'] = $_GET['category'];- $statsSubtitleParts[] = $categories[$_GET['category']]['name'] == "No category" ? translate("no_category", $i18n) : $categories[$_GET['category']]['name'];+if (isset($_GET['category']) && $_GET['category'] !== '') {+ $categoryIds = array_map('intval', explode(',', $_GET['category']));+ $conditions[] = "category_id IN (" . implode(',', $categoryIds) . ")";+ foreach ($categoryIds as $cid) {+ if (isset($categories[$cid])) {+ $statsSubtitleParts[] = $categories[$cid]['name'] == "No category" ? translate("no_category", $i18n) : $categories[$cid]['name'];+ }+ }}-if (isset($_GET['payment'])) {- $conditions[] = "payment_method_id = :payment";- $params[':payment'] = $_GET['payment'];- $statsSubtitleParts[] = $paymentMethodsCount[$_GET['payment']]['name'];+if (isset($_GET['payment']) && $_GET['payment'] !== '') {+ $paymentIds = array_map('intval', explode(',', $_GET['payment']));+ $conditions[] = "payment_method_id IN (" . implode(',', $paymentIds) . ")";+ foreach ($paymentIds as $pid) {+ if (isset($paymentMethodsCount[$pid])) {+ $statsSubtitleParts[] = $paymentMethodsCount[$pid]['name'];+ }+ }}$conditions[] = "user_id = :userId";@@ -157,35 +196,39 @@ if ($result) {$price = getPricePerMonth($cycle, $frequency, $originalSubscriptionPrice);if ($inactive == 0) {- $activeSubscriptions++;+ if ($cycle != 5) {+ $activeSubscriptions++;+ $paymentMethodsCount[$paymentMethodId]['count'] += 1;+ }$totalCostPerMonth += $price;$memberCost[$payerId]['cost'] += $price;$categoryCost[$categoryId]['cost'] += $price;- $paymentMethodsCount[$paymentMethodId]['count'] += 1;if ($price > $mostExpensiveSubscription['price']) {$mostExpensiveSubscription['price'] = $price;$mostExpensiveSubscription['name'] = $name;$mostExpensiveSubscription['logo'] = $logo;}- // Calculate ammount due this month- $nextPaymentDate = DateTime::createFromFormat('Y-m-d', trim($next_payment));- $tomorrow = new DateTime('tomorrow');- $endOfMonth = new DateTime('last day of this month');-- if ($nextPaymentDate >= $tomorrow && $nextPaymentDate <= $endOfMonth) {- $timesToPay = 1;- $daysInMonth = $endOfMonth->diff($tomorrow)->days + 1;- $daysRemaining = $endOfMonth->diff($nextPaymentDate)->days + 1;- if ($cycle == 1) {- $timesToPay = $daysRemaining / $frequency;- }- if ($cycle == 2) {- $weeksInMonth = ceil($daysInMonth / 7);- $weeksRemaining = ceil($daysRemaining / 7);- $timesToPay = $weeksRemaining / $frequency;+ if ($cycle != 5) {+ // Calculate ammount due this month+ $nextPaymentDate = DateTime::createFromFormat('Y-m-d', trim($next_payment));+ $tomorrow = new DateTime('tomorrow');+ $endOfMonth = new DateTime('last day of this month');++ if ($nextPaymentDate >= $tomorrow && $nextPaymentDate <= $endOfMonth) {+ $timesToPay = 1;+ $daysInMonth = $endOfMonth->diff($tomorrow)->days + 1;+ $daysRemaining = $endOfMonth->diff($nextPaymentDate)->days + 1;+ if ($cycle == 1) {+ $timesToPay = $daysRemaining / $frequency;+ }+ if ($cycle == 2) {+ $weeksInMonth = ceil($daysInMonth / 7);+ $weeksRemaining = ceil($daysRemaining / 7);+ $timesToPay = $weeksRemaining / $frequency;+ }+ $amountDueThisMonth += $originalSubscriptionPrice * $timesToPay;}- $amountDueThisMonth += $originalSubscriptionPrice * $timesToPay;}} else {$inactiveSubscriptions++;diff --git a/includes/version.php b/includes/version.phpindex 20aea75..0dd9727 100644--- a/includes/version.php+++ b/includes/version.php@@ -1,3 +1,3 @@<?php-$version = "v4.8.4";+$version = "v4.9.0";?>diff --git a/index.php b/index.phpindex d2a8094..ca51cd0 100644--- a/index.php+++ b/index.php@@ -72,7 +72,7 @@ $user = $result->fetchArray(SQLITE3_ASSOC);$first_name = $user['firstname'] ?? $user['username'] ?? '';// Fetch the next 3 enabled subscriptions up for payment-$stmt = $db->prepare("SELECT id, logo, name, price, currency_id, next_payment, inactive FROM subscriptions WHERE user_id = :userId AND next_payment >= date('now') AND inactive = 0 ORDER BY next_payment ASC LIMIT 3");+$stmt = $db->prepare("SELECT id, logo, name, price, currency_id, next_payment, inactive FROM subscriptions WHERE user_id = :userId AND next_payment >= date('now') AND inactive = 0 AND cycle != 5 ORDER BY next_payment ASC LIMIT 3");$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);$result = $stmt->execute();$upcomingSubscriptions = [];@@ -81,7 +81,7 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {}// Fetch enabled subscriptions with manual renewal that are overdue-$stmt = $db->prepare("SELECT id, logo, name, price, currency_id, next_payment, inactive, auto_renew FROM subscriptions WHERE user_id = :userId AND next_payment < date('now') AND auto_renew = 0 AND inactive = 0 ORDER BY next_payment ASC");+$stmt = $db->prepare("SELECT id, logo, name, price, currency_id, next_payment, inactive, auto_renew FROM subscriptions WHERE user_id = :userId AND next_payment < date('now') AND auto_renew = 0 AND inactive = 0 AND cycle != 5 ORDER BY next_payment ASC");$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);$result = $stmt->execute();$overdueSubscriptions = [];diff --git a/libs/OTPHP/ParameterTrait.php b/libs/OTPHP/ParameterTrait.phpindex dc92861..49a4053 100644--- a/libs/OTPHP/ParameterTrait.php+++ b/libs/OTPHP/ParameterTrait.php@@ -157,9 +157,9 @@ trait ParameterTraitreturn $value;},- 'secret' => static fn (string $value): string => mb_strtoupper(trim($value, '=')),+ 'secret' => static fn (string $value): string => strtoupper(trim($value, '=')),'algorithm' => static function (string $value): string {- $value = mb_strtolower($value);+ $value = strtolower($value);in_array($value, hash_algos(), true) || throw new InvalidArgumentException(sprintf('The "%s" digest is not supported.',$valuediff --git a/migrations/000005.php b/migrations/000005.phpindex 2a531c6..0629bdf 100644--- a/migrations/000005.php+++ b/migrations/000005.php@@ -5,6 +5,6 @@ $columnQuery = $db->query("SELECT * FROM pragma_table_info('user') where name='l$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {- $db->exec('ALTER TABLE user ADD COLUMN language TEXT DEFAULT "en"');- $db->exec('UPDATE user SET language = "en"');+ $db->exec("ALTER TABLE user ADD COLUMN language TEXT DEFAULT 'en'");+ $db->exec("UPDATE user SET language = 'en'");}diff --git a/migrations/000009.php b/migrations/000009.phpindex 6f3048c..9a32d1a 100644--- a/migrations/000009.php+++ b/migrations/000009.php@@ -6,5 +6,5 @@ $columnQuery = $db->query("SELECT * FROM pragma_table_info('household') where na$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {- $db->exec('ALTER TABLE household ADD COLUMN email TEXT DEFAULT ""');+ $db->exec("ALTER TABLE household ADD COLUMN email TEXT DEFAULT ''");}\ No newline at end of filediff --git a/migrations/000012.php b/migrations/000012.phpindex 6e8bf7b..dbb57bd 100644--- a/migrations/000012.php+++ b/migrations/000012.php@@ -5,7 +5,7 @@$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {- $db->exec('ALTER TABLE notifications ADD COLUMN `encryption` TEXT DEFAULT "tls"');- $db->exec('UPDATE notifications SET `encryption` = "tls"');+ $db->exec("ALTER TABLE notifications ADD COLUMN `encryption` TEXT DEFAULT 'tls'");+ $db->exec("UPDATE notifications SET `encryption` = 'tls'");}?>\ No newline at end of filediff --git a/migrations/000014.php b/migrations/000014.phpindex a8e0f7e..c28a5ee 100644--- a/migrations/000014.php+++ b/migrations/000014.php@@ -6,7 +6,7 @@ $columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {$db->exec("ALTER TABLE settings ADD COLUMN color_theme TEXT DEFAULT 'blue'");- $db->exec('UPDATE settings SET `color_theme` = "blue"');+ $db->exec("UPDATE settings SET `color_theme` = 'blue'");}// This migrations adds custom_colors table to the database, so the user can set custom accent colors to the applicationdiff --git a/migrations/000016.php b/migrations/000016.phpindex 1cbd13f..37032d4 100644--- a/migrations/000016.php+++ b/migrations/000016.php@@ -5,36 +5,36 @@* Existing values on the notifications table will be split and migrated to the new tables.*/-$db->exec('CREATE TABLE IF NOT EXISTS telegram_notifications (+$db->exec("CREATE TABLE IF NOT EXISTS telegram_notifications (enabled BOOLEAN DEFAULT 0,- bot_token TEXT DEFAULT "",- chat_id TEXT DEFAULT ""-)');+ bot_token TEXT DEFAULT '',+ chat_id TEXT DEFAULT ''+)");-$db->exec('CREATE TABLE IF NOT EXISTS webhook_notifications (+$db->exec("CREATE TABLE IF NOT EXISTS webhook_notifications (enabled BOOLEAN DEFAULT 0,- headers TEXT DEFAULT "",- url TEXT DEFAULT "",- request_method TEXT DEFAULT "POST",- payload TEXT DEFAULT "",- iterator TEXT DEFAULT ""-)');--$db->exec('CREATE TABLE IF NOT EXISTS gotify_notifications (+ headers TEXT DEFAULT '',+ url TEXT DEFAULT '',+ request_method TEXT DEFAULT 'POST',+ payload TEXT DEFAULT '',+ iterator TEXT DEFAULT ''+)");++$db->exec("CREATE TABLE IF NOT EXISTS gotify_notifications (enabled BOOLEAN DEFAULT 0,- url TEXT DEFAULT "",- token TEXT DEFAULT ""-)');+ url TEXT DEFAULT '',+ token TEXT DEFAULT ''+)");-$db->exec('CREATE TABLE IF NOT EXISTS email_notifications (+$db->exec("CREATE TABLE IF NOT EXISTS email_notifications (enabled BOOLEAN DEFAULT 0,- smtp_address TEXT DEFAULT "",+ smtp_address TEXT DEFAULT '',smtp_port INTEGER DEFAULT 587,- smtp_username TEXT DEFAULT "",- smtp_password TEXT DEFAULT "",- from_email TEXT DEFAULT "",- encryption TEXT DEFAULT "tls"-)');+ smtp_username TEXT DEFAULT '',+ smtp_password TEXT DEFAULT '',+ from_email TEXT DEFAULT '',+ encryption TEXT DEFAULT 'tls'+)");$db->exec('CREATE TABLE IF NOT EXISTS notification_settings (days INTEGER DEFAULT 0diff --git a/migrations/000017.php b/migrations/000017.phpindex e838607..3969f34 100644--- a/migrations/000017.php+++ b/migrations/000017.php@@ -4,15 +4,15 @@* This migration adds tables to store the date about the new notification methods (pushover and discord)*/-$db->exec('CREATE TABLE IF NOT EXISTS pushover_notifications (+$db->exec("CREATE TABLE IF NOT EXISTS pushover_notifications (enabled BOOLEAN DEFAULT 0,- user_key TEXT DEFAULT "",- token TEXT DEFAULT ""-)');+ user_key TEXT DEFAULT '',+ token TEXT DEFAULT ''+)");-$db->exec('CREATE TABLE IF NOT EXISTS discord_notifications (+$db->exec("CREATE TABLE IF NOT EXISTS discord_notifications (enabled BOOLEAN DEFAULT 0,- webhook_url TEXT DEFAULT "",- bot_username TEXT DEFAULT "",- bot_avatar_url TEXT DEFAULT ""-)');\ No newline at end of file+ webhook_url TEXT DEFAULT '',+ bot_username TEXT DEFAULT '',+ bot_avatar_url TEXT DEFAULT ''+)");\ No newline at end of filediff --git a/migrations/000020.php b/migrations/000020.phpindex b6eb10f..dd2e817 100644--- a/migrations/000020.php+++ b/migrations/000020.php@@ -15,7 +15,7 @@ foreach ($tablesToUpdate as $table) {}-$db->exec('CREATE TABLE IF NOT EXISTS admin (+$db->exec("CREATE TABLE IF NOT EXISTS admin (id INTEGER PRIMARY KEY,registrations_open BOOLEAN DEFAULT 0,max_users INTEGER DEFAULT 0,@@ -26,10 +26,10 @@ $db->exec('CREATE TABLE IF NOT EXISTS admin (smtp_username TEXT,smtp_password TEXT,from_email TEXT,- encryption TEXT DEFAULT "tls"-)');+ encryption TEXT DEFAULT 'tls'+)");-$db->exec('INSERT INTO admin (id, registrations_open, require_email_verification, server_url, max_users, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption) VALUES (1, 0, 0, "", 0, "", 587, "", "", "", "tls")');+$db->exec("INSERT INTO admin (id, registrations_open, require_email_verification, server_url, max_users, smtp_address, smtp_port, smtp_username, smtp_password, from_email, encryption) VALUES (1, 0, 0, '', 0, '', 587, '', '', '', 'tls')");$updateQuery = "UPDATE payment_methods SET icon = 'images/uploads/icons/' || icon WHERE id < 32 AND icon NOT LIKE '%/images/uploads/icons%'";$db->exec($updateQuery);diff --git a/migrations/000021.php b/migrations/000021.phpindex 8ba7cd3..4ab009b 100644--- a/migrations/000021.php+++ b/migrations/000021.php@@ -4,11 +4,11 @@* This migration adds tables to store the data about a new notification method Ntfy*/-$db->exec('CREATE TABLE IF NOT EXISTS ntfy_notifications (+$db->exec("CREATE TABLE IF NOT EXISTS ntfy_notifications (enabled BOOLEAN DEFAULT 0,- host TEXT DEFAULT "",- topic TEXT DEFAULT "",- headers TEXT DEFAULT "",+ host TEXT DEFAULT '',+ topic TEXT DEFAULT '',+ headers TEXT DEFAULT '',user_id INTEGER,FOREIGN KEY (user_id) REFERENCES user(id)-)');\ No newline at end of file+)");\ No newline at end of filediff --git a/migrations/000023.php b/migrations/000023.phpindex c193492..4942704 100644--- a/migrations/000023.php+++ b/migrations/000023.php@@ -4,8 +4,8 @@* This migration adds a table to store custom css styles per user*/-$db->exec('CREATE TABLE IF NOT EXISTS custom_css_style (- css TEXT DEFAULT "",+$db->exec("CREATE TABLE IF NOT EXISTS custom_css_style (+ css TEXT DEFAULT '',user_id INTEGER,FOREIGN KEY (user_id) REFERENCES user(id)-)');\ No newline at end of file+)");\ No newline at end of filediff --git a/migrations/000026.php b/migrations/000026.phpindex cf9d39f..f9cce30 100644--- a/migrations/000026.php+++ b/migrations/000026.php@@ -6,7 +6,7 @@ $columnQuery = $db->query("SELECT * FROM pragma_table_info('email_notifications'$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {- $db->exec('ALTER TABLE email_notifications ADD COLUMN other_emails TEXT DEFAULT "";');+ $db->exec("ALTER TABLE email_notifications ADD COLUMN other_emails TEXT DEFAULT ''");}$columnQuery = $db->query("SELECT * FROM pragma_table_info('settings') where name='show_original_price'");diff --git a/migrations/000029.php b/migrations/000029.phpindex 3e65c91..2e164a9 100644--- a/migrations/000029.php+++ b/migrations/000029.php@@ -14,6 +14,6 @@ $users = $db->query('SELECT * FROM user');while ($user = $users->fetchArray(SQLITE3_ASSOC)) {if (empty($user['api_key'])) {$apiKey = bin2hex(random_bytes(32));- $db->exec('UPDATE user SET api_key = "' . $apiKey . '" WHERE id = ' . $user['id']);+ $db->exec("UPDATE user SET api_key = '" . $apiKey . "' WHERE id = " . $user['id']);}}diff --git a/migrations/000037.php b/migrations/000037.phpindex 51eedaa..e267c5a 100644--- a/migrations/000037.php+++ b/migrations/000037.php@@ -5,12 +5,12 @@ $columnQuery = $db->query("SELECT * FROM pragma_table_info('user') where name='f$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {- $db->exec('ALTER TABLE user ADD COLUMN firstname TEXT DEFAULT ""');+ $db->exec("ALTER TABLE user ADD COLUMN firstname TEXT DEFAULT ''");}$columnQuery = $db->query("SELECT * FROM pragma_table_info('user') where name='lastname'");$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;if ($columnRequired) {- $db->exec('ALTER TABLE user ADD COLUMN lastname TEXT DEFAULT ""');+ $db->exec("ALTER TABLE user ADD COLUMN lastname TEXT DEFAULT ''");}diff --git a/migrations/000042.php b/migrations/000042.phpindex a5b950b..3728a5c 100644--- a/migrations/000042.php+++ b/migrations/000042.php@@ -8,12 +8,12 @@ $tableQuery = $db->query("SELECT name FROM sqlite_master WHERE type='table' AND$tableExists = $tableQuery->fetchArray(SQLITE3_ASSOC);if (!$tableExists) {- $db->exec('CREATE TABLE serverchan_notifications (+ $db->exec("CREATE TABLE serverchan_notifications (enabled BOOLEAN DEFAULT 0,- sendkey TEXT DEFAULT "",+ sendkey TEXT DEFAULT '',user_id INTEGER,FOREIGN KEY (user_id) REFERENCES user(id)- )');+ )");}?>\ No newline at end of filediff --git a/migrations/000046.php b/migrations/000046.phpnew file mode 100644index 0000000..27a189c--- /dev/null+++ b/migrations/000046.php@@ -0,0 +1,4 @@+<?php+// This migration adds a new cycle type for one-time purchases.++$db->exec("INSERT OR IGNORE INTO cycles (id, days, name) VALUES (5, 0, 'One-time')");diff --git a/scripts/stats.js b/scripts/stats.jsindex 50c0baa..4a7a9cd 100644--- a/scripts/stats.js+++ b/scripts/stats.js@@ -131,46 +131,31 @@ function toggleSubMenu(subMenu) {document.querySelectorAll('.filter-item').forEach(function(item) {item.addEventListener('click', function(e) {+ const urlParams = new URLSearchParams(window.location.search);+ let newUrl = 'stats.php?';+if (this.hasAttribute('data-categoryid')) {const categoryId = this.getAttribute('data-categoryid');- const urlParams = new URLSearchParams(window.location.search);- let newUrl = 'stats.php?';-- if (urlParams.get('category') === categoryId) {- urlParams.delete('category');- } else {- urlParams.set('category', categoryId);- }-- newUrl += urlParams.toString();- window.location.href = newUrl;+ const current = urlParams.get('category') ? urlParams.get('category').split(',') : [];+ const idx = current.indexOf(categoryId);+ if (idx !== -1) { current.splice(idx, 1); } else { current.push(categoryId); }+ current.length ? urlParams.set('category', current.join(',')) : urlParams.delete('category');} else if (this.hasAttribute('data-memberid')) {const memberId = this.getAttribute('data-memberid');- const urlParams = new URLSearchParams(window.location.search);- let newUrl = 'stats.php?';-- if (urlParams.get('member') === memberId) {- urlParams.delete('member');- } else {- urlParams.set('member', memberId);- }-- newUrl += urlParams.toString();- window.location.href = newUrl;+ const current = urlParams.get('member') ? urlParams.get('member').split(',') : [];+ const idx = current.indexOf(memberId);+ if (idx !== -1) { current.splice(idx, 1); } else { current.push(memberId); }+ current.length ? urlParams.set('member', current.join(',')) : urlParams.delete('member');} else if (this.hasAttribute('data-paymentid')) {const paymentId = this.getAttribute('data-paymentid');- const urlParams = new URLSearchParams(window.location.search);- let newUrl = 'stats.php?';-- if (urlParams.get('payment') === paymentId) {- urlParams.delete('payment');- } else {- urlParams.set('payment', paymentId);- }-- newUrl += urlParams.toString();- window.location.href = newUrl;+ const current = urlParams.get('payment') ? urlParams.get('payment').split(',') : [];+ const idx = current.indexOf(paymentId);+ if (idx !== -1) { current.splice(idx, 1); } else { current.push(paymentId); }+ current.length ? urlParams.set('payment', current.join(',')) : urlParams.delete('payment');}++ newUrl += urlParams.toString();+ window.location.href = newUrl;});});diff --git a/scripts/subscriptions.js b/scripts/subscriptions.jsindex fa011ee..2168bd5 100644--- a/scripts/subscriptions.js+++ b/scripts/subscriptions.js@@ -45,6 +45,7 @@ function resetForm() {replacementSubscription.classList.add("hide");const form = document.querySelector("#subs-form");form.reset();+ toggleOneTimeCycleUI(false);closeLogoSearch();const deleteButton = document.querySelector("#deletesub");deleteButton.style = 'display: none';@@ -75,6 +76,7 @@ function fillEditFormFields(subscription) {frequencySelect.value = subscription.frequency;const cycleSelect = document.querySelector("#cycle");cycleSelect.value = subscription.cycle;+ toggleOneTimeCycleUI(subscription.cycle == 5);const paymentSelect = document.querySelector("#payment_method");paymentSelect.value = subscription.payment_method_id;const categorySelect = document.querySelector("#category");@@ -388,6 +390,9 @@ function fetchSubscriptions(id, event, initiator) {if (activeFilters['renewalType'] !== "") {getSubscriptions += getSubscriptions.includes("?") ? `&renewalType=${activeFilters['renewalType']}` : `?renewalType=${activeFilters['renewalType']}`;}+ if (activeFilters['notifications'].length > 0) {+ getSubscriptions += getSubscriptions.includes("?") ? `¬ifications=${activeFilters['notifications']}` : `?notifications=${activeFilters['notifications']}`;+ }fetch(getSubscriptions).then(response => response.text())@@ -501,6 +506,15 @@ function submitFormData(formData, submitButton, endpoint) {});}+document.addEventListener('DOMContentLoaded', function () {+ const cycleSelectEl = document.querySelector("#cycle");+ if (cycleSelectEl) {+ cycleSelectEl.addEventListener("change", function () {+ toggleOneTimeCycleUI(this.value === "5");+ });+ }+});+document.addEventListener('DOMContentLoaded', function () {const subscriptionForm = document.querySelector("#subs-form");const submitButton = document.querySelector("#save-button");@@ -510,6 +524,17 @@ document.addEventListener('DOMContentLoaded', function () {e.preventDefault();submitButton.disabled = true;++ const cycleVal = document.querySelector("#cycle")?.value;+ if (cycleVal === "5") {+ const freq = document.querySelector("#frequency");+ if (freq) freq.value = 1;+ const cancellationDate = document.querySelector("#cancellation_date");+ if (cancellationDate) cancellationDate.value = "";+ const notifyDays = document.querySelector("#notify_days_before");+ if (notifyDays) notifyDays.value = -1;+ }+const formData = new FormData(subscriptionForm);const fileInput = document.querySelector("#logo");@@ -638,6 +663,7 @@ activeFilters['members'] = [];activeFilters['payments'] = [];activeFilters['state'] = "";activeFilters['renewalType'] = "";+activeFilters['notifications'] = [];document.addEventListener("DOMContentLoaded", function () {var filtermenu = document.querySelector('#filtermenu-button');@@ -743,11 +769,21 @@ document.querySelectorAll('.filter-item').forEach(function (item) {});this.classList.add('selected');}+ } else if (this.hasAttribute('data-notificationtype')) {+ const notifType = this.getAttribute('data-notificationtype');+ if (activeFilters['notifications'].includes(notifType)) {+ const idx = activeFilters['notifications'].indexOf(notifType);+ activeFilters['notifications'].splice(idx, 1);+ this.classList.remove('selected');+ } else {+ activeFilters['notifications'].push(notifType);+ this.classList.add('selected');+ }}if (activeFilters['categories'].length > 0 || activeFilters['members'].length > 0 ||- activeFilters['payments'].length > 0 || activeFilters['state'] !== "" ||- activeFilters['renewalType'] !== "") {+ activeFilters['payments'].length > 0 || activeFilters['state'] !== "" ||+ activeFilters['renewalType'] !== "" || activeFilters['notifications'].length > 0) {document.querySelector('#clear-filters').classList.remove('hide');} else {document.querySelector('#clear-filters').classList.add('hide');@@ -765,7 +801,8 @@ function clearFilters() {activeFilters['payments'] = [];activeFilters['state'] = "";activeFilters['renewalType'] = "";-+ activeFilters['notifications'] = [];+document.querySelectorAll('.filter-item').forEach(function (item) {item.classList.remove('selected');});@@ -795,16 +832,22 @@ function expandActions(event, subscriptionId) {allActions.forEach((openAction) => {if (openAction !== actions) {openAction.classList.remove('is-open');+ openAction.classList.remove('open-above');}});// Toggle the clicked actionsactions.classList.toggle('is-open');- // Update currentActionsif (actions.classList.contains('is-open')) {+ actions.classList.remove('open-above');+ const rect = actions.getBoundingClientRect();+ if (rect.bottom > window.innerHeight) {+ actions.classList.add('open-above');+ }currentActions = actions;} else {+ actions.classList.remove('open-above');currentActions = null;}}@@ -833,6 +876,40 @@ function swipeHintAnimation() {}}+function toggleOneTimeCycleUI(isOneTime) {+ const frequencySelect = document.querySelector("#frequency");+ const autoRenewGroup = document.querySelector("#auto-renew-group");+ const autoRenewCheckbox = document.querySelector("#auto_renew");+ const autofillDesktop = document.querySelector("#autofill-next-payment-button.hideOnMobile");+ const labelRecurring = document.querySelector("#next-payment-label-recurring");+ const labelOnetime = document.querySelector("#next-payment-label-onetime");+ const notificationsGroup = document.querySelector("#notifications-group");+ const notifyDaysCancellationGroup = document.querySelector("#notify-days-cancellation-group");+ const notificationsCheckbox = document.querySelector("#notifications");++ if (isOneTime) {+ if (frequencySelect) frequencySelect.style.display = 'none';+ if (autoRenewGroup) autoRenewGroup.style.display = 'none';+ if (autoRenewCheckbox) { autoRenewCheckbox.checked = false; autoRenewCheckbox.disabled = true; }+ if (autofillDesktop) autofillDesktop.style.display = 'none';+ if (labelRecurring) labelRecurring.style.display = 'none';+ if (labelOnetime) labelOnetime.style.display = '';+ if (notificationsGroup) notificationsGroup.style.display = 'none';+ if (notifyDaysCancellationGroup) notifyDaysCancellationGroup.style.display = 'none';+ if (notificationsCheckbox) { notificationsCheckbox.checked = false; notificationsCheckbox.disabled = true; }+ } else {+ if (frequencySelect) frequencySelect.style.display = '';+ if (autoRenewGroup) autoRenewGroup.style.display = '';+ if (autoRenewCheckbox) autoRenewCheckbox.disabled = false;+ if (autofillDesktop) autofillDesktop.style.display = '';+ if (labelRecurring) labelRecurring.style.display = '';+ if (labelOnetime) labelOnetime.style.display = 'none';+ if (notificationsGroup) notificationsGroup.style.display = '';+ if (notifyDaysCancellationGroup) notifyDaysCancellationGroup.style.display = '';+ if (notificationsCheckbox) notificationsCheckbox.disabled = false;+ }+}+function autoFillNextPaymentDate(e) {e.preventDefault();const frequencySelect = document.querySelector("#frequency");diff --git a/settings.php b/settings.phpindex 9bba17a..441fb34 100644--- a/settings.php+++ b/settings.php@@ -78,20 +78,20 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];?><button class="image-button medium" onClick="editMember(<?= $member['id'] ?>)" name="save"title="<?= translate('save_member', $i18n) ?>">- <?php include "images/siteicons/svg/save.php"; ?>+ <i class="fa-solid fa-check"></i></button><?phpif ($index !== 0) {?><button class="image-button medium" onClick="removeMember(<?= $member['id'] ?>)"title="<?= translate('delete_member', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php} else {?><button class="image-button medium disabled" title="<?= translate('cant_delete_member', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php}@@ -853,21 +853,21 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];placeholder="Category"><button class="image-button medium" onClick="editCategory(<?= $category['id'] ?>)" name="save"title="<?= translate('save_category', $i18n) ?>">- <?php include "images/siteicons/svg/save.php"; ?>+ <i class="fa-solid fa-check"></i></button><?phpif ($canDelete) {?><button class="image-button medium" onClick="removeCategory(<?= $category['id'] ?>)"title="<?= translate('delete_category', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php} else {?><button class="image-button medium disabled"title="<?= translate('cant_delete_category_in_use', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php}@@ -946,21 +946,21 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];placeholder="Currency Code" <?= !$canDelete ? 'disabled' : '' ?>><button class="image-button medium" onClick="editCurrency(<?= $currency['id'] ?>)" name="save"title="<?= translate('save_currency', $i18n) ?>">- <?php include "images/siteicons/svg/save.php"; ?>+ <i class="fa-solid fa-check"></i></button><?phpif ($canDelete) {?><button class="image-button medium" onClick="removeCurrency(<?= $currency['id'] ?>)"title="<?= translate('delete_currency', $i18n) ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php} else {$cantDeleteMessage = $isMainCurrency ? translate('cant_delete_main_currency', $i18n) : translate('cant_delete_currency_in_use', $i18n);?><button class="image-button medium disabled" title="<?= $cantDeleteMessage ?>">- <?php include "images/siteicons/svg/delete.php"; ?>+ <i class="fa-solid fa-trash-can"></i></button><?php}@@ -1245,7 +1245,7 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];<input type="hidden" id="icon-url" name="icon-url"><div id="icon-search-button" class="image-button medium disabled"title="<?= translate('search_logo', $i18n) ?>" onClick="searchPaymentIcon()">- <?php include "images/siteicons/svg/websearch.php"; ?>+ <i class="fa-solid fa-magnifying-glass"></i></div><div id="icon-search-results" class="icon-search"><header>diff --git a/stats.php b/stats.phpindex 3a36ef2..17156cb 100644--- a/stats.php+++ b/stats.php@@ -47,13 +47,11 @@ require_once 'includes/stats_calculations.php';<div class="filtermenu-submenu-content" id="filter-member"><?phpforeach ($members as $member) {- if ($member['count'] == 0) {+ $isSelected = isset($_GET['member']) && in_array($member['id'], array_map('intval', explode(',', $_GET['member'])));+ if (($menuMemberCounts[$member['id']] ?? 0) == 0 && !$isSelected) {continue;}- $selectedClass = '';- if (isset($_GET['member']) && $_GET['member'] == $member['id']) {- $selectedClass = 'selected';- }+ $selectedClass = $isSelected ? 'selected' : '';?><div class="filter-item <?= $selectedClass ?>" data-memberid="<?= $member['id'] ?>"><?= $member['name'] ?></div>@@ -77,20 +75,17 @@ require_once 'includes/stats_calculations.php';<div class="filtermenu-submenu-content" id="filter-category"><?phpforeach ($categories as $category) {- if ($category['count'] > 0) {- if ($category['name'] == "No category") {- $category['name'] = translate("no_category", $i18n);- }- $selectedClass = '';- if (isset($_GET['category']) && $_GET['category'] == $category['id']) {- $selectedClass = 'selected';- }- ?>- <div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>">- <?= $category['name'] ?>- </div>- <?php+ $isSelected = isset($_GET['category']) && in_array($category['id'], array_map('intval', explode(',', $_GET['category'])));+ if (($menuCategoryCounts[$category['id']] ?? 0) == 0 && !$isSelected) {+ continue;}+ $categoryName = $category['name'] == "No category" ? translate("no_category", $i18n) : $category['name'];+ $selectedClass = $isSelected ? 'selected' : '';+ ?>+ <div class="filter-item <?= $selectedClass ?>" data-categoryid="<?= $category['id'] ?>">+ <?= $categoryName ?>+ </div>+ <?php}?></div>@@ -110,13 +105,11 @@ require_once 'includes/stats_calculations.php';<div class="filtermenu-submenu-content" id="filter-payment"><?phpforeach ($paymentMethods as $payment) {- if ($payment['count'] == 0) {+ $isSelected = isset($_GET['payment']) && in_array($payment['id'], array_map('intval', explode(',', $_GET['payment'])));+ if (($menuPaymentCounts[$payment['id']] ?? 0) == 0 && !$isSelected) {continue;}- $selectedClass = '';- if (isset($_GET['payment']) && $_GET['payment'] == $payment['id']) {- $selectedClass = 'selected';- }+ $selectedClass = $isSelected ? 'selected' : '';?><div class="filter-item <?= $selectedClass ?>" data-paymentid="<?= $payment['id'] ?>"><?= $payment['name'] ?>@@ -244,6 +237,7 @@ require_once 'includes/stats_calculations.php';}}+ usort($categoryDataPoints, fn($a, $b) => $b['y'] <=> $a['y']);$showCategoryCostGraph = count($categoryDataPoints) > 1;$memberDataPoints = [];@@ -259,6 +253,7 @@ require_once 'includes/stats_calculations.php';}}+ usort($memberDataPoints, fn($a, $b) => $b['y'] <=> $a['y']);$showMemberCostGraph = count($memberDataPoints) > 1;$paymentMethodDataPoints = [];@@ -271,6 +266,7 @@ require_once 'includes/stats_calculations.php';}}+ usort($paymentMethodDataPoints, fn($a, $b) => $b['y'] <=> $a['y']);$showPaymentMethodsGraph = count($paymentMethodDataPoints) > 1;if ($showCategoryCostGraph || $showMemberCostGraph || $showPaymentMethodsGraph || $showTotalMonthlyCostGraph || $showVsBudgetGraph) {?>diff --git a/styles/styles.css b/styles/styles.cssindex aed1bf4..6acbdbb 100644--- a/styles/styles.css+++ b/styles/styles.css@@ -506,6 +506,11 @@ button.mobile-action-renew {display: flex;}+.subscription-main .actions.open-above {+ top: auto;+ bottom: 100%;+}+.subscription-main .actions>li {display: flex;align-items: center;@@ -524,8 +529,19 @@ button.mobile-action-renew {background-color: #f9f9f9;}+.subscription-main .actions>li.delete:hover {+ background-color: #fff5f5;+}++.subscription-main .actions>li.delete:hover>i {+ color: #e53e3e;+}+.subscription-main .actions>li>i {color: var(--main-color);+ font-size: 16px;+ width: 20px;+ text-align: center;}.subscription-main .actions>li:hover>i {@@ -544,6 +560,7 @@ button.mobile-action-renew {.subscription-notes {display: none;flex-direction: row;+ align-items: center;padding: 6px 5px;overflow: hidden;}@@ -553,10 +570,12 @@ button.mobile-action-renew {height: 32px;}-.subscription-secondary svg,-.subscription-notes svg {+.subscription-secondary i,+.subscription-notes i {+ font-size: 19px;+ color: var(--main-color);width: 20px;- height: 20px;+ text-align: center;}.subscription-main>span,@@ -1052,11 +1071,20 @@ header #avatar {}.image-button>i {- color: var(--hover-color);- font-size: 28px;+ color: var(--main-color);+ font-size: 18px;padding: 2px;}+.image-button:hover>i {+ color: var(--hover-color);+}++.image-button.disabled>i {+ opacity: 0.35;+ cursor: not-allowed;+}+.image-button>svg {width: 32px;height: 32px;@@ -1088,6 +1116,11 @@ header #avatar {object-fit: contain;}+#logo-search-button>i,+#icon-search-button>i {+ font-size: 26px;+}+.payments-list {display: flex;flex-wrap: wrap;@@ -1703,13 +1736,15 @@ button.dark-theme-button i {}.icon-preview:after {- content: "Upload Icon";+ content: "\f093";+ font-family: "Font Awesome 6 Free";+ font-weight: 900;display: flex;justify-content: center;align-items: center;height: 100%;color: var(--main-color);- font-size: 16px;+ font-size: 22px;text-align: center;}@@ -2358,6 +2393,7 @@ button.dark-theme-button i {flex-direction: row;flex-grow: 1;flex-wrap: wrap;+ align-items: center;}.user-list .user-list-row {@@ -2380,7 +2416,7 @@ button.dark-theme-button i {display: flex;flex-basis: 50%;gap: 12px;- align-items: baseline;+ align-items: center;}.user-list a {@@ -2393,8 +2429,10 @@ button.dark-theme-button i {}.user-list .user-list-icon {- width: 16px;+ width: 22px;text-align: center;+ font-size: 16px;+ color: var(--main-color);}.calendar-nav {diff --git a/subscriptions.php b/subscriptions.phpindex 88c6d69..300b1e8 100644--- a/subscriptions.php+++ b/subscriptions.php@@ -194,6 +194,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden'MMM d, yyyy');+ $print = [];foreach ($subscriptions as $subscription) {if ($subscription['inactive'] == 1 && isset($settings['hideDisabledSubscriptions']) && $settings['hideDisabledSubscriptions'] === 'true') {continue;@@ -205,6 +206,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden$cycle = $subscription['cycle'];$frequency = $subscription['frequency'];$print[$id]['billing_cycle'] = getBillingCycle($cycle, $frequency, $i18n);+ $print[$id]['one_time'] = ($cycle == 5);$paymentMethodId = $subscription['payment_method_id'];$print[$id]['currency_code'] = $currencies[$subscription['currency_id']]['code'];$currencyId = $subscription['currency_id'];@@ -291,7 +293,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden<input type="hidden" id="logo-url" name="logo-url"><div id="logo-search-button" class="image-button medium disabled" title="<?= translate('search_logo', $i18n) ?>"onClick="searchLogo()">- <?php include "images/siteicons/svg/websearch.php"; ?>+ <i class="fa-solid fa-magnifying-glass"></i></div><input type="hidden" id="id" name="id"><div id="logo-search-results" class="logo-search">@@ -345,7 +347,7 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden</select></div></div>- <div class="split33">+ <div class="split33" id="auto-renew-group"><label><?= translate('auto_renewal', $i18n) ?></label><div class="inline height50"><input type="checkbox" id="auto_renew" name="auto_renew" checked>@@ -370,7 +372,8 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden</button><div class="split50"><label for="next_payment" class="split-label">- <?= translate('next_payment', $i18n) ?>+ <span id="next-payment-label-recurring"><?= translate('next_payment', $i18n) ?></span>+ <span id="next-payment-label-onetime" style="display:none"><?= translate('payment_date', $i18n) ?></span><div id="autofill-next-payment-button" class="autofill-next-payment hideOnDesktop"title="<?= translate('calculate_next_payment_date', $i18n) ?>" onClick="autoFillNextPaymentDate(event)"><i class="fa-solid fa-wand-magic-sparkles"></i>@@ -429,12 +432,12 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden</select></div>- <div class="form-group-inline grow">+ <div class="form-group-inline grow" id="notifications-group"><input type="checkbox" id="notifications" name="notifications" onchange="toggleNotificationDays()"><label for="notifications" class="grow"><?= translate('enable_notifications', $i18n) ?></label></div>- <div class="form-group">+ <div class="form-group" id="notify-days-cancellation-group"><div class="inline"><div class="split66 mobile-split-50"><label for="notify_days_before"><?= translate('notify_me', $i18n) ?></label>