Refactor product selection logic in productAdder for improved clarity and add confirmation prompt for deletion
This commit is contained in:
parent
21fdb8bf6c
commit
77ced928b0
@ -526,14 +526,13 @@ include 'header.php';
|
||||
<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
|
||||
// Produkte laden (gefiltert nach Kategorie falls ausgewählt, sonst alle)
|
||||
$products = [];
|
||||
$result = $conn->query("
|
||||
SELECT productID, model
|
||||
FROM products
|
||||
WHERE categoryID = " . (int)$categoryID . "
|
||||
ORDER BY model
|
||||
");
|
||||
$query = "SELECT productID, model FROM products ORDER BY model";
|
||||
if ($categoryID > 0) {
|
||||
$query = "SELECT productID, model FROM products WHERE categoryID = " . (int)$categoryID . " ORDER BY model";
|
||||
}
|
||||
$result = $conn->query($query);
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$products[] = $row;
|
||||
}
|
||||
@ -546,7 +545,7 @@ include 'header.php';
|
||||
</div>
|
||||
|
||||
<div class="auth__actions">
|
||||
<button type="submit" class="auth__submit">
|
||||
<button type="submit" class="auth__submit" style="background-color: #ef4444; border-color: #ef4444;" onclick="return confirm('Möchtest du das Produkt wirklich löschen?');">
|
||||
Produkt löschen
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user