{#
/**
* @var \Pimcore\Templating\PhpEngine view
* @var \Pimcore\Templating\GlobalVariables app
* #
* @var detailAccordionId int
* @var detailOpeningTimes
* @var openingTimes \Elements\Bundle\AdvancedTimeFramerBundle\Model\Object\Data\AdvancedTimeFramer
*/ #}
<section class="demi-infrastructure-detail-content-block demi-infrastructure-detail-content-block--times">
<div class="container">
{% if (detailOpeningTimes is defined and detailOpeningTimes) or (openingTimes is defined and openingTimes) %}
<div id="times-accordion" role="tablist">
<div class="card">
<div class="card-header" role="tab" id="times-acc-heading-{{ detailAccordionId }}">
<h3 class="mb-0 h5">
<a data-toggle="collapse" href="#times-acc-detail-{{ detailAccordionId }}"
aria-expanded="false" class="collapsed">
{{ 'demi.infrastructure.detail.openinghours' | trans }}
<i class="icon icon-open pull-right" aria-label="{{ 'demi.open' | trans }}"></i>
</a>
</h3>
</div>
<div id="times-acc-detail-{{ detailAccordionId }}" class="collapse" aria-expanded="false"
aria-labelledby="times-acc-heading-{{ detailAccordionId }}" data-parent="#times-accordion">
<div class="card-body">
{% if detailOpeningTimes %}
<div class="wysiwyg">
{{ detailOpeningTimes|raw }}
</div>
{% endif %}
{% if openingTimes %}
{% set days = demi_infrastructureGetDays() %}
<div class="wysiwyg">
{% for range in openingTimes %}
<div class="row mt-4">
<div class="col-12">
{{ elements_dateFormatRange(range['fromDate'], range['toDate'], 'daterange-long-long', 'daterange-long-long') }}
<div class="row">
{% if range.weekdaysNum is defined and range.times is not empty %}
{% if range.weekdaysNum|length > 3 %}
{% set inRow = true %}
{% set inRow = range.weekdaysNum|map((v) => v == 0 ? 7 : v)|filter((v, k) => (k+1) is not same as v) is empty %}
{% if inRow %}
<div class="col-auto">{{ ('demi.infrastructure.detail.openinghours.' ~ days[range.weekdaysNum|first]) | trans }} - {{ ('demi.infrastructure.detail.openinghours.' ~ days[range.weekdaysNum|last]) | trans }}</div>
{% else %}
{% set dayStrings = [] %}
{% for weekdayNum in range.weekdaysNum %}
{% set dayStrings = dayStrings|merge([(('demi.infrastructure.detail.openinghours.' ~ days[weekdayNum]) | trans)]) %}
{% endfor %}
<div class="col-auto">{{ dayStrings|join(', ') }}</div>
{% endif %}
{% else %}
{% set dayStrings = [] %}
{% for weekdayNum in range.weekdaysNum %}
{% set dayStrings = dayStrings|merge([(('demi.infrastructure.detail.openinghours.' ~ days[weekdayNum]) | trans)]) %}
{% endfor %}
<div class="col-auto">{{ dayStrings|join(', ') }}</div>
{% endif %}
{% for time in range.times %}
<div class="col-sm-12">
{% if time.fromTime == time.toTime %}
{% if time.fromTime == "00:00" %}
{{ 'demi.infrastructure.detail.openinghours.all-day'|trans }}
{% else %}
{{ time.fromTime ~ ' ' ~ 'demi.infrastructure.detail.openinghours.oclock' | trans }}
{% endif %}
{% else %}
{{ time.fromTime ~ " - " ~ time.toTime ~ ' ' ~ 'demi.infrastructure.detail.openinghours.oclock' | trans }}
{% endif %}
</div>
{% endfor %}
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
{% if demiExtensionASTable is defined and demiExtensionASTable and demiExtensionASTable.table is not empty %}
{% set tableId = 'extension-as-table' %}
<div id="{{ tableId }}-accordion" role="tablist">
<div class="card">
<div class="card-header" role="tab" id="times-acc-heading-{{ tableId }}">
<h3 class="mb-0 h5">
<a data-toggle="collapse" href="#times-acc-detail-{{ tableId }}"
aria-expanded="false" class="collapsed">
{{ demiExtensionASTable.tableTitle ?: ('demi.infrastructure.detail.'~tableId) | trans }}
<i class="icon icon-open pull-right" aria-label="{{ 'demi.open' | trans }}"></i>
</a>
</h3>
</div>
<div id="times-acc-detail-{{ tableId }}" class="collapse" aria-expanded="false"
aria-labelledby="times-acc-heading-{{ tableId }}" data-parent="#{{ tableId }}-accordion">
<div class="card-body">
<table class="table table-sm table-striped text-white">
{% for row in demiExtensionASTable.table %}
{% set first = loop.first %}
{% if first %}
<thead>
{% elseif loop.index == 2 %}
<tbody>
{% endif %}
<tr>
{% for cell in row %}
{% if first %}
<th scope="col">{{ cell }}</th>
{% else %}
<td>{{ cell }}</td>
{% endif %}
{% endfor %}
</tr>
{% if not first %}
</thead>
{% elseif loop.last %}
</tbody>
{% endif %}
{% endfor %}
</table>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</section>