{% 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') }}">{{ '首页'|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">
        您的退款申请已提交，请等待管理员的处理。
        <button class="btn btn-warning btn-sm cancel-refund" data-url="{{ path('order_cancel_refund', {id:classroom.id, targetType:"classroom"}) }}">
          取消退款，继续学习！
        </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' %}
          {{ '您已经不是会员，不能学习此' ~ setting("classroom.name")|default("班级") ~ '！'|trans }}
          {% if classroom.price > 0 %}
            {{ '请重新'|trans }}<a class="alert-link" href="{{ path('vip') }}" target="_blank">{{ '开通会员'|trans }}</a>
          {% else %}
            <a class="alert-link js-exit" href="javascript:;" data-url="{{ path('classroom_exit', { id:classroom.id }) }}"
              data-go="{{ path('classroom_show', { id:classroom.id }) }}">{{ '退出'|trans }}</a>
          {% endif %}！
        {% elseif vipChecked == 'member_expired' %}
          {{ '您的会员已过期，不能学习此' ~ setting("classroom.name")|default("班级") ~ '，请先'|trans }}<a class="alert-link" href="{{ path('vip_renew') }}"
          target="_blank">{{ '续费'|trans }}</a>{{ '。'|trans }}
        {% elseif vipChecked == 'level_low' %}
          {{ '会员等级不够，不能学习此' ~ setting("classroom.name")|default("班级") ~ '。请先'|trans }}<a class="alert-link" href="{{ path('vip_upgrade') }}"
          target="_blank">{{ '升级会员'|trans }}</a>{{ '。'|trans }}
        {% else %}
          {{ '该' ~ setting("classroom.name")|default("班级") ~ '已不支持会员免费学，'|trans }}<a class="alert-link js-exit" href="javascript:;"
          data-url="{{ path('classroom_exit', { id:classroom.id }) }}"
          data-go="{{ path('classroom_show', { id:classroom.id }) }}">{{ '退出'|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="">
                {{ '扫二维码继续学习'|trans }}
                {{ '二维码时效为半小时'|trans }}
              </span>
            </span>
          </h2>
          <div class="metas">
            <div class="score">
              {{ web_macro.star(classroom.rating) }}
              <span>({{ classroom.ratingNum }}{{ '评价'|trans }})</span>
            </div>
            {% if member.role == 'auditor' %}
              <div class="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 %}
                    {{ '免费'|trans }}
                  {% endif %}
                  {% else %}
                    {% if classroom.price > 0 %}
                      {{ classroom.price }}{{ '元'|trans }}
                    {% else %}
                      {{ '免费'|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">班级有效期</span>
                <span>{{ memberDeadline|date('Y-m-d') }}</span>
              {% endif %}
            {% endif %}
          </div>

          <div class="class-serve hidden-sm hidden-xs">
            <div class="serve-frame">
              {{ '承诺服务'|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">你的班级已过有效期，无法继续学习</div>
              {% elseif classroom.expiryMode == 'days' %}
                <div class="alert alert-warning">你的班级已过有效期，无法继续学习，请<a
                    href="{{ path('classroom_member_deadline_reach', {classroomId:classroom.id}) }}">
                    {% if classroom.buyable == 1 %}
                      {{ '重新购买'|trans }}
                    {% else %}
                      {{ '重新加入'|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 %}">
            <li>
              <p><i class="es-icon es-icon-person"></i></p>
              <p>{{ '学员'|trans }}({{ classroom.studentNum + classroom.auditorNum }})</p>
            </li>
            <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>{{ '分享'|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="会员{{ setting("classroom.name")|default("班级") }}"
                data-content="{% include 'course/header/parts/normal-header-vip.html.twig' with {courseVip:classroomMemberLevel,userVipStatus:checkMemberLevelResult} %}"
                data-original-title="会员{{ setting("classroom.name")|default("班级") }}">
                <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">
              {{ '您现在是'|trans }}<span class="color-warning">{{ '旁听生'|trans }}</span>{{ '，不能完整学习'|trans }}<i
                class="es-icon es-icon-help color-primary"
                data-toggle="tooltip" data-placement="top" title=""
                data-original-title="{{ '旁听生只能参与话题讨论，正式学员可以完整地学习所有内容，享受所有教学服务'|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="{{ '%name%管理'|trans({'%name%':setting('classroom.name')|default('班级'|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="{{ '%name%管理'|trans({'%name%':setting('classroom.name')|default('班级'|trans)}) }}">
            <i class="es-icon es-icon-setting"></i>
          </a>
        {% endif %}
        {% if classroom_permit(classroom.id, 'Take', true) and not isclassroomteacher|default(false) and not member.locked %}
          {% if 'headTeacher' not in member.role %}
            <a type="button"
              {% if  'student' in member.role and member.orderId > 0 %}
                class="btn btn-default setting hidden-xs hidden-sm"
                href="#modal"
                data-toggle="modal"
                data-url="{{ path('order_refund', {id:classroom.id, targetType:'classroom'}) }}"
              {% else %}
                class="btn btn-default setting hidden-xs hidden-sm"
                href="{{ path('classroom_exit', {id:classroom.id}) }}" id="quit"
              {% endif %}
            >
              <i class="es-icon es-icon-exit"></i>
            </a>
          {% endif %}
        {% endif %}
      </div>
    </div>
  </div>
</section>


{# {% if is_plugin_installed('ClassroomPlan') %}
  {{ render(controller('ClassroomPlanBundle:ClassroomPlan:joinPlanBlock',{classroomId:classroom.id})) }}
{% endif %}
 #}