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

{% block body_class %}content-blocks{% endblock %}

{% block title %}
it{% trans "Content blocks" %} | {{ block.super }}
{% endblock %}

{% block header %}
<div class="page-header">
	<h1>{% trans "Content blocks" %}</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"><a href=".">{% trans "Content blocks" %}</a></li>
</ul>
{% endblock %}

{% block dashboard_content %}


<div class="sub-header">
	<h2>{% trans "All content blocks" %}</h2>
</div>

{% if num_promotions %}

<table class="table table-striped table-bordered">
	<thead>
		<tr>
			<th>{% trans "Name" %}</th>
			<th>{% trans "Type" %}</th>
			<th>{% trans "Number of times used" %}</th>
			<th>{% trans "Date created" %}</th>
			<th>{% trans "Actions" %}</th>
		</tr>
	</thead>
	<tbody>
		{% for promotion in promotions %}
		<tr>
			<td>{{ promotion.name }}</td>
			<td>{{ promotion.type }}</td>
			<td>{{ promotion.num_times_used }}</td>
			<td>{{ promotion.date_created }}</td>
			<td>
				<a class="btn btn-success" href="{% url dashboard:promotion-update promotion.code promotion.id %}">{% trans "Edit" %}</a>
				<a class="btn btn-danger" href="{% url dashboard:promotion-delete promotion.code promotion.id %}">{% trans "Delete" %}</a>
			</td>
		</tr>
		{% endfor %}
	</tbody>
</table>

{% else %}

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

{% endif %}

<div class="well well-info">
	<h3 class="app-ico ico_expand icon">{% trans "Create a new content block" %}</h3>
    <form action="{% url dashboard:promotion-create-redirect %}" method="get" class="form-inline">
        {% include "partials/form_fields_inline.html" with form=select_form %}
		<button type="submit" class="btn btn-primary">{% trans "Create block" %}</button>
    </form>
</div>

{% endblock dashboard_content %}
