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>
|
||||
Reference in New Issue
Block a user