{% extends 'base.html.twig' %} {% set maxPerUser = stats.defaultAllocation * 6 %} {% block title %}Distribution des tokens - {{ company.name }}{% endblock %} {% block body %}
{# ================================================================ BREADCRUMB - Adapté selon le rôle (Admin vs Manager) ================================================================ #}
{% if is_granted('ROLE_ADMIN') %} {# Admin : voit la liste des entreprises #} {% include '_molecules/breadcrumb/breadcrumb.html.twig' with { homeHref: path('app_dashboard'), items: [ { label: 'Entreprises', href: path('admin_company_list') }, { label: company.name, href: path('admin_company_show', {uuid: company.uuid}) }, { label: 'Distribution des tokens' } ] } only %} {% else %} {# Manager : accès direct à son entreprise #} {% include '_molecules/breadcrumb/breadcrumb.html.twig' with { homeHref: path('app_dashboard'), items: [ { label: 'Mon entreprise', href: path('admin_company_show', {uuid: company.uuid}) }, { label: 'Distribution des tokens' } ] } only %} {% endif %}
{# ================================================================ HEADER ================================================================ #}
{% include '_atoms/icon/icon.html.twig' with { name: 'token', size: 'xl', color: 'primary' } only %}

Distribution des tokens

Gérez l'allocation mensuelle des tokens pour {{ company.name }}. Répartissez le budget entre les membres de l'équipe selon leurs besoins. {% if maxPerUser > 0 %} Le contrat autorise un stockage maximum de {{ maxPerUser|number_format(0, ',', ' ') }} tokens par utilisateur (6 mois d'accumulation). {% endif %}

{% include '_atoms/button/button.html.twig' with { label: 'Retour', variant: 'ghost', size: 'lg', icon: 'arrow-left', href: path('admin_company_show', {uuid: company.uuid}) } only %}
{# ================================================================ LAYOUT GRID : Sidebar (1 col) + Main (2 cols) Hauteur synchronisée avec scroll interne ================================================================ #} {% set allocatedPercent = stats.monthlyBudget > 0 ? (stats.totalAllocated / stats.monthlyBudget * 100)|round : 0 %}
{# ============================================================= SIDEBAR GAUCHE (1 col) - Design amélioré ============================================================= #} {# ============================================================= ZONE PRINCIPALE (2 cols) - Même hauteur avec scroll ============================================================= #}
{# Header fixe avec titre + recherche + actions #}
{# Ligne 1 : Titre + Actions #}
{% include '_atoms/icon/icon.html.twig' with { name: 'users-group', size: 'md', color: 'primary' } only %}

Équipe

{{ stats.users|length }} membre{{ stats.users|length > 1 ? 's' : '' }}

{# Actions #}
{% include '_atoms/button/button.html.twig' with { label: 'Tout remettre à 0', variant: 'soft-error', size: 'sm', icon: 'refresh', radius: 'lg', attr: { id: 'reset-all-btn' } } only %}
{% include '_atoms/button/button.html.twig' with { label: 'Répartir équitablement', variant: 'soft-primary', size: 'sm', icon: 'users-group', radius: 'lg', type: 'submit' } only %}
{# Ligne 2 : Barre de recherche (composition d'atomes : icon) #}
{# Corps scrollable #}
{% if stats.users|length > 0 %}
{% for userStat in stats.users|sort((a, b) => a.user.fullName <=> b.user.fullName) %} {% set member = userStat.user %} {% set allocation = userStat.monthlyAllocation %} {% set percentage = stats.monthlyBudget > 0 ? (allocation / stats.monthlyBudget * 100)|round : 0 %}
{# Infos utilisateur #}
{% include '_atoms/avatar/avatar.html.twig' with { name: member.fullName, size: 'sm' } only %}
{{ member.fullName }} Solde : {{ userStat.currentBalance|number_format(0, ',', ' ') }}
{# Slider + Input #}
{% endfor %}
{# Message "aucun résultat" (caché par défaut, affiché par JS) #} {% else %} {% include '_molecules/empty-state/empty-state.html.twig' with { title: 'Aucun utilisateur actif', description: "Il n'y a pas d'utilisateur actif dans cette entreprise.", icon: 'users', size: 'md' } only %} {% endif %}
{# ================================================================ JAVASCRIPT : Interactions sliders + budget ================================================================ #} {% block javascripts %} {{ parent() }} {% endblock %} {% endblock %}