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

{% load costs %}

{% block rail %}

  <div class="ui tag labels">
    <div class="ui label blue">
      {{ service.subscriptions_count }}
      <div class="detail">abonnements</div>

    </div>
    <br>
  {% if document.type == document.TYPE_PLAN %}
  <a class="ui label orange" title="Ce document se base sur des estimations">
    {{ document.get_type_display }}
  </a>
  {% else %}
  <span class="ui label">
    {{ document.get_type_display }}
    <div class="ui detail">{{ document.date|date:"b Y" }}</div>
  </span>
  {% endif %}
  </div>

  <div class="ui segment" style="width: 100%">
  <p>
    <a class="ui ribbon left label">Notes</a>
{{ service.description|linebreaks }}
  </p>
  </div>
{% endblock %}


{% block content %}
<h2 class="ui header sixteen wide column">Coût récurent mensuel</h2>
<table class="ui celled structured table">
  <thead>
    <tr>
      <th>Type</th><th>Nom</th><th class="right aligned">Coût mensuel <br> (par abonnement)</th>
    </tr>
  </thead>
  <tbody>
  {% for usage in goods_uses %}
    <tr>
      {% if forloop.first %}
      <td rowspan="{{ goods_uses|length }}">Amortissement</td>
      {% endif %}
      <td>
       {{ usage.resource.name }}
        <span class="bare-info">
       {% if usage.resource.capacity_unit %}
           ({{ usage.unit_share|human_round }} {{ usage.resource.get_capacity_unit_display }})
         {% else %}
           ({{ usage.unit_real_share|percent }})
         {% endif %}
        </span>
      </td>
      <td class="right aligned">{{ usage.unit_monthly_provision_share|price }}</td>
    </tr>
  {% endfor %}
  {% for usage in costs_uses %}
    <tr>
      {% if forloop.first %}
      <td rowspan="{{ costs_uses|length }}">Récurent</td>
      {% endif %}
      <td>
      {{ usage.resource.name }}
        <span class="bare-info">
               {% if usage.resource.capacity_unit %}
           ({{ usage.unit_share|human_round }} {{ usage.resource.get_capacity_unit_display }})
         {% else %}
           ({{ usage.unit_real_share|percent }})
         {% endif %}
        </span>
      </td>
      <td class="right aligned">{{ usage.unit_cost_share|price }}</td>
    </tr>
  {% endfor %}
  </tbody>
  <tfoot>
    <tr>
      <th colspan="2"><strong>Coût de revient par abonnement</strong></th>
      <th class="right aligned"><strong>{{ unit_costs_price|price }}</strong></th>
    </tr>
  </tfoot>
</table>

<h2>Coût de mise en place (FAS)</h2>
<table class="ui celled structured table">
  <thead>
    <tr>
      <th>Nom</th><th>Coût (par nouvel abonnement)</th>
    </tr>
  </thead>
  <tbody>
{% for good_use in goods_uses %}
    <tr>
      <td>{{ good_use.resource.name }}</td>
      <td>{{ good_use.unit_value_share|price }}</td>
    </tr>
{% endfor %}
  </tbody>
  <tfoot>
    <tr>
      <th><strong>Coût de mise en place par nouvel abonnement</strong></th>
      <th><strong>{{ unit_goods_value_share|price }}</strong></th>
    </tr>
  </tfoot>
</table>

La mise en place lissée sur 12 mois, elle équivaut à
{{ monthly_fas|price }}/mois.
</p>

{% endblock %}