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

{% block title %}
{% trans "Range management" %} | {{ 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">{% trans "Range management" %}</li>
</ul>
{% endblock %}

{% block header %}
<div class="page-header">
    <a href="{% url dashboard:range-create %}" class="btn btn-primary btn-large pull-right"><i class="icon-plus"></i> {% trans "Create new range" %}</a>
    <h1>{% trans "Range management" %}</h1>
</div>
{% endblock header %}

{% block dashboard_content %}

<table class="table table-striped table-bordered">
    <caption><i class="icon-reorder icon-large"></i> {% trans "Ranges" %}</caption>
    {% if ranges.count %}
    <thead>
        <tr>
            <th>{% trans "Name" %}</th>
            <th>{% trans "Num products" %}</th>
            <th>{% trans "Date created" %}</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    {% for range in ranges %}
    <tr>
        <td>{{ range.name }}</td>
        <td>{{ range.num_products|default:"-" }}</td>
        <td>{{ range.date_created }}</td>
        <td>
            <div class="btn-toolbar">
                <div class="btn-group">
                  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
                    Actions
                    <span class="caret"></span>
                  </a>
                  <ul class="dropdown-menu pull-right">
				      {% if range.is_editable %}
                      <li><a href="{% url dashboard:range-update range.id %}">{% trans "Edit" %}</a></li>
                      {% if not range.includes_all_products %}
                      <li><a href="{% url dashboard:range-products range.id %}">{% trans "Edit products" %}</a></li>
                      {% endif %}
					  {% endif %}
                      <li><a href="{% url dashboard:range-delete range.id %}">{% trans "Delete" %}</a></li>
                  </ul>
                </div>
            </div>
        </td>
    </tr>
    {% endfor %}
    </tbody>
    {% else %}
        <tr><td>{% trans "No ranges found." %}</td></tr>
    {% endif %}
</table>
{% include "partials/pagination.html" %}

{% endblock dashboard_content %}
