{% extends 'dashboard/layout.html' %}
{% load currency_filters %}
{% block body_class %}catalogue{% endblock %}
{% block title %}
Stock alerts | {{ block.super }}
{% endblock %}
{% block breadcrumbs %}
<ul class="breadcrumb">
    <li>
        <a href="{% url dashboard:index %}">Dashboard</a>
        <span class="divider">/</span>
    </li>
    <li class="active"><a href=".">Catalogue</a></li>
</ul>
{% endblock %}

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

{% block dashboard_content %}

{% comment %}
<form action="." method="get" class="form-horizontal">
	{% include "partials/form_fields.html" with form=form %}
	<div class="form-actions">
		<button type="submit" class="btn btn-primary">Search</button>
	</div>
</form>
{% endcomment %}

<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 %}">All</a>
    	<a class="btn btn-info" href="{% url dashboard:stock-alert-list %}?status=Open">Open</a>
    	<a class="btn btn-info" href="{% url dashboard:stock-alert-list %}?status=Closed">Closed</a>
    </p>
</div>

<div class="sub-header">
	<h2>{{ description }}</h2>
</div>
{% if alerts %}
<table class="table table-striped table-bordered">
    <tr>
        <th>Product</th>
        <th>Partner</th>
        <th>Low stock threshold</th>
        <th>Current available stock</th>
		<th>Date alert raised</th>
		<th>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 %}">Update</a>
		</td>
    </tr>
    {% endfor %}
</table>

{% else %}

<p>No stock alerts found.</p>

{% endif %}

{% endblock dashboard_content %}
