{% set dependentTrainingMissing = false %}
{% for deptid in deptraining.getDependentTrainingsJsonDecoded() %}
    {% set singleTrainingMissing = true %}
    {% for training in trainings %}
        {% if training.id == deptid %}
            {% set singleTrainingMissing = false %}
        {% endif %}
    {% endfor %}
    {% for dateTraining in trainingsdate %}
        {% if dateTraining.trainingId == deptid %}
            {% set singleTrainingMissing = false %}
        {% endif %}
    {% endfor %}

    {% if singleTrainingMissing %}
        {% set dependentTrainingMissing = true %}
    {% endif %}
{% endfor %}

<li class="ui-state-default mylist noSortable deptraining" id="training_dep_{{ random() }}" style="cursor: default" value="{{ deptraining.trainingid }}" data-deptrainings="{% for deptid in deptraining.getDependentTrainingsJsonDecoded() %}{{ deptid }}{% if not loop.last %},{% endif %}{% endfor %}">
    <input type="hidden" class="dateArgs" value="{{ deptraining.toJson() }}">
    <div class="listheader-sortable d-flex align-items-center">
        <i class="fas fa-share"></i>
        <span class="listheader-sortable-text">
            {% if dependentTrainingMissing and not lockedit %}
                <i class='fas fa-exclamation-triangle mr-2 text-warning coach-user-training-mgr-missing-dependent-training'></i>
            {% endif %}
            {{ alltrainings[deptraining.trainingId].title }} (ID: {{ alltrainings[deptraining.trainingId].id }})
        </span>
        <div class="ml-auto">
            <button class="btn btn-outline-secondary edit-training-dep" type="button" data-trainingdatedepid="{{ deptraining.id }}" {% if lockedit %}disabled style="cursor: default;"{% endif %}>
                <i class="fas fa-edit"></i>
            </button>
            <button class="btn btn-outline-secondary delete-training-dep" data-trainingdateid="{{ deptraining.id }}" data-trainingname="{{ alltrainings[deptraining.trainingId].title }}" type="button">
                <i class="fas fa-trash-alt"></i>
            </button>
        </div>
    </div>
    <span class="text-muted">
        <small>Abhängig zugewiesen</small>
    </span>
    <div class="w-100">
        <ul class="list-group list-group-flush pl-0 mt-3">
            <li class="list-group-item noSortable">
                <b>Lektionen:</b> {{ alltrainings[deptraining.trainingId].lektioncount() }}
            </li>
            <li class="list-group-item noSortable">
                <b>Zuweisung:</b> +{{ deptraining.timeAdd }} {% if deptraining.timeMultiplier == "hours" %}Stunde(n){% elseif deptraining.timeMultiplier == "days" %}Tag(e){% elseif deptraining.timeMultiplier == "weeks" %}Woche(n){% elseif deptraining.timeMultiplier == "months" %}Monat(e){% endif %}
            </li>
            <li class="list-group-item noSortable">
                <b>Abhängige Training(s):</b> 
                {% for deptid in deptraining.getDependentTrainingsJsonDecoded() %}
                    {{ alltrainings[deptid].getTitle() }}{% if not loop.last %},{% endif %}
                {% else %}-{% endfor %}
            </li>
            <li class="list-group-item noSortable">
                <b>Bedingung:</b> {% if deptraining.getDependentCondition() == "or" %}Oder{% elseif deptraining.getDependentCondition == "and" %}Und{% endif %}
            </li>
            <li class="list-group-item noSortable">
                <b>Modus:</b> 
                {% if deptraining.trainingMode == 0 %}
                Individuell
                {% elseif deptraining.trainingMode == 1 %}
                Sequentiell
                {% elseif deptraining.trainingMode == 2 %}
                Begleitet
                {% endif %}
            </li>
            <li class="list-group-item noSortable">
                <b>E-Coaching:</b> 
                {% if deptraining.getEcoachingEnable() == "0" or (deptraining.lektionSettingsIsArray() and deptraining.getLektionSettingsJsonDecoded()|first == 1) %}
                    Deaktiviert
                {% elseif deptraining.trainingMode == 2 and deptraining.lektionSettingsIsArray() and deptraining.lektionSettingsIsDifferent() %}
                    <i>erweitert</i>
                    <ul class="w-100 list-group">
                        {% for lektion in alltrainings[deptraining.trainingId].lektionsliste %}
                            <li class="list-group-item py-1 px-2 noSortable">
                                <b>{{ lektion.title }}:</b>
                                {% if deptraining.getLektionSettingsJsonDecoded()[lektion.id] == 2 %}
                                    Aktiviert
                                {% else %}
                                    Deaktiviert
                                {% endif %}
                            </li>
                        {% endfor %}
                    </ul>
                {% else %}
                    Aktiviert
                {% endif %}
            </li>
            <li class="list-group-item noSortable">
                <b>Weiterleitung nach Login:</b> 
                {% if deptraining.getRedirect() %}
                    Ja
                {% else %}
                    Nein
                {% endif %}
            </li>
        </ul>
    </div>

</li>