{% extends 'base.html.twig' %}
{% import "macros/user_macro.html.twig" as userMacro %}
{% set title = 'product.head_title'|trans %}
{% set breadcrumb = {
('product.title'|trans): path('product_index'),
} %}
{% if searchObject.shopid is not null %}
{% set title = title ~ ' - ' ~ 'product.shop'|trans ~ ' ' ~ searchObject.shopid.name %}
{% set breadcrumb = breadcrumb|merge({
('product.shops'|trans): path('shop_list'),
(searchObject.shopid.name): path('shop_view', {id: searchObject.shopid.id}),
('product.referenced'|trans): path('product_index', {shopid: searchObject.shopid.id})
}) %}
{% elseif categsTree is not empty %}
{% set title = title ~ ' - ' %}
{% for categTree in categsTree %}
{% set breadcrumb = breadcrumb|merge({
(categTree.name): path('product_index', {categid: categTree.id})
}) %}
{% set title = title ~ categTree.name %}
{% if loop.index < categsTree|length %}
{% set title = title ~ ' : ' %}
{% endif %}
{% endfor %}
{% endif %}
{% if searchObject.brandid is not null %}
{% set title = title ~ ' - ' ~ 'product.brand'|trans ~ ' ' ~ searchObject.brandid.name %}
{% endif %}
{% block body %}
{% include 'product/partials/tabs.html.twig' with {activeTab: 'all'} %}
<div class="tipscontainer">
<div class="tipscontent2">
{% if searchObject.brandid is not null %}
<img src="{{ asset('images/main/icons/cart.png') }}" alt="" /> <a href="{{ path('shop_list', {brandid: searchObject.brandid.id}) }}">{{ 'product.see_reseller_brand'|trans({'%name%': searchObject.brandid.name}) }}</a><br />
<div class="sep1"></div>
{% endif %}
{% if is_granted(constant("App\\Entity\\User::ROLE_PRODUCT_ADMIN")) %}
<img src="{{ asset('images/main/icons/add.png') }}" alt="">
<a href="{{ path('product_create') }}">{{ 'product.create'|trans }}</a><br>
<img src="{{ asset('images/main/icons/cart.png') }}" alt="">
<a href="{{ path('brand_list') }}">{{ 'product.all_brands'|trans }}</a><br>
<img src="{{ asset('images/main/icons/cart.png') }}" alt="">
<a href="{{ path('company_list') }}">{{ 'product.all_societies'|trans }}</a><br>
{% endif %}
</div>
</div>
<div class="maincontent">
<div class="partbox">
{{ 'product.description'|trans }}<br><br>
</div>
</div>
<div class="sep1" style="clear: both;"></div>
<div class="maincontentlarge" style="clear: both;">
<div class="partbox">
{% include 'product/partials/sidebar_product_list.html.twig' %}
<div style="margin-left: 205px;">
<div style="margin-bottom: 15px;" class="partbox sorting">
<a {% if sort is null or sort == 'p.createdAt' %}class="active disabled"{% endif %}
href="{{ path('product_index', app.request.query.all|merge({sort: 'p.createdAt', direction: 'desc'})) }}">{{ 'product.filter.most_recent'|trans }}</a>
<span class="vertsep"></span>
<a {% if sort == 'p.name' %}class="active disabled"{% endif %}
href="{{ path('product_index', app.request.query.all|merge({sort: 'p.name', direction: 'asc'})) }}">{{ 'product.filter.by_name'|trans }}</a>
<span class="vertsep"></span>
<a {% if sort == 'p.totalFavorite' %}class="active disabled"{% endif %}
href="{{ path('product_index', app.request.query.all|merge({sort: 'p.totalFavorite', direction: 'desc'})) }}">{{ 'product.filter.most_liked'|trans }}</a>
</div>
{% if products is empty %}
{{ 'product.not_found'|trans }}
{% else %}
<div class="row">
<div class="col-md-12">
{{ knp_pagination_render(products, '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig') }}
</div>
</div>
{{ include ('product/partials/list.html.twig') }}
<div class="row">
<div class="col-md-12">
{{ knp_pagination_render(products, '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig') }}
</div>
</div>
{% endif %}
</div>
</div>
</div>
<div class="tipscontainer">
{#@todo publicité#}
<div class="tipstitle">{{ 'product.add_product'|trans }}</div>
<div class="tipscontent">
{{ 'product.add_product_description'|trans }}
</div>
</div>
<div class="maincontent">
<div class="partbox">
<h2>{{ 'product.last_product_review'|trans }}</h2>
<div>
{% for comment in comments %}
<div class="commentbox" style="float: left; width: 280px; margin-bottom: 10px; min-height: 145px; margin-right: 15px;">
<b><a href="{{ path('product_view', {id: comment.product.id}) }}#comments">{{ comment.product.name }}</a> : </b><br>
{% if comment.createdBy %}
{{ userMacro.avatarDiv(comment.createdBy, "float: left; margin-right: 5px; margin-bottom: 5px; clear: right;", 2, 'small') }}
{% endif %}
<div style="zmargin-left: 60px; font-size: 11px;">
{{ comment.commentresume|truncate(180,false,'[...]')|raw }}
</div>
<div style="zfloat: right; color: #999999; clear: both;" class="title4">
<img src="{{ asset('/images/main/stars' ~ comment.voteValue ~ '.png') }}" alt="" />
<span class="vertsep"></span>
{{ comment.createdAt|momentFromNow }}
</div>
</div>
{% endfor %}
</div>
</div>
<div class="partbox" style="clear: both;">
<h2>{{ 'product.moderator_team'|trans }}</h2>
{% for moderator in moderators if moderators is not empty %}
{% if moderator %}
{{ userMacro.avatarDiv(moderator, "", 2, 'small', true) }}
{% endif %}
{% endfor %}
</div>
</div>
{% endblock %}