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

{% block title %} Service {% 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">Service</h1>
    <ol class="breadcrumb float-sm-right">
        <li class="breadcrumb-item">Service</li>
    </ol>
</div>




<!-- Begin Page Content -->
<div class="container-fluid">
    
    {% include 'backend_admin/basic/notice.html.twig' %}
    
    <!-- DataTales Example -->
    <div class="card shadow mb-4">
       
        <div class="card-header py-3">
            <h6 class="m-0 font-weight-bold text-info">Liste des services</h6>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" width="100%" cellspacing="0" id="tablesService">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Titre</th>
                            <th>Société</th>
                            <th>Date Ajoute</th>
                            <th>Limitation</th>
                            <th>Activer</th>
                            <th>Détail</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for service in services %}
                            <tr>
                                <td>{{ service.getId() }}</td>
                                <td>{{ service.getTitre()}}</td>
                                <td>{{ service.getSociete().getNom() }}</td>
                                <td>{{ service.getDateAdd()|date("d/m/Y")}}</td>
                                <td>
                                    {% if service.getLimitType() == 0 %}
                                        Par Date: <b>{{ service.getLimitDate()|date("d/m/Y")  }}</b>
                                    {% elseif service.getLimitType() == 1 %}
                                        Par RDV: 
                                        <button  title="Gestion des Rendez-vous" class="btn btn-dark" onclick="ServiceRdvAjaxShow({{ service.id }});return false;">
                                            <i class="fa-solid fa-calendar-check fa-sm"></i>
                                        </button>
                                    {% endif %}
                                </td>
                                <td>
                                    {% if service.isActive() %}
                                        <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>
                                    <a href="{{ path('backend_admin_service_update', {'id': service.getId() }) }}" title="Détail" class="btn btn-info btn-action">
                                        <i class="fa-solid fa-magnifying-glass"></i>
                                    </a>
                                    
                                    <a href="{{ path('backend_admin_service_uploder',{id:service.id}) }}" title="gestion des images" class="btn btn-warning"><i class="fa-regular fa-image"></i></a>
                                    
                                    {% if service.isActive() %}
                                        <a href="{{ path('backend_admin_service_activation',{id:service.id, 'activation': 'false'}) }}" title="déactiver" class="btn btn-danger"><i class="fa-solid fa-x"></i></a>
                                    {% elseif (service.isActive() == false) and (service.getImageDefault() != '') %}
                                        <a href="{{ path('backend_admin_service_activation',{id:service.id, 'activation': 'true'}) }}" title="activer" class="btn btn-success"><i class="fa-solid fa-check"></i></a>
                                    {% endif %}

                                    {% if service.getLimitType() == 1 %}
                                        <a href="{{ path('backend_admin_service_rdv_add', {id:service.id} )}}" title="Ajouter RDV" class="btn btn-dark">
                                            <i class="fa-regular fa-square-plus"></i>
                                        </a>
                                    {% endif %}
                                    
                                </td>
                            </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1"aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Liste des Rendez-vous</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <table class="table table-bordered" width="100%" cellspacing="0">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Date Début</th>
                            <th>Date Fin</th>
                            <th>Heur Début</th>
                            <th>Heur Fin</th>
                            <th>Durée Entre RDV</th>
                            <th>Exclure</th>
                            <th>Détail</th>
                        </tr>
                    </thead>
                    <tbody id="data-rdv"></tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block javascripts %}
    <script>
        var pathServiceRdvAjaxShow = "{{ path('backend_admin_service_rdv_ajax_show') }}";
    </script>
    {{ parent() }}
    {{ encore_entry_script_tags('app_backend_article_service') }}
{% endblock %}