{% import "common/data-dict-macro.html.twig" as dict_macro %}
{% extends 'my/layout.html.twig' %}

{% block title %}{{'在教课程'|trans}} - {{ parent() }}{% endblock %}

{% set side_nav = 'my-teaching-courses' %}

{% set type="question" %}

{% block main %}

<div class="panel panel-default panel-col lesson-manage-panel">
  <div class="panel-heading">
    <span class="pull-right">
      <a id="create-course" href="{{ path('course_set_manage_create') }}" class="btn btn-info btn-sm"><span class="glyphicon glyphicon-plus"></span> {{'创建课程'|trans}}</a>
    </span>
    {{'在教课程'|trans}}
  </div>

  <div class="panel-body">
    {% include 'my/teaching/course-tab.html.twig'%}

    <table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
      <thead>
      <tr>
        <th width="50%">{{'名称'|trans}}</th>
        <th>{{'浏览数'|trans}}</th>
        <th>{{'状态'|trans}}</th>
        <th width="20%">{{'操作'|trans}}</th>
      </tr>
      </thead>
      <tbody>
      {% if courses %}
       	{% for course in courses %}
       	 <tr>
            <td>
              <a class="pull-left mrm link-primary" href="{{ path('open_course_show', {courseId:course.id}) }}" title="{{ course.title }}">
                <img class="course-picture" src="{{ filepath(course.middlePicture, 'course.png') }}" alt="{{ course.title }}" width="100">
              </a>

              <div class="mlm">
                <a class="link-primary" href="{{ path('open_course_show', {courseId:course.id}) }}" title="{{ course.title }}">{{ course.title }}</a>
                {% if course.type == 'liveOpen' %}
                  <span class="label label-success live-label">{{'直播'|trans}}</span>
                {% endif  %}
              </div>
            </td>
            <td>{{ course.hitNum }}</td>
            <td>{{ dict_macro.courseStatus( course.status) }}</td>
            <td>
              <div class="btn-group">
                {% if 'ROLE_SUPER_ADMIN' in app.user.roles %}
                  <a class="mr10 link-primary" href="{{ path('open_course_manage', {id:course.id}) }}">{{'管理'|trans}}</a>
                {% elseif 'ROLE_TEACHER' in app.user.roles %}
                  <a class="mr10 link-primary" href="{{ path('open_course_manage', {id:course.id}) }}">{{'查看'|trans}}</a>
                {% endif %}
                <a href="javascript:;"  class="link-primary dropdown-toggle ml10" data-toggle="dropdown">
                  更多
                  <i class="es-icon es-icon-arrowdropdown"></i>
                </a>
                <ul class="dropdown-menu pull-right">
                  {% if course.type != 'liveOpen' %}
                    <li><a href="{{ path('open_course_manage_lesson', {id:course.id}) }}">{{'课时管理'|trans}}</a></li>
                    <li><a href="{{ path('open_course_manage_files', {id:course.id}) }}">{{'文件管理'|trans}}</a></li>
                  {% endif %}
                  <li><a href="{{ path('open_course_manage_students', {id:course.id}) }}">{% if setting('default.user_name') %}{{setting('default.user_name')|default('学员'|trans)}}{% else %}{{'学员'|trans}}{% endif %}{{'管理'|trans}}</a></li>
                </ul>
              </div>
            </td>
          </tr>
        {% endfor %}
        {% else %}
          <tr>
            <td colspan="20">
              <div class="empty">
                <a class="link-primary"  href="{{ path('course_set_manage_create') }}" target="_blank">
                  {{'你还没有在教的公开课哦, 赶快去创建吧!'|trans}}
                </a>
              </div>
            </td>
          </tr>
       {% endif %}
        
      </tbody>
    </table>
    <nav class="text-center">
      {{ web_macro.paginator(paginator) }}
    </nav>
  </div>
</div>

{% endblock %}