Skip to content

Commit

Permalink
feat: add cancelation reminders (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellite authored Jul 5, 2024
1 parent 911de4c commit c393146
Show file tree
Hide file tree
Showing 32 changed files with 600 additions and 56 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ See instructions to run Wallos below.
```bash
0 1 * * * php /var/www/html/endpoints/cronjobs/updatenextpayment.php >> /var/log/cron/updatenextpayment.log 2>&1
0 2 * * * php /var/www/html/endpoints/cronjobs/updateexchange.php >> /var/log/cron/updateexchange.log 2>&1
0 8 * * * php /var/www/html/endpoints/cronjobs/sendcancellationnotifications.php >> /var/log/cron/sendcancellationnotifications.log 2>&1
0 9 * * * php /var/www/html/endpoints/cronjobs/sendnotifications.php >> /var/log/cron/sendnotifications.log 2>&1
*/2 * * * * php /var/www/html/endpoints/cronjobs/sendverificationemails.php >> /var/log/cron/sendverificationemail.log 2>&1
*/2 * * * * php /var/www/html/endpoints/cronjobs/sendresetpasswordemails.php >> /var/log/cron/sendresetpasswordemails.log 2>&1
Expand Down Expand Up @@ -138,6 +139,8 @@ If you want to trigger an Update of the exchange rates, change your main currenc

![Screenshot](screenshots/wallos-stats.png)

![Screenshot](screenshots/wallos-calendar.png)

![Screenshot](screenshots/wallos-form.png)

![Screenshot](screenshots/wallos-dashboard-mobile-light.png) ![Screenshot](screenshots/wallos-dashboard-mobile-dark.png)
Expand Down
1 change: 1 addition & 0 deletions cronjobs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Run the scripts every day
0 1 * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/updatenextpayment.php >> /var/log/cron/updatenextpayment.log 2>&1
0 2 * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/updateexchange.php >> /var/log/cron/updateexchange.log 2>&1
0 8 * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/sendcancellationnotifications.php >> /var/log/cron/sendcancellationnotifications.log 2>&1
0 9 * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/sendnotifications.php >> /var/log/cron/sendnotifications.log 2>&1
*/2 * * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/sendverificationemails.php >> /var/log/cron/sendverificationemails.log 2>&1
*/2 * * * * /usr/local/bin/php /var/www/html/endpoints/cronjobs/sendresetpasswordemails.php >> /var/log/cron/sendresetpasswordemails.log 2>&1
470 changes: 470 additions & 0 deletions endpoints/cronjobs/sendcancellationnotifications.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion endpoints/cronjobs/sendnotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
$pushover['token'] = $row["token"];
}

// Check if Nrfy notifications are enabled and get the settings
// Check if Ntfy notifications are enabled and get the settings
$query = "SELECT * FROM ntfy_notifications WHERE user_id = :userId";
$stmt = $db->prepare($query);
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
Expand Down
12 changes: 7 additions & 5 deletions endpoints/subscription/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function resizeAndUploadLogo($uploadedFile, $uploadDir, $name, $settings)
$notify = isset($_POST['notifications']) ? true : false;
$notifyDaysBefore = $_POST['notify_days_before'];
$inactive = isset($_POST['inactive']) ? true : false;
$cancellationDate = $_POST['cancellation_date'] ?? null;

if ($logoUrl !== "") {
$logo = getLogoFromUrl($logoUrl, '../../images/uploads/logos/', $name, $settings, $i18n);
Expand All @@ -188,21 +189,21 @@ function resizeAndUploadLogo($uploadedFile, $uploadDir, $name, $settings)

if (!$isEdit) {
$sql = "INSERT INTO subscriptions (name, logo, price, currency_id, next_payment, cycle, frequency, notes,
payment_method_id, payer_user_id, category_id, notify, inactive, url, notify_days_before, user_id)
payment_method_id, payer_user_id, category_id, notify, inactive, url, notify_days_before, user_id, cancellation_date)
VALUES (:name, :logo, :price, :currencyId, :nextPayment, :cycle, :frequency, :notes,
:paymentMethodId, :payerUserId, :categoryId, :notify, :inactive, :url, :notifyDaysBefore, :userId)";
:paymentMethodId, :payerUserId, :categoryId, :notify, :inactive, :url, :notifyDaysBefore, :userId, :cancellationDate)";
} else {
$id = $_POST['id'];
if ($logo != "") {
$sql = "UPDATE subscriptions SET name = :name, logo = :logo, price = :price, currency_id = :currencyId,
next_payment = :nextPayment, cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId,
payer_user_id = :payerUserId, category_id = :categoryId, notify = :notify, inactive = :inactive,
url = :url, notify_days_before = :notifyDaysBefore WHERE id = :id AND user_id = :userId";
url = :url, notify_days_before = :notifyDaysBefore, camcelation_date = :cancellationDate WHERE id = :id AND user_id = :userId";
} else {
$sql = "UPDATE subscriptions SET name = :name, price = :price, currency_id = :currencyId, next_payment = :nextPayment,
cycle = :cycle, frequency = :frequency, notes = :notes, payment_method_id = :paymentMethodId, payer_user_id = :payerUserId,
category_id = :categoryId, notify = :notify, inactive = :inactive, url = :url,notify_days_before = :notifyDaysBefore
WHERE id = :id AND user_id = :userId";
category_id = :categoryId, notify = :notify, inactive = :inactive, url = :url, notify_days_before = :notifyDaysBefore,
cancellation_date = :cancellationDate WHERE id = :id AND user_id = :userId";
}
}

Expand All @@ -228,6 +229,7 @@ function resizeAndUploadLogo($uploadedFile, $uploadDir, $name, $settings)
$stmt->bindParam(':url', $url, SQLITE3_TEXT);
$stmt->bindParam(':notifyDaysBefore', $notifyDaysBefore, SQLITE3_INTEGER);
$stmt->bindParam(':userId', $userId, SQLITE3_INTEGER);
$stmt->bindParam(':cancellationDate', $cancellationDate, SQLITE3_TEXT);

if ($stmt->execute()) {
$success['status'] = "Success";
Expand Down
3 changes: 2 additions & 1 deletion endpoints/subscription/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
]));
}

$query = "INSERT INTO subscriptions (name, logo, price, currency_id, next_payment, cycle, frequency, notes, payment_method_id, payer_user_id, category_id, notify, url, inactive, notify_days_before, user_id) VALUES (:name, :logo, :price, :currency_id, :next_payment, :cycle, :frequency, :notes, :payment_method_id, :payer_user_id, :category_id, :notify, :url, :inactive, :notify_days_before, :user_id)";
$query = "INSERT INTO subscriptions (name, logo, price, currency_id, next_payment, cycle, frequency, notes, payment_method_id, payer_user_id, category_id, notify, url, inactive, notify_days_before, user_id, cancellation_date) VALUES (:name, :logo, :price, :currency_id, :next_payment, :cycle, :frequency, :notes, :payment_method_id, :payer_user_id, :category_id, :notify, :url, :inactive, :notify_days_before, :user_id, :cancellation_date)";
$cloneStmt = $db->prepare($query);
$cloneStmt->bindValue(':name', $subscriptionToClone['name'], SQLITE3_TEXT);
$cloneStmt->bindValue(':logo', $subscriptionToClone['logo'], SQLITE3_TEXT);
Expand All @@ -35,6 +35,7 @@
$cloneStmt->bindValue(':inactive', $subscriptionToClone['inactive'], SQLITE3_INTEGER);
$cloneStmt->bindValue(':notify_days_before', $subscriptionToClone['notify_days_before'], SQLITE3_INTEGER);
$cloneStmt->bindValue(':user_id', $userId, SQLITE3_INTEGER);
$cloneStmt->bindValue(':cancellation_date', $subscriptionToClone['cancellation_date'], SQLITE3_TEXT);

if ($cloneStmt->execute()) {
$response = [
Expand Down
1 change: 1 addition & 0 deletions endpoints/subscription/get.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
$subscriptionData['inactive'] = $row['inactive'];
$subscriptionData['url'] = htmlspecialchars_decode($row['url'] ?? "");
$subscriptionData['notify_days_before'] = $row['notify_days_before'];
$subscriptionData['cancellation_date'] = $row['cancellation_date'];

$subscriptionJson = json_encode($subscriptionData);
header('Content-Type: application/json');
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notizen",
"enable_notifications" => "Benachrichtigungen für dieses Abonnement aktivieren",
"default_value_from_settings" => "Standardwert aus den Einstellungen",
"cancellation_notification" => "Benachrichtigung bei Kündigung",
"delete" => "Löschen",
"cancel" => "Abbrechen",
"upload_logo" => "Logo hochladen",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/el.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Σημειώσεις",
"enable_notifications" => "Ενεργοποίηση ειδοποιήσεων για αυτή τη συνδρομή",
"default_value_from_settings" => "Προεπιλεγμένη τιμή από τις ρυθμίσεις",
"cancellation_notification" => "Ειδοποίηση ακύρωσης",
"delete" => "Διαγραφή",
"cancel" => "Ακύρωση",
"upload_logo" => "Φόρτωση λογότυπου",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notes",
"enable_notifications" => "Enable Notifications for this subscription",
"default_value_from_settings" => "Default value from settings",
"cancellation_notification" => "cancellation Notification",
"delete" => "Delete",
"cancel" => "Cancel",
"upload_logo" => "Upload Logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/es.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notas",
"enable_notifications" => "Habilitar notificaciones para esta suscripción",
"default_value_from_settings" => "Valor predeterminado de la configuración",
"cancellation_notification" => "Notificación de cancelación",
"delete" => "Eliminar",
"cancel" => "Cancelar",
"upload_logo" => "Cargar Logotipo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notes",
"enable_notifications" => "Activer les notifications pour cet abonnement",
"default_value_from_settings" => "Valeur par défaut des paramètres",
"cancellation_notification" => "Notification d'annulation",
"delete" => "Supprimer",
"cancel" => "Annuler",
"upload_logo" => "Télécharger le logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/it.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
'notes' => 'Note',
'enable_notifications' => 'Abilita notifiche per questo abbonamento',
'default_value_from_settings' => 'Valore predefinito dalle impostazioni',
"cancellation_notification" => "Notifica di cancellazione",
'delete' => 'Cancella',
'cancel' => 'Annulla',
'upload_logo' => 'Carica logo',
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/jp.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "注釈",
"enable_notifications" => "この定期購入の通知を有効にする",
"default_value_from_settings" => "設定からデフォルト値を使用",
"cancellation_notification" => "キャンセル通知",
"delete" => "削除",
"cancel" => "キャンセル",
"upload_logo" => "ロゴのアップロード",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ko.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "메모",
"enable_notifications" => "이 구독에 대한 알림을 활성화합니다.",
"default_value_from_settings" => "설정에서 기본값 사용",
"cancellation_notification" => "구독 취소 알림",
"delete" => "삭제",
"cancel" => "취소",
"upload_logo" => "로고 업로드",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pl.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notatki",
"enable_notifications" => "Włącz powiadomienia dla tej subskrypcji",
"default_value_from_settings" => "Wartość domyślna z ustawień",
"cancellation_notification" => "Powiadomienie o anulowaniu",
"delete" => "Usuń",
"cancel" => "Anuluj",
"upload_logo" => "Prześlij logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notas",
"enable_notifications" => "Activar notificações para esta subscrição",
"default_value_from_settings" => "Valor por defeito das definições",
"cancellation_notification" => "Notificação de cancelamento",
"delete" => "Remover",
"cancel" => "Cancelar",
"upload_logo" => "Enviar Logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/pt_br.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Anotações",
"enable_notifications" => "Ativar notificações para essa assinatura",
"default_value_from_settings" => "Valor padrão das configurações",
"cancellation_notification" => "Notificação de cancelamento",
"delete" => "Excluir",
"cancel" => "Cancelar",
"upload_logo" => "Enviar Logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Примечания",
"enable_notifications" => "Включить уведомления для этой подписки",
"default_value_from_settings" => "Значение по умолчанию из настроек",
"cancellation_notification" => "Уведомление об отмене",
"delete" => "Удалить",
"cancel" => "Отмена",
"upload_logo" => "Загрузить логотип",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sl.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Opombe",
"enable_notifications" => "Omogoči obvestila za to naročnino",
"default_value_from_settings" => "Privzeta vrednost iz nastavitev",
"cancellation_notification" => "Obvestilo o preklicu",
"delete" => "Izbriši",
"cancel" => "Prekliči",
"upload_logo" => "Naloži logotip",
Expand Down
2 changes: 2 additions & 0 deletions includes/i18n/sr.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"url" => "URL",
"notes" => "Напомене",
"enable_notifications" => "Омогући обавештења за ову претплату",
"default_value_from_settings" => "Подразумевана вредност из подешавања",
"cancellation_notification" => "Обавештење о отказивању",
"delete" => "Обриши",
"cancel" => "Откажи",
"upload_logo" => "Постави логотип",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/sr_lat.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Beleške",
"enable_notifications" => "Omogući obaveštenja za ovu pretplatu",
"default_value_from_settings" => "Podrazumevana vrednost iz podešavanja",
"cancellation_notification" => "Obaveštenje o otkazivanju",
"delete" => "Izbriši",
"cancel" => "Otkaži",
"upload_logo" => "Učitaj logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/tr.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "Notlar",
"enable_notifications" => "Bu abonelik için bildirimleri etkinleştir",
"default_value_from_settings" => "Ayarlar'dan varsayılan değeri al",
"cancellation_notification" => "İptal Bildirimi",
"delete" => "Sil",
"cancel" => "İptal",
"upload_logo" => "Logo Yükle",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_cn.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"notes" => "备注",
"enable_notifications" => "为此订阅启用通知",
"default_value_from_settings" => "默认值从设置中获取",
"cancellation_notification" => "取消通知",
"delete" => "删除",
"cancel" => "取消",
"upload_logo" => "上传 Logo",
Expand Down
1 change: 1 addition & 0 deletions includes/i18n/zh_tw.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"notes" => "備註",
"enable_notifications" => "為該訂閱開啟通知",
"default_value_from_settings" => "從設定中取得預設值",
"cancellation_notification" => "取消通知",
"delete" => "刪除",
"cancel" => "取消",
"upload_logo" => "上傳圖示",
Expand Down
2 changes: 1 addition & 1 deletion includes/version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$version = "v2.13.0";
$version = "v2.14.0";
?>
Loading

0 comments on commit c393146

Please sign in to comment.