{% extends 'entreprise/entreprise_base.html.twig' %} {% block title %}Mon Abonnement | Dashboard{% endblock %} {% block body %}
{# --- HEADER --- #}

Abonnement & Facturation

{% include 'flash_messages.html.twig' %} {# --- KPI CARDS --- #}
Plan Actuel {{ abonnementActuel ? abonnementActuel.abonnement.titre : 'Aucun' }}
Solde Portefeuille {{ app.user.entreprise.soldeCredit|number_format(0, ',', ' ') }} F.CFA
Fin d'engagement {{ abonnementActuel ? abonnementActuel.dateFin|date('d M Y') : '-' }}
Temps Restant {% if abonnementActuel %} {% set diff = date(abonnementActuel.dateFin).diff(date('now')) %} {{ diff.days }} jours {% else %}0 jours{% endif %}
{# --- HISTORIQUE & TABLE --- #}
Historique des souscriptions
{# Tri optimisé : 1=Actuel, 2=Programmé, 3=Expiré/Autre, 4=Annulé #} {% set sortedHistorique = historique|sort((a, b) => ( (a.statut in ['ACTIF', 'RENOUVELE'] and a.dateDebut|date('Y-m-d') <= "now"|date('Y-m-d') and a.dateFin|date('Y-m-d') >= "now"|date('Y-m-d')) ? 1 : (a.statut == 'ACTIF' and a.dateDebut|date('Y-m-d') > "now"|date('Y-m-d') ? 2 : (a.statut == 'ANNULE' ? 4 : 3)) ) <=> ( (b.statut in ['ACTIF', 'RENOUVELE'] and b.dateDebut|date('Y-m-d') <= "now"|date('Y-m-d') and b.dateFin|date('Y-m-d') >= "now"|date('Y-m-d')) ? 1 : (b.statut == 'ACTIF' and b.dateDebut|date('Y-m-d') > "now"|date('Y-m-d') ? 2 : (b.statut == 'ANNULE' ? 4 : 3)) ) ) %} {% for item in sortedHistorique %} {% set today = "now"|date('Y-m-d') %} {% set isExpired = item.dateFin and item.dateFin|date('Y-m-d') < today %} {% set isFuture = item.dateDebut|date('Y-m-d') > today %} {% set isActuallyActive = (item.statut in ['ACTIF', 'RENOUVELE']) and not isExpired and not isFuture %} {% endfor %}
Référence Offre & Coût Période d'engagement Statut Actions
{{ item.reference }} {% if isActuallyActive %} ACTUEL {% endif %} {% if item.statut == 'ACTIF' and isFuture %}
Programmé {% endif %}
{{ item.abonnement.titre }}
{% set total = item.montantPaye + item.montantViaCredit %} {{ total|number_format(0, ',', ' ') }} F.CFA {% if item.montantViaCredit > 0 %} {% endif %}
{{ item.dateDebut|date('d/m/Y') }} {{ item.dateFin ? item.dateFin|date('d/m/Y') : '∞' }}
{% if item.statut == 'ACTIF' %} {% if isFuture %} À venir {% else %} En cours {% endif %} {% elseif item.statut == 'RENOUVELE' %} {% if not isExpired %} En cours (Prolongé) {% else %} Renouvelé {% endif %} {% elseif item.statut == 'ANNULE' %} Annulé (Avoir) {% elseif isExpired %} Expiré {% else %} {{ item.statut }} {% endif %}
{# Proposer le renouvellement seulement si c'est l'actif ou un futur proche du même plan #} {% if isActuallyActive %} {% endif %}
{% endblock %}