{% extends 'teacher/discipline/MapBase' %}

{% set step_5 = 'active' %}

{% block discipline_media %}
    {{ HTML.script('static/js/optionLoader.js')|raw }}
    {{ HTML.script('static/js/discipline/editStudents.js')|raw }}
    {{ HTML.style('static/css/teacher/discipline/edit/students.css')|raw }}
{% endblock %}

{% macro outputStudent(Student, DisciplineCreationISAllowed) %}
    <div id="{{ Student.ID }}" class="Student {% if Student.AttachType == 'detach' %}StatusUnbind{% else %}StatusBind{% endif %}">
        <span class="Name">{{ Student.LastName }} {{ Student.FirstName }} {{ Student.SecondName  }}</span>

        {% if DisciplineCreationISAllowed %}
            {% if Student.AttachType == 'detach' %}
                <button class="action Action_BindStudent">Прикрепить студента</button>
            {% else %}
                <button class="action Action_UnbindStudent">Отсоединить студента</button>
            {% endif %}
        {% endif %}
    </div>
{% endmacro %}


{% import 'teacher/discipline/edit/students' as idx %}

{% block map_content %}
{% if SemesterID >=7 %}
<div style="text-align: center; color: red;">
    <p>Список студентов определяется учебным планом, сформированным в 1С</p>
</div>
{% endif %}

<div class="StudentsList">
    <input type="hidden" class="HiddenInputFacultyID" value="{{ Discipline.FacultyID }}">

    <div class="GeneralStudentsList">
        <h2 class="BlueTitle">Основные студенты</h2>
        {% for groupID, group in Groups %}
            <div class="GradeAndGroupTitle ActionShowHideGroupContainer" id="{{ groupID }}">
                <span class="info">{{ Rus[group[0].Degree] }}, курс {{ group[0].GradeNum }} группа {{ group[0].GroupNum }} | {{ GroupsForDiscipline[group[0].GroupID]["SpecName"] }}</span>
                <span class="Action">Открыть список ▼</span>
            </div>

            <div class="GroupContainer">
                <div class="hideListAction"></div>
                {% for student in group %}
                    {{ idx.outputStudent(student, DisciplineCreationISAllowed) }}
                {% endfor %}
            </div>
        {% endfor %}
    </div>

    <div class="AttachedStudentsList">
        <h2 class="BlueTitle">Прикрепленные студенты</h2>
        {% for groupID, group in GroupsAttached %}
            <div class="GroupContainerAttached" id="{{ groupID }}">
                <div class="groupInfo"><div class = "groupInfoAlone">{{ group[0].GradeNum }}.{{ group[0].GroupNum }}</div></div>
                {% for student in group %}
                    {{ idx.outputStudent(student, DisciplineCreationISAllowed) }}
                {% endfor %}
            </div>
        {% endfor %}
    </div>

    {% if DisciplineCreationISAllowed %}
        <div class="SearchStudents">
            <h2 class="BlueTitle">Поиск студентов</h2>

            <div class="SearchSettings">
                <select class="SelectGrade defaultForm">
                    <option value="0">Выберите курс:</option>
                    {% for Grade in GradesList %}
                        {% set Title = (Grade['Degree'] == 'master' ? 'Магистратура' : ( Grade['Degree'] == 'bachelor' ? 'Бакалавриат' : (Grade['Degree'] == 'specialist' ? 'Специалитет' : 'Аспирантура'))) %}
                        <option value="{{ Grade.ID }}" {% if Grade.ID == Discipline.GradeID %}selected{% endif %}>
                            {{ Title }} {{ Grade.Num }}
                        </option>
                    {% endfor %}
                </select>

                <select class="SelectStudyGroup defaultForm FLeft">
                    <option value="0">Выберите группу:</option>
                    {% for Group in GroupsList %}
                        <option value="{{ Group.ID }}">Группа {{ Group.GroupNum }} - {{ Group.SpecName }}</option>
                    {% endfor %}
                </select>

                <div class="ClearFix">
                    <input type="text" class="InputStudentName defaultForm FLeft P1Width" placeholder="Фамилия Имя Отчество"
                           value="">
                    <div class="defaultForm FRight P2Width Margin10 Top">
                        <button class="defaultForm BlueButton FullWidth noMargin searchBtn">Поиск</button>
                    </div>
                </div>
            </div>
            <div class="SearchResult"></div>
        </div>
    {% endif %}
</div>
{% endblock %}