{# @tailwind-safelist bg-primary/10 bg-cohorts/10 bg-warning/10 bg-error/10 bg-success/10 bg-info/10 bg-pink/10 text-primary text-cohorts text-warning text-error text-success text-info text-pink #} {% extends 'base.html.twig' %} {% block title %}Gestion des entreprises - Admin{% endblock %} {% block body %}
{# ================================================================ HEADER ================================================================ #}
{% include '_molecules/page-header/page-header.html.twig' with { title: 'Gestion des entreprises', subtitle: 'Consultez et gérez l\'ensemble des entreprises partenaires. Créez de nouvelles structures, configurez leurs accès Moodle et suivez leurs contrats.', icon: 'buildings', backHref: path('app_dashboard'), backLabel: 'Retour au dashboard' } only %} {% include '_atoms/button/button.html.twig' with { label: 'Nouvelle entreprise', variant: 'primary', size: 'lg', icon: 'plus', href: path('admin_company_new') } only %}
{# ================================================================ FILTRES ================================================================ #}
{# Filtres par statut #} {% include '_molecules/filter-tabs/filter-tabs.html.twig' with { filters: [ { id: 'all', label: 'Toutes', count: statusCounts.all, href: path('admin_company_list', {sort: filters.sort, sam: filters.sam}) }, { id: 'active', label: 'Actives', count: statusCounts.active, href: path('admin_company_list', {status: 'active', sort: filters.sort, sam: filters.sam}) }, { id: 'inactive', label: 'Inactives', count: statusCounts.inactive, href: path('admin_company_list', {status: 'inactive', sort: filters.sort, sam: filters.sam}) } ], active: filters.status == '' ? 'all' : filters.status, name: 'status' } only %} {# Filtre SAM #} {% include '_molecules/filter-tabs/filter-tabs.html.twig' with { filters: [ { id: 'yes', label: 'SAM activé', count: statusCounts.sam_yes, href: path('admin_company_list', {status: filters.status, sort: filters.sort, sam: 'yes'}) }, { id: 'no', label: 'SAM désactivé', count: statusCounts.sam_no, href: path('admin_company_list', {status: filters.status, sort: filters.sort, sam: 'no'}) } ], active: filters.sam != '' ? filters.sam : '__none__', name: 'sam' } only %} {# Tri #} {% include '_molecules/filter-tabs/filter-tabs.html.twig' with { filters: [ { id: 'name', label: 'Nom', href: path('admin_company_list', {status: filters.status, sort: 'name', sam: filters.sam}) }, { id: 'date_desc', label: 'Récentes', href: path('admin_company_list', {status: filters.status, sort: 'date_desc', sam: filters.sam}) }, { id: 'date_asc', label: 'Anciennes', href: path('admin_company_list', {status: filters.status, sort: 'date_asc', sam: filters.sam}) } ], active: filters.sort, name: 'sort' } only %}
{# ================================================================ LISTE DES ENTREPRISES EN CARDS ================================================================ #} {% if companies|length > 0 %}
{% for company in companies %} {% set data = companyData[company.id] ?? {hasActiveContract: false} %} {# Header avec avatar et infos #}
{# Avatar de l'entreprise #}
{{ company.name|slice(0, 2)|upper }}

{{ company.name }}

{% include '_atoms/icon/icon.html.twig' with { name: 'users', size: 'xs', color: 'gray' } only %} {{ userCounts[company.id] ?? 0 }} utilisateur{{ (userCounts[company.id] ?? 0) > 1 ? 's' : '' }}
{# Badge statut #} {% if company.isActive %} {% include '_atoms/badge/badge.html.twig' with { label: 'Active', variant: 'success', dot: true, size: 'sm' } only %} {% else %} {% include '_atoms/badge/badge.html.twig' with { label: 'Inactive', variant: 'error', dot: true, size: 'sm' } only %} {% endif %}
{# Statut contrat #}
{% if data.hasActiveContract %} {% include '_atoms/icon/icon.html.twig' with { name: 'check-circle', size: 'md', color: 'success' } only %} Contrat actif {% else %} {% include '_atoms/icon/icon.html.twig' with { name: 'warning', size: 'md', color: 'warning' } only %} Sans contrat {% endif %}
{# Footer avec accès SAM #}
{% include '_atoms/logo/logo-with-text.html.twig' with { variant: 'sam', showBadge: false, size: 'sm', disabled: not company.hasSamAccess } %}
{% endfor %}
{# Pagination - Style Moodia #} {% if pagination.total > 1 %}
{% set paginationFilters = {} %} {% if filters.status %}{% set paginationFilters = paginationFilters|merge({status: filters.status}) %}{% endif %} {% if filters.sort %}{% set paginationFilters = paginationFilters|merge({sort: filters.sort}) %}{% endif %} {% include '_molecules/pagination/pagination.html.twig' with { currentPage: pagination.current, totalPages: pagination.total, baseUrl: path('admin_company_list', paginationFilters), variant: 'moodia' } only %}
{% endif %} {% else %}
{% include '_molecules/empty-state/empty-state.html.twig' with { title: 'Aucune entreprise', description: 'Commencez par créer votre première entreprise partenaire.', icon: 'buildings', variant: 'minimal', actions: [{ label: 'Créer une entreprise', href: path('admin_company_new'), variant: 'primary', icon: 'plus' }] } only %}
{% endif %}
{% endblock %}