updated fg_scan to enable print only is requested

This commit is contained in:
Quality App System
2026-01-15 18:57:48 +02:00
parent 7f9a418215
commit 13d93d8a14

View File

@@ -155,6 +155,30 @@ document.addEventListener('DOMContentLoaded', function() {
scanToBoxesEnabled = this.checked; scanToBoxesEnabled = this.checked;
localStorage.setItem('scan_to_boxes_enabled', this.checked); localStorage.setItem('scan_to_boxes_enabled', this.checked);
console.log('Toggle changed - Scan to boxes:', scanToBoxesEnabled); console.log('Toggle changed - Scan to boxes:', scanToBoxesEnabled);
// Connect or disconnect QZ Tray based on toggle state
if (scanToBoxesEnabled) {
console.log('Scan-to-boxes enabled, connecting QZ Tray...');
if (window.qz && !window.qz.websocket.isActive()) {
window.qz.websocket.connect().then(() => {
console.log('QZ Tray connected');
showNotification('✅ QZ Tray connected for box label printing', 'success');
}).catch(err => {
console.warn('QZ Tray connection failed:', err);
showNotification('⚠️ QZ Tray connection failed. Box labels cannot be printed.', 'warning');
});
}
} else {
console.log('Scan-to-boxes disabled, disconnecting QZ Tray...');
if (window.qz && window.qz.websocket.isActive()) {
window.qz.websocket.disconnect().then(() => {
console.log('QZ Tray disconnected');
showNotification(' QZ Tray disconnected', 'info');
}).catch(err => {
console.warn('QZ Tray disconnect failed:', err);
});
}
}
}); });
} }
@@ -773,13 +797,22 @@ document.addEventListener('DOMContentLoaded', function() {
} }
}); });
// Initialize QZ Tray for printing box labels // Initialize QZ Tray for printing box labels - only if scan-to-boxes is enabled
if (window.qz) { function initializeQzTray() {
window.qz.websocket.connect().then(() => { if (window.qz && scanToBoxesEnabled) {
console.log('QZ Tray connected for box label printing'); window.qz.websocket.connect().then(() => {
}).catch(err => { console.log('QZ Tray connected for box label printing');
console.warn('QZ Tray not available:', err); }).catch(err => {
}); console.warn('QZ Tray not available:', err);
});
} else if (window.qz && !scanToBoxesEnabled) {
console.log('Scan-to-boxes disabled, skipping QZ Tray connection');
}
}
// Initialize on page load if enabled
if (scanToBoxesEnabled) {
initializeQzTray();
} }
}); });
</script> </script>
@@ -789,6 +822,12 @@ document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
// Quick box creation button // Quick box creation button
document.getElementById('quick-box-create-btn').addEventListener('click', async function() { document.getElementById('quick-box-create-btn').addEventListener('click', async function() {
// Check if scan-to-boxes is enabled
if (!scanToBoxesEnabled) {
showNotification('⚠️ Please enable "Scan to Boxes" feature first', 'warning');
return;
}
try { try {
this.disabled = true; this.disabled = true;
this.textContent = 'Creating...'; this.textContent = 'Creating...';
@@ -908,6 +947,13 @@ document.addEventListener('DOMContentLoaded', function() {
// Assign to scanned box button // Assign to scanned box button
document.getElementById('assign-to-box-btn').addEventListener('click', async function() { document.getElementById('assign-to-box-btn').addEventListener('click', async function() {
// Check if scan-to-boxes is enabled
if (!scanToBoxesEnabled) {
showNotification('⚠️ "Scan to Boxes" feature is disabled', 'warning');
closeBoxModal();
return;
}
const boxNumber = document.getElementById('scan-box-input').value.trim(); const boxNumber = document.getElementById('scan-box-input').value.trim();
if (!boxNumber) { if (!boxNumber) {
showNotification('⚠️ Please scan or enter a box number', 'warning'); showNotification('⚠️ Please scan or enter a box number', 'warning');