Update management terminology in account, productAdder, offerAdder, and shopAdder pages

This commit is contained in:
Fabian Schieder 2026-04-06 21:27:54 +02:00
parent b3410a378f
commit 21fdb8bf6c
4 changed files with 75 additions and 6 deletions

View File

@ -229,13 +229,13 @@ include 'header.php';
if (!empty($_SESSION['user_roles']) && in_array('ADMIN', $_SESSION['user_roles'], true)): if (!empty($_SESSION['user_roles']) && in_array('ADMIN', $_SESSION['user_roles'], true)):
?> ?>
<a href="productAdder.php" class="auth__submit account__action-link"> <a href="productAdder.php" class="auth__submit account__action-link">
Produkt hinzufügen Produkt verwalten
</a> </a>
<a href="offerAdder.php" class="auth__submit account__action-link" style="margin-top: 10px; background-color: #f59e0b;"> <a href="offerAdder.php" class="auth__submit account__action-link" style="margin-top: 10px; background-color: #f59e0b;">
Angebot hinzufügen Angebot verwalten
</a> </a>
<a href="shopAdder.php" class="auth__submit account__action-link" style="margin-top: 10px; background-color: #10b981;"> <a href="shopAdder.php" class="auth__submit account__action-link" style="margin-top: 10px; background-color: #10b981;">
Shop hinzufügen Shop verwalten
</a> </a>
<a href="admin_users.php" class="auth__submit account__action-link" style="margin-top: 10px; background-color: #3b82f6;"> <a href="admin_users.php" class="auth__submit account__action-link" style="margin-top: 10px; background-color: #3b82f6;">
Benutzerverwaltung Benutzerverwaltung

View File

@ -111,7 +111,7 @@ include 'header.php';
<section class="auth__grid" style="grid-template-columns: 1fr;"> <section class="auth__grid" style="grid-template-columns: 1fr;">
<div class="auth__card"> <div class="auth__card">
<header class="auth__header"> <header class="auth__header">
<h2 class="auth__title">Angebot hinzufügen</h2> <h2 class="auth__title">Angebot verwalten</h2>
</header> </header>
<?php if ($message): ?> <?php if ($message): ?>

View File

@ -68,6 +68,28 @@ if (isset($_GET['categoryID']) && ctype_digit($_GET['categoryID'])) {
======================= */ ======================= */
$conn = db_connect(); $conn = db_connect();
/* =======================
2b) Produkt löschen
======================= */
$deleteMessage = '';
$deleteMessageType = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'delete_product') {
$delProductID = (int)$_POST['product_id'];
$catIDFromForm = (int)$_POST['categoryID']; // to redirect back
if ($delProductID > 0) {
$delStmt = $conn->prepare("DELETE FROM products WHERE productID = ?");
$delStmt->bind_param("i", $delProductID);
if ($delStmt->execute()) {
$deleteMessage = 'Produkt erfolgreich gelöscht!';
$deleteMessageType = 'success';
} else {
$deleteMessage = 'Fehler beim Löschen des Produkts (möglicherweise sind noch Angebote oder Attribute verknüpft?).';
$deleteMessageType = 'error';
}
$delStmt->close();
}
}
/** /**
* @section Kategorien-Laden * @section Kategorien-Laden
* @brief Abrufen aller verfügbaren Kategorien. * @brief Abrufen aller verfügbaren Kategorien.
@ -419,7 +441,7 @@ include 'header.php';
<?php if ($categoryID > 0): ?> <?php if ($categoryID > 0): ?>
<div class="auth__card"> <div class="auth__card">
<header class="auth__header"> <header class="auth__header">
<h2 class="auth__title">Produkt hinzufügen</h2> <h2 class="auth__title">Produkt verwalten</h2>
</header> </header>
<form method="post" class="auth__form" enctype="multipart/form-data"> <form method="post" class="auth__form" enctype="multipart/form-data">
@ -484,6 +506,53 @@ include 'header.php';
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- Produkt löschen -->
<div class="auth__card">
<header class="auth__header">
<h2 class="auth__title">Produkt löschen</h2>
</header>
<?php if ($deleteMessage): ?>
<div class="auth__message auth__message--<?= $deleteMessageType ?>">
<?= htmlspecialchars($deleteMessage) ?>
</div>
<?php endif; ?>
<form method="post" class="auth__form">
<input type="hidden" name="categoryID" value="<?= $categoryID ?>">
<input type="hidden" name="action" value="delete_product">
<div class="auth__select__wrap">
<label class="auth__select__label" for="product_id">Produkt</label>
<select id="product_id" name="product_id" class="auth__select" required>
<option value="">Produkt wählen</option>
<?php
// Produkte der ausgewählten Kategorie für die Löschauswahl laden
$products = [];
$result = $conn->query("
SELECT productID, model
FROM products
WHERE categoryID = " . (int)$categoryID . "
ORDER BY model
");
while ($row = $result->fetch_assoc()) {
$products[] = $row;
}
foreach ($products as $product): ?>
<option value="<?= $product['productID'] ?>">
<?= htmlspecialchars($product['model']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="auth__actions">
<button type="submit" class="auth__submit">
Produkt löschen
</button>
</div>
</form>
</div>
</section> </section>
</main> </main>

View File

@ -127,7 +127,7 @@ include 'header.php';
<section class="auth__grid" style="grid-template-columns: 1fr;"> <section class="auth__grid" style="grid-template-columns: 1fr;">
<div class="auth__card"> <div class="auth__card">
<header class="auth__header"> <header class="auth__header">
<h2 class="auth__title">Shop hinzufügen</h2> <h2 class="auth__title">Shop verwalten</h2>
</header> </header>
<?php if ($message): ?> <?php if ($message): ?>