src/Elements/Bundle/DemiFrontendBundle/Resources/views/Infrastructure/detail/accordion-opening-times.html.twig line 1

Open in your IDE?
  1. {#
  2. /**
  3.  * @var \Pimcore\Templating\PhpEngine view
  4.  * @var \Pimcore\Templating\GlobalVariables app
  5.  * #
  6.  * @var detailAccordionId int
  7.  * @var detailOpeningTimes
  8.  * @var openingTimes \Elements\Bundle\AdvancedTimeFramerBundle\Model\Object\Data\AdvancedTimeFramer
  9.  */ #}
  10. <section class="demi-infrastructure-detail-content-block demi-infrastructure-detail-content-block--times">
  11.     <div class="container">
  12.         {% if (detailOpeningTimes is defined and detailOpeningTimes) or (openingTimes is defined and openingTimes) %}
  13.             <div id="times-accordion" role="tablist">
  14.                 <div class="card">
  15.                     <div class="card-header" role="tab" id="times-acc-heading-{{ detailAccordionId }}">
  16.                         <h3 class="mb-0 h5">
  17.                             <a data-toggle="collapse" href="#times-acc-detail-{{ detailAccordionId }}"
  18.                                aria-expanded="false" class="collapsed">
  19.                                 {{ 'demi.infrastructure.detail.openinghours' | trans }}
  20.                                 <i class="icon icon-open pull-right" aria-label="{{ 'demi.open' | trans }}"></i>
  21.                             </a>
  22.                         </h3>
  23.                     </div>
  24.                     <div id="times-acc-detail-{{ detailAccordionId }}" class="collapse" aria-expanded="false"
  25.                          aria-labelledby="times-acc-heading-{{ detailAccordionId }}" data-parent="#times-accordion">
  26.                         <div class="card-body">
  27.                             {% if detailOpeningTimes %}
  28.                                 <div class="wysiwyg">
  29.                                     {{ detailOpeningTimes|raw }}
  30.                                 </div>
  31.                             {% endif %}
  32.                             {% if openingTimes %}
  33.                                 {% set days = demi_infrastructureGetDays() %}
  34.                                 <div class="wysiwyg">
  35.                                     {% for range in openingTimes %}
  36.                                         <div class="row mt-4">
  37.                                             <div class="col-12">
  38.                                                 {{ elements_dateFormatRange(range['fromDate'], range['toDate'], 'daterange-long-long', 'daterange-long-long') }}
  39.                                                 <div class="row">
  40.                                                     {% if range.weekdaysNum is defined and range.times is not empty %}
  41.                                                         {% if range.weekdaysNum|length > 3 %}
  42.                                                             {% set inRow = true %}
  43.                                                             {% set inRow = range.weekdaysNum|map((v) => v == 0 ? 7 : v)|filter((v, k) => (k+1) is not same as v) is empty %}
  44.                                                             {% if inRow %}
  45.                                                                 <div class="col-auto">{{ ('demi.infrastructure.detail.openinghours.' ~ days[range.weekdaysNum|first]) | trans }} - {{ ('demi.infrastructure.detail.openinghours.' ~ days[range.weekdaysNum|last]) | trans }}</div>
  46.                                                             {% else %}
  47.                                                                 {% set dayStrings = [] %}
  48.                                                                 {% for weekdayNum in range.weekdaysNum %}
  49.                                                                     {% set dayStrings = dayStrings|merge([(('demi.infrastructure.detail.openinghours.' ~ days[weekdayNum]) | trans)]) %}
  50.                                                                 {% endfor %}
  51.                                                                 <div class="col-auto">{{ dayStrings|join(', ') }}</div>
  52.                                                             {% endif %}
  53.                                                         {% else %}
  54.                                                             {% set dayStrings = [] %}
  55.                                                             {% for weekdayNum in range.weekdaysNum %}
  56.                                                                 {% set dayStrings = dayStrings|merge([(('demi.infrastructure.detail.openinghours.' ~ days[weekdayNum]) | trans)]) %}
  57.                                                             {% endfor %}
  58.                                                             <div class="col-auto">{{ dayStrings|join(', ') }}</div>
  59.                                                         {% endif %}
  60.                                                         {% for time in range.times %}
  61.                                                             <div class="col-sm-12">
  62.                                                                 {% if time.fromTime ==  time.toTime %}
  63.                                                                     {% if time.fromTime == "00:00" %}
  64.                                                                         {{ 'demi.infrastructure.detail.openinghours.all-day'|trans }}
  65.                                                                     {% else %}
  66.                                                                         {{ time.fromTime ~  ' ' ~ 'demi.infrastructure.detail.openinghours.oclock' | trans }}
  67.                                                                     {% endif %}
  68.                                                                 {% else %}
  69.                                                                     {{ time.fromTime ~ " - " ~ time.toTime ~ ' ' ~ 'demi.infrastructure.detail.openinghours.oclock' | trans }}
  70.                                                                 {% endif %}
  71.                                                             </div>
  72.                                                         {% endfor %}
  73.                                                     {% endif %}
  74.                                                 </div>
  75.                                             </div>
  76.                                         </div>
  77.                                     {% endfor %}
  78.                                 </div>
  79.                             {% endif %}
  80.                         </div>
  81.                     </div>
  82.                 </div>
  83.             </div>
  84.         {% endif %}
  85.         {% if demiExtensionASTable is defined and demiExtensionASTable and demiExtensionASTable.table is not empty %}
  86.             {% set tableId = 'extension-as-table' %}
  87.             <div id="{{ tableId }}-accordion" role="tablist">
  88.                 <div class="card">
  89.                     <div class="card-header" role="tab" id="times-acc-heading-{{ tableId }}">
  90.                         <h3 class="mb-0 h5">
  91.                             <a data-toggle="collapse" href="#times-acc-detail-{{ tableId }}"
  92.                                aria-expanded="false" class="collapsed">
  93.                                 {{ demiExtensionASTable.tableTitle ?: ('demi.infrastructure.detail.'~tableId) | trans }}
  94.                                 <i class="icon icon-open pull-right" aria-label="{{ 'demi.open' | trans }}"></i>
  95.                             </a>
  96.                         </h3>
  97.                     </div>
  98.                     <div id="times-acc-detail-{{ tableId }}" class="collapse" aria-expanded="false"
  99.                          aria-labelledby="times-acc-heading-{{ tableId }}" data-parent="#{{ tableId }}-accordion">
  100.                         <div class="card-body">
  101.                             <table class="table table-sm table-striped text-white">
  102.                                 {% for row in demiExtensionASTable.table %}
  103.                                     {% set first = loop.first %}
  104.                                     {% if first %}
  105.                                         <thead>
  106.                                     {% elseif loop.index == 2 %}
  107.                                         <tbody>
  108.                                     {% endif %}
  109.                                     <tr>
  110.                                         {% for cell in row %}
  111.                                             {% if first %}
  112.                                                 <th scope="col">{{ cell }}</th>
  113.                                             {% else %}
  114.                                                 <td>{{ cell }}</td>
  115.                                             {% endif %}
  116.                                         {% endfor %}
  117.                                     </tr>
  118.                                     {% if not first %}
  119.                                         </thead>
  120.                                     {% elseif loop.last %}
  121.                                         </tbody>
  122.                                     {% endif %}
  123.                                 {% endfor %}
  124.                             </table>
  125.                         </div>
  126.                     </div>
  127.                 </div>
  128.             </div>
  129.         {% endif %}
  130.     </div>
  131. </section>