- Przycisk "Drukuj" w prepare.php i show.php z AJAX + duplikat protection - Bulk print z listy zamówień (checkboxy + header action) - Kolejka wydruku w Ustawienia > Drukowanie (filtr statusu, retry) - POST /api/print/jobs/bulk endpoint (package_ids + order_ids) - ensureLabel() auto-download przez ShipmentProviderRegistry - Apaczka carrier_id = nazwa usługi, kolumna Przewoznik - Tab persistence (localStorage), label file_exists check - Fix use statement ApaczkaApiClient, redirect po utworzeniu przesyłki - Phase 17 (receipt duplicate guard) + Phase 18 (print queue backend) docs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
104 lines
3.3 KiB
PHP
104 lines
3.3 KiB
PHP
<?php $statusPanelList = is_array($statusPanel ?? null) ? $statusPanel : []; ?>
|
|
<?php $statusPanelTitle = 'Statusy'; ?>
|
|
|
|
<section class="order-show-layout">
|
|
<?php require __DIR__ . '/../components/order-status-panel.php'; ?>
|
|
|
|
<div class="order-show-main">
|
|
<section class="card orders-list-page">
|
|
<div class="orders-head">
|
|
<div>
|
|
<h2 class="section-title"><?= $e($t('orders.title')) ?></h2>
|
|
<p class="muted mt-12"><?= $e($t('orders.description')) ?></p>
|
|
</div>
|
|
</div>
|
|
<?php if (!empty($errorMessage)): ?>
|
|
<div class="alert alert--warning mt-12" role="alert">
|
|
<?= $e((string) $errorMessage) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
|
|
<?php require __DIR__ . '/../components/table-list.php'; ?>
|
|
</div>
|
|
</section>
|
|
|
|
<script>
|
|
(function () {
|
|
var POPUP_GAP = 12;
|
|
|
|
document.addEventListener('mouseenter', function (e) {
|
|
if (!e.target || !e.target.closest) return;
|
|
var wrap = e.target.closest('.orders-image-hover-wrap');
|
|
if (!wrap) return;
|
|
var popup = wrap.querySelector('.orders-image-hover-popup');
|
|
if (!popup) return;
|
|
|
|
var rect = wrap.getBoundingClientRect();
|
|
var pw = 350;
|
|
var ph = 350;
|
|
|
|
var left = rect.right + POPUP_GAP;
|
|
if (left + pw > window.innerWidth) {
|
|
left = rect.left - pw - POPUP_GAP;
|
|
}
|
|
|
|
var top = rect.top + rect.height / 2 - ph / 2;
|
|
if (top < 4) top = 4;
|
|
if (top + ph > window.innerHeight - 4) top = window.innerHeight - 4 - ph;
|
|
|
|
popup.style.left = left + 'px';
|
|
popup.style.top = top + 'px';
|
|
}, true);
|
|
|
|
// Bulk print labels
|
|
var bulkPrintBtn = document.querySelector('.js-bulk-print-labels');
|
|
if (bulkPrintBtn) {
|
|
bulkPrintBtn.addEventListener('click', function () {
|
|
var checked = document.querySelectorAll('.js-table-select-item:checked');
|
|
if (checked.length === 0) {
|
|
if (window.OrderProAlerts) {
|
|
window.OrderProAlerts.show({ message: 'Zaznacz co najmniej jedno zamowienie.', type: 'warning' });
|
|
}
|
|
return;
|
|
}
|
|
|
|
var orderIds = [];
|
|
checked.forEach(function (cb) { orderIds.push(cb.value); });
|
|
var csrf = bulkPrintBtn.getAttribute('data-csrf') || '';
|
|
|
|
bulkPrintBtn.disabled = true;
|
|
bulkPrintBtn.textContent = 'Wysylam...';
|
|
|
|
fetch('/api/print/jobs/bulk', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ order_ids: orderIds, _token: csrf })
|
|
})
|
|
.then(function (r) { return r.json(); })
|
|
.then(function (data) {
|
|
var created = (data.created || []).length;
|
|
var skipped = (data.skipped || []).length;
|
|
var msg = 'Wyslano ' + created + ' zlecen do drukarki.';
|
|
if (skipped > 0) {
|
|
msg += ' Pominieto ' + skipped + ' (brak etykiety lub juz w kolejce).';
|
|
}
|
|
if (window.OrderProAlerts) {
|
|
window.OrderProAlerts.show({ message: msg, type: 'success' });
|
|
}
|
|
bulkPrintBtn.disabled = false;
|
|
bulkPrintBtn.textContent = 'Drukuj etykiety';
|
|
})
|
|
.catch(function () {
|
|
if (window.OrderProAlerts) {
|
|
window.OrderProAlerts.show({ message: 'Blad sieci — sprobuj ponownie.', type: 'error' });
|
|
}
|
|
bulkPrintBtn.disabled = false;
|
|
bulkPrintBtn.textContent = 'Drukuj etykiety';
|
|
});
|
|
});
|
|
}
|
|
})();
|
|
</script>
|
|
|