{% extends 'base.html' %}
{% load i18n %}

{% block head %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}assessments/css/assessments.css">
    <script src="{{ STATIC_URL }}common/js/ajax-modal.js"></script>
{% endblock %}

{% block subtitle %}
  {% trans 'Assessments' %}
{% endblock %}

{% block actions %}
    {% if current_job_profile %}
        <form class="form-inline">
            {% if managed_groups %}
                <select class="form-control" id="managed-group">
                        <option value="" {% if not current_managed_group %}selected{% endif %}>{% trans 'Global' %}</option>
                    {% for managed_group in managed_groups %}
                        <option value="{{ managed_group.pk }}"
                        {% if current_managed_group == managed_group %}
                            selected
                        {% endif %}>
                            {{ managed_group.name }}
                        </option>
                    {% endfor %}
                </select>
            {% endif %}
            <select class="form-control" id="job-profile">
                {% for job_profile in job_profiles %}
                    <option value="{{ job_profile.competencytree.get_competency_list_url }}"
                    {% if current_job_profile == job_profile %}
                        selected
                    {% endif %}>
                        {{ job_profile.name }}
                    </option>
                {% endfor %}
            </select>
            <script type="text/javascript">
                $(document).ready(function(){
                    $('#job-profile').change(function(){
                        window.location = $(this).val();
                    });
                    $('#managed-group').change(function(){
                        var group_uuid = $(this).val();
                        var location = window.location.href.split('?')[0];
                        if (group_uuid !== '') {
                            var url = location + '?group_uuid=' + group_uuid;
                        } else {
                            var url = location;
                        }
                        window.location = url;
                    });
                });
            </script>
        </form>
    {% endif %}
{% endblock %}

{% block main %}
    {% if current_job_profile %}
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation" class="{% if current_sub_section == 'certification_results' %}active{% endif %}">
                <a href="{{ competency_tree.get_certification_results_url }}">
                    <h5>{% trans 'Certification validation' %}</h5>
                </a>
            </li>
            <li role="presentation" class="{% if current_sub_section == 'competency_tree' %}active{% endif %}">
                <a href="{{ competency_tree.get_competency_list_url }}">
                    <h5>{% trans 'Competencies tree' %}</h5>
                </a>
            </li>
            <li role="presentation" class="{% if current_sub_section == 'certification_program' %}active{% endif %}">
                <a href="{{ competency_tree.get_certification_program_url }}">
                    <h5>{% trans 'Certification Levels' %}</h5>
                </a>
            </li>
            <li role="presentation" class="{% if current_sub_section == 'recommendations' %}active{% endif %}">
                <a href="{{ competency_tree.get_curriculum_url }}">
                    <h5>{% trans 'Curriculum' %}</h5>
                </a>
            </li>
        </ul>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active">
                <div class="clearfix">
                    <div class="pull-left">
                        <h4>{% block section_title %}{% endblock %}</h4>
                    </div>
                    <div class="pull-right">
                        {% block section_actions %}{% endblock %}
                    </div>
                </div>
                <hr>
                {% block section_content %}{% endblock %}
            </div>
        </div>

    {% else %}

        <p>{% trans "You cannot view any assessment at the moment." %}</p>
        <p>{% trans "Please contact an administrator to receive the proper permissions." %}</p>

    {% endif %}
{% endblock %}
