{% extends "costs/document_detail.html" %}

{% load costs %}

{% block content %}

<section class="text container ui row">
    <div class="ui icon message">
        <i class="time icon"></i>
        <p>
            Cette page présente les chiffres de <a href="{{ document.get_absolute_url }}">{{ document }}</a>
            ; les étiquettes indiquent les variations depuis <a href="{{ other_document.get_absolute_url }}">{{ other_document }}</a>.
        </p>
    </div>
</section>
<table class="ui structured table">
  <thead>
    <tr>
      <th>Service</th><th>Coût mensuel par abonnement</th>
      <th>Nb. abonnements</th>
    </tr>
  </thead>
  <tbody>
{% for service_record in deltas.services %}
      <tr>
          <td>
              <a href="{{ service_record.service.get_absolute_url }}">
              {{ service_record.service.name }}
              {% if not service_record.other_service %}<span class="ui horizontal label">NEW</span{% endif %}
              </a>
          </td>
          <td >
            {{ service_record.service.get_prices.unit_consolidated_cost|price }}
            {% if service_record.other_service %}
               {% with service_record.deltas.unit_consolidated_cost as consolidated_price_diff %}
                 {% if consolidated_price_diff != 0 %}
                   <span class="ui tag label">
                     {{ service_record.deltas.unit_consolidated_cost|price_diff }}
                   </span>
                 {% endif %}
               {% endwith %}
            {% endif %}
          </td>
          <td>
            {{ service_record.service.subscriptions_count }}
            {% if service_record.other_service %}
              {% with service_record.deltas.subscriptions_count as subscriptions_count_diff %}
                {% if subscriptions_count_diff != 0 %}
                  <span class="ui tag label">{{ subscriptions_count_diff|int_diff }}</span>
                {% endif %}
              {% endwith %}
            {% endif %}
          </td>

  </tr>
{% empty %}
  <tr><td>Pas de service pour l'instant.</td></li>
{% endfor %}
  </tbody>
  </table>
</section>

{% endblock %}
