article_overview.php aktualisiert

This commit is contained in:
M_Viper 2024-02-28 19:02:06 +00:00
parent 9fcd0c924c
commit eafac54731
1 changed files with 48 additions and 1 deletions

View File

@ -38,6 +38,7 @@
<li><a href="index.php">Home</a></li> <li><a href="index.php">Home</a></li>
<li><a href="add_material_form.php">Artikel hinzufügen</a></li> <li><a href="add_material_form.php">Artikel hinzufügen</a></li>
<li><a href="article_overview.php">Artikel Übersicht</a></li> <li><a href="article_overview.php">Artikel Übersicht</a></li>
<li><a href="Material_chrome.zip">chrome Erweiterung</a></li>
<li><a href="backup_restore.php">Backup</a></li> <li><a href="backup_restore.php">Backup</a></li>
</ul> </ul>
</nav> </nav>
@ -63,6 +64,7 @@
<th>Anzahl soll</th> <th>Anzahl soll</th>
<th>Anzahl ist</th> <th>Anzahl ist</th>
<th>Ablaufdatum</th> <th>Ablaufdatum</th>
<th>Benachrichtigungstage</th>
<th>Barcode</th> <th>Barcode</th>
<th>Bild</th> <th>Bild</th>
<th>Aktionen</th> <th>Aktionen</th>
@ -123,6 +125,7 @@
} }
echo ">" . $row["amount_is"] . "</td>"; echo ">" . $row["amount_is"] . "</td>";
echo "<td>" . $expiration_date . "</td>"; echo "<td>" . $expiration_date . "</td>";
echo "<td>" . $notification_days . "</td>";
echo "<td>" . $row["barcode"] . "</td>"; echo "<td>" . $row["barcode"] . "</td>";
echo "<td>"; echo "<td>";
if (!empty($row["image"])) { if (!empty($row["image"])) {
@ -143,6 +146,7 @@
<input type='number' name='amount_should' value='" . $row["amount_should"] . "'> <input type='number' name='amount_should' value='" . $row["amount_should"] . "'>
<input type='number' name='amount_is' value='" . $row["amount_is"] . "'> <input type='number' name='amount_is' value='" . $row["amount_is"] . "'>
<input type='date' name='expiration_date' value='" . $row["expiration_date"] . "'> <input type='date' name='expiration_date' value='" . $row["expiration_date"] . "'>
<input type='number' name='notification_days' value='" . $row["notification_days"] . "'>
<input type='text' name='barcode' value='" . $row["barcode"] . "'> <input type='text' name='barcode' value='" . $row["barcode"] . "'>
<input type='hidden' name='id' value='" . $row["id"] . "'> <input type='hidden' name='id' value='" . $row["id"] . "'>
<input type='submit' value='Speichern'> <input type='submit' value='Speichern'>
@ -202,7 +206,50 @@
return confirm("Möchten Sie diesen Artikel wirklich löschen?"); return confirm("Möchten Sie diesen Artikel wirklich löschen?");
} }
// Überprüfen, ob der Browser die Notification API unterstützt
if ("Notification" in window) {
// Überprüfen, ob der Benutzer Berechtigung für Benachrichtigungen erteilt hat
if (Notification.permission === "granted") {
// Funktion zum Erstellen einer Benachrichtigung
function createNotification(title, options) {
new Notification(title, options);
}
} else if (Notification.permission !== "denied") {
// Aufforderung an den Benutzer, um Berechtigung für Benachrichtigungen zu bitten
Notification.requestPermission().then(function (permission) {
if (permission === "granted") {
function createNotification(title, options) {
new Notification(title, options);
}
}
});
}
}
// Überprüfung, ob das Ablaufdatum innerhalb von x Tagen liegt und eine Benachrichtigung senden
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 options = {
body: "Das Ablaufdatum von " + itemName + " liegt in " + notificationDays + " Tagen an.",
icon: "icon.png" // Hier das Bild für die Benachrichtigung ändern
};
createNotification("Ablaufdatum nahe", options);
}
}
// Aufrufen der Funktion für jedes Element in der Tabelle
var rows = document.getElementsByClassName("expiring");
for (var i = 0; i < rows.length; i++) {
var cells = rows[i].getElementsByTagName("td");
var expirationDate = cells[5].innerText; // Das 6. td-Element enthält das Ablaufdatum
var notificationDays = parseInt(cells[6].innerText); // Das 7. td-Element enthält die Benachrichtigungstage
var itemName = cells[0].innerText; // Das 1. td-Element enthält den Artikelnamen
checkExpiryDate(expirationDate, notificationDays, itemName);
}
</script> </script>
</body> </body>
<span class="watermark">© copyright 2024 by M_Viper</span> <span class="watermark">© copyright 2024 by M_Viper</span>