{# templates/macros.html #} {% macro color_por_dias(dias) %} {% if dias <= 29 %} bg-teal-200 {% elif dias <=59 %} bg-yellow-200 {% elif dias <=89 %} bg-orange-200 {% else %} bg-red-200 {% endif %} {% endmacro %} {% macro render_date(label, name, fecha) %}
{% endmacro %} {% macro render_input(label, name, value='', type='text', placeholder='', required=True) %}
{% endmacro %} {% macro render_select(label, name, items, selected_value) %}
{% endmacro %} {% macro render_submit_button(label) %}
{% endmacro %} {% macro render_no_data() %}
[{{ datetime.now().strftime('%H:%M:%S') }}] No se encontró data con los parámetros seleccionados.
{% endmacro %} {% macro render_email(email, nro_marcas) %} {% if email %} {% set pdf_urls = email.pdf_url or [] %}
Email ({{ nro_marcas }}M)
{% for url in pdf_urls %} {% endfor %}
{% if pdf_urls %}
    {% for url in pdf_urls %} {% set clean_url = url.replace('%5C', '/').replace('\\', '/').replace('%20', ' ') %}
  1. {{ clean_url.rsplit('/', 1)[-1] }}
  2. {% endfor %}
{% endif %}

{{ email.rendered_html | safe }}
{% endif %} {% endmacro %} {% macro render_html_json(html, json) %}
Ver HTML y JSON
HTML
         {{ html | e }}
            
JSON
        {{ json | tojson(indent=2) }}
      
{% endmacro %} {% macro render_cliente_propietarios(i, cliente, propietarios) %}

Notificación #{{ i }}

Cliente {{ cliente }}
{% set lista = propietarios or [] %} {% set plural = lista|length > 1 %} {% if lista %}
{{ "Solicitantes | Propietarios" if plural else "Solicitante | Propietario" }} {% for p in lista %} {{ loop.index ~ '. ' if plural else '' }}{{ p.nombre }} {% endfor %}
{% endif %}
{% endmacro %} {% macro render_marcas(marcas) %} {% if marcas %} {% set total = marcas | length %}
{{ 'Marca' if total == 1 else 'Marcas' }} ({{ total }}) {% for marca in marcas %}
Marca {{ loop.index }}
{% for key, value in marca | dictsort %} {% set value_str = value|string %} {% if value_str | trim %}
{% if value_str.startswith('https://') and (value_str.endswith('.jpg') or value_str.endswith('.png')) %} {{ key | replace('_', ' ') }}:
{{ key }} {% else %} {{ key | replace('_', ' ') }}: {{ value_str }} {% endif %}
{% endif %} {% endfor %}
{% endfor %}
{% endif %} {% endmacro %} {% macro render_facturas(facturas) %} {% if facturas %}
{{ 'Factura' if facturas|length == 1 else 'Facturas' }} ({{ facturas|length }}) {% for f in facturas %} {% set dias_int = f.get('dias_vencido') if f.get('dias_vencido') is number else 0 %} {% set color_class = '' %} {% if dias_int > 0 %} {% if dias_int <= 30 %} {% set color_class='bg-green-100' %} {% elif dias_int <=60 %} {% set color_class='bg-yellow-100' %} {% elif dias_int <=90 %} {% set color_class='bg-orange-100' %} {% else %} {% set color_class='bg-red-100' %} {% endif %} {% endif %}
Factura {{ loop.index }}  No.: {{ f.nro }}  Fecha: {{ f.fecha }}
Estado: {{ f.estado }} {% if dias_int > 0 %} ({{ dias_int }} días) {% endif %}
Cliente: {{ f.cliente }}
Resumen: {{ f.resumen }}
{% endfor %}
{% endif %} {% endmacro %} {% macro javascript_enviar_correo() %} {% endmacro %}