{% extends 'dashboard/layout.html' %}
{% load dashboard_tags %}
{% load i18n %}

{% block body_class %}users{% endblock %}

{% block title %}
{% trans "Customers" %} | {{ block.super }}
{% endblock %}

{% block header %}
<div class="page-header"> 	
    <h1>{% trans "Customers" %}</h1>
</div>
{% endblock header %}

{% block breadcrumbs %}
<ul class="breadcrumb">	  	
    <li>	  	
        <a href="{% url dashboard:index %}">{% trans "Dashboard" %}</a>	  	
        <span class="divider">/</span>	  	
    </li>	  	
    <li class="active">{% trans "Customers" %}</li>	  	
</ul>
{% endblock %}

{% block dashboard_content %}
<div class="table-header">
    <h3><i class="icon-search icon-large"></i> {% trans "Search" %}</h3>
</div>
<div class="well">
    <form action="." method="get" class="form-inline">
        {% include "partials/form_fields_inline.html" with form=form %}
		<input type="submit" value="{% trans "Search" %}" class="btn btn-primary"/>
		<a href="{% url dashboard:users-index %}" class="btn">{% trans "Reset" %}</a>
    </form>
</div>


{% if user_list.count %}
<form action="." method="post" class="form-inline">
    {% csrf_token %}
    <table class="table table-striped table-bordered table-hover">
        <caption>
            <h3 class="pull-left">
                <i class="icon-group icon-large"></i>
                {% if queryset_description != "All users" %}
                  {{ queryset_description }}
                {% endif %}
            </h3>
            <div class="pull-right">
                <div class="form-inline">
                    <i class="icon-refresh"></i> {% trans "Bulk Actions" %}
                    <label for="inlineCheckboxes">{% trans "With selected customers:" %}</label>
                    <label>
                        <input type="radio" name="action" value="make_active" /> {% trans "Make active" %}
                    </label>
                    <label>
                        <input type="radio" name="action" value="make_inactive" /> {% trans "Make inactive" %}
                    </label>
                    <input type="submit" value="{% trans "Go!" %}" class="btn btn-primary" />
                </div>
            </div>
        </caption>
        <tr>
            <th></th>
            <th>{% trans "Email" %}</th>
            <th>{% trans "First name" %}</th>
            <th>{% trans "Last name" %}</th>
            <td>{{ user.is_active|yesno:_("True,False") }}</td>
            <td>{{ user.is_staff|yesno:_("True,False") }}</td>
            <th>{% trans "Date registered" %}</th>
            <th>{% trans "Num Orders" %}</th>
            <th></th>
        </tr>
        {% for user in user_list %}
        <tr>
            <td><input type="checkbox" name="selected_user" class="selected_user" value="{{ user.id }}"/>
            <td>{{ user.email }}</td>
            <td>{{ user.first_name }}</td>
            <td>{{ user.last_name }}</td>
            <td>{{ user.is_active }}</td>
            <td>{{ user.is_staff }}</td>
            <td>{{ user.date_joined|date:"d/m/y H:s" }}</td>
            <td>{% num_orders user %}</td>
            <td>
                <a href="{% url dashboard:user-detail user.id %}" class="btn btn-info">{% trans "View" %}</a>
            </td>
        </tr>
        {% endfor %}
    </table>
    {% include "partials/pagination.html" %}
</form>

{% else %}
<table class="table table-striped table-bordered table-hover">
    <caption>{{ queryset_description }}</caption>
    <tr><td>{% trans "No customers found." %}</td></tr>
</table>
{% endif %}

{% endblock dashboard_content %}
