Fix: JS-Bug in Artikelliste, Barcode/QR Variablen repariert und Massen-Generierung hinzugefügt
All checks were successful
Docker Build & Push / build-and-push (push) Successful in 38s
All checks were successful
Docker Build & Push / build-and-push (push) Successful in 38s
This commit is contained in:
@@ -634,36 +634,52 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
updateBulkUI();
|
||||
});
|
||||
});
|
||||
|
||||
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 => {
|
||||
cb.checked = isChecked;
|
||||
if (isChecked) bulkSelectedArticles.add(cb.value);
|
||||
else bulkSelectedArticles.delete(cb.value);
|
||||
});
|
||||
updateBulkUI();
|
||||
});
|
||||
}
|
||||
updateBulkUI();
|
||||
}
|
||||
|
||||
const selectAllCb = document.getElementById('bulk-select-all');
|
||||
if (selectAllCb) {
|
||||
selectAllCb.addEventListener('change', function() {
|
||||
const isChecked = this.checked;
|
||||
document.querySelectorAll('.bulk-select-checkbox').forEach(cb => {
|
||||
cb.checked = isChecked;
|
||||
if (isChecked) {
|
||||
bulkSelectedArticles.add(cb.value);
|
||||
} else {
|
||||
bulkSelectedArticles.delete(cb.value);
|
||||
}
|
||||
});
|
||||
updateBulkUI();
|
||||
});
|
||||
}
|
||||
|
||||
function updateBulkUI() {
|
||||
const count = bulkSelectedArticles.size;
|
||||
document.getElementById('bulk-selected-count').textContent = count;
|
||||
const countEl = document.getElementById('bulk-selected-count');
|
||||
if (countEl) countEl.textContent = count;
|
||||
|
||||
const container = document.getElementById('bulk-action-container');
|
||||
if (count > 0 && currentView === 'list') {
|
||||
container.style.display = '';
|
||||
const idsInput = document.getElementById('bulk_article_ids_input');
|
||||
if(idsInput) idsInput.value = Array.from(bulkSelectedArticles).join(',');
|
||||
} else {
|
||||
container.style.display = 'none';
|
||||
if (container) {
|
||||
if (count > 0 && currentView === 'list') {
|
||||
container.style.display = 'flex';
|
||||
const idsInput = document.getElementById('bulk_article_ids_input');
|
||||
if(idsInput) idsInput.value = Array.from(bulkSelectedArticles).join(',');
|
||||
} else {
|
||||
container.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (selectAllCb) {
|
||||
const allCheckboxes = document.querySelectorAll('.bulk-select-checkbox');
|
||||
if (allCheckboxes.length > 0) {
|
||||
const allChecked = Array.from(allCheckboxes).every(cb => cb.checked);
|
||||
const someChecked = Array.from(allCheckboxes).some(cb => cb.checked);
|
||||
selectAllCb.checked = allChecked;
|
||||
selectAllCb.indeterminate = someChecked && !allChecked;
|
||||
} else {
|
||||
selectAllCb.checked = false;
|
||||
selectAllCb.indeterminate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,22 +13,6 @@ if (!isset($_SESSION['user_id'])) {
|
||||
}
|
||||
|
||||
require_once 'db_connect.php';
|
||||
// AKTION: BARCODE GENERIEREN
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'generate_barcode' && isset($_GET['id'])) {
|
||||
$location_id = intval($_GET['id']);
|
||||
$token = bin2hex(random_bytes(16));
|
||||
$stmt_token = $conn->prepare("UPDATE storage_locations SET public_token = ? WHERE id = ? AND user_id IN ($placeholders)");
|
||||
$all_params = array_merge([$token, $location_id], $household_member_ids);
|
||||
$all_types = 'si' . $types;
|
||||
$stmt_token->bind_param($all_types, ...$all_params);
|
||||
$stmt_token->execute();
|
||||
$stmt_token->close();
|
||||
header("Location: storage_locations.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'header.php';
|
||||
|
||||
$current_user_id = $_SESSION['user_id'];
|
||||
$message = '';
|
||||
|
||||
@@ -55,6 +39,44 @@ if ($household_id) {
|
||||
$placeholders = implode(',', array_fill(0, count($household_member_ids), '?'));
|
||||
$types = str_repeat('i', count($household_member_ids));
|
||||
|
||||
// AKTION: BARCODE GENERIEREN
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'generate_barcode' && isset($_GET['id'])) {
|
||||
$location_id = intval($_GET['id']);
|
||||
$token = bin2hex(random_bytes(16));
|
||||
$stmt_token = $conn->prepare("UPDATE storage_locations SET public_token = ? WHERE id = ? AND user_id IN ($placeholders)");
|
||||
$all_params = array_merge([$token, $location_id], $household_member_ids);
|
||||
$all_types = 'si' . $types;
|
||||
$stmt_token->bind_param($all_types, ...$all_params);
|
||||
$stmt_token->execute();
|
||||
$stmt_token->close();
|
||||
header("Location: storage_locations.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
// AKTION: ALLE BARCODES FÜR EBENE 2 GENERIEREN
|
||||
if (isset($_GET['action']) && $_GET['action'] == 'generate_all_barcodes' && isset($_GET['parent_id'])) {
|
||||
$parent_id = intval($_GET['parent_id']);
|
||||
$stmt_children = $conn->prepare("SELECT id FROM storage_locations WHERE parent_id = ? AND user_id IN ($placeholders) AND public_token IS NULL");
|
||||
$all_params_sel = array_merge([$parent_id], $household_member_ids);
|
||||
$all_types_sel = 'i' . $types;
|
||||
$stmt_children->bind_param($all_types_sel, ...$all_params_sel);
|
||||
$stmt_children->execute();
|
||||
$res = $stmt_children->get_result();
|
||||
|
||||
while ($row = $res->fetch_assoc()) {
|
||||
$token = bin2hex(random_bytes(16));
|
||||
$stmt_token = $conn->prepare("UPDATE storage_locations SET public_token = ? WHERE id = ?");
|
||||
$stmt_token->bind_param("si", $token, $row['id']);
|
||||
$stmt_token->execute();
|
||||
$stmt_token->close();
|
||||
}
|
||||
$stmt_children->close();
|
||||
header("Location: storage_locations.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'header.php';
|
||||
|
||||
// Formularverarbeitung
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// AKTION: ORT HINZUFÜGEN
|
||||
@@ -210,18 +232,24 @@ foreach ($all_locations as $location) {
|
||||
<div class="btn-group">
|
||||
<?php
|
||||
$has_children_tokens = false;
|
||||
$has_missing_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']];
|
||||
} else {
|
||||
$has_missing_tokens = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($has_children_tokens):
|
||||
if ($has_missing_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>
|
||||
<a href="storage_locations.php?action=generate_all_barcodes&parent_id=<?php echo $loc1['id']; ?>" class="btn btn-sm btn-outline-warning" title="Fehlende QR-Codes für alle Unterebenen erstellen"><i class="fas fa-qrcode"></i><i class="fas fa-plus fa-xs"></i></a>
|
||||
<?php endif; ?>
|
||||
<?php 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 generierten 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="QR-Code erstellen"><i class="fas fa-qrcode"></i></a>
|
||||
|
||||
Reference in New Issue
Block a user