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>
|
<select id="product_id" name="product_id" class="auth__select" required>
|
||||||
<option value="">Produkt wählen</option>
|
<option value="">Produkt wählen</option>
|
||||||
<?php
|
<?php
|
||||||
// Produkte der ausgewählten Kategorie für die Löschauswahl laden
|
// Produkte laden (gefiltert nach Kategorie falls ausgewählt, sonst alle)
|
||||||
$products = [];
|
$products = [];
|
||||||
$result = $conn->query("
|
$query = "SELECT productID, model FROM products ORDER BY model";
|
||||||
SELECT productID, model
|
if ($categoryID > 0) {
|
||||||
FROM products
|
$query = "SELECT productID, model FROM products WHERE categoryID = " . (int)$categoryID . " ORDER BY model";
|
||||||
WHERE categoryID = " . (int)$categoryID . "
|
}
|
||||||
ORDER BY model
|
$result = $conn->query($query);
|
||||||
");
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
while ($row = $result->fetch_assoc()) {
|
||||||
$products[] = $row;
|
$products[] = $row;
|
||||||
}
|
}
|
||||||
@ -546,7 +545,7 @@ include 'header.php';
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="auth__actions">
|
<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
|
Produkt löschen
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user