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_presupuesto" 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_presupuesto" 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; ?>
|
||||
|
||||
<!-- Manejo de errores provenientes de presupuestoController -->
|
||||
|
||||
<!-- 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/presupuestos/presupuestoValidator.js"></script>
|
||||
|
||||
<!-- Tabla, búsqueda y filtro por columnas -->
|
||||
|
||||
<script src="js/presupuestos/presupuestoTableProducto.js"></script>
|
||||
@@ -0,0 +1,270 @@
|
||||
<?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-file-invoice-dollar icon-xl me-2"></i>
|
||||
Nuevo Presupuesto
|
||||
</h4>
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
<a class="btn btn-success invisible">
|
||||
<i class="fas fa-plus me-1"></i>
|
||||
</a>
|
||||
|
||||
<a href="?opt=crear_cliente&from=crear_presupuesto" 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_presupuesto" 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_presupuesto" 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_presupuesto" 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_presupuesto"
|
||||
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="tablaProductosPresupuesto" 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_presupuesto" 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 class="text-left">
|
||||
$ <?= number_format($p['precio'], 2) ?>
|
||||
</td>
|
||||
|
||||
<td class="text-left">
|
||||
<?= htmlspecialchars($p['descuento_total']) ?>%
|
||||
</td>
|
||||
|
||||
<td class="text-left">
|
||||
<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_presupuesto"
|
||||
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 Presupuesto</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_presupuesto" class="btn btn-primary py-2">
|
||||
Siguiente
|
||||
<i class="fas fa-arrow-right ms-1"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Errores provinientes de presupuestoController -->
|
||||
|
||||
<!-- 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/presupuestos/presupuestoValidator.js"></script>
|
||||
@@ -0,0 +1,418 @@
|
||||
<?php require __DIR__ . '/../../includes/navBar.php'; ?>
|
||||
|
||||
<?php
|
||||
// Datos desde back end (si existen)
|
||||
|
||||
$presupuesto = $_SESSION['presupuesto_extra'] ?? [];
|
||||
|
||||
$condIva = $presupuesto['cond_iva'] ?? 'consumidor_final';
|
||||
$cuit = $presupuesto['cuit'] ?? '';
|
||||
$formaPago = $presupuesto['forma_pago'] ?? 'efectivo';
|
||||
$tipoPago = $presupuesto['tipo_pago'] ?? 'pago_unico';
|
||||
$descuentoIngresado = $presupuesto['descuento'] ?? 0;
|
||||
$recargoIngresado = $presupuesto['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 Presupuesto
|
||||
</h4>
|
||||
|
||||
<a href="?opt=crear_presupuesto" 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_presupuesto" method='POST' action="index.php?opt=guardar_datos_presupuesto" 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 align-middle table-hover 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 el presupuesto sin confirmarlo para continuar más tarde">
|
||||
|
||||
<i class="fas fa-save me-1"></i>
|
||||
Guardar como borrador
|
||||
</button>
|
||||
|
||||
<!-- ACCION PRINCIPAL -->
|
||||
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
formaction="index.php?opt=generar_presupuesto_pdf"
|
||||
formmethod="POST"
|
||||
class="btn btn-success py-2">
|
||||
<i class="fas fa-file-alt me-1"></i>
|
||||
Generar comprobante
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Errores provenientes de presupuestoController -->
|
||||
|
||||
<!-- 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>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Validar mediante js -->
|
||||
|
||||
<script src="js/presupuestos/presupuestoValidator.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', '3_cuotas', '6_cuotas', '12_cuotas'],
|
||||
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_presupuesto" 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_presupuesto" 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 presupuestoController -->
|
||||
|
||||
<!-- 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/presupuestos/presupuestoValidator.js"></script>
|
||||
|
||||
<!-- Tabla, búsqueda y filtro por columnas -->
|
||||
|
||||
<script src="js/presupuestos/presupuestoTableCliente.js"></script>
|
||||
Reference in New Issue
Block a user