From 0a7217e1279320132acb4b48f8d61b4d57a63ccd Mon Sep 17 00:00:00 2001 From: M_Viper Date: Thu, 29 Feb 2024 10:08:10 +0000 Subject: [PATCH] article_overview.php aktualisiert --- article_overview.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/article_overview.php b/article_overview.php index 48783b2..5d15bdf 100644 --- a/article_overview.php +++ b/article_overview.php @@ -38,8 +38,7 @@
  • Home
  • Artikel hinzufügen
  • Artikel Übersicht
  • -
  • chrome Erweiterung
  • -
  • Backup
  • +
  • Einstellungen
  • @@ -240,6 +239,38 @@ createNotification("Ablaufdatum nahe", options); } } + + // Gotify-Benachrichtigung senden + function sendGotifyNotification(message) { + var gotifyConfig = JSON.parse(''); + var gotifyUrl = gotifyConfig.gotify_url; + var appToken = gotifyConfig.app_token; + + var xhr = new XMLHttpRequest(); + xhr.open("POST", gotifyUrl + "/message?token=" + appToken, true); + xhr.setRequestHeader('Content-Type', 'application/json'); + + xhr.onreadystatechange = function() { + if (xhr.readyState === 4 && xhr.status === 200) { + console.log("Gotify notification sent successfully."); + } + }; + + var data = JSON.stringify({ message: message }); + xhr.send(data); + } + + // Gotify-Benachrichtigung senden, wenn das Ablaufdatum innerhalb der Benachrichtigungstage liegt + function checkExpiryDate(expirationDate, notificationDays, itemName) { + var tenDaysBeforeExpiry = new Date(expirationDate); + tenDaysBeforeExpiry.setDate(tenDaysBeforeExpiry.getDate() - notificationDays); + var currentDate = new Date(); + + if (currentDate >= tenDaysBeforeExpiry && currentDate <= new Date(expirationDate)) { + var message = "Das Ablaufdatum von " + itemName + " liegt in " + notificationDays + " Tagen an."; + sendGotifyNotification(message); + } + } // Aufrufen der Funktion für jedes Element in der Tabelle var rows = document.getElementsByClassName("expiring");