Carpeta views
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0">
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<h4 class="mb-0 title-shadow">
|
||||
<i class="fas fa-box-open icon-xl me-2"></i>
|
||||
Selección de Productos
|
||||
</h4>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<!-- BOTÓN FANTASMA (mantiene el layout) -->
|
||||
|
||||
<a class="btn btn-success invisible">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
</a>
|
||||
|
||||
<a href="?opt=crear_venta" class="btn btn-soft-secondary text-white">
|
||||
<i class="fas fa-arrow-left me-1"></i>
|
||||
Volver
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BODY -->
|
||||
|
||||
<div class="card-body px-4 py-4">
|
||||
|
||||
<?php if (empty($productos)): ?>
|
||||
<div class="text-center text-muted py-5">
|
||||
No hay productos registrados.
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<!-- FILTRO POR COLUMNA + BUSCADOR -->
|
||||
|
||||
<!-- Input de búsqueda añadido automáticamente por DataTables -->
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-1">
|
||||
|
||||
<div id="filtrosIzquierda" class="d-flex align-items-center gap-2">
|
||||
|
||||
<select id="columnFilter"
|
||||
class="form-select form-select-sm"
|
||||
style="width:auto;">
|
||||
<option value="">Todas las columnas</option>
|
||||
<option value="0">ID</option>
|
||||
<option value="1">Marca</option>
|
||||
<option value="2">Modelo</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<form method="POST" action="index.php?opt=agregar_producto_caja" novalidate>
|
||||
|
||||
<!-- CAMPO OCULTO (para verificación de token) -->
|
||||
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="tablaProductos" class="table table-hover align-middle mb-0">
|
||||
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Marca</th>
|
||||
<th>Modelo</th>
|
||||
<th>Precio Unit. Fin.</th>
|
||||
<th>Descuento Tot. (%)</th>
|
||||
<th>Stock</th>
|
||||
<th>Seleccionar</th>
|
||||
<th>Cantidad</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($productos as $p): ?>
|
||||
<tr>
|
||||
<td><?= $p['id'] ?? '' ?></td>
|
||||
<td><?= htmlspecialchars($p['marca'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($p['modelo'] ?? '') ?></td>
|
||||
<td>$ <?= number_format($p['precio_final'], 2, '.', ',') ?></td>
|
||||
<td><?= htmlspecialchars($p['descuento_total'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($p['stock'] ?? '') ?></td>
|
||||
|
||||
<!-- CHECKBOX PARA SELECCIONAR PRODUCTO -->
|
||||
|
||||
<td class="text-left">
|
||||
<input type="checkbox"
|
||||
name="ids[]"
|
||||
value="<?= $p['id'] ?>"
|
||||
class="form-check-input">
|
||||
</td>
|
||||
|
||||
<!-- INPUT DE CANTIDAD -->
|
||||
|
||||
<td class="text-center">
|
||||
<input type="number"
|
||||
name="cantidades[<?= $p['id'] ?>]"
|
||||
value="1"
|
||||
min="1"
|
||||
max="<?= $p['stock'] ?>"
|
||||
class="form-control form-control-sm"
|
||||
style="width: 60px;">
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- BOTÓN FINALIZAR SELECCIÓN -->
|
||||
|
||||
<div class="mt-3 text-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-check me-1"></i> Finalizar Selección
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Errores provenientes de ventaController -->
|
||||
|
||||
<!-- ERROR -->
|
||||
|
||||
<script>
|
||||
const serverErrors = <?php
|
||||
if (!empty($_SESSION['flash_error'])) {
|
||||
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
||||
unset($_SESSION['flash_error']);
|
||||
echo json_encode($errorsArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- SUCCES -->
|
||||
|
||||
<script>
|
||||
const serverSuccess = <?php
|
||||
if (!empty($_SESSION['flash_success'])) {
|
||||
$successArray = explode('<br>', $_SESSION['flash_success']);
|
||||
unset($_SESSION['flash_success']);
|
||||
echo json_encode($successArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/ventas/ventaValidator.js"></script>
|
||||
|
||||
<!-- Tabla, búsqueda y filtro por columnas -->
|
||||
|
||||
<script src="js/ventas/ventaTableProducto.js"></script>
|
||||
@@ -0,0 +1,269 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
<?php require __DIR__ . '/../../includes/modal.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0 card-viewport">
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<h4 class="mb-0 title-shadow">
|
||||
<i class="fas fa-shopping-cart icon-xl me-2"></i>
|
||||
Nueva Venta
|
||||
</h4>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<a href="?opt=listar_ventas" class="btn btn-primary">
|
||||
<i class="fas fa-folder-open me-1"></i>
|
||||
Ventas Registradas
|
||||
</a>
|
||||
|
||||
<a href="?opt=crear_cliente&from=crear_venta" class="btn btn-success">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
Nuevo Cliente
|
||||
</a>
|
||||
|
||||
<a href="?opt=home_operador" class="btn btn-soft-secondary text-white">
|
||||
<i class="fas fa-arrow-left me-1"></i>
|
||||
Volver
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body p-4 d-flex flex-column card-body-scroll">
|
||||
|
||||
<!-- CLIENTE -->
|
||||
|
||||
<div class="mb-4 flex-shrink-0">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<h6 class="text-muted mb-0">Cliente</h6>
|
||||
|
||||
<div class="ms-4 d-flex gap-2">
|
||||
|
||||
<a href="?opt=seleccionar_cliente" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-user fa-fw me-1"></i>
|
||||
Seleccionar Cliente
|
||||
</a>
|
||||
|
||||
<form method="POST" action="?opt=eliminar_cliente" class="d-inline">
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<button class="btn btn-danger btn-sm">
|
||||
<i class="fas fa-times fa-fw me-1"></i>
|
||||
Eliminar Cliente
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa mb-1">ID</label>
|
||||
<input class="form-control campo-readonly"
|
||||
value="<?= htmlspecialchars($cliente['id'] ?? '') ?>" readonly>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa mb-1">Nombre y Apellido</label>
|
||||
<input class="form-control campo-readonly"
|
||||
value="<?= htmlspecialchars(($cliente['nombre'] ?? '') . ' ' . ($cliente['apellido'] ?? '')) ?>" readonly>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa mb-1">Teléfono</label>
|
||||
<input class="form-control campo-readonly"
|
||||
value="<?= htmlspecialchars($cliente['telefono'] ?? '') ?>" readonly>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa mb-1">Email</label>
|
||||
<input class="form-control campo-readonly"
|
||||
value="<?= htmlspecialchars($cliente['email'] ?? '') ?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- LISTADO -->
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-2 flex-shrink-0">
|
||||
<h6 class="text-muted mb-0">Listado de Productos</h6>
|
||||
|
||||
<div class="ms-4 d-flex gap-2">
|
||||
|
||||
<a href="?opt=agregar_producto" class="btn btn-success btn-sm">
|
||||
<i class="fas fa-plus fa-fw me-1"></i>
|
||||
Agregar Producto
|
||||
</a>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger btn-sm btnConfirmar"
|
||||
title="Vaciar Lista"
|
||||
data-action="vaciar_caja_venta"
|
||||
data-mensaje="Todos los productos serán retirados de la lista, ¿estás seguro?"
|
||||
data-titulo="Vaciar Lista"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#modalConfirmacion">
|
||||
|
||||
<i class="fas fa-times fa-fw me-1"></i>
|
||||
Vaciar Lista
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABLA -->
|
||||
|
||||
<div class="table-scroll-crear my-2">
|
||||
|
||||
<table id="tablaProductosVenta" class="table table-fixed table-hover align-middle mb-0 table-resumen-venta">
|
||||
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Producto</th>
|
||||
<th class="text-left">Precio Unit. Fin.</th>
|
||||
<th class="text-left">Descuento (%)</th>
|
||||
<th class="text-left">Cantidad</th>
|
||||
<th class="text-center">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php if (empty($productos)): ?>
|
||||
<tr>
|
||||
<td colspan="6" class="text-center">-</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($productos as $p): ?>
|
||||
<tr>
|
||||
<form method="POST" action="index.php?opt=editar_cantidad" novalidate>
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
<input type="hidden" name="id_producto" value="<?= $p['id_producto'] ?>">
|
||||
|
||||
<td><?= $p['id_producto'] ?></td>
|
||||
|
||||
<td>
|
||||
<?= htmlspecialchars($p['marca'] . ' ' . $p['modelo']) ?>
|
||||
</td>
|
||||
|
||||
<td>$ <?= number_format($p['precio_final'], 2) ?></td>
|
||||
|
||||
<td><?= htmlspecialchars($p['descuento_total']) ?> %</td>
|
||||
|
||||
<td>
|
||||
<input type="number"
|
||||
name="cantidad"
|
||||
value="<?= $p['cantidad'] ?>"
|
||||
min="1"
|
||||
max="<?= $p['stock'] ?>"
|
||||
class="form-control form-control-sm"
|
||||
style="width: 60px;">
|
||||
</td>
|
||||
|
||||
<td class="text-center">
|
||||
<button type="submit" class="btn btn-primary btn-sm">
|
||||
<i class="fas fa-pen fa-fw"></i>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
formaction="?opt=eliminar_producto"
|
||||
class="btn btn-danger btn-sm">
|
||||
<i class="fas fa-times fa-fw"></i>
|
||||
</button>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- TOTALES -->
|
||||
|
||||
<div class="flex-shrink-0 mt-3">
|
||||
|
||||
<h6 class="text-muted mb-3">Datos de Venta</h6>
|
||||
|
||||
<div class="row g-3">
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Subtotal</label>
|
||||
<input class="form-control campo-readonly"
|
||||
value="$ <?= number_format($subtotal, 2) ?>" readonly>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Descuento</label>
|
||||
<input class="form-control campo-readonly"
|
||||
value="$ <?= number_format($descuento, 2) ?>" readonly>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Total</label>
|
||||
<input class="form-control campo-readonly fw-semibold"
|
||||
value="$ <?= number_format($total, 2) ?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 text-end">
|
||||
<a href="?opt=resumen_venta" class="btn btn-primary py-2">
|
||||
Siguiente
|
||||
<i class="fas fa-arrow-right ms-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Errores provinientes de ventaController -->
|
||||
|
||||
<!-- ERROR -->
|
||||
|
||||
<script>
|
||||
const serverErrors = <?php
|
||||
if (!empty($_SESSION['flash_error'])) {
|
||||
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
||||
unset($_SESSION['flash_error']);
|
||||
echo json_encode($errorsArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- SUCCES -->
|
||||
|
||||
<script>
|
||||
const serverSuccess = <?php
|
||||
if (!empty($_SESSION['flash_success'])) {
|
||||
$successArray = explode('<br>', $_SESSION['flash_success']);
|
||||
unset($_SESSION['flash_success']);
|
||||
echo json_encode($successArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- MODAL -->
|
||||
|
||||
<script src="js/globalModal.js"></script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/ventas/ventaValidator.js"></script>
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="row justify-content-center">
|
||||
|
||||
<div class="col-lg-8">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0">
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
|
||||
<h4 class="mb-0 title-shadow">
|
||||
<i class="fas fa-file-alt me-2"></i>
|
||||
Venta Confirmada
|
||||
</h4>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body text-center p-5">
|
||||
|
||||
<i class="fas fa-check-circle text-success fa-4x mb-4"></i>
|
||||
|
||||
<h4>Venta guardada correctamente</h4>
|
||||
|
||||
<p class="text-muted">
|
||||
Comprobante N°
|
||||
<strong><?= $numeroVenta ?></strong>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p>
|
||||
¿Desea descargar el comprobante generado?
|
||||
</p>
|
||||
|
||||
<div class="d-flex justify-content-center gap-3 mt-5">
|
||||
|
||||
<form method="POST" action="?opt=generar_venta_pdf">
|
||||
|
||||
<!-- CAMPO OCULTO (para verificación de token) -->
|
||||
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<button class="btn btn-success">
|
||||
<i class="fas fa-download me-1 my-2"></i>
|
||||
Descargar Comprobante
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<a href="?opt=continuar_sin_comprobante" class="btn btn-secondary">
|
||||
<i class="fas fa-arrow-right me-1 my-2"></i>
|
||||
Continuar
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Errores provenients de ventaController -->
|
||||
|
||||
<!-- ERROR -->
|
||||
|
||||
<script>
|
||||
const serverErrors = <?php
|
||||
if (!empty($_SESSION['flash_error'])) {
|
||||
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
||||
unset($_SESSION['flash_error']);
|
||||
echo json_encode($errorsArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- SUCCES -->
|
||||
|
||||
<script>
|
||||
const serverSuccess = <?php
|
||||
if (!empty($_SESSION['flash_success'])) {
|
||||
$successArray = explode('<br>', $_SESSION['flash_success']);
|
||||
unset($_SESSION['flash_success']);
|
||||
echo json_encode($successArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/ventas/ventaValidator.js"></script>
|
||||
|
||||
<!-- Evita que Chrome use BFCache -->
|
||||
|
||||
<script>
|
||||
window.onpageshow = function(event) {
|
||||
if (event.persisted) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,180 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0">
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<!-- IZQUIERDA -->
|
||||
|
||||
<div class="d-flex align-items-center gap-4">
|
||||
<h4 class="mb-0 tittle-shadow">
|
||||
<i class="fas fa-folder-open icon-xl me-2"></i> Listado de Ventas
|
||||
</h4>
|
||||
|
||||
<div class="d-flex align-items-center gap-3">
|
||||
|
||||
<!-- AÑO -->
|
||||
|
||||
<form method="GET" action="index.php" class="d-flex align-items-center gap-2 select-group mb-0">
|
||||
|
||||
<input type="hidden" name="opt" value="listar_ventas">
|
||||
|
||||
<i class="fas fa-calendar-alt text-light"></i>
|
||||
|
||||
<select name="anio" class="form-select custom-select select-informe" onchange="this.form.submit()">
|
||||
|
||||
<?php for ($i = $anioActual; $i >= 2020; $i--): ?>
|
||||
<option value="<?= $i ?>" <?= $i == $anioSeleccionado ? 'selected' : '' ?>>
|
||||
<?= $i ?>
|
||||
</option>
|
||||
<?php endfor; ?>
|
||||
|
||||
</select>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- DERECHA -->
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<!-- BOTÓN FANTASMA (mantiene el layout) -->
|
||||
|
||||
<a class="btn btn-success invisible">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
</a>
|
||||
|
||||
<a href="?opt=crear_venta" class="btn btn-soft-secondary text-white">
|
||||
<i class="fas fa-arrow-left me-1"></i>
|
||||
Volver
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BODY -->
|
||||
|
||||
<div class="card-body px-4 py-4">
|
||||
|
||||
<?php if (empty($ventas)): ?>
|
||||
<div class="text-center text-muted py-5">
|
||||
No hay ventas registradas.
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<!-- FILTRO POR COLUMNA + BUSCADOR -->
|
||||
|
||||
<!-- Input de búsqueda añadido automáticamente por DataTables -->
|
||||
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
|
||||
<select id="columnFilter"
|
||||
class="form-select form-select-sm ms-2"
|
||||
style="width: auto;">
|
||||
<option value="0">ID Venta</option>
|
||||
<option value="1">Fecha</option>
|
||||
<option value="6">Cliente</option>
|
||||
<option value="7">Operador</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="tablaVentas" class="table table-hover align-middle mb-0">
|
||||
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Fecha</th>
|
||||
<th>Total</th>
|
||||
<th>Descuento (%)</th>
|
||||
<th>Recargo (%)</th>
|
||||
<th>Forma de Pago</th>
|
||||
<th>Cliente</th>
|
||||
<th>Operador</th>
|
||||
<th class="text-center">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($ventas as $v): ?>
|
||||
<tr>
|
||||
<td><?= $v['id'] ?></td>
|
||||
<td data-order="<?= $v['fecha'] ?>">
|
||||
<?= htmlspecialchars($v['fecha_formateada']) ?>
|
||||
</td>
|
||||
<td>$ <?= number_format($v['total'], 2, '.', ',') ?></td>
|
||||
<td><?= number_format($v['descuento_pct'], 2, '.', ',') ?> %</td>
|
||||
<td><?= number_format($v['recargo_pct'], 2, '.', ',') ?> %</td>
|
||||
<td><?= htmlspecialchars($v['forma_pago']) . ' (' . $v['tipo_pago'] ?>)</td>
|
||||
<td><?= htmlspecialchars($v['cliente_nombre'] . ' ' . $v['cliente_apellido']) ?></td>
|
||||
<td><?= htmlspecialchars($v['vendedor_nombre'] . ' ' . $v['vendedor_apellido']) ?></td>
|
||||
|
||||
<td class="text-center">
|
||||
<div class="d-inline-flex align-items-center gap-2">
|
||||
|
||||
<!-- VER DETALLE PRODUCTOS -->
|
||||
|
||||
<a href="?opt=detalle_venta&id=<?= $v['id'] ?>"
|
||||
class="btn btn-primary btn-sm"
|
||||
title="Detalle Productos">
|
||||
<i class="fas fa-box-open fa-sm fa-fw"></i>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Errores provenientes de ventaController -->
|
||||
|
||||
<!-- ERROR -->
|
||||
|
||||
<script>
|
||||
const serverErrors = <?php
|
||||
if (!empty($_SESSION['flash_error'])) {
|
||||
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
||||
unset($_SESSION['flash_error']);
|
||||
echo json_encode($errorsArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- SUCCES -->
|
||||
|
||||
<script>
|
||||
const serverSuccess = <?php
|
||||
if (!empty($_SESSION['flash_success'])) {
|
||||
$successArray = explode('<br>', $_SESSION['flash_success']);
|
||||
unset($_SESSION['flash_success']);
|
||||
echo json_encode($successArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/ventas/ventaValidator.js"></script>
|
||||
|
||||
<!-- Tabla, búsqueda y filtro por columnas -->
|
||||
|
||||
<script src="js/ventas/ventaTableLista.js"></script>
|
||||
@@ -0,0 +1,423 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
<?php require __DIR__ . '/../../includes/modal.php'; ?>
|
||||
|
||||
<?php
|
||||
// Datos desde back end (si existen)
|
||||
|
||||
$venta = $_SESSION['venta_extra'] ?? [];
|
||||
|
||||
$condIva = $venta['cond_iva'] ?? 'consumidor_final';
|
||||
$cuit = $venta['cuit'] ?? '';
|
||||
$formaPago = $venta['forma_pago'] ?? 'efectivo';
|
||||
$tipoPago = $venta['tipo_pago'] ?? 'pago_unico';
|
||||
$descuentoIngresado = $venta['descuento'] ?? 0;
|
||||
$recargoIngresado = $venta['recargo'] ?? 0;
|
||||
?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0 card-viewport">
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<h4 class="mb-0 title-shadow">
|
||||
<i class="fas fa-receipt icon-xl me-2"></i>
|
||||
Resumen de Venta
|
||||
</h4>
|
||||
|
||||
<a href="?opt=crear_venta" class="btn btn-soft-secondary text-white">
|
||||
<i class="fas fa-arrow-left me-1"></i>
|
||||
Volver
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BODY -->
|
||||
|
||||
<form id="form_crear_venta" method='POST' action="index.php?opt=guardar_datos_venta" novalidate>
|
||||
|
||||
<!-- CAMPO OCULTO (para verificación de token) -->
|
||||
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="card-body p-4 d-flex flex-column card-body-scroll">
|
||||
|
||||
<!-- CLIENTE -->
|
||||
|
||||
<div class="mb-4 flex-shrink-0">
|
||||
|
||||
<h6 class="text-muted mb-2">Datos Del Cliente</h6>
|
||||
|
||||
<div class="row g-3">
|
||||
|
||||
<!-- NOMBRE Y APELLIDO -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Nombre y Apellido</label>
|
||||
<input class="form-control campo-readonly" readonly
|
||||
value="<?= htmlspecialchars($cliente['nombre'] . ' ' . $cliente['apellido']) ?? '' ?>">
|
||||
</div>
|
||||
|
||||
<!-- TELÉFONO -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Teléfono Cliente</label>
|
||||
<input class="form-control campo-readonly" readonly
|
||||
value="<?= htmlspecialchars($cliente['telefono'] ?? '') ?>">
|
||||
</div>
|
||||
|
||||
<!-- COND. IVA -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Cond. IVA</label>
|
||||
<select class="form-select form-select-sm" name="cond_iva" id="condIva">
|
||||
<option value="consumidor_final" <?= $condIva === 'consumidor_final' ? 'selected' : '' ?>>
|
||||
Consumidor Final
|
||||
</option>
|
||||
<option value="responsable_inscripto" <?= $condIva === 'responsable_inscripto' ? 'selected' : '' ?>>
|
||||
Responsable Inscripto
|
||||
</option>
|
||||
<option value="monotributo" <?= $condIva === 'monotributo' ? 'selected' : '' ?>>
|
||||
Monotributo
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- CUIT -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="form-label">CUIT</label>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<input type="text" name="cuit_1" maxlength="2" class="form-control text-center"
|
||||
data-bs-toggle="tooltip"
|
||||
title="Tipo de persona"
|
||||
value="<?= substr($cuit ?? '', 0, 2) ?>">
|
||||
|
||||
<input type="text" name="cuit_2" maxlength="8" class="form-control text-center"
|
||||
data-bs-toggle="tooltip"
|
||||
title="DNI"
|
||||
value="<?= substr($cuit ?? '', 2, 8) ?>">
|
||||
|
||||
<input type="text" name="cuit_3" maxlength="1" class="form-control text-center"
|
||||
data-bs-toggle="tooltip"
|
||||
title="Dígito verificador"
|
||||
value="<?= substr($cuit ?? '', 10, 1) ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PRODUCTOS -->
|
||||
|
||||
<h6 class="text-muted mb-2">Productos</h6>
|
||||
|
||||
<div class="table-scroll my-3">
|
||||
|
||||
<table class="table table-fixed table-hover align-middle mb-0 table-resumen-venta">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Producto</th>
|
||||
<th class="text-end">Precio Unit. Fin.</th>
|
||||
<th class="text-end">Descuento (%)</th>
|
||||
<th class="text-end">Cantidad</th>
|
||||
<th class="text-end">Subtotal</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($productos as $p): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?= htmlspecialchars($p['marca'] . ' ' . $p['modelo']) ?>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
$ <?= number_format($p['precio_final'], 2) ?>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<?= htmlspecialchars($p['descuento_total']) ?> %
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<?= $p['cantidad'] ?>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
$ <?= number_format($p['precio_final'] * $p['cantidad'], 2) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- DATOS DE PAGO -->
|
||||
|
||||
<div class="flex-shrink-0 mt-0">
|
||||
|
||||
<h6 class="text-muted mb-2">Datos De Pago</h6>
|
||||
|
||||
<div class="row g-3">
|
||||
|
||||
<!-- FORMA DE PAGO -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Forma de pago</label>
|
||||
<select class="form-select form-select-sm" name="forma_pago" id="formaPago">
|
||||
<option value="efectivo" <?= $formaPago === 'efectivo' ? 'selected' : '' ?>>Efectivo</option>
|
||||
<option value="transferencia" <?= $formaPago === 'transferencia' ? 'selected' : '' ?>>Transferencia</option>
|
||||
<option value="debito" <?= $formaPago === 'debito' ? 'selected' : '' ?>>Débito</option>
|
||||
<option value="credito" <?= $formaPago === 'credito' ? 'selected' : '' ?>>Crédito</option>
|
||||
<option value="echeq" <?= $formaPago === 'echeq' ? 'selected' : '' ?>>Echeq</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- TIPO DE PAGO -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Tipo de pago</label>
|
||||
<select class="form-select form-select-sm" name="tipo_pago" id="tipoPago">
|
||||
<option value="pago_unico" <?= $tipoPago === 'pago_unico' ? 'selected' : '' ?>>Pago Único</option>
|
||||
<option value="3_cuotas" <?= $tipoPago === '3_cuotas' ? 'selected' : '' ?>>3 Cuotas</option>
|
||||
<option value="6_cuotas" <?= $tipoPago === '6_cuotas' ? 'selected' : '' ?>>6 Cuotas</option>
|
||||
<option value="12_cuotas" <?= $tipoPago === '12_cuotas' ? 'selected' : '' ?>>12 Cuotas</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- DESCUENTO -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Descuento (%)</label>
|
||||
<div class="input-porcentaje">
|
||||
<input
|
||||
type="number"
|
||||
name="descuento"
|
||||
id="descuentoPago"
|
||||
value="<?= number_format($descuentoIngresado ?? 0, 2, '.', '') ?>"
|
||||
min="0"
|
||||
step="0.01"
|
||||
class="form-control form-control-sm text-end"
|
||||
>
|
||||
<span class="input-group-text">%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- RECARGO -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Recargo (%)</label>
|
||||
<div class="input-porcentaje">
|
||||
<input
|
||||
type="number"
|
||||
name="recargo"
|
||||
id="recargoPago"
|
||||
value="<?= number_format($recargoIngresado ?? 0, 2, '.', '') ?>"
|
||||
min="0"
|
||||
step="0.01"
|
||||
class="form-control form-control-sm text-end"
|
||||
>
|
||||
<span class="input-group-text">%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TOTALES -->
|
||||
|
||||
<div class="flex-shrink-0 mt-3">
|
||||
|
||||
<div class="d-flex align-items-center gap-2 mb-2">
|
||||
<h6 class="text-muted mb-0">Totales</h6>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
|
||||
<!-- SUBTOTAL -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Subtotal</label>
|
||||
<input class="form-control campo-readonly" readonly
|
||||
value="$ <?= number_format($subtotal, 2) ?>">
|
||||
</div>
|
||||
|
||||
<!-- DESCUENTO TOTAL -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Descuento</label>
|
||||
<input class="form-control campo-readonly" readonly
|
||||
value="$ <?= number_format($descuento, 2) ?>">
|
||||
</div>
|
||||
|
||||
<!-- RECARGO TOTAL -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa">Recargo</label>
|
||||
<input class="form-control campo-readonly" readonly
|
||||
value="$ <?= number_format($recargo, 2) ?>">
|
||||
</div>
|
||||
|
||||
<!-- TOTAL -->
|
||||
|
||||
<div class="col-md-3">
|
||||
<label class="label-formventa fw-semibold">Total</label>
|
||||
<input class="form-control campo-readonly fw-semibold" readonly
|
||||
value="$ <?= number_format($total, 2) ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ACCIONES -->
|
||||
|
||||
<div class="mt-4 pt- d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<!-- ACCIÓN SECUNDARIA (BORRADOR) -->
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-soft-secondary text-white py-2"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="Guarda la venta sin confirmarla para continuar más tarde">
|
||||
|
||||
<i class="fas fa-save me-1"></i>
|
||||
Guardar como borrador
|
||||
</button>
|
||||
|
||||
<!-- ACCIONES PRINCIPALES -->
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
formaction="index.php?opt=confirmar_venta"
|
||||
formmethod="POST"
|
||||
class="btn btn-primary py-2">
|
||||
<i class="fas fa-check me-1"></i>
|
||||
Confirmar venta
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Errores provenientes de ventaController -->
|
||||
|
||||
<!-- ERROR -->
|
||||
|
||||
<script>
|
||||
const serverErrors = <?php
|
||||
if (!empty($_SESSION['flash_error'])) {
|
||||
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
||||
unset($_SESSION['flash_error']);
|
||||
echo json_encode($errorsArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- SUCCES -->
|
||||
|
||||
<script>
|
||||
const serverSuccess = <?php
|
||||
if (!empty($_SESSION['flash_success'])) {
|
||||
$successArray = explode('<br>', $_SESSION['flash_success']);
|
||||
unset($_SESSION['flash_success']);
|
||||
echo json_encode($successArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- MODAL -->
|
||||
|
||||
<script src="js/globalModal.js"></script>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/ventas/ventaValidator.js"></script>
|
||||
|
||||
<!-- LÓGICA DE FORMA DE PAGOS -->
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
const formaPago = document.getElementById("formaPago");
|
||||
const tipoPago = document.getElementById("tipoPago");
|
||||
const recargoPago = document.getElementById("recargoPago");
|
||||
|
||||
const reglasPago = {
|
||||
efectivo: ['pago_unico'],
|
||||
transferencia: ['pago_unico'],
|
||||
echeq: ['pago_unico'],
|
||||
debito: ['pago_unico'],
|
||||
credito: ['pago_unico', '3_cuotas', '6_cuotas', '12_cuotas']
|
||||
};
|
||||
|
||||
function actualizarTipoPago() {
|
||||
|
||||
const forma = formaPago.value;
|
||||
const permitidos = reglasPago[forma] ?? ['pago_unico'];
|
||||
|
||||
Array.from(tipoPago.options).forEach(opt => {
|
||||
opt.disabled = !permitidos.includes(opt.value);
|
||||
});
|
||||
|
||||
// Si el valor actual no está permitido, forzamos uno válido
|
||||
|
||||
if (!permitidos.includes(tipoPago.value)) {
|
||||
tipoPago.value = permitidos[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Eventos
|
||||
|
||||
formaPago.addEventListener("change", actualizarTipoPago);
|
||||
|
||||
// Init
|
||||
|
||||
actualizarTipoPago();
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Evita que Chrome use BFCache -->
|
||||
|
||||
<script>
|
||||
window.onpageshow = function(event) {
|
||||
if (event.persisted) {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- Tooltip -->
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]');
|
||||
tooltipTriggerList.forEach(el => new bootstrap.Tooltip(el));
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Pasar al siguiente input en CUIT -->
|
||||
|
||||
<script>
|
||||
document.querySelectorAll("input[name^='cuit_']").forEach((input, index, inputs) => {
|
||||
input.addEventListener("input", () => {
|
||||
if (input.value.length === input.maxLength && inputs[index + 1]) {
|
||||
inputs[index + 1].focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,162 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0">
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<h4 class="mb-0 title-shadow">
|
||||
<i class="fas fa-users icon-xl me-2"></i>
|
||||
Selección de Cliente
|
||||
</h4>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<!-- BOTÓN FANTASMA (mantiene el layout) -->
|
||||
|
||||
<a class="btn btn-success invisible">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
</a>
|
||||
|
||||
<a href="?opt=crear_venta" class="btn btn-soft-secondary text-white">
|
||||
<i class="fas fa-arrow-left me-1"></i>
|
||||
Volver
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BODY -->
|
||||
|
||||
<div class="card-body px-4 py-4">
|
||||
|
||||
<?php if (empty($clientes)): ?>
|
||||
<div class="text-center text-muted py-5">
|
||||
No hay clientes registrados.
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<!-- FILTRO POR COLUMNA + BUSCADOR -->
|
||||
|
||||
<!-- Input de búsqueda añadido automáticamente por DataTables -->
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-1">
|
||||
|
||||
<div id="filtrosIzquierda" class="d-flex align-items-center gap-2">
|
||||
|
||||
<select id="columnFilter"
|
||||
class="form-select form-select-sm"
|
||||
style="width:auto;">
|
||||
<option value="">Todas las columnas</option>
|
||||
<option value="0">ID</option>
|
||||
<option value="1">Nombre</option>
|
||||
<option value="2">Apellido</option>
|
||||
<option value="3">Teléfono</option>
|
||||
<option value="4">Email</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<form method="POST" action="index.php?opt=seleccionar_cliente" novalidate>
|
||||
|
||||
<!-- CAMPO OCULTO (para verificación de token) -->
|
||||
|
||||
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="tablaClientes" class="table table-hover align-middle mb-0">
|
||||
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nombre</th>
|
||||
<th>Apellido</th>
|
||||
<th>Teléfono</th>
|
||||
<th>Email</th>
|
||||
<th>Seleccionar</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($clientes as $c): ?>
|
||||
<tr>
|
||||
<td><?= $c['id'] ?? '' ?></td>
|
||||
<td><?= htmlspecialchars($c['nombre'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($c['apellido'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($c['telefono'] ?? '') ?></td>
|
||||
<td><?= htmlspecialchars($c['email'] ?? '') ?></td>
|
||||
|
||||
<!-- CHECKBOX PARA SELECCIONAR CLIENTE -->
|
||||
|
||||
<td class="text-left">
|
||||
<input type="checkbox"
|
||||
name="id_cliente"
|
||||
value="<?= $c['id'] ?>"
|
||||
class="form-check-input">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- BOTÓN FINALIZAR SELECCIÓN -->
|
||||
|
||||
<div class="mt-3 text-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="fas fa-check me-1"></i> Finalizar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Errores provenientes de ventaController -->
|
||||
|
||||
<!-- ERROR -->
|
||||
|
||||
<script>
|
||||
const serverErrors = <?php
|
||||
if (!empty($_SESSION['flash_error'])) {
|
||||
$errorsArray = explode('<br>', $_SESSION['flash_error']);
|
||||
unset($_SESSION['flash_error']);
|
||||
echo json_encode($errorsArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
<!-- SUCCES -->
|
||||
|
||||
<script>
|
||||
const serverSuccess = <?php
|
||||
if (!empty($_SESSION['flash_success'])) {
|
||||
$successArray = explode('<br>', $_SESSION['flash_success']);
|
||||
unset($_SESSION['flash_success']);
|
||||
echo json_encode($successArray);
|
||||
} else {
|
||||
echo '[]';
|
||||
}
|
||||
?>;
|
||||
</script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/ventas/ventaValidator.js"></script>
|
||||
|
||||
<!-- Tabla, búsqueda y filtro por columnas -->
|
||||
|
||||
<script src="js/ventas/ventaTableCliente.js"></script>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
|
||||
<div class="container my-5">
|
||||
|
||||
<div class="card card-rounded card-shadow border-0">
|
||||
|
||||
<!-- HEADER -->
|
||||
|
||||
<div class="card-header header-dark px-4 py-3">
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
||||
|
||||
<h4 class="mb-0 title-shadow">
|
||||
<i class="fas fa-shopping-cart icon-xl me-2"></i>
|
||||
Detalle de Venta N° <?= htmlspecialchars($idVenta) ?>
|
||||
</h4>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<!-- BOTÓN FANTASMA (mantiene el layout) -->
|
||||
|
||||
<a class="btn btn-success invisible">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
</a>
|
||||
|
||||
<a href="?opt=listar_ventas" class="btn btn-soft-secondary text-white">
|
||||
<i class="fas fa-arrow-left me-1"></i>
|
||||
Volver
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- BODY -->
|
||||
|
||||
<div class="card-body px-4 py-4">
|
||||
|
||||
<?php if (empty($venta_detalle)): ?>
|
||||
<div class="text-center text-muted py-5">
|
||||
No existe el detalle de la venta.
|
||||
</div>
|
||||
<?php else: ?>
|
||||
|
||||
<!-- FILTRO POR COLUMNA + BUSCADOR -->
|
||||
|
||||
<!-- Input de búsqueda añadido automáticamente por DataTables -->
|
||||
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
|
||||
<select id="columnFilter"
|
||||
class="form-select form-select-sm ms-2"
|
||||
style="width: auto;">
|
||||
<option value="0">ID Producto</option>
|
||||
<option value="1">Producto</option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="tablaDetalleVenta" class="table table-hover align-middle mb-0">
|
||||
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Producto</th>
|
||||
<th>Precio Unit.</th>
|
||||
<th>Cantidad</th>
|
||||
<th>Descuento (%)</th>
|
||||
<th>Subtotal</th>
|
||||
<th>ID Pedido</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php foreach ($venta_detalle as $vd): ?>
|
||||
<tr>
|
||||
<td><?= $vd['id_producto'] ?? '' ?></td>
|
||||
<td><?= htmlspecialchars($vd['marca'] . ' ' . $vd['modelo']) ?? '' ?></td>
|
||||
<td>$ <?= number_format($vd['precio_unitario'], 2, '.', ',') ?></td>
|
||||
<td><?= htmlspecialchars($vd['cantidad'] ?? '') ?></td>
|
||||
<td><?= number_format($vd['descuento_pct'], 2, '.', ',') ?> %</td>
|
||||
<td>$ <?= number_format($vd['subtotal'], 2, '.', ',') ?></td>
|
||||
<td><?= htmlspecialchars($vd['id_pedido'] ?? '') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabla, búsqueda y filtro por columnas -->
|
||||
|
||||
<script src="js/ventas/ventaTableDetalle.js"></script>
|
||||
Reference in New Issue
Block a user