{% load i18n %}
{% load staticfiles %}
<div class="table-responsive">
    {% csrf_token %}
    <table class="table table-condensed transaction-list" data-url="{% url "plugins:banktransfer:import.action" event=request.event.slug organizer=request.event.organizer.slug %}">
        <thead>
        <tr>
            <th></th>
            <th>{% trans "Date" %}</th>
            <th>{% trans "Payer and reference" %}</th>
            <th>{% trans "Amount" %}</th>
            <th>{% trans "Result" %}</th>
            <th>{% trans "Order" %}</th>
        </tr>
        </thead>
        <tbody>
        {% for trans in list %}
            <tr data-id="{{ trans.id }}">
                <td class="actions">
                    {% if trans.order and trans.state == 'invalid' %}
                        <div class="btn-group" role="group">
                            <button type="button" class="btn btn-default" name="action_{{ trans.id }}" value="accept"
                                data-toggle="tooltip" title="{% trans "Accept anyway" %}" data-placement="right">
                                <span class="fa fa-check"></span>
                            </button>
                            <button type="button" class="btn btn-default" name="action_{{ trans.id }}" value="discard"
                                data-toggle="tooltip" title="{% trans "Discard" %}">
                                <span class="fa fa-trash"></span>
                            </button>
                        </div>
                    {% elif trans.state == 'nomatch' %}
                        <input type="text" class="form-control" placeholder="{% trans "Order code" %}">
                        <div class="btn-group" role="group">
                            <button class="btn btn-default" type="button" name="action_{{ trans.id }}"
                                    value="assign" data-toggle="tooltip" title="{% trans "Assign to order" %}" data-placement="right">
                                <span class="fa fa-check"></span>
                            </button>
                            <button type="button" class="btn btn-default" name="action_{{ trans.id }}" value="discard"
                                data-toggle="tooltip" title="{% trans "Discard" %}">
                                <span class="fa fa-trash"></span>
                            </button>
                        </div>
                    {% elif trans.state == 'error' or trans.state == 'already' %}
                        <div class="btn-group" role="group">
                            <button type="button" class="btn btn-default" name="action_{{ trans.id }}" value="retry"
                                data-toggle="tooltip" title="{% trans "Retry" %}" data-placement="right">
                                <span class="fa fa-refresh"></span>
                            </button>
                            <button type="button" class="btn btn-default" name="action_{{ trans.id }}" value="discard"
                                data-toggle="tooltip" title="{% trans "Discard" %}">
                                <span class="fa fa-trash"></span>
                            </button>
                        </div>
                    {% endif %}
                </td>
                <td>{{ trans.date }}</td>
                <td>
                    {{ trans.payer }}<br/>
                    {{ trans.reference }}
                    <div class="comment-box">
                        <strong>{% trans "Comment:" %}</strong>
                        <span class="comment">{{ trans.comment }}</span>
                        <a href="#" class="comment-modify btn btn-default btn-xs">
                            <span class="fa fa-edit"></span>
                        </a>
                    </div>
                </td>
                <td>{{ trans.amount|floatformat:2 }}</td>
                <td>
                    {% if trans.message %}
                        {% trans trans.message %}
                    {% elif trans.state == 'nomatch' %}
                        {% trans "No order code detected" %}
                    {% elif trans.state == 'invalid' %}
                        {% trans "Invalid for this order" %}
                    {% elif trans.state == 'error' %}
                        {% trans "Error while processing" %}
                    {% elif trans.state == 'valid' %}
                        {% trans "The order is already marked as paid" %}
                    {% elif trans.state == 'already' %}
                        {% trans "Order already paid" %}
                    {% endif %}
                </td>
                <td>
                    {% if trans.order %}
                        <a href="{% url "control:event.order" event=request.event.slug organizer=request.event.organizer.slug code=trans.order.code %}"
                            data-toggle="tooltip" title="{{ trans.order.total|floatformat:2 }} {{ request.event.currency }}">
                            {{ trans.order.code }}
                        </a>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
</div>
