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

{% block title %}Tableau de bord - VitiCore{% endblock %}
{% block section_label %}Pilotage{% endblock %}
{% block page_title %}Tableau de bord{% endblock %}

{% block topbar_actions %}
    {% if shopConfig and shopConfig.matomoConfigured %}
        <a class="admin-button" href="https://matomo.cpcreation.net/" target="_blank" rel="noopener noreferrer">
            Visites
        </a>
    {% endif %}
{% endblock %}

{% block content %}
    <section class="admin-home">
        <div class="admin-home-hero">
            <div>
                <p class="admin-home-kicker">Vue operationnelle</p>
                <h2>Acces rapides</h2>
                <p>Les entrees principales de l'administration restent accessibles en un scan, sans quitter le theme Terra.</p>
            </div>
            <div class="admin-home-meta">
                <span>Back-office</span>
                <strong>{{ 'now'|date('d/m/Y') }}</strong>
            </div>
        </div>

        <div class="admin-home-grid">
            <div class="admin-home-main">
                <div class="admin-quick-grid">
                    {% if is_granted('ROLE_ORDER') or is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_order') }}">
                            <span class="admin-quick-mark">CO</span>
                            <span>
                                <strong>Commandes</strong>
                                <small>Historique, suivi et documents</small>
                            </span>
                        </a>

                        {% if invoiceFeatureEnabled() %}
                            <a class="admin-quick-card" href="{{ path('admin_order_invoices') }}">
                                <span class="admin-quick-mark">FA</span>
                                <span>
                                    <strong>Factures</strong>
                                    <small>Edition, export et controle</small>
                                </span>
                            </a>
                        {% endif %}
                    {% endif %}

                    {% if is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_client') }}">
                            <span class="admin-quick-mark">CL</span>
                            <span>
                                <strong>Clients</strong>
                                <small>Comptes, verification et export</small>
                            </span>
                        </a>
                    {% endif %}

                    {% if is_granted('ROLE_PRODUCT') or is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_product') }}">
                            <span class="admin-quick-mark">PR</span>
                            <span>
                                <strong>Produits</strong>
                                <small>Catalogue, prix et visibilite</small>
                            </span>
                        </a>
                    {% endif %}

                    {% if is_granted('ROLE_PAYMENT_PAYMENT') or is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_payment_payment') }}">
                            <span class="admin-quick-mark">PA</span>
                            <span>
                                <strong>Paiements</strong>
                                <small>Transactions et etats</small>
                            </span>
                        </a>
                    {% endif %}

                    {% if is_granted('ROLE_PROMO') or is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_promo') }}">
                            <span class="admin-quick-mark">RE</span>
                            <span>
                                <strong>Remises</strong>
                                <small>Codes promo et campagnes</small>
                            </span>
                        </a>
                    {% endif %}

                    {% if is_granted('ROLE_NEWS') or is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_news') }}">
                            <span class="admin-quick-mark">AC</span>
                            <span>
                                <strong>Actualites</strong>
                                <small>Articles et contenus editoriaux</small>
                            </span>
                        </a>
                    {% endif %}

                    {% if is_granted('ROLE_ADMIN') %}
                        <a class="admin-quick-card" href="{{ path('admin_library') }}">
                            <span class="admin-quick-mark">ME</span>
                            <span>
                                <strong>Mediatheque</strong>
                                <small>Images et ressources</small>
                            </span>
                        </a>

                        <a class="admin-quick-card" href="{{ path('admin_shop_config') }}">
                            <span class="admin-quick-mark">CF</span>
                            <span>
                                <strong>Configuration</strong>
                                <small>Boutique, reglages et services</small>
                            </span>
                        </a>
                    {% endif %}
                </div>

                <section class="admin-dashboard-panel">
                    <div class="admin-panel-heading">
                        <p>Creation rapide</p>
                        <h3>Ajouter un contenu</h3>
                    </div>

                    <div class="admin-action-list">
                        {% if is_granted('ROLE_PRODUCT') or is_granted('ROLE_ADMIN') %}
                            <a href="{{ path('admin_product_new') }}">Nouveau produit</a>
                        {% endif %}
                        {% if is_granted('ROLE_NEWS') or is_granted('ROLE_ADMIN') %}
                            <a href="{{ path('admin_news_new') }}">Nouvelle actualite</a>
                        {% endif %}
                        {% if is_granted('ROLE_ADMIN') %}
                            <a href="{{ path('admin_client_new') }}">Nouveau client</a>
                            <a href="{{ path('admin_library_new') }}">Ajouter une image</a>
                        {% endif %}
                        {% if is_granted('ROLE_PROMO') or is_granted('ROLE_ADMIN') %}
                            <a href="{{ path('admin_promo_new') }}">Nouveau code promo</a>
                        {% endif %}
                    </div>
                </section>
            </div>

            <aside class="admin-home-aside">
                <section class="admin-dashboard-panel">
                    <div class="admin-panel-heading">
                        <p>A traiter</p>
                        <h3>Raccourcis de controle</h3>
                    </div>

                    <div class="admin-check-list">
                        {% if is_granted('ROLE_ORDER') or is_granted('ROLE_ADMIN') %}
                            <a href="{{ path('admin_order') }}">
                                <span>Commandes recentes</span>
                                <small>Ouvrir</small>
                            </a>
                            {% if invoiceFeatureEnabled() %}
                                <a href="{{ path('admin_order_invoices') }}">
                                    <span>Facturation</span>
                                    <small>Verifier</small>
                                </a>
                            {% endif %}
                        {% endif %}
                        {% if is_granted('ROLE_PAYMENT_PAYMENT') or is_granted('ROLE_ADMIN') %}
                            <a href="{{ path('admin_payment_payment') }}">
                                <span>Paiements en ligne</span>
                                <small>Suivre</small>
                            </a>
                        {% endif %}
                        {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_SOCIAL') %}
                            <a href="{{ path('admin_social') }}">
                                <span>Reseaux sociaux</span>
                                <small>Publier</small>
                            </a>
                        {% endif %}
                    </div>
                </section>

                {% if is_granted('ROLE_ADMIN') %}
                    <section class="admin-dashboard-panel">
                        <div class="admin-panel-heading">
                            <p>Administration</p>
                            <h3>Reglages frequents</h3>
                        </div>

                        <div class="admin-settings-list">
                            <a href="{{ path('admin_user') }}">Utilisateurs</a>
                            <a href="{{ path('admin_locale') }}">Locales</a>
                            <a href="{{ path('admin_shop_config') }}">Boutique</a>
                        </div>
                    </section>
                {% endif %}
            </aside>
        </div>
    </section>
{% endblock %}
