Skip to content

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

feat: allow notifications on due date

Miguel Ribeiro87f148d1745b
diff --git a/api/subscriptions/get_ical_feed.php b/api/subscriptions/get_ical_feed.php
index 27634cc..758c5bc 100644
--- a/api/subscriptions/get_ical_feed.php
+++ b/api/subscriptions/get_ical_feed.php
@@ -111,7 +111,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" || $_SERVER["REQUEST_METHOD"] === "GET
$paymentMethods[$paymentMethod['id']] = $paymentMethod['name'];
}
- $sql = "SELECT * FROM subscriptions WHERE user_id = :userId ORDER BY next_payment ASC";
+ $sql = "SELECT * FROM subscriptions WHERE user_id = :userId AND inactive = 0 ORDER BY next_payment ASC";
$stmt = $db->prepare($sql);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
diff --git a/endpoints/cronjobs/sendnotifications.php b/endpoints/cronjobs/sendnotifications.php
index 0f403dc..0d029e7 100644
--- a/endpoints/cronjobs/sendnotifications.php
+++ b/endpoints/cronjobs/sendnotifications.php
@@ -217,7 +217,7 @@ while ($userToNotify = $usersToNotify->fetchArray(SQLITE3_ASSOC)) {
$i = 0;
$currentDate = new DateTime('now');
while ($rowSubscription = $resultSubscriptions->fetchArray(SQLITE3_ASSOC)) {
- if ($rowSubscription['notify_days_before'] !== 0) {
+ if ($rowSubscription['notify_days_before'] !== -1) {
$daysToCompare = $rowSubscription['notify_days_before'];
} else {
$daysToCompare = $days;
diff --git a/endpoints/notifications/testemailnotifications.php b/endpoints/notifications/testemailnotifications.php
index 85aa418..b7805a5 100644
--- a/endpoints/notifications/testemailnotifications.php
+++ b/endpoints/notifications/testemailnotifications.php
@@ -60,7 +60,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
}
$mail->Port = $smtpPort;
- $getUser = "SELECT * FROM user WHERE id = 1";
+ $getUser = "SELECT * FROM user WHERE id = $userId";
$user = $db->querySingle($getUser, true);
$email = $user['email'];
$name = $user['username'];
diff --git a/includes/i18n/de.php b/includes/i18n/de.php
index 7143055..f4759a9 100644
--- a/includes/i18n/de.php
+++ b/includes/i18n/de.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "E-Mail Benachrichtigung aktivieren",
"notify_me" => "Benachrichtige mich",
"day_before" => "Tag bevor",
+ "on_due_date" => "Am Fälligkeitsdatum",
"days_before" => "Tage bevor",
"smtp_address" => "SMTP Adresse",
"port" => "Port",
diff --git a/includes/i18n/el.php b/includes/i18n/el.php
index 3ef529c..fb33d10 100644
--- a/includes/i18n/el.php
+++ b/includes/i18n/el.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Ενεργοποίηση ειδοποιήσεων με email",
"notify_me" => "Ειδοποίησε με",
"day_before" => "ημέρα πριν",
+ "on_due_date" => "την ημερομηνία λήξης",
"days_before" => "ημέρες πριν",
"smtp_address" => "SMTP Address",
"port" => "Θύρα",
diff --git a/includes/i18n/en.php b/includes/i18n/en.php
index 969510f..d2f6213 100644
--- a/includes/i18n/en.php
+++ b/includes/i18n/en.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Enable email notifications",
"notify_me" => "Notify me",
"day_before" => "day before",
+ "on_due_date" => "On due date",
"days_before" => "days before",
"smtp_address" => "SMTP Address",
"port" => "Port",
diff --git a/includes/i18n/es.php b/includes/i18n/es.php
index 4c5b3a0..521c71f 100644
--- a/includes/i18n/es.php
+++ b/includes/i18n/es.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Habilitar notificaciones por correo electrónico",
"notify_me" => "Notificarme",
"day_before" => "día antes",
+ "on_due_date" => "En la fecha de vencimiento",
"days_before" => "días antes",
"smtp_address" => "Dirección SMTP",
"port" => "Puerto",
diff --git a/includes/i18n/fr.php b/includes/i18n/fr.php
index 09cc02d..b0d611d 100644
--- a/includes/i18n/fr.php
+++ b/includes/i18n/fr.php
@@ -158,6 +158,7 @@ $i18n = [
"enable_email_notifications" => "Activer les notifications par courriel",
"notify_me" => "Me prevenir",
"day_before" => "jour avant",
+ "on_due_date" => "Le jour de l'échéance",
"days_before" => "jours avant",
"smtp_address" => "Adresse SMTP",
"port" => "Port",
diff --git a/includes/i18n/it.php b/includes/i18n/it.php
index 1c4346b..bb72c9a 100644
--- a/includes/i18n/it.php
+++ b/includes/i18n/it.php
@@ -165,6 +165,7 @@ $i18n = [
"enable_email_notifications" => 'Abilita le notifiche via e-mail',
"notify_me" => 'Avvisami',
"day_before" => 'giorno prima',
+ "on_due_date" => 'Alla data di scadenza',
"days_before" => 'giorni prima',
"smtp_address" => 'Indirizzo SMTP',
"port" => 'Porta',
diff --git a/includes/i18n/jp.php b/includes/i18n/jp.php
index 35e66ab..c1b3db9 100644
--- a/includes/i18n/jp.php
+++ b/includes/i18n/jp.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "電子メール通知を有効にする",
"notify_me" => "通知",
"day_before" => "日前",
+ "on_due_date" => "支払い日",
"days_before" => "日前",
"smtp_address" => "SMTPアドレス",
"port" => "ポート番号",
diff --git a/includes/i18n/ko.php b/includes/i18n/ko.php
index 989ff83..c43a115 100644
--- a/includes/i18n/ko.php
+++ b/includes/i18n/ko.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "이메일 알림 활성화",
"notify_me" => "알림 받기",
"day_before" => "일 전",
+ "on_due_date" => "만기일",
"days_before" => "일 전",
"smtp_address" => "SMTP 주소",
"port" => "포트",
diff --git a/includes/i18n/nl.php b/includes/i18n/nl.php
index cc53dd0..0a2c6c1 100644
--- a/includes/i18n/nl.php
+++ b/includes/i18n/nl.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "E-mail notificaties inschakelen",
"notify_me" => "Informeer mij",
"day_before" => "dag voor",
+ "on_due_date" => "Op vervaldatum",
"days_before" => "dagen voor",
"smtp_address" => "SMTP-adres",
"port" => "Poort",
diff --git a/includes/i18n/pl.php b/includes/i18n/pl.php
index 16906b9..d261767 100644
--- a/includes/i18n/pl.php
+++ b/includes/i18n/pl.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Włącz powiadomienia e-mail",
"notify_me" => "Powiadom mnie",
"day_before" => "dzień wcześniej",
+ "on_due_date" => "W dniu wymagalności",
"days_before" => "dni wcześniej",
"smtp_address" => "Adres SMTP",
"port" => "Port",
diff --git a/includes/i18n/pt.php b/includes/i18n/pt.php
index 5258152..6dcb685 100644
--- a/includes/i18n/pt.php
+++ b/includes/i18n/pt.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Activar notificações por email",
"notify_me" => "Notificar-me",
"day_before" => "dia antes",
+ "on_due_date" => "Na data de vencimento",
"days_before" => "dias antes",
"smtp_address" => "Endereço SMTP",
"port" => "Porto",
diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.php
index 75c88af..04e032a 100644
--- a/includes/i18n/pt_br.php
+++ b/includes/i18n/pt_br.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Ativar notificações por email",
"notify_me" => "Me notificar",
"day_before" => "dia antes",
+ "on_due_date" => "Na data de vencimento",
"days_before" => "dias antes",
"smtp_address" => "Endereço SMTP",
"port" => "Porta",
diff --git a/includes/i18n/ru.php b/includes/i18n/ru.php
index 6ae08e6..d964972 100644
--- a/includes/i18n/ru.php
+++ b/includes/i18n/ru.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Включить уведомления по электронной почте",
"notify_me" => "Уведомить меня за",
"day_before" => "день до события",
+ "on_due_date" => "в день события",
"days_before" => "дня(дней) до события",
"smtp_address" => "SMTP-адрес",
"port" => "Порт",
diff --git a/includes/i18n/sl.php b/includes/i18n/sl.php
index f75e11e..a3eff0d 100644
--- a/includes/i18n/sl.php
+++ b/includes/i18n/sl.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Omogoči e-poštna obvestila",
"notify_me" => "Obvesti me",
"day_before" => "dan prej",
+ "on_due_date" => "Na dan zapadlosti",
"days_before" => "dni prej",
"smtp_address" => "SMTP naslov",
"port" => "vrata",
diff --git a/includes/i18n/sr.php b/includes/i18n/sr.php
index 1b34629..0e4254a 100644
--- a/includes/i18n/sr.php
+++ b/includes/i18n/sr.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Омогући обавештења е-поштом",
"notify_me" => "Обавести ме",
"day_before" => "дан пре",
+ "on_due_date" => "на дан доспећа",
"days_before" => "дана пре",
"smtp_address" => "SMTP адреса",
"port" => "Порт",
diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.php
index 4b94815..814bc7b 100644
--- a/includes/i18n/sr_lat.php
+++ b/includes/i18n/sr_lat.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Omogući obaveštenja e-poštom",
"notify_me" => "Obavesti me",
"day_before" => "dan pre",
+ "on_due_date" => "Na dan dospeća",
"days_before" => "dana pre",
"smtp_address" => "SMTP adresa",
"port" => "Port",
diff --git a/includes/i18n/tr.php b/includes/i18n/tr.php
index b210f01..ef97818 100644
--- a/includes/i18n/tr.php
+++ b/includes/i18n/tr.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "E-posta bildirimlerini etkinleştir",
"notify_me" => "Beni bilgilendir",
"day_before" => "bir gün önce",
+ "on_due_date" => "Vadesinde",
"days_before" => "günler önce",
"smtp_address" => "SMTP Adresi",
"port" => "Port",
diff --git a/includes/i18n/vi.php b/includes/i18n/vi.php
index 7ecfc09..dd6a292 100644
--- a/includes/i18n/vi.php
+++ b/includes/i18n/vi.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "Bật thông báo qua email",
"notify_me" => "Thông báo cho tôi",
"day_before" => "ngày trước",
+ "on_due_date" => "Vào ngày đáo hạn",
"days_before" => "ngày trước",
"smtp_address" => "Địa chỉ SMTP",
"port" => "Cổng",
diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.php
index 1b8f9a5..279aadc 100644
--- a/includes/i18n/zh_cn.php
+++ b/includes/i18n/zh_cn.php
@@ -165,6 +165,7 @@ $i18n = [
"enable_email_notifications" => "启用电子邮件通知",
"notify_me" => "通知提前时间",
"day_before" => "天", // 设置标题(`notify_me`)中已经表明是提前多少天,因此这里直接用单位即可
+ "on_due_date" => "到期日",
"days_before" => "天",
"smtp_address" => "SMTP 地址",
"port" => "端口",
diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.php
index fb2dc71..2858f82 100644
--- a/includes/i18n/zh_tw.php
+++ b/includes/i18n/zh_tw.php
@@ -157,6 +157,7 @@ $i18n = [
"enable_email_notifications" => "啟用電子信箱通知",
"notify_me" => "通知提前時間",
"day_before" => "天",
+ "on_due_date" => "到期日當天",
"days_before" => "天",
"smtp_address" => "SMTP 信箱地址",
"port" => "連接埠",
diff --git a/includes/version.php b/includes/version.php
index e8c2498..ac4dcd4 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
-$version = "v2.43.1";
+$version = "v2.44.0";
?>
\ No newline at end of file
diff --git a/index.php b/index.php
index 9f73eab..f8e5681 100644
--- a/index.php
+++ b/index.php
@@ -570,7 +570,8 @@ $headerClass = count($subscriptions) > 0 ? "main-actions" : "main-actions hidden
<div class="split66 mobile-split-50">
<label for="notify_days_before"><?= translate('notify_me', $i18n) ?></label>
<select id="notify_days_before" name="notify_days_before" disabled>
- <option value="0"><?= translate('default_value_from_settings', $i18n) ?></option>
+ <option value="-1"><?= translate('default_value_from_settings', $i18n) ?></option>
+ <option value="0"><?= translate('on_due_date', $i18n) ?></option>
<option value="1">1 <?= translate('day_before', $i18n) ?></option>
<?php
for ($i = 2; $i <= 90; $i++) {
diff --git a/migrations/000034.php b/migrations/000034.php
new file mode 100644
index 0000000..5301283
--- /dev/null
+++ b/migrations/000034.php
@@ -0,0 +1,4 @@
+<?php
+// This migration changes all the notify_days_before from 0 to -1 to to support the added "on the day" option
+
+$db->exec('UPDATE subscriptions SET `notify_days_before` = -1 WHERE `notify_days_before` = 0');
\ No newline at end of file
diff --git a/settings.php b/settings.php
index f946088..0a2e073 100644
--- a/settings.php
+++ b/settings.php
@@ -322,13 +322,18 @@ $userData['currency_symbol'] = $currencies[$main_currency]['symbol'];
<label for="days"><?= translate('notify_me', $i18n) ?>:</label>
<div class="form-group-inline">
<select name="days" id="days">
+ <option value="0" <?= $notifications['days'] == 0 ? "selected" : "" ?>>
+ <?= translate('on_due_date', $i18n) ?>
+ </option>
+ <option value="1" <?= $notifications['days'] == 1 ? "selected" : "" ?>>
+ 1 <?= translate('day_before', $i18n) ?>
+ </option>
<?php
- for ($i = 1; $i <= 7; $i++) {
- $dayText = $i > 1 ? translate('days_before', $i18n) : translate('day_before', $i18n);
+ for ($i = 2; $i <= 7; $i++) {
$selected = $i == $notifications['days'] ? "selected" : "";
?>
<option value="<?= $i ?>" <?= $selected ?>>
- <?= $i ?> <?= $dayText ?>
+ <?= $i ?> <?= translate('day_before', $i18n) ?>
</option>
<?php
}