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

{% block body_class %}catalogue{% endblock %}

{% block title %}
{% trans "Stock alerts" %} | {{ 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 "Catalogue" %}</a></li>
</ul>
{% endblock %}

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

{% block dashboard_content %}

<div class="well well-info">
	<h3 class="app-ico ico_sync icon">Filter</h3>
    <p>
	<a class="btn btn-info" href="{% url dashboard:stock-alert-list %}">{% trans "All" %}</a>
	<a class="btn btn-info" href="{% url dashboard:stock-alert-list %}?status=Open">{% trans "Open" %}</a>
	<a class="btn btn-info" href="{% url dashboard:stock-alert-list %}?status=Closed">{% trans "Closed" %}</a>
    </p>
</div>

<div class="sub-header">
	<h2>{{ description }}</h2>
</div>
{% if alerts %}
<table class="table table-striped table-bordered">
    <tr>
		<th>{% trans "Product" %}</th>
		<th>{% trans "Partner" %}</th>
		<th>{% trans "Low stock threshold" %}</th>
		<th>{% trans "Current available stock" %}</th>
		<th>{% trans "Date alert raised" %}</th>
		<th>{% trans "Status" %}</th>
        <th></th>
    </tr>
    {% for alert in alerts %}
    <tr>
		<td>{{ alert.stockrecord.product.get_title }}</td>
        <td>{{ alert.stockrecord.partner.name }}</td>
		<td>{{ alert.stockrecord.low_stock_threshold }}</td>
		<td>{{ alert.stockrecord.net_stock_level }}</td>
		<td>{{ alert.date_created }}</td>
		<td>{{ alert.status }}</td>
		<td>
			<a class="btn btn-info" href="{% url dashboard:catalogue-product alert.stockrecord.product.id %}">{% trans "Update" %}</a>
		</td>
    </tr>
    {% endfor %}
</table>

{% else %}

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

{% endif %}

{% endblock dashboard_content %}
