{% import 'macro.html.twig' as web_macro %}
{% set memberDeadline = member.deadline|default(0) %}

<section class="class-header after {% if 'auditor' in member.role %} auditor{% endif %}">
  <div class="container">

    <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>

    {% 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', {orderId:member.orderId}) }}">
          {{ 'classroom.cancle_refund_btn'|trans }}
        </button>
      </div>
    {% endif %}

    {% if vipChecked|default('ok') != 'ok' %}
      <div class="alert alert-danger alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
        {% if vipChecked == 'not_member' %}
          {{ 'classroom.not_vip_member_tips'|trans({'%classroomName%': setting("classroom.name")|default('classroom'|trans)})|raw }}
          {% if classroom.price > 0 %}
            {{ 'classroom.not_vip_member_and_become_vip_tips'|trans({'%vipUrl%': path('vip')})|raw }}
          {% else %}
            <a class="alert-link js-exit" href="javascript:;" data-url="{{ path('classroom_exit', { id:classroom.id }) }}">{{ 'classroom.exit'|trans }}</a>
          {% endif %}！
        {% elseif vipChecked == 'member_expired' %}
          {{ 'classroom.vip_member_expired_tips'|trans({'%classroomName%': setting("classroom.name")|default('classroom'|trans), '%vipRenewUrl%': path('vip_renew')})|raw }}
        {% elseif vipChecked == 'level_low' %}
          {{ 'classroom.vip_member_level_low_tips'|trans({'%classroomName%': setting("classroom.name")|default('classroom'|trans), '%vipUpgrade%': path('vip_upgrade')})|raw }}
        {% else %}
          {{ 'classroom.vip_checked_fail_tips'|trans({'%classroomName%': setting("classroom.name")|default('classroom'|trans)})|raw }}
          <a class="alert-link js-exit" href="javascript:" data-url="{{ path('classroom_exit', { id:classroom.id }) }}">{{ 'classroom.exit'|trans }}</a>
        {% endif %}
      </div>
    {% endif %}

    <div class="class-header-mian">
      <div class="class-bg-layer"></div>
      <div class="class-header-bg clearfix">
        <div class="class-img">
          <a href="{{ path('classroom_show',{id:classroom.id}) }}">
            <img src="{{ filepath(classroom.largePicture, 'classroom.png') }}" alt="{{ classroom.title }}"
              href="{{ path('classroom_show',{id:classroom.id}) }}">
          </a>
        </div>
        <div class="class-info">
          <h2 class="title">
            {{ classroom.title }}
            <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">
            <div class="score">
              {{ web_macro.star(classroom.rating) }}
              <span>({{ classroom.ratingNum }}{{ 'classroom.reviews'|trans }})</span>
            </div>
            {% if member.role == 'auditor' %}
              <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>
            {% endif %}
          </div>

          <div class="hidden-sm fsn">
            {% if classroom.expiryMode != 'forever' %}
              {% if 'student' in member.role or 'member' in member.role %}
                <span class="mrm">{{ 'classroom.expiryDays'|trans }}</span>
                <span>{{ memberDeadline|date('Y-m-d') }}</span>
              {% endif %}
            {% endif %}
          </div>

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

        <div class="class-operation">
          {% if (memberDeadline != 0 and date(memberDeadline) < date()) and ('student' in member.role or 'member' in member.role) %}
            <div class="class-deadline">
              {% if classroom.expiryMode == 'date' %}
                <div class="alert alert-warning">{{ 'classroom.over_expiry_date_tips'|trans }}</div>
              {% elseif classroom.expiryMode == 'days' %}
                <div class="alert alert-warning"><a
                    href="{{ path('classroom_member_deadline_reach', {classroomId:classroom.id}) }}">
                    {% if classroom.buyable == 1 %}
                      {{ 'classroom.over_expiry_day_and_buyable_tips'|trans }}
                    {% else %}
                      {{ 'classroom.over_expiry_day_and_not_buyable_tips'|trans }}
                    {% endif %}
                  </a></div>
              {% endif %}
            </div>
          {% endif %}

          <ul class="class-data clearfix {% if classroomMemberLevel and 'auditor' in member.role %}hidden-sm{% else %}two-col{% 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>
            <span class="es-share top">
              <a class="dropdown-toggle" href="" 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 'auditor' in member.role and 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)}) }}">
                <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>
          
          {% if 'auditor' in member.role %}
            <div class="class-auditor hidden-sm">
              {{ 'classroom.auditor_join_tips'|trans|raw }}
              <i
                class="es-icon es-icon-help color-primary"
                data-toggle="tooltip" data-placement="top" title=""
                data-original-title="{{ 'classroom.auditor_and_member_different_tips'|trans }}"></i><br>

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

            </div>
          {% endif %}
        </div>

        {% if classroom_permit(classroom.id, 'Manage') and has_permission('admin_classroom_content_manage') %}
          <a href="{{ path('classroom_manage',{id:classroom.id}) }}" class="btn btn-default setting hidden-xs hidden-sm"
            title="{{ 'classroom.classroom_manage'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}">
            <i class="es-icon es-icon-setting"></i>
          </a>
        {% elseif classroom_permit(classroom.id, 'Handle') %}
          <a href="{{ path('classroom_manage_testpaper', {id:classroom.id,status:'reviewing'}) }}" class="btn btn-default setting hidden-xs hidden-sm"
            title="{{ 'classroom.classroom_manage'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}">
            <i class="es-icon es-icon-setting"></i>
          </a>
        {% endif %}
        {% if 'student' in member.role or 'auditor' in member.role %}
          <a type="button" class="btn btn-default setting hidden-xs hidden-sm" data-toggle="modal" data-target="#modal" data-url="{{ path('course_exit_modal', {action:path('classroom_exit', {id:classroom.id})}) }}">
            <i class="es-icon es-icon-exit"></i>
          </a>
        {% endif %}

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