{% extends 'admin/base.html.twig' %}

{% block title %}Dashboard{% endblock %}

{% block body %}
<div class="mb-8">
    <h1 class="text-3xl font-black uppercase tracking-tighter italic heading-page">Dashboard</h1>
    <p class="font-bold text-gray-500 italic">Bonjour {{ app.user.firstName }}, bienvenue sur l'administration.</p>
</div>

<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-10">
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400">CA Global HT</p>
        <p class="text-3xl font-black text-indigo-600 mt-2">{{ totalCA|number_format(2, ',', ' ') }} &euro;</p>
    </div>
    <div class="admin-card-yellow">
        <p class="admin-stat-label font-black uppercase">Commission E-Ticket</p>
        <p class="text-3xl font-black mt-2">{{ commissionEticket|number_format(2, ',', ' ') }} &euro;</p>
    </div>
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400">Commission Stripe</p>
        <p class="text-3xl font-black mt-2">{{ commissionStripe|number_format(2, ',', ' ') }} &euro;</p>
    </div>
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400">Commandes payees</p>
        <p class="text-3xl font-black mt-2">{{ nbOrders }}</p>
    </div>
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400">Billets generes</p>
        <p class="text-3xl font-black mt-2">{{ nbBillets }}</p>
    </div>
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400">Organisateurs actifs</p>
        <p class="text-3xl font-black mt-2">{{ nbOrgas }}</p>
    </div>
</div>

<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-10">
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400 mb-2">Revenus E-Ticket</p>
        <div class="flex items-baseline gap-2">
            <p class="text-2xl font-black text-green-600">{{ (totalCA - commissionStripe)|number_format(2, ',', ' ') }} &euro;</p>
            <p class="text-xs font-bold text-gray-400">CA - Stripe</p>
        </div>
        <div class="mt-4 pt-4 border-t-2 border-gray-200">
            <div class="flex justify-between text-sm font-bold mb-1">
                <span class="text-gray-500">CA Global HT</span>
                <span>{{ totalCA|number_format(2, ',', ' ') }} &euro;</span>
            </div>
            <div class="flex justify-between text-sm font-bold mb-1">
                <span class="text-gray-500">- Stripe</span>
                <span class="text-red-600">{{ commissionStripe|number_format(2, ',', ' ') }} &euro;</span>
            </div>
            <div class="flex justify-between text-sm font-bold mb-1">
                <span class="text-gray-500">- Reverse orga</span>
                <span class="text-red-600">{{ (totalCA - commissionEticket - commissionStripe)|number_format(2, ',', ' ') }} &euro;</span>
            </div>
            <div class="flex justify-between text-sm font-black pt-2 border-t border-gray-200">
                <span>Net E-Ticket</span>
                <span class="text-indigo-600">{{ commissionEticket|number_format(2, ',', ' ') }} &euro;</span>
            </div>
        </div>
    </div>
    <div class="admin-card">
        <p class="admin-stat-label font-black uppercase text-gray-400 mb-2">Export mensuel</p>
        <div class="flex flex-wrap gap-2 mb-4">
            <a href="{{ path('app_admin_export', {year: "now"|date('Y'), month: "now"|date('n')}) }}" class="admin-btn-sm-yellow text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all py-2 px-3">CSV {{ "now"|date('m/Y') }}</a>
            <a href="{{ path('app_admin_export', {year: "now"|date_modify('-1 month')|date('Y'), month: "now"|date_modify('-1 month')|date('n')}) }}" class="admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all py-2 px-3">CSV {{ "now"|date_modify('-1 month')|date('m/Y') }}</a>
            <a href="{{ path('app_admin_export_pdf', {year: "now"|date('Y'), month: "now"|date('n')}) }}" class="admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all py-2 px-3">PDF {{ "now"|date('m/Y') }}</a>
            <a href="{{ path('app_admin_export_pdf', {year: "now"|date_modify('-1 month')|date('Y'), month: "now"|date_modify('-1 month')|date('n')}) }}" class="admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all py-2 px-3">PDF {{ "now"|date_modify('-1 month')|date('m/Y') }}</a>
        </div>
        <p class="admin-stat-label font-black uppercase text-gray-400 mb-4">Actions rapides</p>
        <div class="space-y-3">
            <a href="{{ path('app_admin_orders') }}" class="block admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all text-center py-2">Voir toutes les commandes</a>
            <a href="{{ path('app_admin_organizers') }}" class="block admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all text-center py-2">Gerer les organisateurs</a>
            <a href="{{ path('app_admin_invite_organizer') }}" class="block admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all text-center py-2">Inviter un organisateur</a>
            <a href="{{ path('app_admin_logs') }}" class="block admin-btn-sm-white text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all text-center py-2">Audit trail</a>
            <form method="post" action="{{ path('app_admin_sync_meilisearch') }}" class="block">
                <button type="submit" class="w-full admin-btn-sm-yellow text-xs font-black uppercase tracking-widest hover:bg-indigo-600 hover:text-black transition-all py-2">Sync Meilisearch</button>
            </form>
        </div>
    </div>
</div>
{% endblock %}
