{% extends 'base.html.twig' %}
{% block title %}{{ 'vinyls.title'|trans }}{% endblock %}
{% block meta %}
<meta name="description" content="Mazykka Vinyles {% if search %}{{ ('navigation.' ~ search|lower)|trans|default(search) }}{% endif %}, {% for vinyl in vinyls %} {{ vinyl.designation }}{% if not loop.last %},{% endif %} {% endfor %}">
<meta name="keywords" content="Mazykka, vinyles, {% if vinyls|length > 0 %} {% for style in vinyls[0].styles %} {{ style.name }}{% if not loop.last %},{% endif %} {% endfor %} {% endif %}">
<meta property="og:url" content="path(app.request.attributes.get('_route'), app.request.attributes.get('_route_params'))" />
{% endblock %}
{% block hero %}
{% if search %}
<h1 class="text-center">{{ 'vinyls.title'|trans }} <span> {{ ('navigation.' ~ search|lower)|trans|default(search)|capitalize }} </span></h1>
{% else %}
<h1 class="text-center"><span>{{ 'vinyls.all_vinyls'|trans }}</span></h1>
{% endif %}
{% endblock %}
{% block body %}
<section class="vinyls_list">
<div class="">
<div class="filter__item">
<div class="row">
<div class="col-lg-2 col-md-3 col-sm-3 col-6">
<div>
{% set route = app.request.attributes.get('_route') %}
{% if app.request.attributes.get('stylename') %}
{% set route = route ~ "/" ~ app.request.attributes.get('stylename') %}
{% endif %}
<select class="filter__sort form-select">
<option value="{{ path(app.request.attributes.get('_route'), {'stylename': app.request.attributes.get('stylename')}) }}">{{ 'vinyls.sort_by'|trans }}</option>
<option {% if sort == "price-asc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=price&direction=asc">{{ 'vinyls.price_asc'|trans }}</option>
<option {% if sort == "price-desc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=price&direction=desc">{{ 'vinyls.price_desc'|trans }}</option>
<option {% if sort == "year-asc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=year&direction=asc">{{ 'vinyls.year_asc'|trans }}</option>
<option {% if sort == "year-desc" %}selected="selected"{% endif %} value="{{ path(app.request.attributes.get('_route'), app.request.query.all) }}{% if app.request.attributes.get('stylename') %}/{{ app.request.attributes.get('stylename') }}{% endif %}{% if app.request.query.all %}&{% else %}?{% endif %}page={{ page }}&sort=year&direction=desc">{{ 'vinyls.year_desc'|trans }}</option>
</select>
</div>
</div>
<div class="col-lg-10 col-md-6 col-sm-6 col-6 d-flex align-items-center">
<div class="filter__found text-start">
<h4>
<span>{{ vinyls.getTotalItemCount }}</span> {% if vinyls.getTotalItemCount > 1 %}{{ 'vinyl_pages.vinyl_plural'|trans }}{% else %}{{ 'vinyl_pages.vinyl_singular'|trans }}{% endif %} {% if search %}{{ ('navigation.' ~ search|lower)|trans|default(search) }}{% endif %}
</h4>
</div>
</div>
</div>
</div>
<div class="row">
{% for vinyl in vinyls %}
<div class="col-lg-3 col-md-6 col-sm-6 mt-4">
<div class="product__item d-flex flex-column h-100 bg-white rounded p-2 {% if vinyl.quantity > 0 %}box-green{% else %}box-red{% endif %}">
<div class="product__item__pic text-center">
{% if vinyl.img != null %}
<a href="{{ path('vinyls_show', {'slug': vinyl.slug}) }}">
<img src="{{ asset('uploads/vinyles/' ~ vinyl.slug ~ '/' ~ vinyl.img) }}" class="card-img-top" alt="{{ vinyl.designation }} - vinyle {{ vinyl.styles[0].name }}">
</a>
{% else %}
<a href="{{ path('vinyls_show', {'slug': vinyl.slug}) }}">
<img src="{{ asset('uploads/vinyles/default_vinyl.png') }}" class="card-img-top" alt="{{ vinyl.designation }} - vinyle {{ vinyl.styles[0].name }}">
</a>
{% endif %}
</div>
<div class="product__item__text">
<h6>
<a href="{{ path('vinyls_show', {'slug': vinyl.slug}) }}">{{ vinyl.designation }}</a>
</h6>
{% set i = 0 %}
{% for style in vinyl.styles %}
{% set i = i + 1 %}
<a href="{{ path('vinyls_search', {'styles': [style.id]}) }}">{{ style.name|capitalize }}</a>
{% if i < vinyl.styles|length %} | {% endif %}
{% endfor %}
<div>
<div class="badge text-bg-secondary">
<p>{{ vinyl.state|capitalize }}</p>
</div>
</div>
{% if vinyl.promo and vinyl.promo > 0 %}
<h5> <del class="fw-normal fs-6 me-2">{{ vinyl.price|number_format(2) }} €</del> <span class="success">{{ vinyl.promo|number_format(2) }} €{% if vinyl.state == "neuf" %} <span class="vat">{{ 'vinyl_pages.ttc'|trans }}</span>{% endif %}</span></h5>
{% else %}
<h5>{{ vinyl.price|number_format(2) }} €{% if vinyl.state == "neuf" %} <span class="vat">{{ 'vinyl_pages.ttc'|trans }}</span>{% endif %}</h5>
{% endif %}
</div>
<div class="tracklist mt-4">
{% for track in vinyl.tracks %}
<audio controls src="{{ asset('uploads/vinyles/' ~ vinyl.slug ~ '/' ~ track.filename ~ '.mp3' ) }}" controlslist="nodownload" preload="none">
{{ 'vinyl_pages.browser_no_support'|trans }}
<code>{{ 'vinyl_pages.audio_element'|trans }}</code>
{{ 'vinyl_pages.element'|trans }}
</audio>
{% endfor %}
</div>
<div class="mt-auto text-center">
{% if vinyl.quantity > 0 %}
{% if app.user %}
<a href="{{ path('cart_add', {'id': vinyl.id}) }}" class="btn btn-primary mt-2 w-100">
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
</a>
{% else %}
<button type="button" class="btn btn-primary mt-2 w-100" data-bs-toggle="modal" data-bs-target="#needConnexionModal">
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
</button>
{% endif %}
{% else %}
<h3 class="red">{{ 'vinyl_pages.out_of_stock'|trans }}</h3>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
<div class="pagination my-3 d-flex justify-content-center">
{{ knp_pagination_render(vinyls, '@KnpPaginator/Pagination/twitter_bootstrap_v4_pagination.html.twig') }}
</div>
</div>
</section>
{% endblock %}
{% block javascript %}{% endblock %}