Added option forcustom product during checkout
This commit is contained in:
@@ -214,10 +214,63 @@
|
||||
.receipt-table td { padding: 3px 0; vertical-align: top; }
|
||||
.receipt-total-row { border-top: 1px dashed #000; font-weight: bold; font-size: 14px; }
|
||||
}
|
||||
|
||||
/* ── Dropdown Select Fix ── */
|
||||
.form-select,
|
||||
.form-select:focus {
|
||||
background-color: var(--input-bg) !important;
|
||||
color: var(--text-main) !important;
|
||||
border: 1px solid var(--border) !important;
|
||||
box-shadow: none !important;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23adb5bd' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
|
||||
}
|
||||
|
||||
.form-select:focus {
|
||||
border-color: var(--accent) !important;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .form-select {
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dcddde' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="modal fade" id="customProductModal" tabindex="-1" data-bs-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Agregar Producto Manual</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label text-muted small mb-1">Descripción</label>
|
||||
<input type="text" id="custom-name" class="form-control" placeholder="Ej: Varios, Bolsa, etc."
|
||||
onkeydown="if(event.key === 'Enter') document.getElementById('custom-price').focus()">
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
<div class="col-8">
|
||||
<label class="form-label text-muted small mb-1">Precio Unitario</label>
|
||||
<input type="number" id="custom-price" class="form-control" placeholder="Ej: 1500"
|
||||
onkeydown="if(event.key === 'Enter') addCustomProduct()">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<label class="form-label text-muted small mb-1">Tipo</label>
|
||||
<select id="custom-unit" class="form-select">
|
||||
<option value="unit">Unidad</option>
|
||||
<option value="kg">Kg</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer d-flex">
|
||||
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">Cancelar</button>
|
||||
<button class="btn btn-accent flex-grow-1" onclick="addCustomProduct()">Agregar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="receipt-print-zone">
|
||||
<div class="receipt-header">
|
||||
<h3 style="margin: 0; font-weight: 800;">SekiPOS</h3>
|
||||
@@ -368,9 +421,9 @@
|
||||
</span>
|
||||
<input type="text" id="manual-search" class="form-control ps-5 py-2 rounded"
|
||||
placeholder="Buscar producto por nombre o código..." autocomplete="off" onkeyup="filterSearch()">
|
||||
</div>
|
||||
<div id="search-results" class="dropdown-menu w-100 shadow-lg position-absolute mt-1"
|
||||
style="display: none; max-height: 300px; overflow-y: auto; z-index: 1000;">
|
||||
<button class="btn btn-accent px-3" type="button" onclick="openCustomProductModal()" title="Agregar manual">
|
||||
<i class="bi bi-plus-lg"></i> <span class="d-none d-sm-inline ms-1">Manual</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<table class="table mt-3" id="cart-table">
|
||||
@@ -824,6 +877,54 @@
|
||||
window.print();
|
||||
}
|
||||
|
||||
function openCustomProductModal() {
|
||||
// Scrub the inputs clean
|
||||
document.getElementById('custom-name').value = '';
|
||||
document.getElementById('custom-price').value = '';
|
||||
document.getElementById('custom-unit').value = 'unit';
|
||||
|
||||
const modal = bootstrap.Modal.getOrCreateInstance(document.getElementById('customProductModal'));
|
||||
modal.show();
|
||||
setTimeout(() => document.getElementById('custom-name').focus(), 500);
|
||||
}
|
||||
|
||||
function addCustomProduct() {
|
||||
const nameInput = document.getElementById('custom-name').value.trim();
|
||||
const priceInput = parseInt(document.getElementById('custom-price').value, 10);
|
||||
const unitInput = document.getElementById('custom-unit').value;
|
||||
|
||||
if (!nameInput || isNaN(priceInput) || priceInput <= 0) {
|
||||
alert("Por favor ingresa un nombre y un precio válido.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate a unique dummy barcode so the cart math doesn't implode
|
||||
const fakeBarcode = `MANUAL-${Date.now().toString().slice(-6)}`;
|
||||
|
||||
const customProduct = {
|
||||
barcode: fakeBarcode,
|
||||
name: `* ${nameInput}`, // Adds a star to the receipt so you know it was manual
|
||||
price: priceInput,
|
||||
image: '',
|
||||
stock: 0,
|
||||
unit: unitInput
|
||||
};
|
||||
|
||||
if (unitInput === 'kg') {
|
||||
// Send it to your existing weight modal flow
|
||||
pendingProduct = customProduct;
|
||||
bootstrap.Modal.getInstance(document.getElementById('customProductModal')).hide();
|
||||
|
||||
const weightModal = bootstrap.Modal.getOrCreateInstance(document.getElementById('weightModal'));
|
||||
weightModal.show();
|
||||
setTimeout(() => document.getElementById('weight-input').focus(), 500);
|
||||
} else {
|
||||
// Add directly as 1 unit
|
||||
addToCart(customProduct, 1);
|
||||
bootstrap.Modal.getInstance(document.getElementById('customProductModal')).hide();
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the listener is intact
|
||||
document.getElementById('btn-confirm-remove').addEventListener('click', () => {
|
||||
if (itemIndexToRemove !== null) {
|
||||
|
||||
Reference in New Issue
Block a user