{% extends "telemeta/base.html" %}
{% load telemeta_utils %}
{% load i18n %}

{% block head_title %}{% trans "Item" %}- {{ block.super }}{% endblock %}

{% if item %}
{% block title %}
    <img src="{% url telemeta-images "item.png" %}" alt="item" style="vertical-align:middle" /> Item : NEW
{% endblock %}

{% block title_buttons %}
    {% if perms.telemeta.add_mediaitem %}
      <a href="{% url telemeta-items %}"
           class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
    {% endif %}
{% endblock %}

{% block content %}
    {% block infos %}
    <div class="infos">
     <form method="post" id="_addItemForm" action="" enctype="multipart/form-data">{% csrf_token %}
       <ul>{% for error in form.non_field_errors %}<li class="error">{{ error }}</li>{% endfor %}</ul>
       <table>
        {% for field in form %}
            <tr>
            {% if field.html_name == "copied_from_item" %}
                <td>{{ field.label_tag.as_hidden }}{{ field.as_hidden }}</td>
            {% else %}
                <tr><td class="error">{{ field.errors }}</td></tr>
                <td>{{ field.label_tag }}:</td>
                    {% if field.html_name == "collection" %}
                    <td>&nbsp;{% trans "Title" %} : {{ item.collection.title }}<br />
                        &nbsp;{% trans "Code" %} : {{ item.collection.code }}<br />
                        {{ field }}</td>
                    {% else %}
                    <td>{{ field }}</td>
                    {% endif %}
            {% endif %}
            </tr>
    {% endfor %}
       </table>
       <div align="center" style="margin-top:3ex;">
        <a href="{% url telemeta-items %}"
           class="component_icon button icon_cancel">{% trans "Cancel" %}</a>
        <a href="#" class="component_icon button icon_save"
   onclick="var d=document; d.getElementById('wait-img').style.display='inline'; setTimeout(function(){d.getElementById('_addItemForm').submit();},300); return false;">{% trans "Save" %}</a>
           <img id="wait-img" style="display:none" style="vertical-align:middle" alt="wait" src="{% url telemeta-images "wait.gif" %}" />
       </div>
     </form>
    </div>
  {% endblock infos %}
</div> <!-- with-rightcol -->
{% endblock %}

{% block delete %}
{% endblock %}

{% else %}
<p>No such item</p>
{% endif %}
