{% load i18n %}
{% load lfs_tags %}

<form action="{% url lfs_set_cart_filters %}"
      method="POST">

    <table class="filters">
        <tr>
            <td class="discreet">{% trans "Pages" %}</td>
            <td></td>
            <td class="discreet">{% trans "Start" %}</td>
            <td class="discreet">{% trans "End" %}</td>
        </tr>
        <tr>
    <td>
        <div class="navigation-pages">
            {% if page.has_previous %}
                <a class="ajax-link"
                   href="{% url lfs_carts_inline %}?page=1">
                    <img src="{{ STATIC_URL }}icons/resultset_first.png"
                         alt="{% trans 'First' %}"
                         title="{% trans 'First' %}" />
                </a>
                <a class="ajax-link"
                   href="{% url lfs_carts_inline %}?page={{ page.previous_page_number }}">
                    <img src="{{ STATIC_URL }}icons/resultset_previous.png"
                         alt="{% trans 'Previous' %}"
                         title="{% trans 'Previous' %}" />
                </a>
            {% else %}
                <img src="{{ STATIC_URL }}icons/resultset_first.png"
                     alt="{% trans 'First' %}"
                     title="{% trans 'First' %}" />
                <img src="{{ STATIC_URL }}icons/resultset_previous.png"
                     alt="{% trans 'Previous' %}"
                     title="{% trans 'Previous' %}" />
            {% endif %}

            {{ page.number }} {% trans "of" %} {{ paginator.num_pages }}

            {% if page.has_next %}
                <a class="ajax-link"
                   href="{% url lfs_carts_inline %}?page={{ page.next_page_number }}">
                    <img src="{{ STATIC_URL }}icons/resultset_next.png"
                         alt="{% trans 'Next' %}"
                         title="{% trans 'Next' %}" />          
                </a>
                <a class="ajax-link"
                   href="{% url lfs_carts_inline %}?page={{ paginator.num_pages }}">
                    <img src="{{ STATIC_URL }}icons/resultset_last.png"
                         alt="{% trans 'Last' %}"
                         title="{% trans 'Last' %}" />          
                </a>

            {% else %}
                <span>
                    <img src="{{ STATIC_URL }}icons/resultset_next.png"
                         alt="{% trans 'Next' %}"
                         title="{% trans 'Next' %}" />          
                </span>
                <span>              
                    <img src="{{ STATIC_URL }}icons/resultset_last.png"
                         alt="{% trans 'Last' %}"
                         title="{% trans 'Last' %}" />          
                </span>
            {% endif %}
        </div>
    
    </td>
    <td>
        <a href="{% url lfs_set_cart_filters_date %}?start=0&amp;end=0"
           class="ajax-link">T</a>
        <a href="{% url lfs_set_cart_filters_date %}?start=1&amp;end=1"
           class="ajax-link">Y</a>
        <a href="{% url lfs_set_cart_filters_date %}?start=7&amp;end=0"
           class="ajax-link">W</a>
    </td>
    <td>
        <input type="text"
               name="start"
               value="{{ start }}">
    </td>
    <td>

        <input type="text"
               name="end"
               value="{{ end }}">               
    </td>
    <td>
        <input type="submit"
               class="ajax-save-button" />

        <a href="{% url lfs_reset_cart_filters %}"
           class="ajax-link reset">&nbsp;</a>       
    </td>           
    </tr>
    </table>
</form>
<table class="lfs-manage-table" style="margin-top:20px">
    <tr>
        <th class="small">
            {% trans 'ID' %}
        </th>
        <th class="middle" nowrap="nowrap">
            {% trans 'Creation date' %}
        </th>
        <th class="middle" nowrap="nowrap">
            {% trans 'Modification date' %}
        </th>
        <th style="small">
            {% trans 'User' %}
        </th>
        <th class="small right-padding">
            {% trans 'Total' %}
        </th>
        <th class="small right-padding">
            {% trans 'Items' %}
        </th>
        <th>
            {% trans 'Products' %}
        </th>
    </tr>

    {% for cart in carts %}
        <tr class="clickable"
            onclick="window.location='{% url lfs_manage_cart cart.id %}'">
            <td>
                {{ cart.id }}
            </td>
            <td nowrap="nowrap">
                {{ cart.creation_date|date:_("DATETIME_FORMAT") }}
            </td>
            <td nowrap="nowrap">
                {{ cart.modification_date|date:_("DATETIME_FORMAT") }}
            </td>
            <td>
                {% if cart.customer.selected_invoice_address %}
                    {{ cart.customer.selected_invoice_address.firstname }}
                    {{ cart.customer.selected_invoice_address.lastname }}
                {% else %}  
                    ---
                {% endif %}
            </td>
            <td class="number" nowrap="nowrap">
                {{ cart.total|currency }}
            </td>
            <td class="right-padding">
                {{ cart.get_amount_of_items }}
            </td>
            <td>
                {{ cart.products }}
            </td>
        </tr>
    {% endfor %}
</table>
