{% extends 'base.html.twig' %} {% block title %}{{ item.name }} — Garde-manger{% endblock %} {% block theme_color %}#ffffff{% endblock %} {% block body_class %}bg-stone-50 dark:bg-stone-950{% endblock %} {% block body %} {# ── Hero image plein format ── #}
{% if item.imageUrl %} {{ item.name }} {% else %} {% set gradients = ['from-rose-100 to-rose-200','from-amber-100 to-amber-200','from-emerald-100 to-emerald-200','from-sky-100 to-sky-200','from-violet-100 to-violet-200','from-orange-100 to-orange-200'] %} {% set letters = ['text-rose-300','text-amber-300','text-emerald-300','text-sky-300','text-violet-300','text-orange-300'] %} {% set idx = item.id % 6 %}
{{ item.name|slice(0,1)|upper }}
{% endif %} {# Dégradé raccord vers la fiche #}
{# Barre de navigation #}
{# ── Fiche contenu (overlay arrondie) ── #}
{# ── Titre + statut ── #}
{% if item.brand %}

{{ item.brand }}

{% endif %}

{{ item.name }}

{{ item.status.label }} {% if item.category %} {{ item.category }} {% endif %}
{# ── Stock ── #}

Stock actuel

{{ item.stockQuantity }} {% if item.stockUnit %} {{ item.stockUnit }} {% endif %}

{% if stockInsight.estimatedDaysOfStockRemaining is not null and item.stockQuantity > 0 %}

Durée estimée

{{ stockInsight.estimatedDaysOfStockRemaining }}j

{% endif %}
{% if item.reorderThreshold is not null %} {% set pct = item.reorderThreshold > 0 ? min(item.stockQuantity / (item.reorderThreshold * 2) * 100, 100) : 100 %}

Niveau

Seuil : {{ item.reorderThreshold }}{% if item.stockUnit %} {{ item.stockUnit }}{% endif %}

{% endif %} {% if stockInsight.averageConsumedPerDay is not null %}

Consommation moy. : ~{{ stockInsight.averageConsumedPerDay|number_format(2, ',', ' ') }} / jour

{% endif %}
{# ── Nutrition : calories + donuts macros ── #} {% if item.nutriments %} {% set n = item.nutriments %} {% if n.calories is not null or n.proteins is not null or n.carbohydrates is not null or n.fat is not null %}
{# Bande calories #} {% if n.calories is not null %}

Calories

{{ n.calories|number_format(0) }}kcal

{% endif %} {# Donuts macros #} {% if n.proteins is not null or n.carbohydrates is not null or n.fat is not null %} {% set fatKcal = (n.fat ?? 0) * 9 %} {% set carbKcal = (n.carbohydrates ?? 0) * 4 %} {% set protKcal = (n.proteins ?? 0) * 4 %} {% set totalKcal = fatKcal + carbKcal + protKcal %} {% set protPct = totalKcal > 0 ? (protKcal / totalKcal * 100)|round : 0 %} {% set carbPct = totalKcal > 0 ? (carbKcal / totalKcal * 100)|round : 0 %} {% set fatPct = totalKcal > 0 ? (fatKcal / totalKcal * 100)|round : 0 %}
{% if n.proteins is not null %}
{{ protPct }}%

Protéines

{{ n.proteins|number_format(1) }}g

{% endif %} {% if n.carbohydrates is not null %}
{{ carbPct }}%

Glucides

{{ n.carbohydrates|number_format(1) }}g

{% endif %} {% if n.fat is not null %}
{{ fatPct }}%

Lipides

{{ n.fat|number_format(1) }}g

{% endif %}
{% endif %} {# Détail complet (collapsible) #}
{% endif %} {% endif %} {# ── Scores produit ── #} {% if item.nutriscoreGrade or item.novaGroup or item.ecoscoreGrade %}

Scores produit

{% if item.nutriscoreGrade %} {% set nsGrade = item.nutriscoreGrade %} {% set nsDesc = {'a':'Excellent','b':'Bon','c':'Moyen','d':'Mauvais','e':'Très mauvais'} %} {% set scaleC = {'a':'#038141','b':'#85BB2F','c':'#FECB02','d':'#EE8100','e':'#E63E11'} %}

Nutri-Score

{{ nsDesc[nsGrade] ?? '' }}

{{ nsGrade|upper }}
{% for g in ['a','b','c','d','e'] %}
{{ g|upper }}
{% endfor %}
{% endif %} {% if item.novaGroup %} {% set novaC = {1:'#038141',2:'#85BB2F',3:'#EE8100',4:'#E63E11'} %} {% set novaD = {1:'Non transformé',2:'Peu transformé',3:'Transformé',4:'Ultra-transformé'} %}

Groupe NOVA

{{ novaD[item.novaGroup] ?? '' }}

{{ item.novaGroup }}
{% for g in [1,2,3,4] %}
{{ g }}
{% endfor %}
{% endif %} {% if item.ecoscoreGrade %} {% set esGrade = item.ecoscoreGrade %} {% set esDesc = {'a':'Très faible impact','b':'Faible impact','c':'Impact modéré','d':'Impact élevé','e':'Très fort impact'} %} {% set scaleC = {'a':'#038141','b':'#85BB2F','c':'#FECB02','d':'#EE8100','e':'#E63E11'} %}

Éco-Score

{{ esDesc[esGrade] ?? '' }}

{{ esGrade|upper }}
{% for g in ['a','b','c','d','e'] %}
{{ g|upper }}
{% endfor %}
{% endif %}
{% endif %} {# ── Notre avis ── #}

Notre avis

{% if item.personalRating %}
{% for i in 1..5 %} {% endfor %} {{ item.personalRating }}/5
{% else %}

Aucune note pour l'instant.

{% endif %} {% if item.notes %}

"{{ item.notes }}"

{% endif %}
{# ── Historique consommation ── #} {% if consumptionHistory is not empty %}

Historique

{{ consumptionHistory|length }} entrée{{ consumptionHistory|length > 1 ? 's' : '' }}
{% for row in consumptionHistory %}

{{ row.quantity }}{% if item.stockUnit %} {{ item.stockUnit }}{% endif %}

{{ row.consumedAt|date('d/m · H:i') }}
{% endfor %}
{% endif %} {% if item.barcode %}

{{ item.barcode }}

{% endif %}
{# ── Modal configuration ── #} {# ── Barre d'actions flottante ── #}
{# ── Animations ── #} {% endblock %}