{% extends "base.html" %} {% block title %}{% trans name=customer.display_name %}{{ name }} — Customer{% endtrans %}{% endblock %} {% block content %}
{# ── Back + Header ── #}
arrow_back {{ _("Back to Customers") }}

person {{ customer.display_name }} {% if has_bc %} {{ _("BC") }} {% endif %}

{% if customer.website %} {% set ws_href = customer.website if customer.website.startswith('http') else 'https://' + customer.website %}
link {{ customer.website }} open_in_new {% if site_check %} {% if site_check.is_online == true %} {% set tip = _('Online') %} {% if site_check.error_message %}{% set tip = _('Online') ~ ' (' ~ site_check.http_status ~ ' — ' ~ site_check.error_message ~ ')' %} {% elif site_check.http_status %}{% set tip = _('Online') ~ ' (' ~ site_check.http_status ~ ', ' ~ (site_check.response_time_ms or '?') ~ 'ms)' %}{% endif %} {% elif site_check.is_online == false %} {% set tip = _('Offline') %} {% if site_check.error_message %}{% set tip = _('Offline') ~ ' — ' ~ site_check.error_message %}{% endif %} {% endif %} {% if site_check.module_found == true %}{{ _("Module OK") }} {% elif site_check.module_found == false %}{{ _("Module ?") }}{% endif %} {% if site_check.last_check_at %}{% trans when=site_check.last_check_at %}checked {{ when }}{% endtrans %}{% endif %} {% endif %}
{% endif %}
{% if customer.country_code %} {{ customer.country_code }} {% endif %} {% if customer.language %} | {{ customer.language }} {% endif %} | {{ customer.customer_hash[:16] }}...
{# ── Stat cards ── #}

{{ _("Revenue") }}

€{{ customer.total_revenue }}

{{ _("Orders") }}

{{ customer.total_orders }}

{{ _("Products") }}

{{ customer.total_products }}

{{ _("Tickets") }}

{{ customer.total_threads }}

{# ── Info cards: BC + Support ── #}
{# Business Care card #}

verified {{ _("Business Care") }}

{% if has_bc and bc_info %}
{{ _("Status") }} {{ _("Active") }}
{{ _("Product") }} {{ bc_info.product_name or '--' }}
{{ _("Last BC Order") }} {{ bc_info.order_date.strftime('%Y-%m-%d') if bc_info.order_date else '--' }}
{{ _("Amount") }} €{{ bc_info.amount or '0' }}
{% else %}

{{ _("No Business Care subscription") }}

{% endif %}
{# Support Status card #}

support {{ _("Support Status") }}

{% if support_info %}
{{ _("Has Support") }} {% if support_info.has_support %} {{ _("Yes") }} {% elif support_info.has_support == false %} {{ _("No") }} {% else %} {{ _("Unknown") }} {% endif %}
{% if support_info.support_type %}
{{ _("Type") }} {{ support_info.support_type }}
{% endif %} {% if support_info.zen_type %}
{{ _("Zen Type") }} {{ support_info.zen_type }}
{% endif %} {% if support_info.effective_days_left is not none %}
{{ _("Days Left") }} {{ support_info.effective_days_left }} {% if support_info.bc_active %}{% trans until=support_info.effective_support_until.strftime('%Y-%m-%d') %}BC until {{ until }}{% endtrans %}{% endif %}
{% endif %} {% if support_info.support_expiration_date %}
{{ _("Expires") }} {{ support_info.support_expiration_date.strftime('%Y-%m-%d') }}
{% endif %}
{% else %}

{{ _("No support data available") }}

{% endif %}
{# ── Timeline row ── #}

{{ _("Timeline") }}

{{ _("First Order") }} {{ customer.first_order_date.strftime('%Y-%m-%d') if customer.first_order_date else '--' }}
{{ _("Last Order") }} {{ customer.last_order_date.strftime('%Y-%m-%d') if customer.last_order_date else '--' }}
{{ _("First Ticket") }} {{ customer.first_thread_date.strftime('%Y-%m-%d') if customer.first_thread_date else '--' }}
{{ _("Last Ticket") }} {{ customer.last_thread_date.strftime('%Y-%m-%d') if customer.last_thread_date else '--' }}
{# ── Inferred Purchases (from BC subscriptions) ── #} {% if inferred_products %}

lightbulb {{ _("Inferred Purchases") }} {{ _("(from Business Care subscriptions)") }}

{% for ip in inferred_products %}
{% if ip.pico_url %} {% else %}
inventory_2
{% endif %}
{{ ip.name }} {% trans bc_name=ip.bc_name %}Inferred from: {{ bc_name }}{% endtrans %}
{{ _("inferred") }}
{% endfor %}
{% endif %} {# ── Purchase History ── #}

receipt_long {{ _("Purchase History") }} ({{ orders|length }})

{% if orders %}
{% for o in orders %} {% endfor %}
{{ _("Date") }} {{ _("Order ID") }} {{ _("Product") }} {{ _("Type") }} {{ _("Amount") }}
{{ o.order_date.strftime('%Y-%m-%d') if o.order_date else '--' }} {{ o.id_order or o.provider_order_id }}
{% if o.product_type == 'business_care' %}
{{ _("BC") }}
{% elif o.pico_url %} {% endif %} {{ o.product_name or '--' }}
{% if o.transaction_type == 'income' %} {{ _("income") }} {% elif o.transaction_type == 'payment' %} {{ _("payment") }} {% else %} {{ o.transaction_type or '--' }} {% endif %} {% if o.transaction_type == 'income' %} €{{ o.amount or '0' }} {% elif o.transaction_type == 'payment' %} €{{ o.amount or '0' }} {% else %} €{{ o.amount or '0' }} {% endif %}
{% else %}

{{ _("No purchase history") }}

{% endif %}
{# ── Support Threads ── #}

forum {{ _("Support Threads") }} ({{ threads|length }})

{% if threads %}
{% for t in threads %} {% endfor %}
{{ _("Subject") }} {{ _("Product") }} {{ _("Status") }} {{ _("Priority") }} {{ _("Support") }} {{ _("Last Activity") }}
{% if t.ticket_id %} {{ t.subject | truncate(50) }} {% else %} {{ t.subject | truncate(50) }} {% endif %} {{ t.product_name or '--' }} {% if t.status == 'open' %} {{ _("open") }} {% elif t.status == 'in_progress' %} {{ _("in progress") }} {% elif t.status == 'waiting_customer' %} {{ _("waiting") }} {% elif t.status == 'closed' %} {{ _("closed") }} {% else %} -- {% endif %} {% if t.priority %} {% if t.priority == 'p1' %}{{ _("Critical") }}{% elif t.priority == 'p2' %}{{ _("High") }}{% elif t.priority == 'p3' %}{{ _("Normal") }}{% else %}{{ _("Low") }}{% endif %} {% else %} -- {% endif %} {% if t.is_support_expired %} {{ _("expired") }} {% elif t.has_support %} {{ _("active") }} {% elif t.has_support == false %} {{ _("none") }} {% else %} -- {% endif %} {{ t.last_activity_at|localdt('%Y-%m-%d') if t.last_activity_at else '--' }}
{% else %}

{{ _("No support threads") }}

{% endif %}
{% endblock %}