Dateien nach "/" hochladen
This commit is contained in:
parent
2cacfabb69
commit
669dd6f482
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
// Datenbankverbindung herstellen
|
||||||
|
include_once 'config/config.php';
|
||||||
|
|
||||||
|
// Verbindung zur Datenbank herstellen
|
||||||
|
$conn = new mysqli($host, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aktuelles Datum und Zeit abrufen
|
||||||
|
$current_datetime = date("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
// Benachrichtigungsgrenze berechnen (13 Uhr)
|
||||||
|
$notification_datetime = date("Y-m-d 13:00:00");
|
||||||
|
|
||||||
|
// Nur weitermachen, wenn es nach 13 Uhr ist
|
||||||
|
if ($current_datetime >= $notification_datetime) {
|
||||||
|
// SQL-Abfrage vorbereiten
|
||||||
|
$sql = "SELECT * FROM materials WHERE expiration_date <= DATE_ADD(CURDATE(), INTERVAL notification_days DAY)";
|
||||||
|
|
||||||
|
$result = $conn->query($sql);
|
||||||
|
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
// E-Mails für ablaufende Artikel senden
|
||||||
|
while($row = $result->fetch_assoc()) {
|
||||||
|
$to = $row["email"];
|
||||||
|
$subject = 'Artikel Ablaufbenachrichtigung';
|
||||||
|
$message = 'Der Artikel ' . $row["item_name"] . ' mit Barcode ' . $row["barcode"] . ' läuft am ' . $row["expiration_date"] . ' ab.';
|
||||||
|
$headers = 'From: noreply@viper.com' . "\r\n" .
|
||||||
|
'Reply-To: noreply@viper.com' . "\r\n" .
|
||||||
|
'X-Mailer: PHP/' . phpversion();
|
||||||
|
|
||||||
|
mail($to, $subject, $message, $headers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
|
?>
|
Loading…
Reference in New Issue