{% extends 'dashboard.html' %}
{% load static %}

{% block head_title %}Customers | {% endblock %}

{% block content %}
<article>
    <header class="object-header">
        <h1><img src="{% static 'images/customer.png' %}"> Customers</h1>
    </header>
    <section class="panel">
        <header class="panel-header">
            <h4></h4>
        </header>
        <table>
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Email</th>
                    <th>Orders</th>
                </tr>
            </thead>
            <tbody>
                {% for customer in user_list  %}
                <tr class="is-link" onclick="window.location='{% url 'dashboard:customer-detail' customer.pk %}'">
                    <td>{{customer.get_full_name}}</td>
                    <td>{{customer.email}}</td>
                    <td>{{customer.num_orders}}</td>
                </tr>
                {% empty %}
                <tr>
                    <td colspan="3">No customers</td>
                </tr>
                {% endfor %}
            </tbody>
            <tfoot>
                <tr>
                    <td>
                    {% 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 %}
                    </td>
                </tr>
            </tfoot>
        </table>
    </section>
</article>
{% endblock content %}
