{% extends "layout.html" %}

{% load currency_filters %}
{% load history_tags %}
{% load basket_tags %}

{% block header %}
<h2>{{item.get_title}}</h2>
{% endblock header %}


{% block content %}
<div class="images">
    {% for image in item.images.all %}
    <img src="{{ image.fullsize_url }}" title="{{ item.get_title }}" />
    {% if image.caption %}
        <div class="caption">{{ image.caption }}</div>
    {% endif %}
    {% endfor %}
</div>

<table>
    <caption>Product details</caption>
    <tr>
        <th>UPC</th><td>{{item.upc}}</td>
    </tr>
    <tr>
        <th>Product class</th><td><a href="{{ item.product_class.get_absolute_url }}">{{item.product_class.name}}</a></td>
    </tr>
{% if item.stockrecord %}
    <tr>
        <th>Price (excl. tax)</th><td>{{item.stockrecord.price_incl_tax|currency}}</td>
    </tr>
    <tr>
        <th>Price (incl. tax)</th><td>{{item.stockrecord.price_excl_tax|currency}}</td>
    </tr>
    <tr>
        <th>Availability</th>
        <td>{{ item.stockrecord.availability }}</td>
    </tr>
{% endif %}
    <tr>
        <th>Product type</th>
        <td>
        {% if item.is_group %}Product group{% else %}{% if item.is_variant %}Variant{% else %}Stand-alone{% endif %}{% endif %}
        </td>
    </tr>
    {% for attribute in item.attributes.all %}
    <tr>
        <th>{{ attribute.type.name }}</th>
        <th>{{ attribute.value }}</th>
    </tr>
    {% endfor %}
</table>

Batteries Needed: {{ item.batteries_needed }}
Batteries Included: {{ item.batteries_needed }}

{% if item.stockrecord %}

{% basket_form item as form %}

<form action="{% url oscar-basket %}" method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Add to basket" />
</form>
{% endif %}

{% recently_viewed_products %}

{% if item.related_items.count %}
<div class="products">
    <h4>Related items</h4>
    <ul>
    {% for product in item.related_items.all %}
        <li><a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a>
    {% endfor %}
    </ul>
</div>
{% endif %}

{% if item.recommended_items.count %}
<div class="products">
    <h4>Recommended items</h4>
    <ul>
    {% for product in item.recommended_items.all %}
        <li><a href="{{ product.get_absolute_url }}">{{ product.get_title }}</a>
    {% endfor %}
    </ul>
</div>
{% endif %}

{% endblock content %}

