{% 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"><a href=".">{% trans "Range management" %}</a></li>
</ul>
{% endblock %}

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

{% block dashboard_content %}

<p><a href="{% url dashboard:range-create %}" class="btn-large btn-primary">{% trans "Create new range" %}</a></p>

	<div class="sub-header">
		<h2>{% trans "All ranges" %}</h2>
	</div>
	{% if ranges.count %}
		<table class="table table-striped table-bordered">
			<tr>
				<th>{% trans "Name" %}</th>
				<th>{% trans "Num products" %}</th>
				<th>{% trans "Date created" %}</th>
				<th></th>
			</tr>
			{% for range in ranges %}
			<tr>
				<td>{{ range.name }}</td>
				<td>{{ range.num_products|default:"-" }}</td>
				<td>{{ range.date_created }}</td>
				<td>
					<a class="btn btn-primary" href="{% url dashboard:range-update range.id %}">{% trans "Edit" %}</a>
					{% if not range.includes_all_products %}
					<a class="btn btn-info" href="{% url dashboard:range-products range.id %}">{% trans "Edit products" %}</a>
					{% endif %}
					<a class="btn btn-danger" href="{% url dashboard:range-delete range.id %}">{% trans "Delete" %}</a>
				</td>
			</tr>
			{% endfor %}
		</table>
		{% if page_obj %}
			{% include "catalogue/partials/pagination.html" %}
		{% endif %}
	{% else %}
	<p>{% trans "No ranges found." %}</p>
	{% endif %}
{% endblock dashboard_content %}
