<div class="row">
    {% if title is not empty %}
    <div class="col-12">
        <h1 class="text-center mb-5">{{ title }}</h1>
    </div>
    {% endif %}
    <div class="col-12" id="sleepweekParent">
        {% for weekindex, sleepweek in sleepweeks %}
        <div class="card w-100 mb-3">
            <div class="card-header">
                <button class="btn btn-link p-0 {% if loop.first %}show{% else %}collapsed{% endif %}" data-toggle="collapse" data-target="#collapse-week-{{ weekindex }}"
                aria-expanded="{% if loop.first %}true{% else %}false{% endif %}" aria-controls="collapse-week-{{ weekindex }}">
                    <h4 class="m-0 d-flex align-items-center">
                        <i class="fas fa-chevron-right ts-accordion-chevron mr-2"></i>
                        {{ sleepweek.title}}
                        <span class="ml-3 badge badge-dark">
                            {{ sleepweek.days|length }}/7
                        </span>
                        <span class="ml-2 badge btn-primary">
                            {{ sleepweek.efficiency }}&nbsp;%
                        </span>
                    </h4>
                </button>
            </div>
            <div class="card-body collapse {% if loop.first %}show{% endif %}" id="collapse-week-{{ weekindex }}" data-parent="#sleepweekParent">
                <div id="accordion-wrapper-week-{{ weekindex }}">
                    <ul class=" list-group list-group-flush ml-3">
                        {% for day in sleepweek.days %}
                        <div class="sleep-efficiency-card ts-accordion">
                            <div class="card-header" id="card-heading">
                                <button class="btn btn-link collapsed d-flex align-items-center" data-toggle="collapse"
                                    data-target="#collapse-{{ weekindex }}-{{ loop.index+sleepweek.id }}" aria-expanded="false"
                                    aria-controls="collapse-{{ weekindex }}-{{ loop.index+sleepweek.id }}">
                                    <i class="fas fa-plus ts-accordion-plus"></i>
                                    {{ day['toBed']|date("d.m.Y") }}
                                    &nbsp;-&nbsp;
                                    {{ day['getUp']|date("d.m.Y") }}
                                    {% if day.shift is not empty %}
                                        <span class="badge btn-secondary ml-3">
                                            {{ day['shift']}}
                                        </span>
                                    {% endif %}
                                    <span class="badge btn-primary ml-2 ">
                                        {{ day['efficiency']}}&nbsp;%
                                    </span>
                                </button>
                            </div>
                            <div id="collapse-{{ weekindex }}-{{ loop.index+sleepweek.id }}" class="collapse" aria-labelledby="card-heading" data-parent="#accordion-wrapper-week-{{ weekindex }}">
                                <li class="list-group-item">
                                    <b>Ins Bett gegangen:</b>
                                    {{ day['toBed']|date("d.m.Y H:i", false) }}&nbsp;Uhr
                                </li>
                                <li class="list-group-item">
                                    <b>eingeschlafen:</b>
                                    {{ day['asleep']|date("d.m.Y H:i", false) }}&nbsp;Uhr
                                </li>
                                <li class="list-group-item">
                                    <b>aufgewacht:</b> 
                                    {{ day['wokeUp']|date("d.m.Y H:i", false) }}&nbsp;Uhr
                                </li>
                                <li class="list-group-item">
                                    <b>aufgestanden:</b>
                                    {{ day['getUp']|date("d.m.Y H:i", false) }}&nbsp;Uhr
                                </li>
                                {% if day.text is not empty %}
                                    <li class="list-group-item">
                                        <b>Anmerkung:</b>
                                        {{ day['text'] }}
                                    </li>
                                {% endif %}
                                {% if showCompleted %}
                                    <li class="list-group-item">
                                        <b>Morgen-Protokoll:</b>
                                        {% if day.saveMorningProtocol[0]|last == "completed" %}
                                        <i class="fas fa-check text-success"></i>&nbsp;Abgeschlossen
                                        {% else %}
                                        <i class="fas fa-times text-danger"></i>&nbsp;Nicht abgeschlossen
                                        {% endif %}
                                    </li>
                                    <li class="list-group-item">
                                        <b>Abend-Protokoll:</b>
                                        {% if day.saveMorningProtocol[1]|last == "completed" %}
                                        <i class="fas fa-check text-success"></i>&nbsp;Abgeschlossen
                                        {% else %}
                                        <i class="fas fa-times text-danger"></i>&nbsp;Nicht abgeschlossen
                                        {% endif %}
                                    </li>
                                {% endif %}
                            </div>
                        </div>
                        {% endfor %}
                    </ul>
                </div>
            </div>
        </div>
        {% else %}
            {% include 'coach-output-app-data/coach-output-app-data-nodata.html' %}
        {% endfor %}
    </div>
</div>


