{% extends "lfs/base.html" %}
{% load i18n lfs_tags pagination_tags %}

{% block title %}
    {% trans 'Search results' %} - {{ block.super }}
{% endblock %}

{% block section %}search-results{% endblock %}

{% block breadcrumbs %}
    {% breadcrumbs _("Search results") %}
{% endblock %}

{% block wrapper %}

    <h1 class="first-heading">{% trans 'Search results' %}</h1>

    <label for="search">{% trans 'Search' %}:</label>
    <form action="{% url lfs_search %}"
          class="search-results-form">
        <input id="search-input"
               type="text"
               name="q" />

        <input type="submit"
               value="{% trans 'Go!' %}">
    </form>

    <p class="search-results-description">
        {% trans 'You searched for' %} <span class="search-results-query">"{{ q }}"</span>.
        {% blocktrans count total as counter %}1 product was found.{% plural %}{{ counter }} products were found.{% endblocktrans %}
    </p>

    {% if products %}

        {% if not paginator %}
            {% autopaginate products 10 %}
        {% endif %}
        {% paginate %}
        {% sorting %}

        <table class="lfs-default padding-top">
            <tr>
                <th>{% trans 'Image' %}</th>
                <th>{% trans 'Product' %}</th>
                <th class="number">{% trans 'Price' %}</th>
                <th></th>
            <tr>
            {% for product in products %}
                <tr>
                    <td>
                        <a href="{{ product.get_absolute_url }}" class="preview-100-100">
                            <img src="{{ product.get_image.image.url_100x100 }}"
                                 alt="{{ product.get_name }}"
                                 title="{{ product.get_name }}" />
                        </a>
                    </td>
                    <td>
                        <a href="{{ product.get_absolute_url }}">
                            {{ product.get_name }}
                        </a>
                        {% for property in product.get_variant_properties %}
                            <div>
                                {{ property.title }} : {{ property.value }} {{ property.unit|safe }}
                            </div>
                        {% endfor %}

                        {% for property in product.get_displayed_properties %}
                            <div>
                                {{ property.title }} : {{ property.value }} {{ property.unit|safe }}
                            </div>
                        {% endfor %}
                    </td>

                    <td class="number">
                        <div class="product-price">
                            {% if product.for_sale %}
                               <span class="for-sale-standard-price">{{ product.get_standard_price|currency:request }}</span>
                               <span class="for-sale-price">{{ product|get_for_sale_price:request|currency:request }}*</span>
                            {% else %}
                            <span class="standard-price">{{ product|get_price:request|currency:request }}*</span>
                            {% endif %}
                            {% if product.get_price_unit %}/ {{ product.get_price_unit }}{% endif %}
                            {% if product.active_base_price %}
                                <div class="base-price">
                                    {{ product|get_base_price_gross:request|currency:request}}* {% if product.get_base_price_unit %}/ {{ product.get_base_price_unit }}{% endif %}
                                </div>
                            {% endif %}
                            <div class="price-disclaimer">
                                {% trans '*inc. VAT' %}
                            </div>
                        </div>
                    </td>
                    <td class="buttons">
                        <a class="button emphasized"
                           href="{% url lfs_product product.slug %}"
                           type="submit">
                            {% trans 'Details' %}
                        </a>
                    </td>
                </tr>
            {% endfor %}
        </table>
    {% endif %}
{% endblock %}
