From 88063087058cd875895b273b5f7990ff5485cb95 Mon Sep 17 00:00:00 2001 From: Gemini Date: Fri, 15 May 2026 15:47:40 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20JS-Bug=20in=20Artikelliste=20behoben,=20?= =?UTF-8?q?QR-Code=20f=C3=BCr=20Lagerorte=20optimiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/articles.php | 47 +++++++++------------- src/storage_locations.php | 83 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 96 insertions(+), 34 deletions(-) diff --git a/src/articles.php b/src/articles.php index 98e2cb0..417d7a4 100644 --- a/src/articles.php +++ b/src/articles.php @@ -620,29 +620,27 @@ document.addEventListener('DOMContentLoaded', function () { renderTable(); }); }); - } - filterText.addEventListener('input', renderTable); - filterCategory.addEventListener('change', renderTable); - filterManufacturer.addEventListener('change', renderTable); + // Bulk Selection Logic + document.querySelectorAll('.bulk-select-checkbox').forEach(cb => { + cb.checked = bulkSelectedArticles.has(cb.value); + cb.addEventListener('change', function(e) { + e.stopPropagation(); + if (this.checked) { + bulkSelectedArticles.add(this.value); + } else { + bulkSelectedArticles.delete(this.value); + } + updateBulkUI(); + }); + }); - document.getElementById('btn-expand-all').addEventListener('click', function() { - collapsedCategories.clear(); - renderTable(); - }); - - document.getElementById('btn-collapse-all').addEventListener('click', function() { - // Find all currently rendered categories - const visibleCategories = Array.from(document.querySelectorAll('.category-header')).map(el => el.getAttribute('data-category')); - visibleCategories.forEach(c => collapsedCategories.add(c)); - renderTable(); - }); - - renderTable(); -}); - - -tAll.checked = false; + const selectAllCb = document.getElementById('bulk-select-all'); + if (selectAllCb) { + // Remove old listeners if any by cloning + const newSelectAll = selectAllCb.cloneNode(true); + selectAllCb.parentNode.replaceChild(newSelectAll, selectAllCb); + newSelectAll.checked = false; newSelectAll.addEventListener('change', function() { const isChecked = this.checked; document.querySelectorAll('.bulk-select-checkbox').forEach(cb => { @@ -689,11 +687,4 @@ document.addEventListener('DOMContentLoaded', function () { }); -rTable(); - }); - - renderTable(); -}); - - \ No newline at end of file diff --git a/src/storage_locations.php b/src/storage_locations.php index 34a7563..e3ea380 100644 --- a/src/storage_locations.php +++ b/src/storage_locations.php @@ -208,10 +208,25 @@ foreach ($all_locations as $location) {
+ $child['name'], 'token' => $child['public_token']]; + } + } + } + if ($has_children_tokens): + ?> + + - + - + @@ -224,6 +239,11 @@ foreach ($all_locations as $location) {
  • + + + + +
    @@ -284,23 +304,74 @@ function showBarcode(token, name) { const baseUrl = window.location.origin + window.location.pathname.replace('storage_locations.php', 'public_location.php?token='); const url = baseUrl + token; document.getElementById('barcodeLocationName').textContent = name; - document.getElementById('barcodeImage').src = 'https://bwipjs-api.metafloor.com/?bcid=code128&text=' + encodeURIComponent(url) + '&scale=2&includetext=false'; + document.getElementById('barcodeImage').src = 'https://api.qrserver.com/v1/create-qr-code/?size=300x300&data=' + encodeURIComponent(url); document.getElementById('barcodeLink').href = url; new bootstrap.Modal(document.getElementById('barcodeModal')).show(); } + +function showAllBarcodes(jsonStr, level1Name) { + const data = JSON.parse(jsonStr); + const container = document.getElementById('allBarcodesContainer'); + container.innerHTML = ''; + const baseUrl = window.location.origin + window.location.pathname.replace('storage_locations.php', 'public_location.php?token='); + + document.getElementById('printModalLabel').textContent = "QR-Codes für: " + level1Name; + + data.forEach(item => { + const url = baseUrl + item.token; + const col = document.createElement('div'); + col.className = 'col-6 col-md-4 mb-4 text-center'; + col.innerHTML = ` +
    +

    ${item.name}

    + QR Code +
    + `; + container.appendChild(col); + }); + + new bootstrap.Modal(document.getElementById('printModal')).show(); +} + +function printDiv(divId) { + var printContents = document.getElementById(divId).innerHTML; + var originalContents = document.body.innerHTML; + document.body.innerHTML = "QR-Codes drucken" + printContents + ""; + window.print(); + document.body.innerHTML = originalContents; + window.location.reload(); // Reload to restore event listeners after print +} + +