{% load i18n lfs_tags %}

<h2>{% trans 'Data' %}</h2>

<form id="product-data-form"
      action="{% url lfs.manage.views.edit_product_data product.id %}"
      method="post">
      
        <fieldset>
            <legend>{% trans "General" %}</legend>
            <div class="field">
                <div class="label">
                    {{ form.active.label_tag }}:
                </div>
                <div>
                    {{ form.active }}
                </div>
            </div>

            <div class="field">
                <div class="label">
                    {% if product.is_variant %}
                        {{ form.active_name }}
                    {% endif %}
                    {{ form.name.label_tag }}:
                </div>

                {% if form.name.errors %}
                    <div class="error">
                        {{ form.name }} 
                        {{ form.name.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.name }}
                        {% if product.is_variant %}
                            {{ product.parent.name }}
                        {% endif %}
                    </div>                                        
                {% endif %}
            </div>            
        </fieldset>

        <fieldset>
            <legend>{% trans "Urls" %}</legend>

            <div class="field">
                <div class="label">
                    {{ form.slug.label_tag }}:
                </div>

                {% if form.slug.errors %}
                    <div class="error">
                        {{ form.slug }}
                        {{ form.slug.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.slug }}
                        {% if product.is_variant %}
                            {{ product.parent.slug }}
                        {% endif %}
                    </div>
                {% endif %}
            </div>

            <div class="field">
                <div class="label">
                    {% trans "Redirect to" %}
                </div>
                <div>
                    <input type="text"
                           id="redirect_to"
                           name="redirect_to"
                           value="{{ redirect_to }}" />
                </div>
            </div>

        </fieldset>

        <fieldset>
            <legend>{% trans "Article numbers" %}</legend>
            <div class="field">
                <div class="label">
                    {% if product.is_variant %}
                        {{ form.active_sku }}
                    {% endif %}

                    {{ form.sku.label_tag }}:
                </div>

                {% if form.sku.errors %}
                    <div class="error">
                        {{ form.sku }}
                        {{ form.sku.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.sku }}
                        {% if product.is_variant %}
                            {{ product.parent.sku }}
                        {% endif %}
                    </div>
                {% endif %}
            </div>
            <div class="field">
                <div class="label">
                    {{ form.sku_manufacturer.label_tag }}:
                </div>

                {% if form.sku.errors %}
                    <div class="error">
                        {{ form.sku_manufacturer }}
                        {{ form.sku_manufacturer.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.sku_manufacturer }}
                    </div>
                {% endif %}
            </div>
        </fieldset>

        <fieldset>
            <legend>{% trans "Prices" %}</legend>
            <div class="field">
                <div class="label">
                    {% if product.is_variant %}
                        {{ form.active_price }}
                    {% endif %}

                    {{ form.price.label_tag }}:
                </div>

                {% if form.price.errors %}
                    <div class="error">
                        {{ form.price }}
                        {{ form.price.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.price }}
                        {% if product.is_variant %}
                            {{ product.parent.price|currency }}
                        {% endif %}
                    </div>
                {% endif %}
            </div>

            {% if not product.is_variant %}
                <div class="field">
                    <div class="label">
                        {{ form.tax.label_tag }}:
                    </div>

                    {% if form.tax.errors %}
                        <div class="error">
                            {{ form.tax }}
                            {{ form.tax.errors }}
                        </div>
                    {% else %}
                        <div>
                            {{ form.tax }}
                        </div>
                    {% endif %}
                </div>
            {% endif %}

            {% if product.is_configurable_product %}
                <div class="field">
                    <div class="label">
                        {{ form.active_price_calculation }}
                        {{ form.price_calculation.label_tag }}:
                    </div>

                    {% if form.price.errors %}
                        <div class="error">
                            {{ form.price_calculation }}
                            {{ form.price_calculation.errors }}
                        </div>
                    {% else %}
                        <div>
                            {{ form.price_calculation }}
                        </div>
                    {% endif %}
                </div>
            {% endif %}

            <div class="field">
                <div class="label">
                    {{ form.price_calculator.label_tag }}:
                </div>

                {% if form.price.errors %}
                    <div class="error">
                        {{ form.price_calculator}}
                        {{ form.price_calculator.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.price_calculator }}
                        {{ form.price_calculator.help_text }}
                    </div>
                {% endif %}
            </div>

                        {% if product.is_variant %}
                <div class="field">
                    <div class="label">
                        {{ form.for_sale.label_tag }}:
                    </div>
                    <div>
                        {{ form.active_for_sale }}

                        {% if product.parent.for_sale %}
                            {% trans 'Yes' %}
                        {% else %}
                            {% trans 'No' %}
                        {% endif %}
                    </div>
                </div>
                <div class="field">
                    <div class="label">
                        {{ form.active_for_sale_price }}
                        {{ form.for_sale_price.label_tag }}:
                    </div>
                    <div>
                        {{ form.for_sale_price }}
                        {{ product.parent.for_sale_price|currency }}
                    </div>

                </div>
            {% else %}
                <div class="field">

                    <div class="label">
                        {{ form.for_sale }}
                        {{ form.for_sale.label_tag }}:
                    </div>

                    {% if form.for_sale_price.errors %}
                        <div class="error">
                            {{ form.for_sale_price }}
                            {{ form.for_sale_price.errors }}
                        </div>
                    {% else %}
                        <div>
                            {{ form.for_sale_price }}
                        </div>
                    {% endif %}
                </div>
            {% endif %}

        </fieldset>

        {% if not product.is_variant %}
            <fieldset>
                <legend>{% trans "Units" %}</legend>
                <div class="field">
                    <div class="label">
                        {{ form.unit.label_tag }}:
                    </div>
                    <div>
                        {{ form.unit }}
                    </div>
                </div>
                <div class="field">
                    <div class="label">
                        {{ form.price_unit.label_tag }}:
                    </div>
                    <div>
                        {{ form.price_unit }}
                    </div>
                </div>
            </fieldset>
        {% endif %}

        <div class="field">
            <div class="label">
                {% if product.is_variant %}
                    {{ form.active_short_description }}
                {% endif %}
                {{ form.short_description.label_tag }}:
            </div>

            {% if form.short_description.errors %}
                <div class="error">
                    {{ form.short_description }}
                    {{ form.short_description.errors }}
                </div>
            {% else %}
                <div>
                    {{ form.short_description }}
                </div>
            {% endif %}
        </div>

        <div class="field">
            <div class="label">
                {% if product.is_variant %}
                    {{ form.active_description }}
                {% endif %}
                {{ form.description.label_tag }}:
            </div>

            {% if form.description.errors %}
                <div class="error">
                    {{ form.description }}
                    {{ form.description.errors }}
                </div>
            {% else %}
                <div>
                    {{ form.description }}
                </div>
            {% endif %}
        </div>

        <fieldset>
            <legend>{% trans "Appearance" %}</legend>
            <div class="field">
                <div class="label">
                    {% if product.is_variant %}
                        {{ form.active_static_block }}
                    {% endif %}
                    {{ form.static_block.label_tag }}:
                </div>

                {% if form.static_block.errors %}
                    <div class="error">
                        {{ form.static_block }}
                        {{ form.static_block.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.static_block }}
                    </div>
                {% endif %}
            </div>

            <div class="field">
                <div class="label">
                    {{ form.template.label_tag }}:
                </div>
                {% if form.template.errors %}
                    <div class="error">
                        {{ form.template }}
                        {{ form.template.errors }}
                    </div>
                {% else %}
                    <div>
                        {{ form.template }}
                    </div>
                {% endif %}
            </div>
        </fieldset>
        <div class="buttons">
            <input class="ajax-save-button button"
                   type="submit"
                   value="{% trans 'Save data' %}" />
        </div>           
</form>