{% extends 'base_backend_admin.html.twig' %}

{% block title %} Annonce {% endblock %}

{% block content %}
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
    <h1 class="h3 mb-0 text-gray-800">Annonce</h1>
    <ol class="breadcrumb float-sm-right">
        <li class="breadcrumb-item">Annonce</li>
    </ol>
</div>




<!-- Begin Page Content -->
<div class="container-fluid">
    
    {% include 'backend_admin/basic/notice.html.twig' %}

    <a href="{{ path('backend_admin_annonce_add') }}" class="btn btn-success btn-icon-split mb-4">
        <span class="icon text-white"><i class="fa-regular fa-square-plus"></i></span>
        <span class="text text-white">Ajouter une nouvelle annonce</span>
    </a>

    
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
       
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-success">Liste des annonces</h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="dataTableAnnonce" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Titre</th>
                            <th>Prix Promo</th>
                            <th>Réduction</th>
                            <th>Dimension</th>
                            <th>Société</th>
                            <th>Activer</th>
                            <th>Complet</th>
                            <th>Modifier</th>
                        </tr>
                    </thead>
                    <tfoot>
                        <tr>
                            <th>#</th>
                            <th>Titre</th>
                            <th>Prix Promo</th>
                            <th>Réduction</th>
                            <th>Dimension</th>
                            <th>Société</th>
                            <th>Activer</th>
                            <th>Complet</th>
                            <th>Modifier</th>
                        </tr>
                    </tfoot>
                    <tbody>
                        {% for annonce in annonces %}
                            <tr>
                                <td>{{ annonce.getId() }}</td>
                                <td>{{ annonce.getTitre() }}</td>
                                <td>{{ annonce.getPrixPromo() }}</td>
                                <td>{{ annonce.getPourcentageReduction() }}%</td>
                                <td>{{ annonce.Dimension() }}</td>
                                <td>{{ annonce.getSociete().getNom() }}</td>
                                <td>{% if annonce.isActive() and annonce.isComplet() %}
                                        <i class="fa-solid fa-circle-check fa-xl" style="color: #26a269;"></i>
                                    {% else %}
                                        <i class="fa-solid fa-circle-xmark fa-xl" style="color: #e01b24;"></i>
                                    {% endif %}
                                </td>
                                <td>
                                    {% if annonce.isComplet() %}
                                        <i class="fa-solid fa-thumbs-up fa-xl" style="color: #1a5fb4;"></i>
                                    {% else %}
                                        <i class="fa-solid fa-thumbs-down fa-xl" style="color: #c01c28;"></i>
                                    {% endif %}
                                
                                
                                </td>
                                <td>    
                                    <a href="{{ path('backend_admin_annonce_update',{id:annonce.id}) }}" title="modifier" class="btn btn-info btn-action"><i class="fa fa-edit"></i></a>
                                    <a href="{{ path('backend_admin_annonce_uploder',{id:annonce.id}) }}" title="gestion des images" class="btn btn-warning"><i class="fa-regular fa-image"></i></a>
                                    
                                    {% if annonce.isComplet() and not annonce.isActive() %}
                                        <a href="{{ path('backend_admin_annonce_delete',{id:annonce.id, delete: true}) }}" title="activer l'annonce" class="btn btn-success"><i class="fa-solid fa-circle-check"></i></a>
                                    {% elseif  annonce.isComplet() and annonce.isActive() %}
                                        <a href="{{ path('backend_admin_annonce_delete',{id:annonce.id, delete: false}) }}" title="déactiver l'annonce" class="btn btn-danger"><i class="fa-solid fa-circle-xmark"></i></a>
                                    {% endif %}

                                    
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}


{% block javascripts %}
    {{ parent() }}
    {{ encore_entry_script_tags('app_backend_annonce') }}
{% endblock %}