Spaces:
Running
Running
Update script.js
Browse files
script.js
CHANGED
@@ -205,62 +205,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
|
205 |
return;
|
206 |
}
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
if (product && product.quantity >= cartItem.quantity) {
|
214 |
-
product.quantity -= cartItem.quantity;
|
215 |
-
totalSold += cartItem.quantity;
|
216 |
-
totalRevenue += cartItem.quantity * cartItem.salePrice;
|
217 |
-
totalProfit += cartItem.quantity * (cartItem.salePrice - cartItem.purchasePrice);
|
218 |
-
} else {
|
219 |
-
alert(`Недостаточно товара "${cartItem.name}" на складе.`);
|
220 |
-
}
|
221 |
-
});
|
222 |
-
|
223 |
-
localStorage.setItem('products', JSON.stringify(products));
|
224 |
-
localStorage.setItem('stats', JSON.stringify({ totalSold, totalRevenue, totalProfit }));
|
225 |
-
localStorage.removeItem('cart');
|
226 |
-
|
227 |
-
cart = [];
|
228 |
-
updateCartDisplay();
|
229 |
-
productTable.innerHTML = '';
|
230 |
-
loadProducts();
|
231 |
-
updateStatsDisplay();
|
232 |
-
};
|
233 |
-
|
234 |
-
// Функция добавления остатков
|
235 |
-
function addStock(productId) {
|
236 |
-
const quantityToAdd = prompt('Введите количество для прихода:');
|
237 |
-
if (quantityToAdd && !isNaN(quantityToAdd) && quantityToAdd > 0) {
|
238 |
-
let products = JSON.parse(localStorage.getItem('products')) || [];
|
239 |
-
const productIndex = products.findIndex(p => p.id === productId);
|
240 |
|
241 |
-
|
242 |
-
products[productIndex].quantity += parseInt(quantityToAdd);
|
243 |
-
localStorage.setItem('products', JSON.stringify(products));
|
244 |
-
|
245 |
-
// Обновляем таблицу
|
246 |
-
productTable.innerHTML = '';
|
247 |
-
loadProducts();
|
248 |
-
}
|
249 |
-
} else {
|
250 |
-
alert('Пожалуйста, введите корректное количество.');
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
// Функция удаления товара
|
255 |
-
function deleteProduct(productId) {
|
256 |
-
if (confirm('Вы уверены, что хотите удалить этот товар?')) {
|
257 |
-
let products = JSON.parse(localStorage.getItem('products')) || [];
|
258 |
-
products = products.filter(p => p.id !== productId);
|
259 |
-
localStorage.setItem('products', JSON.stringify(products));
|
260 |
-
|
261 |
-
// Обновляем таблицу
|
262 |
-
productTable.innerHTML = '';
|
263 |
-
loadProducts();
|
264 |
-
}
|
265 |
-
}
|
266 |
-
});
|
|
|
205 |
return;
|
206 |
}
|
207 |
|
208 |
+
// Получаем текущую дату и время по бишкекскому времени
|
209 |
+
const now = new Date();
|
210 |
+
const options = { timeZone: 'Asia/Bishkek', year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' };
|
211 |
+
const receiptDateTime = now.toLocaleString('ru-RU', options);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
+
// Заполняем дату и время
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|