Dateien nach "/" hochladen
This commit is contained in:
parent
84d941a624
commit
a4a9186c2f
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
// Datenbankverbindung herstellen
|
||||
include_once 'config/config.php';
|
||||
|
||||
// Standard-E-Mail-Adresse aus der Konfigurationsdatei
|
||||
$email = $email; // Verwenden Sie hier den Variablennamen aus Ihrer config.php
|
||||
|
||||
$response = array(); // Array für die AJAX-Antwort
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Formulardaten abrufen
|
||||
$item_name = $_POST["item_name"];
|
||||
$manufacturer = $_POST["manufacturer"];
|
||||
$location = $_POST["location"];
|
||||
$amount_should = $_POST["amount_should"];
|
||||
$amount_is = $_POST["amount_is"];
|
||||
$expiration_date = $_POST["expiration_date"];
|
||||
$barcode = $_POST["barcode"];
|
||||
|
||||
// Bildverarbeitung, falls ein Bild hochgeladen wurde
|
||||
$image = null;
|
||||
if ($_FILES["image"]["name"]) {
|
||||
$target_dir = "img/";
|
||||
$target_file = $target_dir . basename($_FILES["image"]["name"]);
|
||||
if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) {
|
||||
$image = $target_file;
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
$response['message'] = 'Fehler beim Hochladen des Bildes.';
|
||||
echo json_encode($response); // Fehlermeldung als JSON zurückgeben und das Skript beenden
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Daten in die Datenbank einfügen
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
if ($conn->connect_error) {
|
||||
$response['success'] = false;
|
||||
$response['message'] = 'Verbindung zur Datenbank fehlgeschlagen: ' . $conn->connect_error;
|
||||
echo json_encode($response); // Fehlermeldung als JSON zurückgeben und das Skript beenden
|
||||
exit();
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO materials (item_name, manufacturer, location, amount_should, amount_is, expiration_date, barcode, image, email)
|
||||
VALUES ('$item_name', '$manufacturer', '$location', $amount_should, $amount_is, '$expiration_date', '$barcode', '$image', '$email')";
|
||||
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
$response['success'] = true;
|
||||
$response['message'] = 'Neuer Artikel wurde erfolgreich hinzugefügt.';
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
$response['message'] = 'Fehler beim Hinzufügen des Artikels: ' . $conn->error;
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
|
||||
// JSON-Antwort zurückgeben
|
||||
echo json_encode($response);
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,110 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
<link rel="icon" href="img/favicon.png" type="image/x-icon">
|
||||
<title>Materialverwaltung</title>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const form = document.getElementById('addMaterialForm');
|
||||
form.addEventListener('submit', function(event) {
|
||||
event.preventDefault(); // Verhindert das Standardverhalten des Formulars
|
||||
|
||||
// AJAX-Anfrage senden
|
||||
const formData = new FormData(form);
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', 'add_material.php', true);
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
if (response.success) {
|
||||
const messageElement = document.createElement('p');
|
||||
messageElement.textContent = response.message;
|
||||
messageElement.style.color = 'green';
|
||||
// Nachricht neben dem Button einfügen
|
||||
form.parentNode.insertBefore(messageElement, form.nextSibling);
|
||||
setTimeout(function() {
|
||||
messageElement.remove();
|
||||
}, 3000);
|
||||
// Formular zurücksetzen
|
||||
form.reset();
|
||||
} else {
|
||||
const errorMessage = document.createElement('p');
|
||||
errorMessage.textContent = response.message;
|
||||
errorMessage.style.color = 'red';
|
||||
// Fehlermeldung einfügen
|
||||
form.parentNode.insertBefore(errorMessage, form.nextSibling);
|
||||
setTimeout(function() {
|
||||
errorMessage.remove();
|
||||
}, 3000);
|
||||
}
|
||||
} else {
|
||||
console.error('AJAX-Fehler beim Hinzufügen des Artikels.');
|
||||
}
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
console.error('AJAX-Fehler beim Hinzufügen des Artikels.');
|
||||
};
|
||||
xhr.send(formData);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="header-container">
|
||||
<h1>Materialverwaltung</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li><a href="add_material_form.php">Artikel hinzufügen</a></li>
|
||||
<li><a href="article_overview.php">Artikel Übersicht</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<div class="add-material-box">
|
||||
<h2>Material hinzufügen</h2>
|
||||
<form method="post" action="add_material.php" id="addMaterialForm">
|
||||
<div class="form-group">
|
||||
<label for="item_name">Gegenstand/Medikament:</label>
|
||||
<input type="text" id="item_name" name="item_name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="manufacturer">Hersteller:</label>
|
||||
<input type="text" id="manufacturer" name="manufacturer" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="location">Lagerort:</label>
|
||||
<input type="text" id="location" name="location" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="amount_should">Anzahl soll:</label>
|
||||
<input type="number" id="amount_should" name="amount_should" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="amount_is">Anzahl ist:</label>
|
||||
<input type="number" id="amount_is" name="amount_is" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="expiration_date">Mindesthaltbarkeitsdatum:</label>
|
||||
<input type="date" id="expiration_date" name="expiration_date" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="barcode">Barcode/EAN:</label>
|
||||
<input type="text" id="barcode" name="barcode" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="image">Bild (optional):</label>
|
||||
<input type="file" id="image" name="image">
|
||||
</div>
|
||||
<div class="form-group" style="display: flex; justify-content: flex-end;">
|
||||
<input type="submit" value="Hinzufügen" class="submit-button">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,98 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
<link rel="icon" href="img/favicon.png" type="image/x-icon">
|
||||
<title>Artikelübersicht</title>
|
||||
</head>
|
||||
<body style="background-color: aliceblue;">
|
||||
<header class="header">
|
||||
<div class="header-container">
|
||||
<h1>Materialverwaltung</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li><a href="add_material_form.php">Artikel hinzufügen</a></li>
|
||||
<li><a href="article_overview.php">Artikel Übersicht</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<h2>Artikelübersicht</h2>
|
||||
|
||||
<!-- Artikel suchen -->
|
||||
<form method="GET" action="article_overview.php" style="margin-bottom: 20px;">
|
||||
<input type="text" name="search" placeholder="Artikel suchen" size="50"> <!-- Hier das size-Attribut geändert -->
|
||||
<input type="submit" value="Suchen">
|
||||
</form>
|
||||
|
||||
<!-- Artikel anzeigen -->
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Hersteller</th>
|
||||
<th>Lagerort</th>
|
||||
<th>Anzahl soll</th>
|
||||
<th>Anzahl ist</th>
|
||||
<th>Ablaufdatum</th>
|
||||
<th>Barcode</th>
|
||||
<th>Bild</th>
|
||||
<th>Aktion</th>
|
||||
<th></th> <!-- Neue Zelle für das Löschen-Bild -->
|
||||
</tr>
|
||||
<?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);
|
||||
}
|
||||
|
||||
// SQL-Abfrage vorbereiten
|
||||
$sql = "SELECT * FROM materials";
|
||||
|
||||
// Wenn nach einem Artikel gesucht wird
|
||||
if(isset($_GET['search']) && !empty($_GET['search'])){
|
||||
$search = $_GET['search'];
|
||||
$sql .= " WHERE item_name LIKE '%" . $search . "%' OR manufacturer LIKE '%" . $search . "%' OR location LIKE '%" . $search . "%' OR barcode LIKE '%" . $search . "%'";
|
||||
}
|
||||
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// Daten ausgeben
|
||||
while($row = $result->fetch_assoc()) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row["item_name"] . "</td>";
|
||||
echo "<td>" . $row["manufacturer"] . "</td>";
|
||||
echo "<td>" . $row["location"] . "</td>";
|
||||
echo "<td>" . $row["amount_should"] . "</td>";
|
||||
echo "<td>" . $row["amount_is"] . "</td>";
|
||||
echo "<td>" . $row["expiration_date"] . "</td>";
|
||||
echo "<td>" . $row["barcode"] . "</td>";
|
||||
echo "<td>";
|
||||
if (!empty($row["image"])) {
|
||||
echo "<img src='" . $row["image"] . "' alt='Bild' style='width: 50px; height: 50px;'>";
|
||||
} else {
|
||||
echo "<img src='img/free.png' alt='Standardbild' style='width: 50px; height: 50px;'>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td><a href='remove_article.php?id=" . $row["id"] . "'><img src='img/delete.png' alt='Löschen' style='width: 20px; height: 20px;'></a></td>";
|
||||
echo "<td></td>"; // Platzhalter-Zelle für das Löschen-Bild
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo "<tr><td colspan='10'>Keine Artikel gefunden</td></tr>";
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
// Datenbankverbindung herstellen
|
||||
include_once 'config/config.php';
|
||||
|
||||
// Verbindung zur Datenbank herstellen
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
|
||||
// Prüfen, ob die Verbindung erfolgreich hergestellt wurde
|
||||
if ($conn->connect_error) {
|
||||
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Prüfen, ob es 13 Uhr ist
|
||||
if (date('H') == 13) {
|
||||
// Überprüfen der Artikel mit nahendem Ablaufdatum
|
||||
$checkDate = date('Y-m-d', strtotime('+10 days'));
|
||||
$sql = "SELECT * FROM materials WHERE expiration_date <= '$checkDate'";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// E-Mail senden
|
||||
$to = $email;
|
||||
$subject = 'Wichtige Benachrichtigung: Ablaufdatum nah';
|
||||
$headers = "From: your_email@example.com\r\n";
|
||||
// Weitere Header hier hinzufügen, falls benötigt
|
||||
|
||||
// E-Mail-Nachricht erstellen
|
||||
$message = '<html><body>';
|
||||
$message .= '<h1>Wichtige Benachrichtigung: Ablaufdatum nah</h1>';
|
||||
$message .= '<p>Die Haltbarkeit folgender Artikel läuft in den nächsten 10 Tagen ab:</p>';
|
||||
$message .= '<ul>';
|
||||
|
||||
// Artikelinformationen zur Nachricht hinzufügen
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$message .= '<li>Die Haltbarkeit von "' . $row['item_name'] . '" läuft am ' . $row['expiration_date'] . ' ab.</li>';
|
||||
}
|
||||
|
||||
$message .= '</ul>';
|
||||
$message .= '</body></html>';
|
||||
|
||||
// E-Mail senden
|
||||
mail($to, $subject, $message, $headers);
|
||||
} else {
|
||||
echo "Keine Artikel mit nahendem Ablaufdatum gefunden.";
|
||||
}
|
||||
}
|
||||
|
||||
// Datenbankverbindung schließen
|
||||
$conn->close();
|
||||
?>
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
<link rel="icon" href="img/favicon.png" type="image/x-icon">
|
||||
<title>Materialverwaltung</title>
|
||||
</head>
|
||||
<body>
|
||||
<header class="header">
|
||||
<div class="header-container">
|
||||
<h1>Materialverwaltung</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="index.php">Home</a></li>
|
||||
<li><a href="add_material_form.php">Artikel hinzufügen</a></li>
|
||||
<li><a href="article_overview.php">Artikel Übersicht</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="welcome-container">
|
||||
<img src="img/Willkommen.png" alt="Welcome Image">
|
||||
<h2>Willkommen zur Materialverwaltung!</h2>
|
||||
<p>Dies ist eine einfache Anwendung zur Verwaltung von Materialien mit Ablaufdatum.</p>
|
||||
<p>Verwenden Sie das Menü oben, um Artikel hinzuzufügen oder die Übersicht der Artikel anzuzeigen.</p>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Skript zum Überprüfen des Ablaufdatums einbinden und ausführen
|
||||
include_once 'check_expiration.php';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,104 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/install.css">
|
||||
<title>Materialverwaltung Installer</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Materialverwaltung Installer</h1>
|
||||
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Formulardaten abrufen
|
||||
$host = $_POST["host"];
|
||||
$username = $_POST["username"];
|
||||
$password = $_POST["password"];
|
||||
$database = $_POST["database"];
|
||||
$email = $_POST["email"];
|
||||
|
||||
// Verbindung zur MySQL-Datenbank herstellen
|
||||
$conn = new mysqli($host, $username, $password);
|
||||
if ($conn->connect_error) {
|
||||
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Datenbank erstellen
|
||||
$sql_create_db = "CREATE DATABASE IF NOT EXISTS $database";
|
||||
if ($conn->query($sql_create_db) === TRUE) {
|
||||
echo "<p>Datenbank erfolgreich erstellt.</p>";
|
||||
|
||||
// Datenbank auswählen
|
||||
$conn->select_db($database);
|
||||
|
||||
// Tabelle erstellen
|
||||
$sql_create_table = "CREATE TABLE IF NOT EXISTS materials (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
item_name VARCHAR(255) NOT NULL,
|
||||
manufacturer VARCHAR(255) NOT NULL,
|
||||
location VARCHAR(255) NOT NULL,
|
||||
amount_should INT NOT NULL,
|
||||
amount_is INT NOT NULL,
|
||||
expiration_date DATE NOT NULL,
|
||||
barcode VARCHAR(255) NOT NULL,
|
||||
image VARCHAR(255),
|
||||
email VARCHAR(255) NOT NULL
|
||||
)";
|
||||
if ($conn->query($sql_create_table) === TRUE) {
|
||||
echo "<p>Tabelle 'materials' erfolgreich erstellt.</p>";
|
||||
|
||||
// Speichern der Daten in der config.php-Datei
|
||||
$config_content = "<?php\n";
|
||||
$config_content .= "\$host = '$host';\n";
|
||||
$config_content .= "\$username = '$username';\n";
|
||||
$config_content .= "\$password = '$password';\n";
|
||||
$config_content .= "\$database = '$database';\n";
|
||||
$config_content .= "\$email = '$email';\n";
|
||||
$config_content .= "?>";
|
||||
|
||||
file_put_contents('config/config.php', $config_content);
|
||||
|
||||
// Weiterleitung zur Indexseite nach erfolgreicher Installation
|
||||
header("Location: index.php");
|
||||
exit();
|
||||
} else {
|
||||
echo "<p>Fehler beim Erstellen der Tabelle: " . $conn->error . "</p>";
|
||||
}
|
||||
} else {
|
||||
echo "<p>Fehler beim Erstellen der Datenbank: " . $conn->error . "</p>";
|
||||
}
|
||||
|
||||
// Datenbankverbindung schließen
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
|
||||
<h2>Datenbankverbindung eingeben</h2>
|
||||
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
|
||||
<div class="form-group">
|
||||
<label for="host">Host:</label>
|
||||
<input type="text" id="host" name="host" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="username">Benutzername:</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Passwort:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="database">Datenbankname:</label>
|
||||
<input type="text" id="database" name="database" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">E-Mail-Adresse für Materialbenachrichtigungen:</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
</div>
|
||||
<input type="submit" value="Installieren">
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
// Datenbankverbindung herstellen
|
||||
include_once 'config/config.php';
|
||||
|
||||
// Überprüfen, ob die ID des zu löschenden Artikels übergeben wurde
|
||||
if(isset($_GET['id']) && !empty($_GET['id'])){
|
||||
// ID des zu löschenden Artikels aus der URL erhalten
|
||||
$article_id = $_GET['id'];
|
||||
|
||||
// Verbindung zur Datenbank herstellen
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
if ($conn->connect_error) {
|
||||
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// SQL-Abfrage vorbereiten, um den Artikel zu löschen
|
||||
$sql = "DELETE FROM materials WHERE id = $article_id";
|
||||
|
||||
// Ausführen der SQL-Abfrage
|
||||
if ($conn->query($sql) === TRUE) {
|
||||
// Weiterleitung zur Artikelübersicht, nachdem der Artikel erfolgreich gelöscht wurde
|
||||
header("Location: article_overview.php");
|
||||
exit();
|
||||
} else {
|
||||
echo "Fehler beim Löschen des Artikels: " . $conn->error;
|
||||
}
|
||||
|
||||
// Verbindung zur Datenbank schließen
|
||||
$conn->close();
|
||||
} else {
|
||||
// Falls keine Artikel-ID übergeben wurde, Fehlermeldung ausgeben
|
||||
echo "Fehler: Artikel-ID nicht gefunden";
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue