diff --git a/routes/admin_bp.py b/routes/admin_bp.py index b869419..e3aa227 100644 --- a/routes/admin_bp.py +++ b/routes/admin_bp.py @@ -281,16 +281,21 @@ def manage_products(): now = datetime.now() for zona in Zona.query.all(): + p_val = request.form.get(f'price_{zona.id}', '0') + c_val = request.form.get(f'comm_{zona.id}', '0') + price = int(str(p_val).replace('.', '').replace('$', '')) if p_val else 0 + commission = int(str(c_val).replace('.', '').replace('$', '')) if c_val else 0 + db.session.add(PrecioHistorico( producto_id=new_producto.id, zona_id=zona.id, - price=0, - commission=0, + price=price, + commission=commission, fecha_activacion=now, )) db.session.commit() - flash("Producto maestro creado. No olvides configurar sus precios.", "success") + flash("Producto maestro y sus precios creados exitosamente.", "success") except IntegrityError: db.session.rollback() flash("Ese producto ya existe en el catálogo.", "danger") diff --git a/templates/admin_productos.html b/templates/admin_productos.html index d718f9c..85b5e3e 100644 --- a/templates/admin_productos.html +++ b/templates/admin_productos.html @@ -1,31 +1,21 @@ {% extends "macros/base.html" %} -{% from 'macros/modals.html' import confirm_modal, edit_product_modal %} +{% from 'macros/modals.html' import confirm_modal, edit_product_modal, add_product_modal %} {% from "macros/ui.html" import flashed_messages %} {% block title %}Catálogo de Productos{% endblock %} {% block content %} -

Catálogo de Productos por Zona

+
+

Catálogo de Productos por Zona

+ +
{{ flashed_messages() }} {{ edit_product_modal(zonas) }} - -
-
Agregar Producto Maestro
-
-
-
-
- -
-
- -
-
-
-
-
+{{ add_product_modal(zonas) }}
diff --git a/templates/macros/modals.html b/templates/macros/modals.html index 178d29e..f83caad 100644 --- a/templates/macros/modals.html +++ b/templates/macros/modals.html @@ -82,6 +82,57 @@
{% endmacro %} +{% macro add_product_modal(zonas) %} + +{% endmacro %} + {% macro edit_worker_modal(modulos, bancos) %}