
{% set totProducts = 0 %}
{% for product in products %}
  {% if not common['isOrder'] or common['order_info'].tpordc != 0 or common['shownotavailable'] == 1 or product.is_available %}
    {% set totProducts = totProducts + 1 %}
  {% endif %}
{% endfor %}

<div id="visual-mode">
  <div class="models-block">
    <div class="row">
      <div id="results-counter" class="col-8 col-lg-4 title-model-block">
        {{ totProducts }} {{ totProducts == 1 ? mt._('_common.searchresult') : mt._('_common.searchresults') }}
      </div>
    </div>

    <div class="row articles-container">

{% set i = 12 %}
{% for product in products %}

  {% if not common['isOrder'] or common['order_info'].tpordc != 0 or common['shownotavailable'] == 1 or product.is_available %}

    {# SET PRICE #}
    {% set currentPrice = '' %}
    {% if common['showCatalogPrice'] == 1 %}
      {% set withDiscount = false %}
      {% set currentPrice = product.catalogPrice %}
      {% if currentPrice < 0 %}
        {% set currentPrice = mt._('quantity.priceforsize.short') %}
      {% elseif currentPrice == 0 %}
        {% set currentPrice = '-' %}
      {% else %}
        {% set real_price = currentPrice %}
        {% set cust_disc = product.cust_disc > 0 ? product.cust_disc : 0 %}
        {% set disc_price = real_price * (1 - cust_disc / 100) %}
        {% set withDiscount = disc_price != real_price %}
        {% set currentPrice = disc_price|currency ~ ' ' ~ common['currency'] %}
      {% endif %}
    {% endif %}

    {# SET IMAGES #}
    {% set imgurl1 = "img/model/"  ~ product.flimag %}
    {% set imgurl2 = "img/model/"  ~ product.flimg2 %}
    <?php $exist1 = $product->flimag != '' && file_exists($imgurl1); ?>
    <?php $exist2 = $product->flimg2 != '' && file_exists($imgurl2); ?>
    {% if not exist1 %}{% set imgurl1 = "img/assets/default_model.jpg" %}{% endif %}

    {% set lg = 'col-lg-3' %}
    {% if common['ItemsPerRow'] == 1 %}
      {% set lg = 'col-lg-4' %}
    {% elseif common['ItemsPerRow'] == 2 %}
      {% set lg = 'col-lg-6' %}
    {% endif %}

      <div class="col-6 col-md-4 {{ lg }} model-box" id="{{ common['catalogProductType'] == 0 ? product.cdartn : product.cdarti }}"
        data-code="{{ common['catalogProductType'] == 0 ? product.cdartn : product.cdarti }}" data-price="{{ currentPrice }}"
        data-descr="{{ common['catalogProductType'] == 0 ? product.dsartn : product.dsarti }}">

        <div class='shop-item'>
          <div class='image-model-box shop-thumbnail'>
            {% if (not common['hasWizard']) or (common['isOrder'] and common['order_info'].tpordc == 0) %}
              {% set detailUrl = url('model/' ~ (common['catalogProductType'] == 0 ? product.cdartn : product.cdarti)) %}
            {% else %}
              {% set detailUrl = url('model/wizard/' ~ product.cdartn) %}
            {% endif %}
            <a href="{{ detailUrl }}" class='no-deco'>
    {% if i > 0 %}
              <img class='lazy' src='../img/assets/blank.gif' data-src='../{{ imgurl1 }}' alt="{{ common['catalogProductType'] == 0 ? product.dsartn : product.dsarti }}"
                {% if exist2 %}
                onmouseover="this.src='../{{ imgurl2 }}';"
                onmouseout="this.src='../{{ imgurl1 }}';"
                {% endif %}/>
              <noscript>
    {% endif %}
                <img src='../{{ imgurl1 }}' alt="{{ common['catalogProductType'] == 0 ? product.dsartn : product.dsarti }}"
                  {% if exist2 %}
                  onmouseover="this.src='../{{ imgurl2 }}';"
                  onmouseout="this.src='../{{ imgurl1 }}';"
                  {% endif %}/>
    {% if i > 0 %}
              </noscript>
    {% endif %}
            </a>

            <div class='shop-item-tools'>
              <div class="w-50 float-left text-right">
                {% if (not common['hasWizard']) or (common['isOrder'] and common['order_info'].tpordc == 0) %}
                  {% set detailUrl = url('model/' ~ (common['catalogProductType'] == 0 ? product.cdartn : product.cdarti)) %}
                {% else %}
                  {% set detailUrl = url('model/wizard/' ~ product.cdartn) %}
                {% endif %}
                <a href="{{ detailUrl }}" class="btn-product-sheet">
                  <span>{{ mt._('_common.seemore') }}</span>
                  {{ image("img/assets/product-sheet.jpg", "alt": mt._('_common.productsheet')) }}
                </a>
              </div>
            {% if (common['modelDetailStyle'] == 1 or common['modelDetailStyle'] == 6 or common['modelDetailStyle'] == 8) and common['isOrder'] %}
              <div class='w-50 float-left text-left'>
                <a href='#' class='d-none d-md-block btn-quick-shop'>
                  {{ image("img/assets/quick-shop.jpg", "alt": mt._('_common.buy')) }}
                  <span>{{ mt._('_common.buy') }}</span>
                </a>
              </div>
            {% endif %}
            </div>
          </div>

          <div class='descr-model-box'>{{ common['catalogProductType'] == 0 ? product.dsartn : product.dsarti }}</div>
          <div class='code-model-box'>
            {{ product.hasAvailabilityFlag is defined and product.hasAvailabilityFlag > 0 ? '<span class="model-code yellow-underline">': '' }}
            {{ common['catalogProductType'] == 0 ? product.cdartn : product.cdarti }}
            {{ product.hasAvailabilityFlag is defined and product.hasAvailabilityFlag > 0 ? '</span>' : '' }}
          </div>
          {% if common['showCatalogPrice'] == 1 %}
            {% if common['modelDetailStyle'] != 3 or not common['isOrder'] %}
            {{ elements.getPriceDiv(product.catalogPrice, product.cust_disc, common['currency'], common['cdvalu']) }}
            {% else %}
            {{ elements.getPriceDivWithRetail(product.catalogPrice, common['order_info'].nulist, product.retailPrice, common['order_info'].rulist, product.cust_disc) }}
            {% endif %}
          {% endif %}

    {% if common['isOrder'] and common['order_info'].tpordc == 0 %}
          <div class='availability-model-box text-center'>{{ not product.is_available ? mt._('_common.notavailable') : "&nbsp;" }}</div>
    {% endif %}

        </div>
      </div>
  {% endif %}

  {% set i = i - 1 %}

{% endfor %}
    </div>

  </div>
</div>
