{% extends "admin/base_site.html" %}
{% load i18n staticfiles admin_urls admin_static admin_list %}

{% block extrastyle %}{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
<style>
p.file-upload label {
    color: #333;
    font-size: 11px;
    display: inline;
    float: none;
}
</style>
{% endblock %}

{% block extrahead %}
{{block.super}}
<script type="text/javascript" src="{% static 'js/jquery-1.11.0.min.js' %}"></script>
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
{{form.media}}
{% endblock %}

{% if not is_popup %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans "Home" %}</a>
&rsaquo; <a href="{% url 'admin:app_list' app_label='pcart_data_collections' %}">{% trans "Data collections" %}</a>
&rsaquo; <a href="{% url 'admin:pcart_data_collections_datacollection_changelist' %}">{% trans "Data collections" %}</a>
&rsaquo; <a href="{% url 'admin:pcart_data_collections_datacollection_change' data_collection.pk %}">{{data_collection.title}}</a>
&rsaquo; <a href="{% url 'admin:datacollection_records_list' data_collection.pk %}">{% trans "Data Records" %}</a>
&rsaquo; {% if not data_record %}{% trans "Add data record" %}{% else %}{% trans "Change data record" %}{% endif %}
</div>
{% endblock %}
{% endif %}

{% block content %}<div id="content-main">
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %} method="post" id="datarecord_form" novalidate>{% csrf_token %}{% block form_top %}{% endblock %}
<div>
{% if form.errors %}
    <p class="errornote">
    {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
    </p>
{% endif %}

{% block field_sets %}
<h1>{% if not data_record %}
{% trans "Add data record" %}
{% else %}
{% trans "Change data record" %} <small>({{data_record.id}})</small>
{% endif %}</h1>
<fieldset class="module aligned">
{% for field in form %}
<div class="form-row{% if line.fields|length_is:'1' and line.errors %} errors{% endif %}{% if field.name %} field-{{ field.name }}{% endif %}">
    <div class="{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}{% if field.field.is_checkbox %} checkbox-row{% endif %}">
        {% if not field.is_readonly %}{{ field.errors }}{% endif %}
        {% if field.field.is_checkbox %}
            {{ field }}<label class="vCheckboxLabel{% if field.field.required %} required{% endif %}" for="id_{{field.name}}">{{ field.label }}</label>
        {% else %}
            <label class="{% if field.field.required %}required{% endif %}" for="id_{{field.name}}">{{ field.label }}</label>
            {% if field.is_readonly %}
                <p>{{ field.contents }}</p>
            {% else %}
                {% if field.field.is_file_upload %}
                    <p class="file-upload">{{field}}</p>
                {% else %}
                    {{ field }}
                {% endif %}
            {% endif %}
        {% endif %}
        {% if field.field.help_text %}
            <p class="help">{{ field.field.help_text|safe }}</p>
        {% endif %}
    </div>
</div>
{% endfor %}
</fieldset>
{% endblock %}

{% block submit_buttons_bottom %}
<div class="submit-row">
<input type="submit" value="{% trans "Save" %}" class="default" name="_save" />
{% if show_delete_link %}
<script>
    function delete_record() {
        if(confirm("{% trans "Do you really want to delete this record?" %}")) {
            window.location = "{% url 'admin:datacollection_records_delete' data_collection.pk data_record.pk %}";
        }
    };
</script>
    <p class="deletelink-box"><a href="javascript:delete_record()" class="deletelink">{% trans "Delete" %}</a></p>
{% endif %}
{% if show_save_and_add_another %}<input type="submit" value="{% trans "Save and add another" %}" name="_addanother" />{% endif %}
{% if show_save_and_continue %}<input type="submit" value="{% trans "Save and continue editing" %}" name="_continue" />{% endif %}
</div>

{% endblock %}
</div>
</form></div>
{% endblock %}
