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

{% load costs %}

{% block title %}{{ document.name }}{% endblock %}


{% block rail %}

{% if document.comment %}
<div class="ui segment" style="width: 100%">
  <p>
    <a class="ui ribbon left label">Notes</a>
{{ document.comment|linebreaks }}
  </p>
</div>
{% endif %}

{% endblock %}


{% block content %}

<h2 class="ui header sixteen wide column">Services proposés</h2>
<ul>
{% for service in document.service_set.all %}
  <li>
    <a href="{{ service.get_absolute_url }}">{{ service.name }}</a>
    ({{ service.subscriptions_count }} abonné·e{{ service.subscriptions_count|pluralize:"·s" }})
  </li>
{% empty %}
  <li>Pas de service pour l'instant.</li>
{% endfor %}
</ul>

<h2 class="ui header sixteen wide column">Coûts</h2>

<table class="ui structured table">
  <thead>
    <tr>
      <th>Désignation</th><th>Capacité totale</th>
      <th>Occupation</th><th>Coût mensuel</th>
    </tr>
  </thead>
  <tbody>

{% for cost in document.cost_set.all %}
    <tr>
      <td>
       {{ cost.name }}
        {% if cost.description %}
        <a href="#" title="{{ cost.description }}">
          <i class="info circle icon"></i>
        </a>
        {% endif %}
      </td>
      <td>
        {% if cost.capacity_unit %}
        {{ cost.total_capacity|human_round }} {{ cost.get_capacity_unit_display }}
        {% else %}
        n/a
        {% endif %}
      </td>
      <td>{{ cost.used_fraction|percent }}</td>
      <td>{{ cost.price|price }}</td>
    </tr>
{% empty %}
  <tr><td>Pas de coût pour l'instant.</td></tr>
{% endfor %}
    <tbody>
</table>

<h2>Matériel et frais d'accès</h2>
<table class="ui structured table">
  <thead>
    <tr>
      <th>Désignation</th>
      <th>Capacité totale</th>
      <th>Occupation</th>
      <th>Coût d'achat</th>
    </tr>
  </thead>
  <tbody>

{% for good in document.good_set.all %}
  <tr>
    <td>
     {{ good.name }}
      {% if good.description %}
      <a href="#" title="{{ good.description }}">
        <i class="info circle icon"></i>
      </a>
      {% endif %}
    </td>
    <td>
        {% if good.capacity_unit %}
          {{ good.total_capacity|human_round }} {{ good.get_capacity_unit_display }}
        {% else %}
          n/a
        {% endif %}
    </td>
    <td>
      {{ good.used_fraction|percent }}
    </td>
    <td>
      {{good.price|price }}
    </td>
  </tr>
{% empty %}
  <tr><td>Pas de matériel pour l'instant.</td></tr>
{% endfor %}
</table>
{% endblock %}