{% extends "base_frontoffice.html" %}

{% block content %}



<div class="container mt-4">
    <div class="d-flex justify-content-between align-items-center">
        <h4>GERANT</h4>
        <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addArticleModal" onclick="clear_form()">Ajouter</button>
    </div>

    <!-- Article Table -->
    <div class="table-responsive mt-4">
        <table class="table table-sm align-items-center justify-content-center mb-0">
            <thead class="table-light">
                <tr>
                    <th>NOM</th>
                    <th>SOLDE</th>
                    <th>RETRAIT</th>
                    <th>DEPOT</th>
                    <th>ACTION</th>
                </tr>
            </thead>
            <tbody>
                {% for gerant in all_gerant %}
                <tr>
                    <td>{{ gerant.nom }}</td>
                    <td class="money bg-warning p-1">{{ gerant.solde }}</td>
                    <td class="money ">{{ gerant.retrait }}</td>
                    <td class="money ">{{ gerant.depot }}</td>
                    <td><span class="d-flex">
                        <a class="btn btn-outline-warning btn-sm" href="/journal/gerant?gid={{gerant.id}}">JOURNAL</a>
                    </span>
                    </td>

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

<!-- Modal Form -->
<div class="modal fade" id="addArticleModal" tabindex="-1" aria-labelledby="addArticleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-md">
        <div class="modal-content">
            <form method="POST" action="/add/gerant">
                <div class="modal-header">
                    <h5 class="modal-title" id="addArticleModalLabel">Ajouter un gérant</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Fermer"></button>
                </div>
                <div class="modal-body">
                    <div class="mb-3">
                        <label for="quantityInput" class="form-label">NOM</label>
                        <input type="text" class="form-control" name="name" autocomplete="off">
                      </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-warning" >ENREGISTRER</button>
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annuler</button>
                    
                </div>
            </form>
        </div>
    </div>
</div>
<script>
  window.onload=function(){
    var all_number =$(".money");
    for (let number of all_number){

      number.textContent=parseFloat(number.textContent).toLocaleString("fr-FR", {minimumFractionDigits:2});
    };

};
</script>
{% endblock %}