{% load eo_facture %}
{% if echeances %}
<div class="module" id="echeances">
<h2>Contrats récurrents à facturer</h2>

<table id="echeance" class="table">
    <colgroup>
       <col class="debut"/>
       <col class="client"/>
       <col class="contrat"/>
       <col class="occurence"/>
       <col class="periodicite"/>
    </colgroup>
    <thead>
        <th class="debut">Date anniversaire</th>
        <th class="client">Client</th>
        <th class="contrat">Contrat</th>
        <th class="occurence">Échéance</th>
        <th class="periodicite">Périodicité</th>
        <th class="facturer"></th>
    </thead>
    <tbody>
    {% for echeance in echeances %}
    <tr>
        <td class="debut">{{ echeance.debut|date:"d/m/Y" }} - {{ echeance.fin|date:"d/m/Y" }}</td>
        <td class="client"><a href="{% url "admin:eo_facture_client_change" echeance.contrat.client.id %}">{{ echeance.contrat.client }}</a></td>
        <td class="contrat">
            <a href="{% url "admin:eo_facture_contrat_change" echeance.contrat.id %}">
            {{ echeance.contrat.intitule }}
            </a>
        </td>
        <td class="occurence">{{ echeance.occurrence }} / {{ echeance.contrat.periodicite_nombre_d_echeances }}</td>
        <td class="periodicite">{{ echeance.contrat.get_periodicite_display }}</td>
        <td class="facturer">
            <form method="post" action="{% url "admin:eo_facture_contrat_facturer_echeance" echeance.contrat.id %}">
                {% csrf_token %}
                <input type="hidden" name="echeance" value="{{ echeance.occurrence }}"/>
                <input type="submit" value="Facturer" style="padding: 2px 3px"/>
            </form>
        </td>
    </tr>
    {% endfor %}
</table>
</div>
{% endif %}
