diff --git a/myproject/pos/static/pos/js/terminal.js b/myproject/pos/static/pos/js/terminal.js index c2f4e1b..d291412 100644 --- a/myproject/pos/static/pos/js/terminal.js +++ b/myproject/pos/static/pos/js/terminal.js @@ -859,6 +859,7 @@ function renderCart() { if (cart.size === 0) { list.innerHTML = '

Корзина пуста

'; document.getElementById('cartTotal').textContent = '0.00'; + updateShowcaseButtonState(); // Обновляем состояние кнопки return; } @@ -974,6 +975,9 @@ function renderCart() { }); document.getElementById('cartTotal').textContent = formatMoney(total); + + // Обновляем состояние кнопки "НА ВИТРИНУ" + updateShowcaseButtonState(); } async function removeFromCart(cartKey) { @@ -1051,6 +1055,40 @@ async function clearCart() { document.getElementById('clearCart').onclick = clearCart; +/** + * Обновляет состояние кнопки "НА ВИТРИНУ" + * Блокирует кнопку если в корзине есть витринный комплект + */ +function updateShowcaseButtonState() { + const showcaseBtn = document.getElementById('addToShowcaseBtn'); + if (!showcaseBtn) return; + + // Проверяем наличие витринных комплектов в корзине + let hasShowcaseKit = false; + for (const [cartKey, item] of cart) { + if (item.type === 'showcase_kit') { + hasShowcaseKit = true; + break; + } + } + + if (hasShowcaseKit) { + // Блокируем кнопку + showcaseBtn.disabled = true; + showcaseBtn.classList.add('disabled'); + showcaseBtn.style.opacity = '0.5'; + showcaseBtn.style.cursor = 'not-allowed'; + showcaseBtn.title = '⚠️ В корзине уже есть витринный комплект. Удалите его перед созданием нового'; + } else { + // Разблокируем кнопку + showcaseBtn.disabled = false; + showcaseBtn.classList.remove('disabled'); + showcaseBtn.style.opacity = '1'; + showcaseBtn.style.cursor = 'pointer'; + showcaseBtn.title = 'Создать букет на витрину из текущей корзины'; + } +} + // Кнопка "На витрину" - функционал будет добавлен позже document.getElementById('addToShowcaseBtn').onclick = () => { openCreateTempKitModal(); @@ -1064,7 +1102,21 @@ async function openCreateTempKitModal() { return; } - // Проверяем что в корзине только товары (не комплекты) + // Проверяем что в корзине НЕТ витринных комплектов + let hasShowcaseKit = false; + for (const [cartKey, item] of cart) { + if (item.type === 'showcase_kit') { + hasShowcaseKit = true; + break; + } + } + + if (hasShowcaseKit) { + alert('⚠️ В корзине уже есть витринный комплект!\n\nНельзя создать новый букет на витрину, пока в корзине находится другой витринный букет.\n\nУдалите витринный букет из корзины или завершите текущую продажу.'); + return; + } + + // Проверяем что в корзине только товары (не обычные комплекты) let hasKits = false; for (const [cartKey, item] of cart) { if (item.type === 'kit') {