diff --git a/myproject/pos/static/pos/js/terminal.js b/myproject/pos/static/pos/js/terminal.js index e6f6cea..5928464 100644 --- a/myproject/pos/static/pos/js/terminal.js +++ b/myproject/pos/static/pos/js/terminal.js @@ -81,30 +81,31 @@ function formatMoney(v) { * Обновляет отображение выбранного клиента в UI * Обновляет: * - Кнопку "Выбрать клиента" в корзине (показывает имя клиента) - * - Имя клиента в модалке продажи - * - Видимость кнопки сброса (показываем только для не-системного клиента) + * - Кнопку "Выбрать клиента" в модалке продажи (показывает имя клиента) + * - Видимость кнопок сброса в обоих местах (показываем только для не-системного клиента) */ function updateCustomerDisplay() { - // Обновляем текст кнопки - всегда показываем имя клиента + // Обновляем текст кнопки в корзине const btnText = document.getElementById('customerSelectBtnText'); - btnText.textContent = selectedCustomer.name; - - // Обновляем имя клиента в модалке продажи - const checkoutCustomerName = document.getElementById('checkoutCustomerName'); - if (checkoutCustomerName) { - checkoutCustomerName.textContent = selectedCustomer.name; + if (btnText) { + btnText.textContent = selectedCustomer.name; } - // Показываем/скрываем кнопку сброса - const resetBtn = document.getElementById('resetCustomerBtn'); - if (resetBtn) { - // Показываем кнопку сброса только если выбран НЕ системный клиент - if (selectedCustomer.id !== SYSTEM_CUSTOMER.id) { - resetBtn.style.display = 'block'; - } else { - resetBtn.style.display = 'none'; + // Обновляем текст кнопки в модалке продажи + const checkoutBtnText = document.getElementById('checkoutCustomerSelectBtnText'); + if (checkoutBtnText) { + checkoutBtnText.textContent = selectedCustomer.name; + } + + // Обновляем видимость кнопок сброса (в корзине и в модалке продажи) + const isSystemCustomer = selectedCustomer.id === SYSTEM_CUSTOMER.id; + + [document.getElementById('resetCustomerBtn'), + document.getElementById('checkoutResetCustomerBtn')].forEach(resetBtn => { + if (resetBtn) { + resetBtn.style.display = isSystemCustomer ? 'none' : 'block'; } - } + }); } /** @@ -1436,11 +1437,22 @@ document.getElementById('customerSelectBtn').addEventListener('click', () => { modal.show(); }); -// Кнопка сброса клиента на системного +// Кнопка сброса клиента на системного (в корзине) document.getElementById('resetCustomerBtn').addEventListener('click', () => { selectCustomer(SYSTEM_CUSTOMER.id, SYSTEM_CUSTOMER.name); }); +// Кнопка "Выбрать клиента" в модалке продажи +document.getElementById('checkoutCustomerSelectBtn').addEventListener('click', () => { + const modal = new bootstrap.Modal(document.getElementById('selectCustomerModal')); + modal.show(); +}); + +// Кнопка сброса клиента на системного (в модалке продажи) +document.getElementById('checkoutResetCustomerBtn').addEventListener('click', () => { + selectCustomer(SYSTEM_CUSTOMER.id, SYSTEM_CUSTOMER.name); +}); + // Кнопка "Создать нового клиента" в модалке выбора document.getElementById('createNewCustomerBtn').addEventListener('click', () => { // Закрываем модалку выбора diff --git a/myproject/pos/templates/pos/terminal.html b/myproject/pos/templates/pos/terminal.html index deb234a..6bfe6b6 100644 --- a/myproject/pos/templates/pos/terminal.html +++ b/myproject/pos/templates/pos/terminal.html @@ -277,9 +277,18 @@
- Клиент -
-
+ +
+ +