{% extends 'base.html.twig' %}
{% block page_container %}
<section class="bg-white">
<div class="page-wrapper section-content-group">
{% include "app/OnlineStore/_breadcrumb.html.twig" %}
</div>
</section>
<div class="page-wrapper">
<div class="row mt-1r">
<div class="col-sm-12 col-md-12 col-xs-12 mb-4 mx-0">
<div class="row">
<div class="col-sm-3 col-md-3 col-xs-12 mb-4 mx-0">
<a href="{{ path('app_online_store') }}" class="link-online">
<p class="ff-os-semibold ct-blue fs-22">{{ "section.templates.store_online.content.categories"|trans }}</p>
</a>
{% include "app/OnlineStore/_childs.html.twig" with {
'parentGroup': parentGroup
} %}
</div>
<div class="offset-1 col-sm-8 col-md-8 col-xs-12 section-online">
<div id="results">
<div class="row">
{% for offer in offers|reverse|slice(-1, 1) %}
<div class="col-md-12 col-xs-12 {% if not is_mobile() %}col-pa-7{% endif %}">
{% if offer.url|default(0) %}
<a href="{{ offer.url }}">
<img src="{{ vich_uploader_asset(offer, 'imageFile') }}" class="img-fluid">
</a>
{% else %}
<img src="{{ vich_uploader_asset(offer, 'imageFile') }}" class="img-fluid">
{% endif %}
</div>
{% endfor %}
</div>
<div class="row mt-1r">
{% for offer in offers|slice(1, 3) %}
<div class="col-md-4 col-xs-12 {% if not is_mobile() %}col-pa-7{% endif %} mb-1r">
{% if offer.url|default(0) %}
<a href="{{ offer.url }}">
<img src="{{ vich_uploader_asset(offer, 'imageFile') }}" class="img-fluid">
</a>
{% else %}
<img src="{{ vich_uploader_asset(offer, 'imageFile') }}" class="img-fluid">
{% endif %}
</div>
{% endfor %}
</div>
{# render Ajax template #}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ encore_entry_script_tags('accordion') }}
<script>
function getResults(groupId, order = '', attribute = '') {
$.ajax({
type: "GET",
url: '{{ path('app_results_products') }}',
data: {
parentGroup: groupId,
order: order,
attribute: attribute
}
})
.done(function(response){
template = response;
$('#results').html(template);
})
.fail(function(jqXHR, textStatus, errorThrown){
alert('Error : ' + errorThrown);
});
}
$('.myaccordion').click(function() {
let id = $(this).attr('id');
});
$('.myaccordion a').click(function(event) {
getResults($(this).data().groupId);
});
$(document).on('click', '.order', function() {
let order = $(this).data().order;
let attribute = $(this).data().attribute;
let parentGroupId = $('#parent_group_result').data().groupId;
getResults(parentGroupId, order, attribute);
});
</script>
{% endblock %}