{% load danceschool_tags i18n %}

{% if regClosedSeries %}
	<h2 class="mt-4 reg-section-header">{% trans "Ongoing Series (Registration Closed)" %}</h2>
	<hr />
{% regroup regClosedSeries|dictsort:"month" by month as closed_list %}
	{% for month in closed_list %}
	<div class="reg-section">
        <h3 class="mt-4">{{ month.grouper|readable_month }} {% trans "Class Series" %}</h3>
		<div class="reg-event-group mt-4">
		{% regroup month.list|dictsort:"weekday" by weekday as weekday_list %}
			{% for weekday in weekday_list %}
				
				<div class="card reg-weekday-group">
					<h3 class="card-header reg-weekday-header">{% readable_weekday weekday.grouper %}s</h3>
					
					{% for event in weekday.list %}
					<a name="{{ event.slug }}"></a>
					
					<h5 class="card-header reg-event-header">
						{{ event.startTime|date:"g:i A" }} - {{ event.endTime|date:"g:i A" }}
					</h5>

					<div class="card-body row reg-event" id="reg-event-{{ event.id}}">
						<div class="col-lg-9 col-md-8 reg-event-info">

							<h3 class="card-title reg-event-title">{{ event.name }}</h3>
							
							<h6 class="card-subtitle text-muted reg-event-details">
								{% if event.teachers %}
									{% trans "with" %} {{ event.teachers|join:" &amp; "}}
								{% endif %}
								at
									{% if directions_url %}
									<a href = "{{ directions_url }}#{{ event.location.name|slugify }}">
										{{ event.location.name }}{% if event.room.name %} - {{ event.room.name }}{% endif %}
									</a>
									{% else %}
										{{ event.location.name }}{% if event.room.name %} - {{ event.room.name }}{% endif %}
									{% endif %}

	                                {% if event.url %}<small><a href="{{ event.url }}">{% trans "more info" %}</a></small>{% endif %}
							</h6>
	                        
	                        <div class="card-text reg-event-dates mt-4">
								{% for occurrence in event.eventoccurrence_set.all %}
									{{ occurrence.startTime|date:"N j"}}{% if not forloop.last %}, {% endif %}
								{% endfor %}
							</div>
						</div>
						<div class="col-lg-3 col-md-4 reg-event-register pt-3">
                        	<ul class="list-unstyled">
                            	{% for role in event.availableRoles %}
									<li>{{ role.pluralName }} ({% numRegisteredForRole event role  %} {% trans "registered" %})</li>
								{% empty %}
									<li>({{ event.numRegistered }} {% trans "registered" %})</li>
								{% endfor %}
							</ul>
                            {% if perms.core.override_register_closed %}
								{% get_field_for_object 'event' event.id form as field %}
                            	{{ field }}
		                        {% if validationStr %}
									<div class="alert alert-danger">
										{{ field.errors }}
									</div>
		                        {% endif %}
                            {% endif %}
						</div>
					</div>
					{% endfor %}
				</div> 
			{% endfor %}
		</div>
	</div>
	{% endfor %}
{% endif %}