<div class="modal fade" id="training-mgr-date-modal" tabindex="-1" role="dialog"
    aria-labelledby="training-mgr-date-modal-label" aria-hidden="true">
    <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title" id="training-mgr-date-modal-label">Terminzuweisung</h3>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <form id="modal-date-addtraining-form">
                    <label for="modal-date-addtraining-input-search">Training(s) auswählen:</label>
                    <div>
                        {% if deltatrainings is not empty %}
                        <div class="form-group">
                            <div class="input-group marginbottom10">
                                <input class="form-control" type="text" id="modal-date-addtraining-input-search"
                                    value="" placeholder="Suche..." autocomplete="off" />
                                <div class="input-group-append">
                                    <button class="btn btn-outline-secondary" id="clear-date-addtraining-search-button"
                                        type="button"><i class="fas fa-trash-alt"></i></button>
                                </div>
                            </div>
                            <div id="modal-date-addtraining-check-trainings"
                                class="card panel panel-default list-group-flush"
                                style="height: 25vh; overflow-y: auto;">
                                {% for training in alltrainings %}
                                <div class="form-group top list-group-item p-3 mb-0 d-flex flex-column align-items-center justify-content-between"
                                    data-trainingid="{{ training.id }}">
                                    <div class="w-100 d-flex flex-row">
                                        <div class="form-check d-flex align-items-center">
                                            <input class="form-check-input modal-date-select-training-input"
                                                type="checkbox" value="{{training.id}}"
                                                id="date-training-{{training.id}}">
                                            <label class="checkbox-inline mb-0 ml-0" for="date-training-{{training.id}}"
                                                data-trainingname="{{training.title}}">{{training.title}}</label>
                                        </div>
                                        <div class="d-flex flex-column ml-auto">
                                            <select class="custom-select date-training-modus mb-0" size="1"
                                                id="date-training-{{ training.id }}-modus" disabled>
                                                <option value="0">Individuell</option>
                                                <option value="1">Sequentiell</option>
                                                <option value="2">Begleitet</option>
                                            </select>
                                            <div class="form-check d-flex align-items-center mt-2">
                                                <input class="form-check-input ecoaching-training-modus" type="checkbox"
                                                    id="ecoaching-training-{{training.id}}" disabled>
                                                <label class="checkbox-inline mb-0 mt-0 ml-2"
                                                    for="ecoaching-training-{{ training.id }}">E-Coaching
                                                    aktivieren</label>
                                            </div>
                                            <div class="form-check d-flex align-items-center mt-2">
                                                <input class="form-check-input redirect-training-modus" type="checkbox"
                                                    id="redirect-training-{{training.id}}" disabled>
                                                <label class="checkbox-inline mb-0 mt-0 ml-2"
                                                    for="redirect-training-{{ training.id }}">Weiterleitung nach Login
                                                    aktivieren</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="w-100 mt-2 extended-settings-area d-none">
                                        <div class="accordion" id="extended-settings-parent{{training.id}}">
                                            <div class="card m-0">
                                                <div class="card-header p-1 pl-2"
                                                    id="extended-settings-heading{{training.id}}">
                                                    <h6 class="m-0">
                                                        <button class="btn btn-link collapsed p-0" type="button"
                                                            data-toggle="collapse"
                                                            data-target="#extended-settings-body{{training.id}}"
                                                            aria-expanded="false"
                                                            aria-controls="extended-settings-body{{training.id}}">
                                                            <i class="fas fa-chevron-right ts-accordion-chevron"></i>
                                                            Erweiterte E-Coaching-Einstellungen auf Lektionsebene
                                                        </button>
                                                    </h6>
                                                </div>
                                                <div id="extended-settings-body{{training.id}}" class="collapse"
                                                    aria-labelledby="extended-settings-heading{{training.id}}"
                                                    data-parent="#extended-settings-parent{{training.id}}">
                                                    <div class="card-body p-0">
                                                        <ul class="list-group list-group-flush">
                                                            {% for lektion in training.lektionsliste %}
                                                            <li class="list-group-item d-flex flex-column">
                                                                <div class="w-100">
                                                                    <i class="fas fa-stream"></i>
                                                                    {{ lektion.title }}
                                                                </div>
                                                                <div class="form-group form-check d-flex flex-row align-items-center p-0 m-0">
                                                                    <input type="checkbox"
                                                                        class="form-check-input datedep-checkbox-coaching-lektion {% if
                                                                            loop.first %} datedep-checkbox-coaching-lektion-first {% endif %} m-0"
                                                                        id="e-coaching-lektion{{lektion.id}}" data-lektionid="{{ lektion.id }}" 
                                                                        data-trainingid="{{ training.id }}"
                                                                        name="e-coaching-lektion{{lektion.id}}" disabled checked>
                                                                    <label
                                                                        class="form-check-label pl-2"
                                                                        for="e-coaching-lektion{{lektion.id}}">E-Coach nach
                                                                        Fertigstellung benachrichtigen</label>
                                                                </div>
                                                            </li>
                                                            {% endfor %}
                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                {% endfor %}
                            </div>
                        </div>
                        {% else %}
                        <div class="alert alert-info" role="alert">
                            <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                            <p>
                                Diesem Benutzer können keine Trainings mehr zugewiesen werden.<br>
                                Entweder sind alle Trainings der Plattform bereits zugewiesen oder es befinden sich
                                (teilweise) Trainings in der zeitlichen Zuweisung.
                            </p>
                        </div>
                        {% endif %}
                    </div>
                </form>
                {% include 'coach-user-training-mgr/coach-user-training-mgr-datedep-redirect-note.html' %}
                <nav>
                    <div class="nav nav-tabs" id="nav-tab" role="tablist">
                        <a class="nav-item nav-link active" id="nav-date-tab" data-toggle="tab" href="#nav-date"
                            role="tab" aria-controls="nav-date" aria-selected="true"><i class="fas fa-clock"></i>
                            Zeitpunkt</a>
                        <a class="nav-item nav-link" id="nav-dependency-tab" data-toggle="tab" href="#nav-dependency"
                            role="tab" aria-controls="nav-dependency" aria-selected="false"><i class="fas fa-share"></i>
                            Zeitliche Abhängigkeit</a>
                    </div>
                </nav>
                <div class="tab-content mb-3" id="nav-tabContent">
                    {######################################### Zeitpunkt #############################################}
                    <div class="tab-pane fade show active p-4" id="nav-date" role="tabpanel"
                        aria-labelledby="nav-date-tab">
                        <h4>Zeitpunkt</h4>
                        <div class="alert alert-info mt-3" role="alert">
                            <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                            <p>
                                Weisen Sie Training(s) zu einem bestimmten Datum zu.
                            </p>
                        </div>
                        <div class="form-group mt-2">
                            <label for="modal-date-dateinput" class="ml-0">
                                Zeitpunkt:
                            </label>
                            <div class="input-group">
                                <div class="input-group-prepend"><span class="input-group-text"><i
                                            class="fas fa-calendar"></i></span></div>
                                <input type="date" id="modal-date-dateinput" class="form-control" min="{{ "
                                    now"|date_modify('+1 day')|date('Y-m-d') }}">
                                <div class="input-group-append"><button id="modal-date-dateinput-clear" type="button"
                                        class="btn btn-outline-secondary"><i class="fas fa-trash-alt"></i></button>
                                </div>
                            </div>
                        </div>
                    </div>
                    {######################################### Abhängig zuweisen
                    #############################################}
                    <div class="tab-pane fade p-4" id="nav-dependency" role="tabpanel"
                        aria-labelledby="nav-dependency-tab">
                        <h4>Zeiliche Abhängigkeit von anderem Training</h4>
                        <div class="alert alert-info mt-3" role="alert">
                            <h5><i class="fas fa-info-circle"></i>&nbsp;Hinweis</h5>
                            <p>
                                Weisen Sie Training(s) sofort oder nach einer bestimmten Zeitspanne nach Beendigung
                                eines/mehrerer anderer Trainings zu.
                            </p>
                        </div>
                        <div class="form-row mt-2">
                            <div class="form-group col-md-6">
                                <label for="modal-date-dependency-time" class="ml-0">Zahl:</label>
                                <select id="modal-date-dependency-time" class="custom-select" size="1">
                                    <option selected value="0">0</option>
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                    <option value="5">5</option>
                                    <option value="6">6</option>
                                </select>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="modal-date-dependency-timemultiplier" class="ml-0">Einheit:</label>
                                <select id="modal-date-dependency-timemultiplier" class="custom-select" size="1">
                                    <option value="hours">Stunde(n)</option>
                                    <option selected value="days">Tag(e)</option>
                                    <option value="weeks">Woche(n)</option>
                                    <option value="months">Monat(e)</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-row mt-2">
                            <div class="form-group col-md-6">
                                <label for="modal-date-dependency-trainings" class="ml-0">Nach Beendigung von:</label>
                                <div id="modal-date-dependency-trainings"
                                    class="w-100 card panel panel-default list-group-flush mb-0"
                                    style="height:120px!important;overflow-y: auto;">
                                    {% for tr in alltrainings %}
                                    <div class="form-check list-group-item p-2 mb-0 d-flex align-items-center">
                                        <input class="form-check-input ml-0" type="checkbox"
                                            id="modal-date-dependency-trainings-{{ tr.id }}" value="{{ tr.id }}">
                                        <label class="form-check-label mb-0 pl-2"
                                            for="modal-date-dependency-trainings-{{ tr.id }}">{{ tr.title }}</label>
                                    </div>
                                    {% endfor %}
                                </div>
                                <p class="text-muted mt-2 pl-2"><small>Nur Trainings die dem <span
                                            class="badge badge-secondary">Main</span>-Nutzer bereits zugewiesen wurden
                                        stehen hier zur Auswahl.</small></p>
                            </div>
                            <div class="form-group col-md-6">
                                <label for="modal-date-dependency-condition" class="ml-0">Bedingung:</label>
                                <select id="modal-date-dependency-condition" class="custom-select" size="1" disabled>
                                    <option value="or">oder</option>
                                    <option value="and">und</option>
                                </select>
                                <p class="text-muted mt-2 pl-2"><small>Bei Auswahl von mehreren Trainings kann hier mit
                                        einer Bedingung für die Zuteilung angegeben werden, ob alle Trainings oder eines
                                        der Auswahl absolviert sein müssen.</small></p>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="my-3 alert alert-warning d-none" role="alert" id="modal-date-ambigious">
                    <h5><i class="fas fa-exclamation-triangle"></i>&nbsp;Warnung</h5>
                    <p>
                        Training(s) können nur <b>entweder</b> für einen Zeitpunkt <b>oder</b> in zeitlicher
                        Abhängigkeit zugewiesen werden.
                    </p>
                    <p>
                        Löschen Sie die Eingaben aus einer Methode oder wählen Sie die gewünschte hier:
                    </p>
                    <p class="d-flex justify-content-around">
                        <button type="button" class="btn btn-secondary" id="modal-date-clear-dependency"><i
                                class="fas fa-clock"></i> Zeitpunkt</button>
                        <button type="button" class="btn btn-secondary" id="modal-date-clear-date"><i
                                class="fas fa-share"></i> zeitliche Abhängigkeit</button>
                    </p>
                </div>
                <div class="my-3 alert alert-warning d-none" role="alert" id="modal-date-noselection">
                    <h5><i class="fas fa-exclamation-triangle"></i>&nbsp;Warnung</h5>
                    <p>
                        Sie müssen für <b>eine</b> der beiden Methoden eine Auswahl treffen <b>und mindestens</b> ein
                        Training auswählen.
                    </p>
                </div>
            </div>
            <div class="modal-footer d-flex justify-content-between">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
                <button type="button" class="btn btn-primary" id="modal-date-save">Terminlich zuweisen</button>
            </div>
        </div>
    </div>
</div>