{% extends "trainings/library_base.html" %}
{% load i18n staticfiles template_tools thumbnail %}

{% block head %}
    {{ block.super }}
    {% include "cms/includes/orderable-head.html" %}
    {% include "cms/includes/lightbox-head.html" %}
{% endblock %}

{% block column_main %}
    <div class="clearfix">
        <div class="pull-left">
            <a class="btn btn-default back-button" href="{{ training.get_list_url }}">
                <i class="fa fa-arrow-left"></i> {% trans 'Back' %}
            </a>
            {% if training.version_state == training.VERSION_STATES.ARCHIVED %}
                <i class="fa fa-archive"></i>
                {% trans 'Archived scenario' %}
            {% elif training.version_state == training.VERSION_STATES.DRAFT %}
                <i class="fa fa-pencil"></i>
                {% trans 'Draft scenario' %}
            {% elif training.version_state == training.VERSION_STATES.PUBLISHED %}
                <i class="fa fa-paper-plane"></i>
                {% trans 'Published scenario' %}
            {% endif %}
        </div>
        <div class="pull-right">
            {% include 'trainings/training_actions.html' with display='inline' %}
        </div>
    </div>
    <div class="scrolling-training-wrapper padded-top">
        {% if training.pk and not training.is_editable %}
            <div class="alert alert-info">
                <i class="fa fa-lock"></i>
                {% blocktrans with training_name=training.name training_version_state=training.get_version_state_display %}
                    The training "{{ training_name }}" is "{{ training_version_state }}". Therefore, edition is not allowed anymore. In order to bring changes to it, you need to create a new draft with the button above.
                {% endblocktrans %}
            </div>
        {% endif %}
        <div class="clearfix separator-bottom">
            <h1 class="page-title">{{ training.name }}</h1>
            <div class="clearfix">
                <div class="pull-left training-thumbnail">
                    <a href="{{ training.get_header_image.url }}" class="thumbnail" data-toggle="lightbox" data-title="{{ training.name }}">
                        <img src="{% thumbnail training.get_header_image 150x100 crop quality=100 %}" alt="" width="150">
                    </a>
                </div>
                <div class="pull-left">
                    <p>{{ training.description }}</p>
                    {% if training.job_profile %}
                        <p><strong>{% trans 'Job profile' %}</strong> {{ training.job_profile.name }}</p>
                    {% endif %}
                    {% if training.business_unit %}
                        <p><strong>{% trans 'Group' %}</strong> {{ training.business_unit.name }}</p>
                    {% endif %}
                </div>
            </div>
            <div class="pull-right">
                {% if training.is_editable %}
                    <a href="{{ training.get_edit_url }}" class="btn btn-default dialog-box">
                        <i class="fa fa-pencil"></i>
                        {% trans 'Modify the information' %}
                    </a>
                {% endif %}
            </div>
        </div>
        <div class="clearfix padded-top">
            <div class="pull-left">
                <h2 class="content-title">{% trans 'Activities' %}</h2>
            </div>
            <div class="pull-right">
                {% if training.is_editable %}
                    <a href="{{ training.get_activities_add_url }}" class="btn btn-primary dialog-box">
                        <i class="fa fa-plus"></i> {% trans 'Existing activity' %}
                    </a>
                    <a href="" class="btn btn-primary" data-toggle="modal" data-target="#activity-create">
                        <i class="fa fa-plus"></i> {% trans 'New activity' %}
                    </a>
                {% endif %}
            </div>
        </div>
        <div class="panel panel-default">
            {% include 'trainings/trainingactivity_list_table.html' %}
        </div>
        <ul class="nav add-item">
            {% if training.is_editable %}
                <li>
                    <a href="" class="a-default" data-toggle="modal" data-target="#activity-create">
                        <i class="fa fa-plus"></i> {% trans 'New activity' %}
                    </a>
                </li>
                <li>
                    <a href="{{ training.get_activities_add_url }}" class="a-default dialog-box">
                        <i class="fa fa-plus"></i> {% trans 'Existing activity' %}
                    </a>
                </li>
            {% endif %}
        </ul>
        {% include 'trainings/trainingactivity_create.html' %}
    </div>
{% endblock %}
