{% extends "basket/base.html" %}
{% load i18n %}

{% block title %}{% trans 'Basket' %}{% endblock title %}

{% block content %}
<style type="text/css">
.delete {
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAXUlEQVR42u2SwQoAIAhD88vVLy8KBlaS0i1oJwP3piGVg0Skmpq8HjqZrWl9uwCbGAmwKYGZs/6iqgMyAdJuM8W2QmYKpLt/0AG9ASCv/oAnANd3AEjmAlFT1BypAV+PnRH5YehvAAAAAElFTkSuQmCC) left center no-repeat;
padding-left:20px;
}
</style>
<script type="text/javascript">
<!--
$(document).ready(function() {
    $('#basket-refresh').click(function() {
        $(this).after('<input type="hidden" name="refresh" value="1" />');
    });

    // {% if delete %}
    {% include "basket/delete-script.js" %}
   // {% endif %}
});
//-->
</script>
{% if formset.forms %}
<div id="basket_page_forms">
    <form action="." method="post">
	    <table class="checkout">
	        <tr>
	            <th>&nbsp;</th>
	            <th>{% trans 'Item name' %}</th>
	            <th>{% trans 'Price' %}</th>
	            <th>{% trans 'Quantity' %}</th>
	            <th>{% trans 'Total' %}</th>
	        </tr>
	        {% for form in formset.forms %}
			<tr class="dynamic-form">
	            <td>
                {% if delete %}
                <a class="delete" href="#" onclick="return basket.del(this, {{ form.instance.content_type.id }}, {{ form.instance.content_object.id }});" title="{% trans 'Remove' %}"></a>
                {% endif %}
                
                {{ form.keep }}{{ form.content_type }}{{ form.object_id }}{{ form.id }}</td>
	            <td><a target="_blank" href="{{ form.instance.content_object.get_absolute_url }}" title="{% trans 'Go to item page' %}">{{ form.instance.content_object }}</a></td>
				<td>{{ form.instance.get_price }}</td>
				<td>{{ form.quantity }}{{ form.quantity.errors }}</td>
				<td>{{ form.instance.get_sum }}</td>
			</tr>
	        {% endfor %}
	        <tr>
	            <th colspan="3">{% trans 'Total' %}</th>
	            <th>{{ order.goods }}</th>
	            <th>{{ order.summary }}</th>
	        </tr>
	    </table>
        <p>
		    {{ formset.management_form }}
		    {% csrf_token %}
            <input type="submit" value="{% trans 'Go to checkout' %}" />
            <input type="submit" id="basket-refresh" value="{% trans 'Update items' %}" />
        </p>
	</form>
    {# if you want, you can show order info form here #}
    
    <form action="{% url order_confirm %}" id="basket_order_submit_form" method="POST">
        {{ order_form.as_p }}
        {% csrf_token %}
        <input type="submit" value="{% trans 'Submit order' %}" />
    </form>
{% else %}
	<p>{% trans 'Your basket is empty' %}</p>
{% endif %}
</div>

{% endblock content %}
