{% extends "base/base.html.twig" %}

{% block content %}
    {# courses #}

    {% if (block.type == '4-col') %}
        {% set class =  ' d-col--12--desktop' %}
    {% elseif (block.type == '3-col') %}
        {% set class =  ' d-col--9--desktop' %}
    {% elseif (block.type == '2-col') %}
        {% set class =  ' d-col--6--desktop' %}
    {% elseif (block.type == '1-col') %}
        {% set class =  ' d-col--3--desktop' %}
    {% endif %}

    <div class="d-col d-col--12 {{ class }}">
        <div class="d-courses d-widget">
            <h3 class="d-title">
                {% if block.data.title is empty %}
                    {{ Lang_translate('_DASHBOARDBLOCKCOURSESLMS','dashboard') }}
                {% else %}
                    {{ block.data.title|raw }}
                {% endif %}
            </h3>
            {% for course in block.courses %}
                {% if course.courseStatus > 0 %}
                    {% set status_class = 'green' %}
                {% else %}
                    {% set status_class = 'red' %}
                {% endif %}

                <a class="d-courses__item has-icon--{{ course.type }}" target="_self"
                   href="index.php?modname=course&amp;op=aula&amp;idCourse={{ course.id }}">
                    <div class="d-courses__img-wrapper">
                        <img class="d-courses__img"
                             src="{% if course.img != '' %} {{ course.img }} {% else %}{{ templatePath }}/images/course/course_nologo.png {% endif %}"/>
                    </div>
                    <div class="d-courses__content-wrapper">
                        <div class="d-course__title">
                            {{ course.title }}
                        </div>
                        {% if course.showStartDate or course.showEndDate %}
                            <div class="d-courses__date-wrapper status--{{ status_class }}">
                                <div class="d-courses__date d-courses__date--arrow d-courses__date--start">
                                    {% if course.showStartDate and course.showEndDate %}
                                        {{ course.startDateString }} - {{ course.endDateString }}
                                    {% elseif course.showStartDate and not course.showEndDate %}
                                        {{ course.startDateString }}
                                    {% else %}
                                        {{ course.endDateString }}
                                    {% endif %}
                                </div>
                                {% if course.hours != '' %}
                                    <div class="d-courses__date d-courses__date--arrow d-courses__date--hours">
                                        {{ course.hours }}
                                    </div>
                                {% endif %}
                            </div>
                        {% endif %}
                        {% if course.dates is not empty %}
                            <div class="d-courses__next-course">

                                {{ course.dates[0].startDate }}
                            </div>
                        {% endif %}
                    </div>
                </a>
            {% endfor %}

            {% if block.data.show_button %}
                <div class="d-courses__cta-wrapper">
                    <a class="forma-button forma-button--primary forma-button--full d-button--cert" title=""
                       href="index.php?r=elearning/show&amp;sop=unregistercourse">
                        <span class="forma-button__label">{{ Lang_translate('_ALL_COURSES', 'standard') }}</span>
                    </a>
                </div>
            {% endif %}
        </div>
    </div>

    {# <pre>
     {{ dump(block.courses) }}
   </pre> #}
{% endblock %}
