{% import 'macro.html.twig' as web_macro %}
{% set isNewCoverSize = is_new_classroom_cover_size(classroom) %}

<section class="class-header before">
  <div class="container">
    {% if member.locked|default("0") == "1" %}
      <div class="alert alert-warning">
        {{ 'classroom.refund_tips'|trans }}
        <button class="btn btn-warning btn-sm cancel-refund"
          data-url="{{ path('order_cancel_refund', {id:classroom.id, targetType:"classroom"}) }}">{{ 'classroom.cancle_refund_btn'|trans }}</button>
      </div>
    {% endif %}

    <ol class="breadcrumb breadcrumb-o">
      <li><a href="{{ path('homepage') }}">{{ 'homepage'|trans }}</a></li>
      {% for breadcrumb in breadcrumbs %}
        <li><a href="{{ path('classroom_explore',{'category':breadcrumb.code}) }}">{{ breadcrumb.name }}</a></li>
      {% endfor %}
      <li class="active">{{ classroom.title }}</li>
    </ol>

    <div class="class-header-mian {% if isNewCoverSize %} class-header-main--new {% endif %}">
      <div class="class-bg-layer"></div>
      <div class="class-header-bg clearfix">
        <div class="class-img">
          {{ slot('drp.product_tags.extension', {'type':'classroom','targetId':classroom.id}) }}
          <a href="{{ path('classroom_show',{id:classroom.id}) }}">
            <img src="{{ filepath(classroom.largePicture, 'classroom.png') }}" alt="{{ classroom.title }}">
          </a>
          {% if classroom.status == 'closed' %}
            <span class="class-img__tag cd-tag cd-tag-red">{{ 'classroom.status.closed'|trans }}</span>
          {% endif %}
        </div>
        <div class="class-info">
          <h2 class="title class-info__title">
            <span class="hidden-xs">{{ classroom.title|sub_text(28) }}</span>
            <span class="visible-xs">{{ classroom.title }}</span>
            <span class="es-qrcode top" data-url="{{ path('classroom_qrcode',{id: classroom.id}) }}">
              <i class="es-icon es-icon-qrcode"></i>
              <span class="qrcode-popover">
                <img src="" alt="">
                {{ 'site.tips.scan_qrcode_tips'|trans }}
              </span>
            </span>
          </h2>
          <div class="metas class-info__metas">
            {% if setting('classroom.show_review', '1') == 1 %}
              <div class="score">
                {{ web_macro.star(classroom.rating) }}
                <span>({{ classroom.ratingNum }}{{ 'classroom.reviews'|trans }})</span>
              </div>
            {% endif %}
            <div class="price">
              {{ 'classroom.price'|trans }}：
              <span>
                {% if setting('coin.coin_enabled') and setting('coin.price_type') == 'Coin' %}
                  {% if classroom.price > 0 %}
                    {{ classroom.price * setting('coin.cash_rate') }} {{ setting('coin.coin_name') }}
                  {% else %}
                    {{ 'classroom.price_free'|trans }}
                  {% endif %}
                {% else %}
                  {% if classroom.price > 0 %}
                    {{ classroom.price }}{{ 'site.currency.CNY'|trans }}
                  {% else %}
                    {{ 'classroom.price_free'|trans }}
                  {% endif %}
                {% endif %}
              </span>
            </div>
          </div>

         {# 有效期 #}
          {% if classroom.expiryMode == 'date' %}
            <div class="class-info__expiry hidden-sm">
              <span class="color-gray cd-text-xs">{{ 'classroom.expiry_date_tips'|trans }}</span>
              <span class="gray-darker">{{ classroom.expiryValue|date('Y-m-d') }}</span>
            </div>
          {% elseif classroom.expiryMode == 'days' %}
            <div class="class-info__expiry hidden-sm">
              <span class="color-gray cd-text-xs">{{ 'classroom.expiry_day_tips'|trans({'%expiryValue%': classroom.expiryValue})|raw }}</span>
            </div>
          {% endif %}

          <ul class="class-info__data class-data cd-mt8 hidden-sm clearfix {% if classroomMemberLevel %}active{% endif %}">
            {% if setting('classroom.show_student_num_enabled', '1') == 1 %}
              <li>
                <p><i class="es-icon es-icon-person"></i></p>
                <p>{{ 'site.default.student'|trans }}({{ classroom.studentNum + classroom.auditorNum }})</p>
              </li>
            {% endif %}
            <li>
              <p><i class="es-icon es-icon-book"></i></p>
              <p>{{ 'course'|trans }}({{ classroom.courseNum }})</p>
            </li>
            <li>
              <span class="es-share top js-es-share">
                <a class="dropdown-toggle" href="javascript:;" data-toggle="dropdown" aria-labelledby="dropdownMenu1">
                  <p><i class="es-icon es-icon-share"></i></p>
                  <p>{{ 'site.btn.share'|trans }}</p>
                </a>
                {% include 'common/share-dropdown.html.twig' with {type:'classroom'} %}
              </span>
            </li>
            {% if classroomMemberLevel and  classroom.showable %}
              <li
                class="hidden-xs color-warning icon-vip"
                title="{{ 'classroom.vip_classroom'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}"
                data-content="{% include 'course/header/parts/normal-header-vip.html.twig' with {courseVip:classroomMemberLevel,userVipStatus:checkMemberLevelResult} %}"
                data-original-title="{{ 'classroom.vip_classroom'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}"
                title="{{ 'classroom.vip_classroom'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}">
                <i class="es-icon es-icon-crown"></i><br>
                {% include 'course/header/parts/normal-header-vip-link.html.twig' with {userVipStatus:checkMemberLevelResult, level: classroomMemberLevel} %}
              </li>
            {% endif %}
          </ul>

          <div class="bottom-metas class-info__bottom clearfix">
            <div class="class-info__serve class-serve hidden-sm hidden-xs">
              <div class="serve-label">
                {{ 'classroom.showServices'|trans }}
              </div>
              {% include 'classroom/service-block.html.twig' with {'services':classroom.service } %}
            </div>

            {% if  classroom.showable and classroom.status != 'closed' %}
              <div class="btn-buy">
                {% include 'classroom/part/classroom-buy-btn.html.twig' %}
              </div>
            {% endif %}

          </div>
        </div>

        {#添加admin_v2#}
        {% if classroom_permit(classroom.id, 'Manage') and (has_permission('admin_classroom_content_manage') or has_permission('admin_v2_classroom_content_manage')) %}
          <a class="class-setting hidden-xs hidden-sm" href="{{ path('classroom_manage',{id:classroom.id}) }}"
            title="{{ 'classroom.classroom_manage'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}">
            <i class="es-icon es-icon-setting"></i>
          </a>
        {% endif %}

      </div>
    </div>
  </div>
</section>
