{# templates/benchmarks/observation_items.twig #} {% extends "layouts/base.twig" %} {% block title %}{{ translations.benchmark_observation_items ?? 'Benchmark: Observation items' }}{% endblock %} {% block head %} {{ parent() }} {% endblock %} {% block page_heading %}

{{ translations.benchmark ?? 'Benchmark' }} — {{ translations.observation_items ?? 'Observation items' }}

{{ translations.benchmark_observation_items_subtitle ?? 'Add competitor products, match them to your products and keep prices consistent.' }}

{% endblock %} {% block content %} {# -------------------------------- INPUT DATA (expected from backend) -------------------------------- observation: CompetitorObservationModel competitor: CompetitorModel (optional, if you pass it) products: ProductModel[] (your products) categories: (optional) list of your categories for selection, else we derive from products #} {% set obs = observation %} {% set items = obs.getItems() ?? [] %} {% set totalItems = items|length %} {% set totalPromo = 0 %} {% for it in items %} {% if it.isPromo() %}{% set totalPromo = totalPromo + 1 %}{% endif %} {% endfor %}
{# =========================== HERO / OBS SUMMARY =========================== #}

{{ obs.getObservedAt() ?? '-' }}

{{ translations.observation_id ?? 'Observation' }} #{{ obs.getId() }} {{ translations.items ?? 'Items' }}: {{ totalItems }} {{ translations.promotions ?? 'Promo' }}: {{ totalPromo }}
{% if obs.getNotes() %}
{{ obs.getNotes() }}
{% endif %}
{{ translations.created_at ?? 'Created' }}: {{ obs.getCreatedAt() ?? '-' }} {{ translations.updated_at ?? 'Updated' }}: {{ obs.getUpdatedAt() ?? '-' }}
{{ translations.search_items_hint ?? 'Type to filter the list instantly.' }}
{# =========================== LIST (table) =========================== #}

{{ translations.observation_items ?? 'Observation items' }}

{{ translations.observation_items_hint ?? 'Tip: match items to your products to enable comparisons.' }}
{% if items is empty %}
{{ translations.no_items_yet ?? 'No items yet. Add your first competitor product.' }}
{% else %}
{% for it in items %} {% set id = it.getId() %} {% set nameRaw = it.getNameRaw() ?? '-' %} {% set unitType = it.getUnitType() ?? '' %} {% set unitSize = it.getUnitSize() ?? '' %} {% set price = it.getPrice() %} {% set promoPrice = it.getPromoPrice() %} {% set isPromo = it.isPromo() ? 1 : 0 %} {% set notes = it.getNotes() ?? '' %} {% set myProductId = it.getMyProductId() %} {% set quality = it.getQualityScore() ?? null %} {% set myCatId = it.getMyCategoryId() ?? null %} {% set myProductName = it.getMyProductName() ?? '' %} {% set myCatName = it.getMyCategoryName() ?? '' %} {% set searchText = (nameRaw ~ ' ' ~ notes ~ ' ' ~ myCatName ~ ' ' ~ myProductName)|lower %} {% endfor %}
{{ translations.competitor_product ?? 'Competitor product' }} {{ translations.unit ?? 'Unit' }} {{ translations.price ?? 'Price' }} {{ translations.match_to_my_product ?? 'Match to my product' }} {{ translations.quality ?? 'Quality' }} {{ translations.actions ?? 'Actions' }}
{{ nameRaw }}
{% if notes %} {{ notes }} {% else %} {{ translations.no_notes ?? 'No notes' }} {% endif %}
{% if isPromo %} {{ translations.promo ?? 'Promo' }} {% endif %} {% if myCatId %} {{ translations.category ?? 'Category' }}: {{ myCatName ?: ('#' ~ myCatId) }} {% endif %}
{{ unitType ?: '-' }} {% if unitSize %} {{ unitSize }} {% endif %}
{{ price is not null ? price : '-' }} {% if isPromo and promoPrice is not null %} {{ promoPrice }} {% endif %}
{% if myProductId %}
{{ myProductName ?: (translations.matched ?? 'Matched') }} {{ myCatName ?: (translations.category ?? 'Category') }}
{% else %} - {% endif %}
{% if quality is not null %} {{ quality }}/10 {% else %} - {% endif %}
{% endif %}
{# ========================== MODAL: CREATE / EDIT ITEM ========================== #} {% endblock %} {% block scripts %} {% endblock %}