{% extends "pbp_store/admin_base.html" %}
{% load url from future %}
{% load thumbnail %}
{% load catalog_filters %}

{% block body %}

View : 
{% if category == 'all' %} All {% else %}<a href="{% url 'catalog_list' %}">All</a>{% endif %}
|
{% if category == 'book' %} Books {% else %}<a href="{% url 'catalog_book_list' %}">Books</a>{% endif %}
|
{% if category == 'movie' %} Movies {% else %}<a href="{% url 'catalog_movie_list' %}">Movies</a>{% endif %}
|
{% if category == 'map' %} Maps {% else %}<a href="{% url 'catalog_map_list' %}">Maps</a>{% endif %}
|
{% if category == 'subscription' %} Subscriptions {% else %}<a href="{% url 'catalog_subscription_list' %}">Subscriptions</a>{% endif %}

<table class="table table-striped table-bordered">
    <thead>
        <tr>
            <th>Image</th>
            <th>Type</th>
            <th>Sku</th>
            <th>Title</th>
            <th>Description</th>
            <th>Price</th>
            <th>Shipping Cost</th>
            <th>Featured?</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
{% for item in catalog %}
    <tr>
        <td>{% thumbnail item.image "64x92" as im %}
            <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
            {% endthumbnail %}
        </td>
        <td>{{ item.subclass_type }}</td>
        <td>{{ item.sku }}</td>
        <td>{{ item.title }}</td>
        <td>{{ item.short_description }}</td>
        <td>{{ item.price|currency }}</td>
        <td>{{ item.shipping_cost|currency }}</td>
        <td>{{ item.featured|yesno }}</td>
        <td>
            {% if perms.pbp_core.store_catalog_edit %}
            [<a href="{{item.edit_link}}">Edit</a>] [<a href="{% url 'catalog_delete_item' item.sku %}">delete</a>]
            {% else %}
            n/a
            {% endif %}
            </td>
    </tr>
{% empty %}
    <tr><td colspan="9">No items!</td></tr>
{% endfor %}
</table>

{% if perms.pbp_core.store_catalog_edit %}
<ul>
    <li><a href="{% url 'catalog_add_book' %}">Add Book</a></li>
    <li><a href="{% url 'catalog_add_map' %}">Add Map</a></li>
    <li><a href="{% url 'catalog_add_movie' %}">Add Movie</a></li>
    <li><a href="{% url 'catalog_add_subscription' %}">Add Subscription</a></li>
</ul>
{% endif %}

{% endblock body %}