{% set eventsoncalendar = [] %}
{% set eventsonmap = [] %}
{% for event in events %}
{% for eventdate in event.eventdates %}
{% if eventdate.isOnSale %}
{% if eventdate.venue and services.getSetting("show_map_button") == "yes" %}
{% if eventdate.venue.lat and eventdate.venue.lng %}
{% if eventsonmap|length == 0 %}
{% set eventsonmap = eventsonmap|merge([{"name": event.name, "image": event.imageName ? asset(event.getImagePath) : event.getImagePlaceholder, "address": (eventdate.venue.name ~ ": " ~eventdate.venue.stringifyAddress),"date": (eventdate.startdate|localizeddate('none', 'none', app.request.locale, date_timezone, date_format)), "price": (eventdate.isFree ? "Free"|trans : eventdate.getCheapestTicket.getSalePrice), "lat":eventdate.venue.lat, "lng":eventdate.venue.lng, "link": (path('event', { slug: event.slug })) }]) %}
{% else %}
{% for eventonmap in eventsonmap %}
{% if eventonmap.lat != eventdate.venue.lat and eventonmap.lng != eventdate.venue.lng %}
{% set eventsonmap = eventsonmap|merge([{"name": event.name, "image": event.imageName ? asset(event.getImagePath) : event.getImagePlaceholder, "address": (eventdate.venue.name ~ ": " ~eventdate.venue.stringifyAddress),"date": (eventdate.startdate|localizeddate('none', 'none', app.request.locale, date_timezone, date_format)), "price": (eventdate.isFree ? "Free"|trans : eventdate.getCheapestTicket.getSalePrice), "lat":eventdate.venue.lat, "lng":eventdate.venue.lng, "link": (path('event', { slug: event.slug })) }]) %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% if services.getSetting("show_calendar_button") == "yes" %}
{% set eventsoncalendar = eventsoncalendar|merge([{"title": event.name, "start":eventdate.startdate|date('Y-m-d H:i'), "end": (eventdate.enddate ? eventdate.enddate|date('Y-m-d H:i') : ''), "url": (path('event', {slug : event.slug})) }]) %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% if eventsonmap|length > 0 and services.getSetting("show_map_button") == "yes" and google_maps_api_key != "" %}
{% endif %}
{% if eventsoncalendar|length > 0 and services.getSetting("show_calendar_button") == "yes" %}
{% endif %}
{{ "%resultsCount% event(s) found"|trans({'%resultsCount%': events.getTotalItemCount}) }}
{% if events.getTotalItemCount > 0 %}
{% if eventsonmap|length > 0 and services.getSetting("show_map_button") == "yes" and google_maps_api_key != "" %}
{% endif %}
{% if eventsoncalendar|length > 0 and services.getSetting("show_calendar_button") == "yes" %}
{% endif %}
{% if services.getSetting("show_rss_feed_button") == "yes" %}
{% endif %}
{% endif %}
{% if events.getTotalItemCount > 0 %}
{% for event in events %}
{% include "Global/event-card.html.twig" with {event: event} %}
{% endfor %}
{% else %}
{% include "Global/message.html.twig" with { type: "info", message: ('No events found'|trans), icon: "fas fa-exclamation-circle" } %}
{% endif %}
{{ knp_pagination_render(events, null, {}, {'align': 'center'}) }}
{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('events') }}
{% if services.getSetting("show_map_button") == "yes" and google_maps_api_key != "" %}
{% include "Global/event-info-box.html.twig" %}
{% endif %}
{% endblock %}