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

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

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

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

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

{% block dashboard_content %}
<div class="well well-info">
	<h3 class="app-ico ico_magnify icon">{% trans "Search" %}</h3>
    <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>
<div class="sub-header">
    <h2>{{ queryset_description }}</h2>
</div>
{% if user_list.count %}
<form action="." method="post" class="form-inline">
    {% csrf_token %}

<table class="table table-striped table-bordered">
    <tr>
        <th></th>
		<th>{% trans "Email" %}</th>
		<th>{% trans "First name" %}</th>
		<th>{% trans "Last name" %}</th>
		<th>{% trans "Active" %}</th>
		<th>{% trans "Staff status" %}</th>
		<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>

{% if page_obj %}
    {% include "catalogue/partials/pagination.html" %}
{% endif %}

<div class="well well-danger">
	<h3 class="app-ico ico_sync icon">{% trans "Bulk Actions" %}</h3>
	<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>


</form>

{% else %}

<p>{% trans "No customers found." %}</p>

{% endif %}

{% endblock dashboard_content %}
