{% extends 'base.html.twig' %} {% block title %}{{ company.name }} - Admin{% endblock %} {% block body %}
{# ========================================================================= BREADCRUMB ========================================================================= #}
{% include '_molecules/breadcrumb/breadcrumb.html.twig' with { homeHref: path('app_dashboard'), items: isAdmin ? [ { label: 'Entreprises', href: path('admin_company_list') }, { label: company.name } ] : [ { label: company.name } ] } only %}
{# ========================================================================= HEADER ENTREPRISE ========================================================================= #}
{# Partie gauche: Avatar + Infos #}
{# Avatar entreprise #} {% include '_atoms/avatar/avatar.html.twig' with { initials: company.name|slice(0, 2)|upper, size: '2xl', rounded: 'xl', variant: company.isActive ? 'primary' : 'gray' } only %}
{# Nom + Badge statut #}

{{ company.name }}

{% include '_atoms/badge/badge.html.twig' with { preset: company.isActive ? 'company-active' : 'company-inactive', size: 'md' } only %}
{# Description #} {% if company.description %}

{{ company.description }}

{% endif %} {# Meta infos (ville, email) #}
{% if company.city %} {% include '_atoms/icon/icon.html.twig' with { name: 'home', size: 'sm', color: 'gray' } only %} {{ company.city }} {% endif %} {% if company.email %} {% include '_atoms/icon/icon.html.twig' with { name: 'mail', size: 'sm', color: 'gray' } only %} {{ company.email }} {% endif %}
{# Partie droite: Boutons d'action #} {% if isAdmin %}
{% include '_atoms/button/button.html.twig' with { label: 'Retour', variant: 'ghost', icon: 'arrow-left', size: 'md', href: path('admin_company_list') } only %}
{% include '_atoms/button/button.html.twig' with { label: 'Modifier', variant: 'primary', icon: 'edit', size: 'md', width: 'full', href: path('admin_company_edit', {uuid: company.uuid}) } only %}
{% endif %}
{# ========================================================================= LAYOUT 2 COLONNES ========================================================================= #}
{# ================================================================= COLONNE PRINCIPALE ================================================================= #}
{# ----- Section Contrats ----- #}
{# Header custom avec titre + count à gauche, bouton à droite #}
{% include '_atoms/icon/icon.html.twig' with { name: 'file-text', size: 'md', color: 'primary' } only %}

Contrats

{{ allContracts|length }}
{% if isAdmin %}
{% include '_atoms/button/button.html.twig' with { label: 'Nouveau', variant: 'primary', icon: 'plus', size: 'md', width: 'full', href: path('admin_contract_new', {companyUuid: company.uuid}) } only %}
{% endif %}
{# Body #} {% if allContracts|length > 0 %}
{% for contract in allContracts %} {% set contractStatus = contract.status %} {% include '_molecules/contract-row/contract-row.html.twig' with { name: contract.name, startDate: contract.startDate, endDate: contract.endDate, tokens: contract.monthlyTokens, maxUsers: contract.maxUsers, status: contractStatus, daysRemaining: contract.daysRemaining, isExpiringSoon: contract.isExpiringSoon(30), isActive: contractStatus != 'expired' and contractStatus != 'disabled', hasSamAccess: company.hasSamAccess, href: path('admin_contract_show', {companyUuid: company.uuid, contractUuid: contract.uuid}) } only %} {% endfor %}
{% else %} {% include '_molecules/empty-state/empty-state.html.twig' with { title: 'Aucun contrat', icon: 'file-text', size: 'sm', actionText: isAdmin ? 'Créer un contrat' : null, actionHref: isAdmin ? path('admin_contract_new', {companyUuid: company.uuid}) : null, actionIcon: 'plus' } only %} {% endif %}
{# ----- Section Utilisateurs ----- #}
{# Header custom avec titre + count à gauche, boutons à droite #}
{% include '_atoms/icon/icon.html.twig' with { name: 'users', size: 'md', color: 'primary' } only %}

Utilisateurs

{{ stats.total }}
{% if isAdmin %}
{% include '_atoms/button/button.html.twig' with { label: 'Associer', variant: 'outline', icon: 'user-add', size: 'md', width: 'full', attr: { onclick: "openModal('modal-associate-user')" } } only %}
{% endif %} {% if isAdmin or app.user.isActive %}
{% include '_atoms/button/button.html.twig' with { label: 'Ajouter', variant: 'primary', icon: 'plus', size: 'md', width: 'full', href: path('admin_user_new') } only %}
{% endif %}
{# Body — chargé en Turbo Frame (évite le rendu en boucle de N templates) #}
{# Skeleton de chargement #}
{% for i in 1..3 %}
{% endfor %}
{# ================================================================= SIDEBAR (Colonne droite) ================================================================= #}
{# ----- Carte Informations ----- #} {% embed '_molecules/card/card.html.twig' with { title: 'Informations', padding: 'none' } %} {% block body %}
{% include '_molecules/data-row/data-row.html.twig' with { label: 'SIRET', value: company.siret ? company.siret : null, class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Adresse', value: company.address|default(null), class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Ville', value: (company.postalCode or company.city) ? ((company.postalCode ?? '') ~ ' ' ~ (company.city ?? ''))|trim : null, class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Téléphone', value: company.phone|default(null), class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Site web', value: company.website ? company.website|replace({'http://': 'https://'}) : null, class: 'py-2' } only %}
{% if isAdmin %}
Créé le {{ company.createdAt|date('d/m/Y') }} {% if company.createdBy %}par {{ company.createdBy.fullName }}{% endif %}
{% endif %} {% endblock %} {% endembed %} {# ----- Carte Configuration Moodle ----- #} {% embed '_molecules/card/card.html.twig' with { title: 'Configuration Moodle', padding: 'none' } %} {% block body %}
{% include '_molecules/data-row/data-row.html.twig' with { label: 'URL Moodle', value: company.moodleUrl|default(null), class: 'py-2' } only %}
Token API {% if company.moodleToken %} {{ maskedMoodleToken|default('••••••••••••') }} {% else %} Non configuré {% endif %}
Statut {% if company.moodleUrl and company.moodleToken %} {% include '_atoms/icon/icon.html.twig' with { name: 'refresh', size: 'sm', color: 'gray' } only %} Vérification... {% else %} {% include '_atoms/icon/icon.html.twig' with { name: 'warning', size: 'sm', color: 'gray' } only %} Non configuré {% endif %}
{% if isAdmin %}
{% include '_atoms/button/button.html.twig' with { label: 'Configurer Moodle', variant: 'ghost', icon: 'settings', size: 'md', width: 'full', href: path('admin_company_edit', {uuid: company.uuid}) } only %}
{% endif %} {% endblock %} {% endembed %} {# ----- Carte Tokens ----- #} {% embed '_molecules/card/card.html.twig' with { title: 'Tokens', padding: 'none' } %} {% block body %}
{% include '_molecules/data-row/data-row.html.twig' with { label: 'Budget mensuel', value: contractLimits.monthlyTokens|default(0)|number_format(0, ',', ' '), valueColor: 'primary', class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Déjà alloués', value: distributionStats.totalAllocated|default(0)|number_format(0, ',', ' '), class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Restants à distribuer', value: distributionStats.remainingBudget|default(0)|number_format(0, ',', ' '), valueColor: distributionStats.remainingBudget|default(0) < 0 ? 'error' : 'success', class: 'py-2' } only %} {% include '_molecules/data-row/data-row.html.twig' with { label: 'Plafond stockage', value: tokenStats.maxStorage|default(0)|number_format(0, ',', ' '), class: 'py-2' } only %}
{% include '_atoms/button/button.html.twig' with { label: 'Gérer la distribution', variant: 'primary', icon: 'token', size: 'md', width: 'full', href: path('admin_company_tokens', {uuid: company.uuid}) } only %}
{% endblock %} {% endembed %}
{# ----- Historique des actions (pleine largeur, sous la grille) ----- #} {% if isAdmin %} {% include '_organisms/activity-log/activity-log-section.html.twig' with { logs: logs ?? [] } only %} {% endif %} {# ========================================================================= SECTION: GESTION DE L'ENTREPRISE (en bas de page) ========================================================================= #} {% if isAdmin %}
{% include '_molecules/section-divider/section-divider.html.twig' with { title: "Gestion de l'entreprise", icon: 'settings', iconColor: 'error' } only %}
{# Zone Statut #} {% include '_molecules/status-zone/status-zone.html.twig' with { title: 'Statut de l\'entreprise', description: company.isActive ? 'Cette entreprise est actuellement active. Les utilisateurs peuvent accéder aux services.' : 'Cette entreprise est actuellement inactive. L\'accès aux services est bloqué.', icon: 'power', variant: company.isActive ? 'success' : 'warning', buttonLabel: company.isActive ? 'Désactiver' : 'Activer', buttonIcon: 'power', buttonVariant: company.isActive ? 'warning' : 'success', modalId: 'modal-toggle-status' } only %} {# Zone Danger #} {% include '_molecules/status-zone/status-zone.html.twig' with { title: 'Zone danger', description: 'La suppression d\'une entreprise est définitive et supprimera également tous les contrats associés.', icon: 'trash', variant: 'error', buttonLabel: 'Supprimer', buttonIcon: 'trash', buttonVariant: 'error', modalId: 'modal-delete-company' } only %}
{# Modal de changement de statut #} {% include 'admin/company/_modal_toggle.html.twig' with {company: company, modal_id: 'modal-toggle-status'} %} {# Modal de suppression #} {% include 'admin/company/_modal_delete.html.twig' with {company: company, modal_id: 'modal-delete-company'} %} {% endif %} {# Modal de dissociation #} {% include 'admin/company/_modal_dissociate_shared.html.twig' with {company: company} %} {# Modal d'association (admin uniquement) #} {% if isAdmin %} {% include 'admin/company/_modal_associate_user.html.twig' with {company: company} %} {% endif %}
{% endblock %}