{% extends "base_frontoffice.html" %}

{% block content %}



<div class="container mt-4">
    <h4>Balance Fournisseur</h4>
        
    <div class="d-flex justify-content-between align-items-center">

    <input type="text " id="tableSearch" class="form-control  w-50" placeholder="Recherche ..." >


            <ul class="list-group " >
            <li class="list-group-item d-flex justify-content-between">
              <span >SOLDE: </span>
              <strong class="money">{{fournisseur.solde}}</strong>
            </li>
            </ul>

    </div>
    <!-- Article Table -->
    <div class="table-responsive mt-4">
        <table class="table table-sm align-items-center justify-content-center mb-0" id="commandeTable">
            <thead class="table-light">
                <tr>
                    <th>Date</th>
                    <th>Affectation</th>
                    <th>Credit</th>
                    <th>Debit</th>
                    <th>Solde</th>
                    <th>Réf</th>
                    
                </tr>
            </thead>
            <tbody>
                {% for balance in all_balance %}
                <tr data-id="{{balance.id}}">
                    <td>{{ balance.date_str }}</td>
                    <td>{{ balance.affectation }}</td>
                    <td class="money">{{ balance.credit }}</td>
                    <td class="money">{{ balance.debit }}</td>
                    <td class="money">{{ balance.solde }}</td>
                    <td>{{ balance.ref }}</td>
                </tr>
              
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>

<script>
document.getElementById("tableSearch").addEventListener("keyup", function () {
  const input = this.value.toLowerCase();
  const rows = document.querySelectorAll("#commandeTable tbody tr");

  rows.forEach(row => {
    const rowText = row.innerText.toLowerCase();
    row.style.display = rowText.includes(input) ? "" : "none";
  });
});
</script>
<script>
  window.onload=function(){
    var all_number =$(".money");
    for (let number of all_number){

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

};


function selectClient(self){

    window.location.href="/balance/client?id="+self.value;
}
</script>
{% endblock %}