feat: add complementos feature for linking multiple accessories and quantities to products

This commit is contained in:
2026-06-22 03:35:06 -04:00
parent 97cbe13196
commit 606ed94722
6 changed files with 231 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
{% extends "macros/base.html" %}
{% from 'macros/modals.html' import confirm_modal, edit_product_modal, add_product_modal %}
{% from 'macros/modals.html' import confirm_modal, edit_product_modal, add_product_modal, manage_complementos_modal %}
{% from "macros/ui.html" import flashed_messages %}
{% block title %}Catálogo de Productos{% endblock %}
@@ -28,6 +28,7 @@
<thead class="table-dark">
<tr>
<th>Producto Maestro</th>
<th>Complementos de Regalo</th>
<th class="text-end">Acciones</th>
</tr>
</thead>
@@ -35,10 +36,22 @@
{% for prod in productos %}
<tr class="product-row">
<td class="align-middle fw-bold">{{ prod.name }}</td>
<td class="align-middle">
{% if prod.complementos %}
{% for comp in prod.complementos %}
<span class="badge bg-secondary mb-1" style="font-size: 0.85em;">{{ comp.name }} (x{{ comp.cantidad }})</span>
{% endfor %}
{% else %}
<span class="text-muted italic small">Sin complementos</span>
{% endif %}
</td>
<td class="text-end">
<button type="button" class="btn btn-info btn-sm text-white" onclick="showHistory({{ prod.id }}, '{{ prod.name }}')">
<i class="bi bi-graph-up"></i> Historial
</button>
<button type="button" class="btn btn-warning btn-sm text-dark" data-bs-toggle="modal" data-bs-target="#complementosModal{{ prod.id }}">
<i class="bi bi-gift"></i> Complementos
</button>
<button type="button" class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#pricesModal{{ prod.id }}">
<i class="bi bi-currency-dollar"></i> Precios
</button>
@@ -54,6 +67,7 @@
btn_class='btn-danger',
btn_text='Eliminar'
) }}
{{ manage_complementos_modal(prod, complementos_catalogo) }}
</td>
</tr>
{% endfor %}
@@ -174,6 +188,22 @@
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="row g-2 mb-3 bg-light-subtle border p-2 rounded align-items-end">
<div class="col-md-5">
<label class="form-label small text-muted mb-1">Desde</label>
<input type="date" class="form-control form-control-sm" id="chartFilterDesde">
</div>
<div class="col-md-5">
<label class="form-label small text-muted mb-1">Hasta</label>
<input type="date" class="form-control form-control-sm" id="chartFilterHasta">
</div>
<div class="col-md-2">
<button type="button" class="btn btn-primary btn-sm w-100" id="btnFilterChart"><i class="bi bi-filter"></i> Filtrar</button>
</div>
</div>
<div class="alert alert-info py-1 px-2 mb-2 text-center" style="font-size: 0.85em;">
<i class="bi bi-info-circle-fill me-1"></i> Puedes hacer clic en los nombres de las zonas en la leyenda de arriba para ocultar o mostrar sus líneas en el gráfico.
</div>
<canvas id="priceChart" width="400" height="200"></canvas>
</div>
</div>