Fix: JS-Bug in Artikelliste behoben, QR-Code für Lagerorte optimiert
All checks were successful
Docker Build & Push / build-and-push (push) Successful in 37s

This commit is contained in:
Gemini
2026-05-15 15:47:40 +00:00
parent 58fd05e996
commit 8806308705
2 changed files with 96 additions and 34 deletions

View File

@@ -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();
});
</script>
<?php require_once 'footer.php'; ?>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 () {
});
</script>
<?php require_once 'footer.php'; ?>rTable();
});
renderTable();
});
</script>
<?php require_once 'footer.php'; ?>

View File

@@ -208,10 +208,25 @@ foreach ($all_locations as $location) {
<div class="card-header d-flex justify-content-between align-items-center">
<h6 class="mb-0"><i class="fas fa-box-open me-2"></i><?php echo htmlspecialchars($loc1['name']); ?></h6>
<div class="btn-group">
<?php
$has_children_tokens = false;
$children_data = [];
if (isset($locations_level2[$loc1['id']])) {
foreach ($locations_level2[$loc1['id']] as $child) {
if (!empty($child['public_token'])) {
$has_children_tokens = true;
$children_data[] = ['name' => $child['name'], 'token' => $child['public_token']];
}
}
}
if ($has_children_tokens):
?>
<button type="button" class="btn btn-sm btn-outline-info" onclick="showAllBarcodes('<?php echo htmlspecialchars(json_encode($children_data), ENT_QUOTES, 'UTF-8'); ?>', '<?php echo htmlspecialchars(addslashes($loc1['name'])); ?>')" title="Alle QR-Codes der Unterebenen drucken"><i class="fas fa-print"></i></button>
<?php endif; ?>
<?php if(empty($loc1['public_token'])): ?>
<a href="storage_locations.php?action=generate_barcode&id=<?php echo $loc1['id']; ?>" class="btn btn-sm btn-outline-secondary" title="Barcode erstellen"><i class="fas fa-qrcode"></i></a>
<a href="storage_locations.php?action=generate_barcode&id=<?php echo $loc1['id']; ?>" class="btn btn-sm btn-outline-secondary" title="QR-Code erstellen"><i class="fas fa-qrcode"></i></a>
<?php else: ?>
<button type="button" class="btn btn-sm btn-outline-success" onclick="showBarcode('<?php echo htmlspecialchars($loc1['public_token']); ?>', '<?php echo htmlspecialchars(addslashes($loc1['name'])); ?>')" title="Barcode anzeigen"><i class="fas fa-qrcode"></i></button>
<button type="button" class="btn btn-sm btn-outline-success" onclick="showBarcode('<?php echo htmlspecialchars($loc1['public_token']); ?>', '<?php echo htmlspecialchars(addslashes($loc1['name'])); ?>')" title="QR-Code anzeigen"><i class="fas fa-qrcode"></i></button>
<?php endif; ?>
<button type="button" class="btn btn-sm btn-outline-primary" data-bs-toggle="modal" data-bs-target="#editLocationModal" data-id="<?php echo $loc1['id']; ?>" data-name="<?php echo htmlspecialchars($loc1['name']); ?>"><i class="fas fa-edit"></i></button>
<a href="storage_locations.php?action=delete&id=<?php echo $loc1['id']; ?>" class="btn btn-sm btn-outline-danger" onclick="return confirm('Sicher, dass du diesen Ort löschen willst?');"><i class="fas fa-trash"></i></a>
@@ -224,6 +239,11 @@ foreach ($all_locations as $location) {
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><i class="fas fa-long-arrow-alt-right me-2 text-muted"></i><?php echo htmlspecialchars($loc2['name']); ?></span>
<div class="btn-group">
<?php if(empty($loc2['public_token'])): ?>
<a href="storage_locations.php?action=generate_barcode&id=<?php echo $loc2['id']; ?>" class="btn btn-sm btn-outline-secondary py-0 px-1" title="QR-Code erstellen"><i class="fas fa-qrcode"></i></a>
<?php else: ?>
<button type="button" class="btn btn-sm btn-outline-success py-0 px-1" onclick="showBarcode('<?php echo htmlspecialchars($loc2['public_token']); ?>', '<?php echo htmlspecialchars(addslashes($loc2['name'])); ?>')" title="QR-Code anzeigen"><i class="fas fa-qrcode"></i></button>
<?php endif; ?>
<button type="button" class="btn btn-sm btn-outline-primary py-0 px-1" data-bs-toggle="modal" data-bs-target="#editLocationModal" data-id="<?php echo $loc2['id']; ?>" data-name="<?php echo htmlspecialchars($loc2['name']); ?>"><i class="fas fa-edit"></i></button>
<a href="storage_locations.php?action=delete&id=<?php echo $loc2['id']; ?>" class="btn btn-sm btn-outline-danger py-0 px-1" onclick="return confirm('Sicher, dass du diesen Unter-Ort löschen willst?');"><i class="fas fa-trash"></i></a>
</div>
@@ -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 = `
<div class="border p-3 bg-white" style="page-break-inside: avoid;">
<p class="fw-bold mb-2 text-truncate" style="font-size: 0.9rem;">${item.name}</p>
<img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=${encodeURIComponent(url)}" alt="QR Code" class="img-fluid mb-2">
</div>
`;
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 = "<html><head><title>QR-Codes drucken</title></head><body>" + printContents + "</body></html>";
window.print();
document.body.innerHTML = originalContents;
window.location.reload(); // Reload to restore event listeners after print
}
</script>
<div class="modal fade" id="printModal" tabindex="-1" aria-labelledby="printModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="printModalLabel"><i class="fas fa-print me-2"></i>Alle QR-Codes</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body bg-light">
<div class="row" id="allBarcodesContainer"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Schließen</button>
<button type="button" class="btn btn-primary" onclick="printDiv('allBarcodesContainer')"><i class="fas fa-print me-2"></i>Jetzt drucken</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="barcodeModal" tabindex="-1" aria-labelledby="barcodeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="barcodeModalLabel"><i class="fas fa-barcode me-2"></i>Lagerort Barcode</h5>
<h5 class="modal-title" id="barcodeModalLabel"><i class="fas fa-qrcode me-2"></i>Lagerort QR-Code</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body text-center">
<p class="fw-bold" id="barcodeLocationName"></p>
<p class="small text-muted mb-4">Hinweis: Einen Standard-Barcode (1D) mit einer URL können viele Smartphone-Kameras nicht nativ als Weblink öffnen (dafür sind QR-Codes gedacht). Für das Scannen wird in der Regel eine Barcode-Scanner-App benötigt.</p>
<img id="barcodeImage" src="" alt="Barcode" class="img-fluid border p-2 bg-white mb-3" style="max-width: 100%;">
<p class="small text-muted mb-4">Scanne diesen Code mit deinem Smartphone, um direkt den Inhalt dieses Lagerorts zu sehen.</p>
<img id="barcodeImage" src="" alt="QR Code" class="img-fluid border p-2 bg-white mb-3" style="max-width: 250px;">
<div class="mt-2">
<a id="barcodeLink" href="" target="_blank" class="btn btn-outline-primary btn-sm"><i class="fas fa-external-link-alt me-2"></i>Link manuell testen</a>
</div>