{% extends 'base.html.twig' %}
{% block title %}SiteWEB{% endblock %}
{% block body %}
{% set currentPath = app.request.get('_route') %}
{% set currentparam = app.request.get('_route_params') %}
<div class="row">
<div class="col-12">
<div class="site-sous-menu">
<select class="select2 form-control list-categories-page">
<option {% if currentPath == 'all_categories' %} selected {% endif %} value="{{ absolute_url(path('all_categories')) }}">Toutes les catégories</option>
{% for categorie in categories %}
<option {% if currentparam["slug"] == categorie.slug %} selected {% endif %} value="{{ absolute_url(path('articles_categorie', {'slug': categorie.slug})) }}">{{ categorie.nom }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div class="row">
{% for article in articles %}
{% set classArticle = "" %}
{% if article.endPromo|date('Y-m-d') < "now"|date('Y-m-d') %}
{% set classArticle = "expired-article" %}
{% endif %}
<div class="col-lg-4 col-sm-12">
<div class="card card-article {{classArticle}}" style="margin-top:20px;">
{% if article.best == true %}
<div class="hot-promo" data-toggle="tooltip" title="Ne ratez pas ce promo !"></div>
<img class="hot-promo-icon" data-toggle="tooltip" title="Ne ratez pas ce promo !" src="{{asset('img/hot-promo.png')}}">
{% endif %}
<img class="card-img-top" height="140" src="{{ vich_uploader_asset(article, 'imageFile')|imagine_filter('article') }}" alt="img-promo">
<div class="card-body">
<h5 class="card-title text-center" style="float:left;font-size:15px;margin:0;" title="{{ article.titre | raw |title }}">{{ article.titre |title | slice(0, 18, true) }} {% if article.titre |length > 13 %}...{% endif %}</h5>
<br>
<h6 class="card-title text-left" style="float:left;">
<a href="{{ path('article_store', {'id': article.supplier.id}) }}">
{{article.supplier.name}}
</a>
</h6>
{% if article.endPromo|date('Y-m-d') >= "now"|date('Y-m-d') %}
<a style="float:right;" href="{{ path('web_store_article', {'slug': article.slug}) }}" class="btn btn-primary float-right">Voir Promo</a>
{% endif %}
</div>
<div class="card-footer">
<span class="period-promo {{classArticle}}"><i class="fa fa-calendar-check-o" aria-hidden="true"></i> De {{ article.beginPromo|date("d/m/Y")}} à {{ article.endPromo |date("d/m/Y")}}</span>
<span class="nbre-comment" title="Nombre des commentaires">
{% set nbrecomment = 0 %}
{% for comment in article.commentaires %}
{% if comment.actif == 1 %}
{% set nbrecomment = nbrecomment + 1 %}
{% endif %}
{% endfor %}
{{ nbrecomment }}
<i class="fa fa-comment comment-store-articles"></i>
</span>
</div>
</div>
</div>
{% endfor %}
</div>
{% endblock %}