{% extends "admin/base_site.html" %}
{% load i18n admin_modify %}

{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% load adminmedia %}{% admin_media_prefix %}css/forms.css" />
<style type="text/css">
form#inventoryform input.text {
    width: 6em;
}

tr.ConfigurableProduct {
    font-style: italic;
}
</style>
{% endblock %}
{% block extrahead %}{{ block.super }}
    <script src="{{media_url}}js/jquery.cookie.js" type="text/javascript"></script>
    <script type="text/javascript">
    var satchmo = satchmo || {};
    satchmo.toggle = function(cls, state) {
        $(cls).each(function() { this.checked = state });
       return false;
    };

    $(function() {
        var c = $.cookie("satchmoadmin_exportformat");
        if (c) {
            $('#id_format')[0].value=c;
        }
  
        $('#id_format').change(function() {
            var fmt = $('#id_format')[0].value
            $.cookie("satchmoadmin_exportformat", fmt, {expires: 7});
        });
        $('#mark_all').click(function() {
            satchmo.toggle('input.export', true);
        });
        $('#unmark_all').click(function() {
            satchmo.toggle('input.export', false);
        });
    });
    </script>
{% endblock %}

{% block coltype %}colMS{% endblock %}
{% block bodyclass %}dashboard{% endblock %}
{% block userlinks %}<a href="{% url django-admindocs-docroot %}">{% trans 'Documentation' %}</a> / <a href="{% url admin:password_change %}">{% trans 'Change password' %}</a> / <a href="{% url admin:logout %}">{% trans 'Log out' %}</a>{% endblock %}
{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
     <a href="{% url admin:index %}">{% trans "Home" %}</a> &rsaquo;
     {% trans "Inventory Management" %}
</div>
{% endif %}{% endblock %}
{% block content %}
<div id="content-main">
<h1>{% trans 'WARNING: THIS FUNCTION IS STILL EXPERIMENTAL.  DO NOT USE IN PRODUCTION.' %}</h1>
<h1>{% trans 'Import' %}</h1>
{% if importform.errors %}
    <p class="errornote">
    {% blocktrans count importform.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
{% endif %}
{% if importform.fields %}
<form method="post" id="importform" action="{% url satchmo_admin_product_import %}" enctype="multipart/form-data">{% csrf_token %}
    <p>{% trans 'Import from fixture file:' %}{{ importform.upload }}</p>
    <input type="submit" value="{%trans 'Import' %}" class="Import" />
</form>
{% endif %}
<h1>{% trans 'Export' %}</h1>
{% if form.errors %}
    <p class="errornote">
    {% blocktrans count form.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
    </p>
{% endif %}
{% if form.fields %}
<form method="post" id="productform">{% csrf_token %}
    <table>
        <tr>
            <th>{% trans 'Export?' %}</th>
            <th>{% trans 'Slug' %}</th>
            <th>{% trans 'Name' %}</th>
        </tr>
    {% for field in form %}

            {% if field.is_hidden %}
                {{ field }}
            {% else %}
                {% ifchanged field.field.slug %}
                    {% if field.field.product_id %}
                    <tr class="{{ field.field.subtypes }}">
                        <td>{{ field }}</td>
                        <td><a href="{% url admin:product_product_change field.field.product_id %}">{{ field.label_tag }}</a>
                            {% if field.errors %}
                    		<span class="error">{{ field.errors }}</span><br/>
            		        {% endif %}    
                        </td>
                    {% endif %}
                        <td>{{ field.help_text}}</td></tr>
                {% endifchanged %}
        	{% endif %}

    {% endfor %}

    </table>
    <p>{% trans 'Include images?' %} {{ form.include_images }}</p>
    <p>{% trans 'Include categories?' %} {{ form.include_categories }}</p>
    <p>{% trans 'Format?' %}{{ form.format }}</p>
<input type="submit" value="{% trans 'Export' %}" class="default" />
<input type="reset" value="{% trans 'Reset' %}" class="default" />
<h2>{% trans 'Helpers' %}</h2>
<p><a href="#" id="mark_all">{% trans 'Check all' %}</p>
<p><a href="#" id="unmark_all">{% trans 'Uncheck all' %}</p>
</form>
{% else %}
    <p>{% trans "No products." %}</p>
{% endif %}
</div>
{% endblock %}
