{% set filters = {
'all': { 'label': 'Toutes les locations' },
'upcoming': { 'label': 'Locations à venir', 'condition': 'startDate > now' },
'ongoing': { 'label': 'Locations en cours', 'condition': 'startDate <= now and endDate >= now' },
'past': { 'label': 'Locations passées', 'condition': 'endDate < now' }
} %}
{% set now = "now"|date("Y-m-d") %}
{% for key, filter in filters %}
{{ filter.label }}
{% set filter_found = false %}
{% for rental in rentals %}
{% set startDate = rental.startDate|date("Y-m-d") %}
{% set endDate = rental.endDate|date("Y-m-d") %}
{% if (key == 'upcoming' and startDate > now) or
(key == 'ongoing' and startDate <= now and endDate >= now) or
(key == 'past' and endDate < now) or
(key == 'all') %}
{% set filter_found = true %}