Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.
feat: add over budget warnings on the calendar
Miguel Ribeiro88eae1002f0c
diff --git a/calendar.php b/calendar.phpindex f36dd7f..b424a3c 100644--- a/calendar.php+++ b/calendar.php@@ -18,6 +18,14 @@ function getPriceConverted($price, $currency, $database, $userId)}}+// Get budget from user table+$query = "SELECT budget FROM user WHERE id = :userId";+$stmt = $db->prepare($query);+$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);+$result = $stmt->execute();+$row = $result->fetchArray(SQLITE3_ASSOC);+$budget = $row['budget'];+$currentMonth = date('m');$currentYear = date('Y');$sameAsCurrent = false;@@ -133,7 +141,7 @@ $yearsToLoad = $calendarYear - $currentYear + 1;<?php}?>- <span id="month"><?= translate('month-' . $calendarMonth, $i18n) ?> <?= $calendarYear ?></span>+ <span id="month" class="month"><?= translate('month-' . $calendarMonth, $i18n) ?> <?= $calendarYear ?></span><button class="button tiny" id="next" onclick="nextMonth(<?= $calendarMonth ?>, <?= $calendarYear ?>)"><iclass="fa-solid fa-chevron-right"></i></button></div>@@ -336,6 +344,19 @@ $yearsToLoad = $calendarYear - $currentYear + 1;</div></div>+ <?php+ if ($totalCostThisMonth > $budget) {+ $overBudgetAmount = $totalCostThisMonth - $budget;+ $overBudgetAmount = CurrencyFormatter::format($overBudgetAmount, $code);+ ?>+ <div class="over-budget">+ <i class="fa-solid fa-exclamation-triangle"></i>+ <?= translate('over_budget_warning', $i18n) ?> (<?= $overBudgetAmount ?>)+ </div>+ <?php+ }+ ?>+<div class="calendar-monthly-stats"><div class="calendar-monthly-stats-header"><h3><?= translate("stats", $i18n) ?></h3>diff --git a/endpoints/cronjobs/sendcancellationnotifications.php b/endpoints/cronjobs/sendcancellationnotifications.phpindex 544c079..b6d159f 100644--- a/endpoints/cronjobs/sendcancellationnotifications.php+++ b/endpoints/cronjobs/sendcancellationnotifications.php@@ -10,6 +10,8 @@ require __DIR__ . '/../../libs/PHPMailer/PHPMailer.php';require __DIR__ . '/../../libs/PHPMailer/SMTP.php';require __DIR__ . '/../../libs/PHPMailer/Exception.php';+require 'settimezone.php';+// Get all user ids$query = "SELECT id, username FROM user";$stmt = $db->prepare($query);diff --git a/endpoints/cronjobs/sendnotifications.php b/endpoints/cronjobs/sendnotifications.phpindex 57bde4c..dd890d8 100644--- a/endpoints/cronjobs/sendnotifications.php+++ b/endpoints/cronjobs/sendnotifications.php@@ -12,6 +12,8 @@ require __DIR__ . '/../../libs/PHPMailer/Exception.php';require __DIR__ . '/../../includes/currency_formatter.php';+require 'settimezone.php';+if (php_sapi_name() == 'cli') {$date = new DateTime('now');echo "\n" . $date->format('Y-m-d') . " " . $date->format('H:i:s') . "<br />\n";diff --git a/endpoints/cronjobs/sendresetpasswordemails.php b/endpoints/cronjobs/sendresetpasswordemails.phpindex 39d2318..d470fbd 100644--- a/endpoints/cronjobs/sendresetpasswordemails.php+++ b/endpoints/cronjobs/sendresetpasswordemails.php@@ -6,6 +6,8 @@ use PHPMailer\PHPMailer\Exception;require_once 'validate.php';require_once __DIR__ . '/../../includes/connect_endpoint_crontabs.php';+require 'settimezone.php';+$query = "SELECT * FROM admin";$stmt = $db->prepare($query);$result = $stmt->execute();diff --git a/endpoints/cronjobs/sendverificationemails.php b/endpoints/cronjobs/sendverificationemails.phpindex d491724..dc9d716 100644--- a/endpoints/cronjobs/sendverificationemails.php+++ b/endpoints/cronjobs/sendverificationemails.php@@ -6,6 +6,8 @@ use PHPMailer\PHPMailer\Exception;require_once 'validate.php';require_once __DIR__ . '/../../includes/connect_endpoint_crontabs.php';+require 'settimezone.php';+$query = "SELECT * FROM admin";$stmt = $db->prepare($query);$result = $stmt->execute();diff --git a/endpoints/cronjobs/settimezone.php b/endpoints/cronjobs/settimezone.phpnew file mode 100644index 0000000..e3ca8fd--- /dev/null+++ b/endpoints/cronjobs/settimezone.php@@ -0,0 +1,7 @@+<?php++$timezone = date_default_timezone_get();+if ($timezone == '') {+ $timezone = 'UTC';+}+date_default_timezone_set($timezone);\ No newline at end of filediff --git a/endpoints/cronjobs/storetotalyearlycost.php b/endpoints/cronjobs/storetotalyearlycost.phpindex 9277605..8deeba6 100644--- a/endpoints/cronjobs/storetotalyearlycost.php+++ b/endpoints/cronjobs/storetotalyearlycost.php@@ -2,6 +2,8 @@require_once __DIR__ . '/../../includes/connect_endpoint_crontabs.php';+require 'settimezone.php';+if (php_sapi_name() == 'cli') {$date = new DateTime('now');echo "\n" . $date->format('Y-m-d') . " " . $date->format('H:i:s') . "<br />\n";diff --git a/endpoints/cronjobs/updateexchange.php b/endpoints/cronjobs/updateexchange.phpindex ec18979..f9280bd 100644--- a/endpoints/cronjobs/updateexchange.php+++ b/endpoints/cronjobs/updateexchange.php@@ -2,6 +2,8 @@require_once 'validate.php';require_once __DIR__ . '/../../includes/connect_endpoint_crontabs.php';+require 'settimezone.php';+// Get all user idsif (php_sapi_name() == 'cli') {diff --git a/endpoints/cronjobs/updatenextpayment.php b/endpoints/cronjobs/updatenextpayment.phpindex 422f424..714c5b8 100644--- a/endpoints/cronjobs/updatenextpayment.php+++ b/endpoints/cronjobs/updatenextpayment.php@@ -3,10 +3,11 @@require_once 'validate.php';require_once __DIR__ . '/../../includes/connect_endpoint_crontabs.php';-if (php_sapi_name() == 'cli') {- $date = new DateTime('now');- echo "\n" . $date->format('Y-m-d') . " " . $date->format('H:i:s') . "<br />\n";-}+require 'settimezone.php';++$date = new DateTime('now');+echo "\n" . $date->format('Y-m-d') . " " . $date->format('H:i:s') . "<br />\n";+echo $timezone . "<br />\n";$currentDate = new DateTime();$currentDateString = $currentDate->format('Y-m-d');diff --git a/includes/i18n/cs.php b/includes/i18n/cs.phpindex d39a277..aca25c8 100644--- a/includes/i18n/cs.php+++ b/includes/i18n/cs.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "Prosinec","total_cost" => "Celkové náklady","export_icalendar" => "Exportovat iCalendar",+ "over_budget_warning" => "Překročili jste rozpočet",// TOTP Page"insert_totp_code" => "Vložte kód TOTP",diff --git a/includes/i18n/de.php b/includes/i18n/de.phpindex 29328dc..934c3ed 100644--- a/includes/i18n/de.php+++ b/includes/i18n/de.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Dezember","total_cost" => "Gesamtkosten","export_icalendar" => "iCalendar exportieren",+ "over_budget_warning" => "Sie haben Ihr Budget überschritten",// TOTP Page"insert_totp_code" => "Bitte geben Sie den TOTP-Code ein",diff --git a/includes/i18n/el.php b/includes/i18n/el.phpindex 9eaa8c4..00971a0 100644--- a/includes/i18n/el.php+++ b/includes/i18n/el.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Δεκέμβριος","total_cost" => "Συνολικό κόστος","export_icalendar" => "Εξαγωγή iCalendar",+ "over_budget_warning" => "Έχετε ξεπεράσει τον προϋπολογισμό",// TOTP Page"insert_totp_code" => "Εισάγετε τον κωδικό TOTP",diff --git a/includes/i18n/en.php b/includes/i18n/en.phpindex d58dde2..6c96bd7 100644--- a/includes/i18n/en.php+++ b/includes/i18n/en.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "December","total_cost" => "Total Cost","export_icalendar" => "Export iCalendar",+ "over_budget_warning" => "You're over budget",// TOTP Page"insert_totp_code" => "Insert TOTP code",diff --git a/includes/i18n/es.php b/includes/i18n/es.phpindex 6e999a2..23aa727 100644--- a/includes/i18n/es.php+++ b/includes/i18n/es.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Diciembre","total_cost" => "Costo Total","export_icalendar" => "Exportar iCalendar",+ "over_budget_warning" => "Te has pasado del presupuesto",// TOTP Page"insert_totp_code" => "Introduce el código TOTP",diff --git a/includes/i18n/fr.php b/includes/i18n/fr.phpindex 15fdb17..2d37f11 100644--- a/includes/i18n/fr.php+++ b/includes/i18n/fr.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "Décembre","total_cost" => "Coût total","export_icalendar" => "Exporter en iCalendar",+ "over_budget_warning" => "Vous avez dépassé votre budget",// TOTP Page"insert_totp_code" => "Veuillez insérer le code TOTP",diff --git a/includes/i18n/it.php b/includes/i18n/it.phpindex 912d2a8..955c556 100644--- a/includes/i18n/it.php+++ b/includes/i18n/it.php@@ -398,6 +398,7 @@ $i18n = ["month-12" => "Dicembre","total_cost" => "Costo totale","export_icalendar" => "Esporta iCal",+ "over_budget_warning" => "Avete superato il budget",// TOTP Page"insert_totp_code" => "Inserisci il codice TOTP",diff --git a/includes/i18n/jp.php b/includes/i18n/jp.phpindex f17ad7b..98e8c3c 100644--- a/includes/i18n/jp.php+++ b/includes/i18n/jp.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "12月","total_cost" => "合計費用","export_icalendar" => "iCalendarをエクスポート",+ "over_budget_warning" => "予算オーバーだ",// TOTP Page"insert_totp_code" => "TOTPコードを入力してください",diff --git a/includes/i18n/ko.php b/includes/i18n/ko.phpindex 34dc94c..3849186 100644--- a/includes/i18n/ko.php+++ b/includes/i18n/ko.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "12월","total_cost" => "총 비용","export_icalendar" => "iCalendar 내보내기",+ "over_budget_warning" => "예산이 초과되었습니다",// TOTP Page"insert_totp_code" => "2단계 인증 코드를 입력하세요",diff --git a/includes/i18n/nl.php b/includes/i18n/nl.phpindex 559502d..98bf8e5 100644--- a/includes/i18n/nl.php+++ b/includes/i18n/nl.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "December","total_cost" => "Totale kosten","export_icalendar" => "Exporteer iCalendar",+ "over_budget_warning" => "U bent over uw budget",// TOTP Page"insert_totp_code" => "Voer TOTP code in",diff --git a/includes/i18n/pl.php b/includes/i18n/pl.phpindex 0428e85..d40a475 100644--- a/includes/i18n/pl.php+++ b/includes/i18n/pl.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Grudzień","total_cost" => "Całkowity koszt","export_icalendar" => "Eksportuj do iCalendar",+ "over_budget_warning" => "Przekroczyłeś budżet",// TOTP Page"insert_totp_code" => "Wprowadź kod TOTP",diff --git a/includes/i18n/pt.php b/includes/i18n/pt.phpindex 397565b..6e4c980 100644--- a/includes/i18n/pt.php+++ b/includes/i18n/pt.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Dezembro","total_cost" => "Custo Total","export_icalendar" => "Exportar iCalendar",+ "over_budget_warning" => "O orçamento foi ultrapassado",// TOTP Page"insert_totp_code" => "Insira o código TOTP",diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.phpindex cd728b0..1a66cc4 100644--- a/includes/i18n/pt_br.php+++ b/includes/i18n/pt_br.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Dezembro","total_cost" => "Custo total","export_icalendar" => "Exportar iCalendar",+ "over_budget_warning" => "Você está acima do orçamento",// TOTP Page"insert_totp_code" => "Insira o código TOTP",diff --git a/includes/i18n/ru.php b/includes/i18n/ru.phpindex 62c5e5d..b68e642 100644--- a/includes/i18n/ru.php+++ b/includes/i18n/ru.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Декабрь","total_cost" => "Общая стоимость","export_icalendar" => "Экспорт в iCalendar",+ "over_budget_warning" => "Вы превысили бюджет",// TOTP Page"insert_totp_code" => "Введите код TOTP",diff --git a/includes/i18n/sl.php b/includes/i18n/sl.phpindex bfdd21a..83e36a6 100644--- a/includes/i18n/sl.php+++ b/includes/i18n/sl.php@@ -371,6 +371,7 @@ $i18n = ["month-12" => "December","total_cost" => "Skupni stroški","export_icalendar" => "Izvozi iCalendar",+ "over_budget_warning" => "Presegli ste proračun",// TOTP Page"insert_totp_code" => "Vnesite kodo TOTP",diff --git a/includes/i18n/sr.php b/includes/i18n/sr.phpindex b48952e..5cc6c8d 100644--- a/includes/i18n/sr.php+++ b/includes/i18n/sr.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Децембар","total_cost" => "Укупан трошак","export_icalendar" => "Извоз у iCalendar формат",+ "over_budget_warning" => "Прекорачили сте буџет",// TOTP Page"insert_totp_code" => "Унесите ТОТП код",diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.phpindex 33a2169..c7da6d8 100644--- a/includes/i18n/sr_lat.php+++ b/includes/i18n/sr_lat.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Decembar","total_cost" => "Ukupan trošak","export_icalendar" => "Izvezi iCalendar",+ "over_budget_warning" => "Prekoračili ste budžet",// TOTP Page"insert_totp_code" => "Unesite TOTP kod",diff --git a/includes/i18n/tr.php b/includes/i18n/tr.phpindex 59f4d29..45e365a 100644--- a/includes/i18n/tr.php+++ b/includes/i18n/tr.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Aralık","total_cost" => "Toplam Maliyet","export_icalendar" => "iCalendar olarak dışa aktar",+ "over_budget_warning" => "Bütçenizi aştınız",// TOTP Page"insert_totp_code" => "Lütfen TOTP kodunuzu girin",diff --git a/includes/i18n/uk.php b/includes/i18n/uk.phpindex 7c82187..8faf222 100644--- a/includes/i18n/uk.php+++ b/includes/i18n/uk.php@@ -378,6 +378,7 @@ $i18n = ["month-12" => "Грудень","total_cost" => "Загальна вартість","export_icalendar" => "Експорт у iCalendar",+ "over_budget_warning" => "Ви перевищили бюджет",// TOTP Page"insert_totp_code" => "Введіть код TOTP",diff --git a/includes/i18n/vi.php b/includes/i18n/vi.phpindex 42b0069..16c059a 100644--- a/includes/i18n/vi.php+++ b/includes/i18n/vi.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "Tháng Mười Hai","total_cost" => "Tổng chi phí","export_icalendar" => "Xuất iCalendar",+ "over_budget_warning" => "Bạn đang vượt quá ngân sách",// TOTP Page"insert_totp_code" => "Nhập mã TOTP",];diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.phpindex ed1bbf3..c84564d 100644--- a/includes/i18n/zh_cn.php+++ b/includes/i18n/zh_cn.php@@ -398,6 +398,7 @@ $i18n = ["month-12" => "十二月","total_cost" => "总费用","export_icalendar" => "导出 iCalendar",+ "over_budget_warning" => "您超出预算",// TOTP Page"insert_totp_code" => "请输入 TOTP 代码",diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.phpindex 33c32f7..6e975b6 100644--- a/includes/i18n/zh_tw.php+++ b/includes/i18n/zh_tw.php@@ -379,6 +379,7 @@ $i18n = ["month-12" => "十二月","total_cost" => "總費用","export_icalendar" => "匯出 iCalendar",+ "over_budget_warning" => "您超出預算",// TOTP 頁面"insert_totp_code" => "請輸入 TOTP 驗證碼",diff --git a/includes/version.php b/includes/version.phpindex 8221d82..aba0ade 100644--- a/includes/version.php+++ b/includes/version.php@@ -1,3 +1,3 @@<?php-$version = "v2.50.1";+$version = "v2.51.0";?>\ No newline at end of filediff --git a/styles/styles.css b/styles/styles.cssindex 555d328..03152f0 100644--- a/styles/styles.css+++ b/styles/styles.css@@ -2377,6 +2377,10 @@ button.dark-theme-button i {font-size: 18px;}+.calendar-nav .month {+ text-align: center;+}+.calendar {display: flex;flex-direction: column;@@ -2477,6 +2481,20 @@ button.dark-theme-button i {font-weight: 700;}+.over-budget {+ background-color: rgba(var(--error-color-rgb), 0.2);+ border: 1px solid var(--error-color);+ border-radius: 8px;+ padding: 10px;+ margin-top: 20px;+ text-align: center;+ font-size: 16px;+}++.over-budget>i {+ color: var(--error-color);+}+.subscription-modal {max-width: 400px;}