{% import "TopxiaWebBundle::macro.html.twig" as web_macro %}



<div class="row row-12">
  <div class="col-md-12">
    <div class="panel panel-default  course-header">
      <div class="panel-body clearfix">
        <a href="{{ path('course_show', {id:course.id}) }}">
            <img class="picture" src="{{ filepath(course.largePicture, 'course.png') }}" />
        </a>

        <h1 class="title"><a href="{{ path('course_show', {id:course.id}) }}">{{ course.title }}</a> 
          {% if course.status=='closed' %}  
            <span class="label label-danger ">已关闭</span>
          {% elseif course.status=='draft' %}
            <span class="label label-warning ">未发布</span>
          {% elseif course.status=='published' %}
            {% if course.serializeMode=='serialize' %}
              <span class="label label-success ">更新中</span>
            {% elseif course.serializeMode=='finished' %}
              <span class="label label-warning ">已完结</span>
            {% endif %}
          {% endif %}
        </h1>

        <div class="teachers">
          {% if course.teacherIds|default(null) %}
            教师：
            {% for id in course.teacherIds %}
              {% set user = users[id] %}
              <a href="#modal" data-toggle="modal" data-url="{{ path('course_teacher_info',  {courseId:course.id, id:user.id}) }}">{{ user.nickname }}</a>
            {% endfor %}
          {% endif  %}
        </div>

        <div class="toolbar hidden-xs hidden-lt-ie8">
          {% if not manage %}
          <div class="btn-group">
            <a class="btn btn-default btn-sm" data-toggle="modal" data-url="{{ path('course_review_create', {id:course.id}) }}" data-role="tooltip" title="评价" data-placement="top" href="#modal">
              <i class="esicon esicon-like"></i> {{ course.ratingNum }}</a>
            {% if setting('course.show_student_num_enabled', '1') == 1 or member.role|default('student') == 'teacher' or isAdmin %}
              <a class="btn btn-default btn-sm" data-toggle="modal" data-url="{{ path('course_members', {id:course.id}) }}" data-role="tooltip" title="查看{{setting('default.user_name', '学员')}}的学习进度, 还可以发私信进行联系!" data-placement="bottom"
              href="#modal"><i class="esicon esicon-user"></i> {{course.studentNum}}</a>
            {% endif %}

            <div class="btn-group" data-role="tooltip" title="分享到" data-placement="left" >
              <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                <i class="esicon esicon-share"></i>
              </button>
              {% include 'TopxiaWebBundle:Common:share-dropdown.html.twig' with {type:'course', right: true} %}
            </div>
            {% if canExit %}
              {% if member.joinedType == 'course' and member.orderId %}
              <a class="btn btn-default btn-sm " title="退出学习" type="button" href="#modal" data-toggle="modal" data-url="{{ path('order_refund', {id:course.id, targetType:'course'}) }}">
              <i class="esicon esicon-exit"></i></a>
              {% else %}
              <a class="btn btn-default btn-sm course-exit-btn" id="exit-course-learning" title="退出学习" type="button"  href="javascript:;" data-url="{{ path('course_exit', {id:course.id}) }}"  data-goto="{{ path('course_show', {id:course.id}) }}">
              <i class="esicon esicon-exit"></i></a>
              {% endif %}
            {% endif %}
            {% if canManage %}
            <a class="btn btn-default btn-sm " type="button" href="{{ path('course_manage', {id:course.id}) }}"  title="课程管理"  >
            <i class="esicon esicon-setting"></i>
            </a>
            {% endif %}
          </div>

          {% else %}

            {% if course.status == 'published' %}
              <div class="btn-group">
                <a class="btn btn-default btn-sm" href="{{ path('course_show', {id:course.id}) }}">返回课程主页</a>
              </div>
            {% endif %}

            <div class="btn-group">
              <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">预览 <span class="caret"></span></button>
              <ul class="dropdown-menu pull-right">
                  <li><a href="{{ path('course_show', {id:course.id, previewAs:'member'}) }}" target="_blank">作为 已购买用户</a></li>
                  <li><a href="{{ path('course_show', {id:course.id, previewAs:'guest'}) }}" target="_blank">作为 未购买用户</a></li>
              </ul>
            </div>

            {% if course.status != 'published' %}
              <div class="btn-group">
                <button class="btn btn-success btn-sm course-publish-btn" data-url="{{ path('course_manage_publish', {id:course.id}) }}">发布课程</button>
              </div>
            {% endif  %}

          {% endif %}
        </div>
      </div>
    </div>
    {% 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' %}
          您已经不是会员，不能学习此课程！
          {% if course.price > 0 %}
            请重新<a class="btn-link" href="{{ path('vip') }}" target="_blank">开通会员</a>
          {% else %}
            <a class="btn-link js-exit-course" data-url="{{ path('course_exit', { id:course.id }) }}" data-go="{{ path('course_show', { id:course.id }) }}">返回课程首页</a>
          {% endif %}！
        {% elseif vipChecked == 'member_expired' %}
          您的会员已过期，不能学习此课程，请先<a class="btn-link" href="{{ path('vip_renew') }}" target="_blank">续费</a>。
        {% elseif vipChecked == 'level_low' %}
          会员等级不够，不能学习此课程。请先<a class="btn-link" href="{{ path('vip_upgrade') }}" target="_blank">升级会员</a>。
        {% else %}
          此课程已不支持会员免费学，<a class="btn-link js-exit-course" data-url="{{ path('course_exit', { id:course.id }) }}" data-go="{{ path('course_show', { id:course.id }) }}">返回课程首页</a>
        {% endif %}

      </div>

    {% endif %}

    {% if not isNonExpired %}
       <div class="alert alert-danger alert-dismissable">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          您购买的课程已到期，无法学习课时、提问等。如有疑问，请联系老师，或点击
          <a class="btn btn-primary btn-sm "  href="{{path('course_rebuy',{courseId:course.id})}}">
          {% if course.price>0 %}
          重新购买
          {% else %}
          重新加入
          {% endif %}
          </a>
      </div>
    {% endif %}

  </div>
</div>