diff --git a/index.php b/index.php
index 500bba7..44d763c 100644
--- a/index.php
+++ b/index.php
@@ -4850,13 +4850,22 @@ document.addEventListener('DOMContentLoaded', function() {
@@ -4972,13 +4981,54 @@ document.addEventListener('DOMContentLoaded', function() {
window.openAveryModal = function() {
const modal = new bootstrap.Modal(document.getElementById('averyLabelsModal'));
+ const checkedItems = document.querySelectorAll('.item-checkbox:checked');
+ const container = document.getElementById('averyItemQuantities');
+ const defaultCopies = parseInt(document.getElementById('averyCopies').value) || 1;
+
+ if (container) {
+ container.innerHTML = '';
+ if (checkedItems.length === 0) {
+ container.innerHTML = '
No items selected.';
+ } else {
+ const table = document.createElement('table');
+ table.className = 'table table-sm table-borderless mb-0';
+ const tbody = document.createElement('tbody');
+
+ checkedItems.forEach(cb => {
+ const sku = cb.dataset.sku;
+ const name = cb.dataset.name;
+ const id = cb.dataset.id;
+
+ const tr = document.createElement('tr');
+ tr.innerHTML = `
+
${name} (${sku}) |
+
+
+ |
+ `;
+ tbody.appendChild(tr);
+ });
+ table.appendChild(tbody);
+ container.appendChild(table);
+ }
+ }
+
modal.show();
updateAveryPreview();
};
+ window.updateAllItemQuantities = function() {
+ const globalQty = document.getElementById('averyCopies').value;
+ const itemInputs = document.querySelectorAll('.item-qty-input');
+ itemInputs.forEach(input => {
+ input.value = globalQty;
+ });
+ updateAveryPreview();
+ };
+
window.updateAveryPreview = function() {
const layout = document.getElementById('averyLayout').value;
- const copies = parseInt(document.getElementById('averyCopies').value) || 1;
const container = document.getElementById('averyPrintArea');
const checkedItems = document.querySelectorAll('.item-checkbox:checked');
@@ -4989,11 +5039,22 @@ document.addEventListener('DOMContentLoaded', function() {
const sku = cb.dataset.sku;
const name = cb.dataset.name;
const price = cb.dataset.price;
+ const id = cb.dataset.id;
+
+ // Find specific quantity input
+ const qtyInput = document.querySelector(`.item-qty-input[data-id="${id}"]`);
+ let copies = 1;
+ if (qtyInput) {
+ copies = parseInt(qtyInput.value) || 0;
+ } else {
+ copies = parseInt(document.getElementById('averyCopies').value) || 1;
+ }
for (let i = 0; i < copies; i++) {
const label = document.createElement('div');
label.className = 'avery-label';
- const svgId = `bc-${sku}-${i}`;
+ const uniqueId = Math.random().toString(36).substr(2, 9);
+ const svgId = `bc-${sku}-${uniqueId}`;
label.innerHTML = `
${name}
@@ -5002,15 +5063,17 @@ document.addEventListener('DOMContentLoaded', function() {
container.appendChild(label);
setTimeout(() => {
- const bcHeight = layout === 'L7651' ? 20 : 35;
- JsBarcode(`#${svgId}`, sku, {
- format: "CODE128",
- width: layout === 'L7651' ? 1.0 : 1.2,
- height: bcHeight,
- displayValue: true,
- fontSize: layout === 'L7651' ? 8 : 10,
- margin: 0
- });
+ if (document.getElementById(svgId)) {
+ const bcHeight = layout === 'L7651' ? 20 : 35;
+ JsBarcode(`#${svgId}`, sku, {
+ format: "CODE128",
+ width: layout === 'L7651' ? 1.0 : 1.2,
+ height: bcHeight,
+ displayValue: true,
+ fontSize: layout === 'L7651' ? 8 : 10,
+ margin: 0
+ });
+ }
}, 0);
}
});
diff --git a/uploads/items/item_699421bad9019.jfif b/uploads/items/item_699421bad9019.jfif
new file mode 100644
index 0000000..d918c28
Binary files /dev/null and b/uploads/items/item_699421bad9019.jfif differ