{% extends 'base.html.twig' %} {% block title %}Journal — {{ commercial.user.fullName }} — Admin{% endblock %} {% block body %}
{% include '_molecules/page-header/page-header.html.twig' with { title: 'Journal du commercial', subtitle: commercial.user.fullName ~ ' — ' ~ pagination.totalItems ~ (pagination.totalItems > 1 ? ' actions enregistrées' : ' action enregistrée'), icon: 'clock', backHref: path('admin_commercial_show', {id: commercial.id}), backLabel: 'Retour à la fiche' } only %} {# Le filtre est un GET simple, sans JavaScript : la page filtrée a sa propre URL, elle se partage et se recharge. #}
{% if actionCourante != '' %} {% include '_atoms/icon/icon.html.twig' with { name: 'close', size: 'xs' } only %} Tout voir {% endif %}
{% if logs|length > 0 %}
{% for log in logs %} {% set ctx = log.context ?? {} %}
{% include '_atoms/badge/badge.html.twig' with { label: activity_label(log.action), variant: activity_variant(log.action), size: 'sm' } only %}
{{ log.actorLabel }} {% if log.notes %} — {{ log.notes }} {% endif %} {# Le contexte est déjà écrit en français à l'écriture (CommercialActivityLogger) : rien à traduire ici. #} {% if ctx.modifications is defined or ctx.details is defined %}
{% for modif in ctx.modifications ?? [] %} {{ modif.champ }} {{ modif.avant }} {{ modif.apres }} {% endfor %} {% for libelle, valeur in ctx.details ?? {} %} {{ libelle }} {{ valeur }} {% endfor %}
{% endif %}
{{ log.createdAt|date('d/m/Y H:i') }}
{% endfor %}
{% if pagination.total > 1 %}
{# Le filtre doit survivre au changement de page : sans lui dans l'URL, la page 2 repartirait sur toutes les actions. #} {% include '_molecules/pagination/pagination.html.twig' with { currentPage: pagination.current, totalPages: pagination.total, baseUrl: path('admin_commercial_journal', actionCourante != '' ? {id: commercial.id, action: actionCourante} : {id: commercial.id}), size: 'sm' } only %}
{% endif %} {% else %}
{% include '_molecules/empty-state/empty-state.html.twig' with { title: actionCourante != '' ? 'Aucune action de ce type' : 'Journal vide', description: actionCourante != '' ? 'Ce commercial n\'a aucune action « ' ~ actions[actionCourante] ~ ' » enregistrée.' : 'Rien n\'a encore été enregistré pour ce commercial.', icon: 'clock', variant: 'minimal' } only %}
{% endif %}
{% endblock %}