Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
feat: show renewal type and price in calendar entries
Vic liu59bc32ba082d
diff --git a/calendar.php b/calendar.phpindex dfdb5b9..af16e12 100644--- a/calendar.php+++ b/calendar.php@@ -7,6 +7,21 @@ function getPriceConverted($price, $currency, $database, $userId)return wallos_convert_price($price, $currency, $database, $userId);}+function formatCalendarPrice($price, $currencyId, $currencies)+{+ if (!isset($currencies[$currencyId])) {+ return number_format((float) $price, 2);+ }++ $currency = $currencies[$currencyId];+ $formattedPrice = CurrencyFormatter::format($price, $currency['code']);+ if ($currency['symbol'] != "" && strstr($formattedPrice, $currency['code'])) {+ $formattedPrice = str_replace($currency['code'], $currency['symbol'], $formattedPrice);+ }++ return $formattedPrice;+}+// Get budget from user table$query = "SELECT budget FROM user WHERE id = :userId";$stmt = $db->prepare($query);@@ -84,6 +99,14 @@ $result = $stmt->execute();$row = $result->fetchArray(SQLITE3_ASSOC);$code = $row['code'];+$calendarCurrencies = [];+$stmt = $db->prepare("SELECT id, code, symbol FROM currencies WHERE user_id = :userId");+$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);+$result = $stmt->execute();+while ($row = $result->fetchArray(SQLITE3_ASSOC)) {+ $calendarCurrencies[$row['id']] = $row;+}+$yearsToLoad = $calendarYear - $currentYear + 1;$weekStartsSunday = !empty($settings['week_starts_sunday']);$weekDays = [@@ -268,7 +291,16 @@ if ($weekStartsSunday) {<?php foreach ($paymentsByDay[$day] as $payment) { ?><div class="calendar-event" onClick="showSubscriptionDetails(event, <?= $payment['id'] ?>)"title="<?= htmlspecialchars($payment['name']) ?>">- <?= htmlspecialchars($payment['name']) ?>+ <span class="calendar-event-title">+ <?php if ($payment['cycle'] != 5) { ?>+ <span class="calendar-event-renewal"+ title="<?= $payment['auto_renew'] ? translate('automatically_renews', $i18n) : translate('manual_renewal', $i18n) ?>">+ <?php include $payment['auto_renew'] ? 'images/siteicons/svg/automatic.php' : 'images/siteicons/svg/manual.php'; ?>+ </span>+ <?php } ?>+ <span class="calendar-event-name"><?= htmlspecialchars($payment['name']) ?></span>+ </span>+ <span class="calendar-event-price"><?= formatCalendarPrice($payment['price'], $payment['currency_id'], $calendarCurrencies) ?></span></div><?php } ?></div>diff --git a/styles/styles.css b/styles/styles.cssindex 5041b41..90b0fdf 100644--- a/styles/styles.css+++ b/styles/styles.css@@ -3073,6 +3073,37 @@ button.dark-theme-button i {background-color: rgba(var(--main-color-rgb), 0.18);}+.calendar .calendar-event-title {+ display: flex;+ align-items: center;+ gap: 4px;+ min-width: 0;+}++.calendar .calendar-event-renewal {+ display: inline-flex;+ flex-shrink: 0;+}++.calendar .calendar-event-renewal svg {+ width: 12px;+ height: 12px;+}++.calendar .calendar-event-name {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+}++.calendar .calendar-event-price {+ display: block;+ font-size: 10px;+ opacity: 0.75;+ overflow: hidden;+ text-overflow: ellipsis;+}+@media (max-width: 768px) {.calendar .calendar-header .calendar-cell {padding: 10px 0px 8px;@@ -3097,6 +3128,15 @@ button.dark-theme-button i {padding: 2px 5px;border-radius: 5px;}++ .calendar .calendar-event-renewal svg {+ width: 10px;+ height: 10px;+ }++ .calendar .calendar-event-price {+ font-size: 9px;+ }}.over-budget {