{% load i18n %}
{% load translations %}
<div class="container-fluid">
<div class="row">

<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Billing plan" %}</h4></div>

  {% with billing.plan as plan %}
  <table class="table">
  <tr><th>{% trans "Current plan" %}</th><td>{{ plan.name }} ({{ billing.get_state_display }}{% if billing.trial_expiry %}{% blocktrans with expires=billing.trial_expiry|naturaltime %}, expires {{ expires }}{% endblocktrans %}{% endif %})</td><td><a href="https://weblate.org/hosting/" class="btn btn-default btn-xs pull-right flip">{% trans "See other plans" %}</a></td></tr>
  <tr><th>{% trans "Monthly price" %}</th><td>{{ plan.price }} EUR</td><td></td></tr>
  <tr><th>{% trans "Yearly price" %}</th><td>{{ plan.yearly_price }} EUR</td><td></td></tr>
  <tr><th>{% trans "Strings limit" %}</th>
  {% with plan.limit_strings as max and plan.display_limit_strings as total and billing.count_strings as used %}
  {% include "billing/used.html" %}
  {% endwith %}
  </tr>
  <tr><th>{% trans "Languages limit" %}</th>
  {% with plan.limit_languages as max and plan.display_limit_languages as total and billing.count_languages as used %}
  {% include "billing/used.html" %}
  {% endwith %}
  </tr>
  <tr><th>{% trans "Repositories limit" %}</th>
  {% with plan.limit_repositories as max and plan.display_limit_repositories as total and billing.count_repositories as used %}
  {% include "billing/used.html" %}
  {% endwith %}
  </tr>
  <tr><th>{% trans "Projects limit" %}</th>
  {% with plan.limit_projects as max and plan.display_limit_projects as total and billing.projects.count as used %}
  {% include "billing/used.html" %}
  {% endwith %}
  </tr>
  <tr><th>{% trans "Projects" %}</th>
  <td colspan="2"><div class="list-group">
  {% for project in billing.projects.all %}
  <a class="list-group-item" href="{{ project.get_absolute_url }}">{{ project }}</a>
  {% empty %}
  {% trans "No projects currently assigned!" as msg %}
  {% show_message "warning" msg %}
  <a class="btn btn-primary billing-add-project" href="{% url 'create-project' %}?billing={{ billing.pk }}">{% trans "Add new translation project" %}</a>
  {% endfor %}
  </div></td>
  </tr>
  </table>
  {% endwith %}
</div>
</div>

<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Invoices" %}</h4></div>
<table class="table table-striped">
<thead>
<tr>
<th>{% trans "Invoice period" %}</th>
<th>{% trans "Invoice amount" %}</th>
<th>{% trans "Download invoice" %}</th>
</tr>
</thead>
<tbody>
{% for invoice in billing.invoice_set.all %}
<tr>
<td>{{ invoice.start|date:"SHORT_DATE_FORMAT" }} - {{ invoice.end|date:"SHORT_DATE_FORMAT" }}</td>
<td>{{ invoice.payment }} {{ invoice.get_currency_display }}</td>
<td>
{% if invoice.ref %}
<a href="{% url 'invoice-download' pk=invoice.pk %}">{{ invoice.filename }}</a>
{% else %}
{% trans "Not available" %}
{% endif %}
</td>
</tr>
{% empty %}
<tr><td colspan="3">{% trans "No invoices found!" %}</td/></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>

</div>
