article_overview.php aktualisiert
This commit is contained in:
parent
259178e7d4
commit
97d3e86652
|
@ -22,7 +22,7 @@
|
|||
.low-stock {
|
||||
color: red; /* Schriftfarbe auf Orange ändern */
|
||||
}
|
||||
|
||||
|
||||
/* Stil für die Zeilen, deren Ablaufdatum innerhalb von 10 Tagen liegt */
|
||||
.expiring td {
|
||||
color: red; /* Schriftfarbe auf Rot ändern */
|
||||
|
@ -38,6 +38,7 @@
|
|||
<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>
|
||||
<li><a href="backup_restore.php">Backup</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
@ -67,89 +68,99 @@
|
|||
<th>Aktionen</th>
|
||||
</tr>
|
||||
<?php
|
||||
// Datenbankverbindung herstellen
|
||||
include_once 'config/config.php';
|
||||
// Protokollierungsereignis einbinden
|
||||
include_once 'log_event.php';
|
||||
|
||||
// Verbindung zur Datenbank herstellen
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
if ($conn->connect_error) {
|
||||
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
|
||||
}
|
||||
// Datenbankverbindung herstellen
|
||||
include_once 'config/config.php';
|
||||
|
||||
// SQL-Abfrage vorbereiten
|
||||
$sql = "SELECT * FROM materials";
|
||||
// Verbindung zur Datenbank herstellen
|
||||
$conn = new mysqli($host, $username, $password, $database);
|
||||
if ($conn->connect_error) {
|
||||
die("Verbindung zur Datenbank fehlgeschlagen: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Wenn nach einem Artikel gesucht wird
|
||||
if(isset($_GET['search']) && !empty($_GET['search'])){
|
||||
$search = $_GET['search'];
|
||||
$sql .= " WHERE
|
||||
// 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()) {
|
||||
$expiration_date = date("d.m.Y", strtotime($row["expiration_date"]));
|
||||
$notification_days = intval($row["notification_days"]); // Tage vor dem Ablaufdatum aus der Datenbank lesen
|
||||
$ten_days_before_expiry = date("d.m.Y", strtotime("-" . $notification_days . " days", strtotime($row["expiration_date"]))); // Tage vor dem Ablaufdatum berechnen
|
||||
$current_date = date("d.m.Y"); // Aktuelles Datum
|
||||
|
||||
echo "<tr";
|
||||
if (strtotime($current_date) >= strtotime($ten_days_before_expiry) && strtotime($current_date) <= strtotime($expiration_date)) {
|
||||
echo " class='expiring'"; // Klasse 'expiring' hinzufügen
|
||||
}
|
||||
echo ">";
|
||||
|
||||
echo "<td";
|
||||
if (strtotime($current_date) >= strtotime($ten_days_before_expiry) && strtotime($current_date) <= strtotime($expiration_date)) {
|
||||
echo " style='color: red;'"; // Schriftfarbe auf Rot setzen
|
||||
}
|
||||
echo ">" . $row["item_name"] . "</td>";
|
||||
echo "<td>" . $row["manufacturer"] . "</td>";
|
||||
echo "<td>" . $row["location"] . "</td>";
|
||||
echo "<td>" . $row["amount_should"] . "</td>";
|
||||
echo "<td";
|
||||
if ($row["amount_is"] < $row["amount_should"]) {
|
||||
echo " class='low-stock'";
|
||||
}
|
||||
echo ">" . $row["amount_is"] . "</td>";
|
||||
echo "<td>" . $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;' onclick='toggleEditForm(" . $row["id"] . ")'>";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
// Daten ausgeben
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$expiration_date = date("d.m.Y", strtotime($row["expiration_date"]));
|
||||
$notification_days = intval($row["notification_days"]); // Tage vor dem Ablaufdatum aus der Datenbank lesen
|
||||
$ten_days_before_expiry = date("d.m.Y", strtotime("-" . $notification_days . " days", strtotime($row["expiration_date"]))); // Tage vor dem Ablaufdatum berechnen
|
||||
$current_date = date("d.m.Y"); // Aktuelles Datum
|
||||
|
||||
echo "<tr";
|
||||
if (strtotime($current_date) >= strtotime($ten_days_before_expiry) && strtotime($current_date) <= strtotime($expiration_date)) {
|
||||
echo " class='expiring'"; // Klasse 'expiring' hinzufügen
|
||||
}
|
||||
echo ">";
|
||||
|
||||
echo "<td";
|
||||
if (strtotime($current_date) >= strtotime($ten_days_before_expiry) && strtotime($current_date) <= strtotime($expiration_date)) {
|
||||
echo " style='color: red;'"; // Schriftfarbe auf Rot setzen
|
||||
}
|
||||
echo ">" . $row["item_name"] . "</td>";
|
||||
echo "<td>" . $row["manufacturer"] . "</td>";
|
||||
echo "<td>" . $row["location"] . "</td>";
|
||||
echo "<td>" . $row["amount_should"] . "</td>";
|
||||
echo "<td";
|
||||
if ($row["amount_is"] < $row["amount_should"]) {
|
||||
echo " class='low-stock'";
|
||||
}
|
||||
echo ">" . $row["amount_is"] . "</td>";
|
||||
echo "<td>" . $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;' onclick='toggleEditForm(" . $row["id"] . ")'>";
|
||||
} else {
|
||||
echo "<img src='img/free.png' alt='Standardbild' style='width: 50px; height: 50px;' onclick='toggleEditForm(" . $row["id"] . ")'>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td><img src='img/bearbeiten.png' alt='Bearbeiten' style='width: 20px; height: 20px;' onclick='toggleEditForm(" . $row["id"] . ")'> | <a href='remove_article.php?id=" . $row["id"] . "' onclick='return confirmDelete();'><img src='img/delete.png' alt='Löschen' style='width: 20px; height: 20px;' ></a></td>";
|
||||
|
||||
echo "</tr>";
|
||||
// Bearbeitungsformular für jedes Element einfügen
|
||||
echo "<tr class='edit-form' id='edit-form-" . $row["id"] . "'><td colspan='9'>
|
||||
<form id='form-" . $row["id"] . "' onsubmit='updateItem(event, " . $row["id"] . ")'>
|
||||
<input type='text' name='name' value='" . $row["item_name"] . "'>
|
||||
<input type='text' name='manufacturer' value='" . $row["manufacturer"] . "'>
|
||||
<input type='text' name='location' value='" . $row["location"] . "'>
|
||||
<input type='number' name='amount_should' value='" . $row["amount_should"] . "'>
|
||||
<input type='number' name='amount_is' value='" . $row["amount_is"] . "'>
|
||||
<input type='date' name='expiration_date' value='" . $row["expiration_date"] . "'>
|
||||
<input type='text' name='barcode' value='" . $row["barcode"] . "'>
|
||||
<input type='hidden' name='id' value='" . $row["id"] . "'>
|
||||
<input type='submit' value='Speichern'>
|
||||
</form>
|
||||
</td></tr>";
|
||||
|
||||
// Loggen des Löschens eines Artikels
|
||||
echo "<script>function confirmDelete" . $row["id"] . "() {
|
||||
if(confirm('Möchten Sie diesen Artikel wirklich löschen?')) {
|
||||
window.location.href = 'remove_article.php?id=" . $row["id"] . "';
|
||||
}
|
||||
}</script>";
|
||||
}
|
||||
} else {
|
||||
echo "<img src='img/free.png' alt='Standardbild' style='width: 50px; height: 50px;' onclick='toggleEditForm(" . $row["id"] . ")'>";
|
||||
echo "<tr><td colspan='9'>Keine Artikel gefunden</td></tr>";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "<td><img src='img/bearbeiten.png' alt='Bearbeiten' style='width: 20px; height: 20px;' onclick='toggleEditForm(" . $row["id"] . ")'> | <a href='remove_article.php?id=" . $row["id"] . "' onclick='return confirmDelete();'><img src='img/delete.png' alt='Löschen' style='width: 20px; height: 20px;' ></a></td>";
|
||||
|
||||
echo "</tr>";
|
||||
// Bearbeitungsformular für jedes Element einfügen
|
||||
echo "<tr class='edit-form' id='edit-form-" . $row["id"] . "'><td colspan='9'>
|
||||
<form id='form-" . $row["id"] . "' onsubmit='updateItem(event, " . $row["id"] . ")'>
|
||||
<input type='text' name='name' value='" . $row["item_name"] . "'>
|
||||
<input type='text' name='manufacturer' value='" . $row["manufacturer"] . "'>
|
||||
<input type='text' name='location' value='" . $row["location"] . "'>
|
||||
<input type='number' name='amount_should' value='" . $row["amount_should"] . "'>
|
||||
<input type='number' name='amount_is' value='" . $row["amount_is"] . "'>
|
||||
<input type='date' name='expiration_date' value='" . $row["expiration_date"] . "'>
|
||||
<input type='text' name='barcode' value='" . $row["barcode"] . "'>
|
||||
<input type='hidden' name='id' value='" . $row["id"] . "'>
|
||||
<input type='submit' value='Speichern'>
|
||||
</form>
|
||||
</td></tr>";
|
||||
}
|
||||
} else {
|
||||
echo "<tr><td colspan='9'>Keine Artikel gefunden</td></tr>";
|
||||
}
|
||||
$conn->close();
|
||||
?>
|
||||
$conn->close();
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue