{% load i18n %}
{% load translations %}

  {% with billing.plan as plan %}
  <table class="table">
  <tr>
    <th>{% trans "Current plan" %}</th>
    <td>{{ plan.name }} ({{ billing.get_state_display }}{% if billing.expiry %}{% blocktrans with expires=billing.expiry|naturaltime %}, expires {{ expires }}{% endblocktrans %}{% endif %})</td>
    <td>
        {% if not hide_buttons and payment_enabled and billing.can_be_paid %}
        <a href="{% url 'create-billing' %}?billing={{ billing.pk }}&amp;upgrade=1" class="btn btn-primary pull-right flip">
        {% trans "Change plan" %}
        </a>
        {% endif %}
    </td>
  </tr>
  <tr>
    <th>{% trans "Monthly price" %}</th>
    <td>
        {{ plan.price }} EUR
    </td>
    <td>
        {% if payment_enabled and billing.can_be_paid and plan.price and not hide_buttons %}
        <form class="form-inline" method="post" action="{% url 'create-billing' %}">
        {% csrf_token %}
        <input type="hidden" name="plan" value="{{ plan.id }}" />
        <input type="hidden" name="billing" value="{{ billing.id }}" />
        <input type="hidden" name="period" value="m" />
        <input type="submit" value="{% trans "New payment" %}" class="btn btn-primary pull-right flip" />
        </form>
        {% endif %}
    </td>
  </tr>
  <tr>
    <th>{% trans "Yearly price" %}</th>
    <td>{{ plan.yearly_price }} EUR</td>
    <td>
        {% if payment_enabled and billing.can_be_paid and plan.yearly_price and not hide_buttons %}
        <form class="form-inline" method="post" action="{% url 'create-billing' %}">
        {% csrf_token %}
        <input type="hidden" name="plan" value="{{ plan.id }}" />
        <input type="hidden" name="billing" value="{{ billing.id }}" />
        <input type="hidden" name="period" value="y" />
        <input type="submit" value="{% trans "New payment" %}" class="btn btn-primary pull-right flip" />
        </form>
        {% endif %}
    </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 "Last invoice" %}</th>
  <td colspan="2">{{ billing.last_invoice }}</td></tr>
  <tr><th>{% trans "Projects limit" %}</th>
  {% with plan.limit_projects as max and plan.display_limit_projects as total and projects|length as used %}
  {% include "billing/used.html" %}
  {% endwith %}
  </tr>
  <tr><th>{% trans "Projects" %}</th>
  <td colspan="2"><div class="list-group">
  {% for project in projects %}
  <a class="list-group-item" href="{{ project.get_absolute_url }}">{{ project }}</a>
  {% empty %}
  {% trans "No projects currently assigned!" as msg %}
  {% show_message "warning" msg %}
{% if billing.is_active %}
  <a class="btn btn-primary billing-add-project" href="{% url 'create-project' %}?billing={{ billing.pk }}">{% trans "Add new translation project" %}</a>
{% endif %}
  {% endfor %}
  </div></td>
  </tr>
  </table>
  {% endwith %}
