{% extends 'luxuryadmin/base.html' %}
{% load staticfiles %}
{% load thumbnail %}
{% load icanhaz %}
{% load widget_tweaks %}
{% block js %}
    {{ block.super }}
    <script>
	    TODAY = '{{ today }}';
    </script>
    <script src="{% static 'luxuryadmin/js/collection.js'%}"></script>
{% endblock %}
{% block admin_content %}
    {% icanhaz "productImageRow" %}

	<ul id="adminBreadcrumbs">
		<li><a href="{% url luxuryadmin:collection %}" title="">Admin</a></li>
		<li><a href="{% url luxuryadmin:collection %}" title="">Manage collection</a></li>
		<li>{% if product %}{{ product }}{% else %}Add new item{% endif %}</li>
	</ul>
    {% include 'luxuryadmin/snippets/nav.html' with on='collection' %}
	<h1>{% if product %}Edit item - &#91;{{ product }}&#93;{% else %}Add new item{% endif %}</h1>
	<div class="adminPageWrapper">
			<form method="POST" class="itemForm"
			{% if product %}
				action="{% url luxuryadmin:product product=product.id %}"
			{% else %}
				action="{% url luxuryadmin:product %}"
			{% endif %}
			class="itemForm product">
			<div class="actions top">
				<input type="submit" value="save product"/>
			</div>
			<div id="infoForm">
			        {% include 'luxuryadmin/forms/product.html' with form=form_new_product %}
			</div>
			<h2>Add Images</h2>
			<div id="newProductImagesContainer" url="{% url luxuryadmin:xhr_update_photos %}">
				<table class="images">
					<colgroup>
						<col class="thumbnail" />
		                <col class="main" />
						<col class="order" />
		                <col class="delete" />
		            </colgroup>
		            <thead>
		                <tr>
		                    <th>Image</th>
		                    <th>Main</th>
							<th>Order</th>
		                    <th>Delete</th>
		                </tr>
		            </thead>
		            <tbody>
		           {% include 'luxuryadmin/snippets/images.html' %}
					</tbody>
				</table>
				<div class="chooseFileBox">
					<input
						class="chooseFile"
						type="file"
						name="new_photos"
						url="{% url luxuryadmin:xhr_upload_photo %}"
						multiple
					/>
				</div>
		    </div>
			<div class="actions">
				<input type="submit" value="save product"/>
			</div>
	    </form>
	</div>
{% endblock %}