{% extends template_extends %}

{% load i18n %}
{% load currency_filters %}

{% block content %}
  <h1>Subscription payment transactions</h1>

  {% if messages %}
    <ul class="messages">
      {% for message in messages %}
        <li class="{{ message.tags }}">{{ message }}</li>
      {% endfor %}
    </ul>
  {% endif %}

  <div>
    <a href="{% url 'dfs_dashboard' %}">Back to dashboard</a>
  </div>

  {% if transactions %}
    <table>
      <thead>
        <tr>
          <th>{% trans "User" %}</th>
          <th>{% trans "Plan" %}</th>
          <th>{% trans "Transaction date" %}</th>
          <th>{% trans "Amount" %}</th>=
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for transaction in transactions %}
          <tr>
            <td>{{ transaction.user }}</td>
            <td>{{ transaction.plan }}</td>
            <td>{{ transaction.date_transaction }}</td>
            <td>{{ transaction.amount|currency }}</td>
            <td>
              <a href="{% url 'dfs_transaction_detail' transaction.id %}">
                {% trans "View" %}
              </a>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% else %}
    <p>{% trans "No subscription payment transactions have occurred have been added yet." %}</p>
  {% endif %}

  {% if is_paginated %}
    <div class="pagination">
      <span class="step-links">
        {% if page_obj.has_previous %}
          <a href="?page=1">&laquo; first</a>
          <a href="?page={{ page_obj.previous_page_number }}">previous</a>
        {% endif %}

        <span class="current">
          Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
        </span>

        {% if page_obj.has_next %}
          <a href="?page={{ page_obj.next_page_number }}">next</a>
          <a href="?page={{ page_obj.paginator.num_pages }}">last &raquo;</a>
        {% endif %}
      </span>
    </div>
  {% endif %}
{% endblock %}
