{% extends "layouts/base.twig" %} {% block title %}{{ translations.rms_all_title }}{% endblock %} {% block head %} {% endblock %} {% block page_heading %}

{{ translations.rms_all_heading }}

{{ translations.rms_all_subtitle }}

{% endblock %} {% block content %} {% include "page_components/messages.twig" %} {# Preset date range badges #} {% set today = 'now'|date('Y-m-d') %} {% set d7 = ('now - 6 days')|date('Y-m-d') %} {% set d30 = ('now - 29 days')|date('Y-m-d') %} {% set d90 = ('now - 89 days')|date('Y-m-d') %} {% set monthStart = 'now'|date('Y-m-01') %} {% set lastMonthStart = ('first day of last month')|date('Y-m-d') %} {% set lastMonthEnd = ('last day of last month')|date('Y-m-d') %} {% set yearStart = 'now'|date('Y-01-01') %} {% set presets = [ { key: 'today', label: translations.rms_preset_today ?? 'Today', from: today, to: today }, { key: '7d', label: translations.rms_preset_7d ?? 'Last 7 days', from: d7, to: today }, { key: '30d', label: translations.rms_preset_30d ?? 'Last 30 days', from: d30, to: today }, { key: '90d', label: translations.rms_preset_90d ?? 'Last 90 days', from: d90, to: today }, { key: 'this_month', label: translations.rms_preset_this_month ?? 'This month', from: monthStart, to: today }, { key: 'last_month', label: translations.rms_preset_last_month ?? 'Last month', from: lastMonthStart, to: lastMonthEnd }, { key: 'ytd', label: translations.rms_preset_ytd ?? 'YTD', from: yearStart, to: today } ] %}
{{ translations.rms_presets_label ?? 'Quick range:' }} {% for p in presets %} {{ p.label }} {% endfor %}
{# Filter form #}
{% if sales is empty %}

{{ translations.rms_all_no_data }}

{% else %} {# KPI summary #} {% set totalQty = 0 %} {% set productCount = sales|length %} {% set shopSet = [] %} {% for row in sales %} {% set totalQty = totalQty + row.total_sold_quantity %} {% for shop in row.shops %} {% if shop.shop_id not in shopSet %} {% set shopSet = shopSet|merge([shop.shop_id]) %} {% endif %} {% endfor %} {% endfor %}
{{ translations.rms_kpi_products }}
{{ productCount }}
{{ params.from }} → {{ params.to }}
{{ translations.rms_all_kpi_shops }}
{{ shopSet|length }}
{{ translations.rms_all_kpi_shops_sub }}
{# Results table #}
{{ translations.rms_all_table_title }}
{% set maxQty = sales[0].total_sold_quantity %} {% set shopColors = ['#6366F1','#22C55E','#F59E0B','#EF4444','#14B8A6','#8B5CF6','#F97316','#06B6D4','#EC4899','#84CC16'] %} {% for row in sales %} {% endfor %}
{{ translations.rms_col_product }} {{ translations.rms_col_sku }} {{ translations.rms_col_material }} {{ translations.rms_col_qty }} {{ translations.rms_all_col_shop_breakdown }}
{{ row.catalog_product_name }} {{ row.catalog_product_sku }} {{ row.material_name }} {{ row.total_sold_quantity|number_format(3, '.', ' ')|replace({'.000': '', ',000': ''}) }} {{ row.unit_name }}
{{ maxQty > 0 ? ((row.total_sold_quantity / maxQty) * 100)|round : 0 }}%
{% for i, shop in row.shops %}
{{ shop.shop_name }}
{{ shop.share }}%
{% endfor %}
{% endif %} {% endblock %} {% block scripts %} {{ parent() }} {% if sales is not empty %} {% endif %} {% endblock %}