Fix: Zusatztaschen-Gewicht und Bilder in Packlisten
All checks were successful
Docker Build & Push / build-and-push (push) Successful in 16s

- backpack_utils.php: Setze article_id beim Sync von Zusatztaschen korrekt.
- packing_list_detail.php: Zeige Artikelbild statt Ordner-Icon bei Zusatztaschen.
This commit is contained in:
Gemini Agent
2025-12-07 07:57:05 +00:00
parent 70eef4cd82
commit 80ede8e3a6
2 changed files with 15 additions and 8 deletions

View File

@@ -6,9 +6,6 @@ function sync_backpack_items($conn, $list_id, $user_id, $backpack_id) {
$bp = $conn->query("SELECT name FROM backpacks WHERE id = $backpack_id")->fetch_assoc();
// 2. Check/Create Root Item
// Use NULL safe comparison or check for NULL explicitly
// We need to allow for existing items that might be named differently if user renamed them?
// No, we stick to structure.
$root_id = 0;
$stmt = $conn->prepare("SELECT id FROM packing_list_items WHERE packing_list_id = ? AND carrier_user_id = ? AND backpack_id = ?");
$stmt->bind_param("iii", $list_id, $user_id, $backpack_id);
@@ -28,7 +25,8 @@ function sync_backpack_items($conn, $list_id, $user_id, $backpack_id) {
}
// 3. Sync Compartments
$comps = $conn->query("SELECT id, name FROM backpack_compartments WHERE backpack_id = $backpack_id ORDER BY sort_order ASC");
// FIX: Fetch linked_article_id as well
$comps = $conn->query("SELECT id, name, linked_article_id FROM backpack_compartments WHERE backpack_id = $backpack_id ORDER BY sort_order ASC");
while ($comp = $comps->fetch_assoc()) {
// Check if item exists for this compartment AND this user
$stmt_c = $conn->prepare("SELECT id FROM packing_list_items WHERE packing_list_id = ? AND backpack_compartment_id = ? AND carrier_user_id = ?");
@@ -36,9 +34,12 @@ function sync_backpack_items($conn, $list_id, $user_id, $backpack_id) {
$stmt_c->execute();
if ($stmt_c->get_result()->num_rows == 0) {
// Create Compartment Item
$c_name = $comp['name'];
$stmt_ins_c = $conn->prepare("INSERT INTO packing_list_items (packing_list_id, carrier_user_id, name, backpack_compartment_id, parent_packing_list_item_id, quantity, article_id, order_index) VALUES (?, ?, ?, ?, ?, 1, NULL, 0)");
$stmt_ins_c->bind_param("iisii", $list_id, $user_id, $c_name, $comp['id'], $root_id);
$c_name = $comp['name'];
$c_article_id = !empty($comp['linked_article_id']) ? $comp['linked_article_id'] : NULL;
// FIX: Insert linked article_id if present
$stmt_ins_c = $conn->prepare("INSERT INTO packing_list_items (packing_list_id, carrier_user_id, name, backpack_compartment_id, parent_packing_list_item_id, quantity, article_id, order_index) VALUES (?, ?, ?, ?, ?, 1, ?, 0)");
$stmt_ins_c->bind_param("iisiii", $list_id, $user_id, $c_name, $comp['id'], $root_id, $c_article_id);
$stmt_ins_c->execute();
}
}

View File

@@ -182,7 +182,13 @@ function render_item_row($item, $level, $items_by_parent) {
} elseif ($is_compartment) {
$bg_class = "table-light";
$text_class = "fw-bold fst-italic text-muted";
$icon = '<i class="fas fa-folder-open me-2 text-warning"></i>';
// Check if linked article (image present)
if (!empty($item['image_url'])) {
$img_src = htmlspecialchars($item['image_url']);
$icon = '<img src="' . $img_src . '" class="item-image me-2 article-image-trigger" data-preview-url="' . $img_src . '">';
} else {
$icon = '<i class="fas fa-folder-open me-2 text-warning"></i>';
}
} else {
$img_src = !empty($item['image_url']) ? htmlspecialchars($item['image_url']) : 'assets/images/keinbild.png';
$icon = '<img src="' . $img_src . '" class="item-image me-2 article-image-trigger" data-preview-url="' . $img_src . '">';