{% extends 'courseset-manage/layout.html.twig' %}

{% block title %}{{ '教学计划管理'|trans }} - {{ parent() }}{% endblock %}
{% set side_nav = 'plan' %}

{% do script(['app/js/course-manage/index.js','app/js/course-manage/list/index.js']) %}

{% block main %}
  <div class="panel panel-default" role="courseset-manage-courses" >
    <div class="panel-heading">
      {{ '教学计划管理'|trans }}
      <button class="btn btn-success btn-sm pull-right" data-toggle="modal" data-target="#modal"
        data-url="{{ path('course_set_manage_course_create', {courseSetId: courseSet.id}) }}"><i
          class="es-icon es-icon-anonymous-iconfont"></i>{{ '创建教学计划'|trans }}</button>
    </div>
    <div class="panel-body">
      <table id="courses-list-table" class="table table-striped">
      	<thead>
      	  <th width="30%">{{'名称'|trans}}</th>
          <th>
            {{'学习模式'|trans}}
            <a class="link-medium es-icon es-icon-help ml5 text-normal" 
              data-container="body" data-toggle="popover" data-trigger="hover" 
              data-placement="top" data-content="<ul class='pl20 ul-list-none'>
              <li class='mb10'><b>自由式学习：</b>学员自由安排学习过程</li>
              <li><b>解锁式学习：</b>学员根据既定顺序逐个解锁学习</li></ul>">
            </a>
          </th>
          <th>{{'任务数'|trans}}</th>
          <th>{{'学员'|trans}}</th>
          <th width="15%">{{'价格（元）'|trans}}</th>
          <th>{{'状态'|trans}}</th>
          <th>{{'操作'|trans}}</th>
      	</thead>
      	<tbody>
      		{% for course in courses %}
      		<tr>
      			<td><a class="link-primary" href="{{ path('my_course_show', { id: course.id, previewAs: 'member' }) }}" target="_blank">{{course.title}}</a></td>
            <td>
              {% if course.learnMode|default('freeMode') == 'freeMode' %}
                自由式学习
              {% else %}
                解锁式学习
              {% endif %}
            </td>
      			<td>{{course.taskNum|default(0)}}</td>
      			<td>{{course.studentNum|default(0)}}</td>
      			<td>{{course.price}}{# {{'元'|trans}} #}
                <br>
			          {{ slot('course.marketing.extension', {'course':course}) }}
      			</td>
			      <td>
             {% if course.status == 'published' %}
                <span class="color-success">{{'已发布'|trans}}</span>
              {% elseif course.status=='closed'%}             
                <span class="color-danger">{{'已关闭'|trans}}</span>
              {% else %}
                <span class="color-warning">{{ '未发布'|trans }}</span>
              {% endif %}
            </td>
            <td>
            {% if courseSet.canManage|default() or course.canManage|default()  %}
              <div class="btn-group">
                <a class="mr10 link-primary"
                  href="{{ path('course_set_manage_course_tasks', {courseSetId: courseSet.id, courseId: course.id}) }}">{{ '管理'|trans }}</a>
                <a class="dropdown-toggle link-primary" href="javascript:;"  data-toggle="dropdown">
                  更多
                  <i class="es-icon es-icon-arrowdropdown"></i>
                </a>
                <ul class="dropdown-menu pull-right">
                  <li>
                    <a href="{{ path('my_course_show', { id: course.id, previewAs: 'member' }) }}" target="_blank">
                      <i class="es-icon es-icon-removeredeye mrm"></i>
                      {{ '预览'|trans }}
                    </a>
                  </li>
                  <li>
                    <a href="javascript:;" data-toggle="modal" data-target="#modal"
                      data-url="{{ path('course_set_manage_course_copy', {courseSetId: courseSet.id, courseId: course.id}) }}">
                      <i class="es-icon es-icon-contentcopy mrm"></i>
                      {{ '复制为'|trans }}
                    </a>
                  </li>
                  {% if course.status|default('') == 'published' %}
                    <li>
                      <a href="javascript:;"
                        data-check-url="{{ path('course_set_manage_course_close_check', {courseSetId: courseSet.id, courseId: course.id}) }}"
                        data-url="{{ path('course_set_manage_course_close', {courseSetId: courseSet.id, courseId: course.id}) }}"
                        class="js-close-course">
                        <i class="es-icon es-icon-close01 mrm"></i>
                        {{ '关闭'|trans }}
                      </a>
                    </li>
                  {% else %}
                    <li>
                      <a href="javascript:;"
                        data-url="{{ path('course_set_manage_course_delete', {courseSetId: courseSet.id, courseId: course.id}) }}"
                        class="js-delete-course"><i class="es-icon es-icon-delete mrm"></i>{{ '删除'|trans }}</a>
                    </li>
                    <li>
                      <a href="javascript:;"
                        data-url="{{ path('course_set_manage_course_publish', {courseSetId: courseSet.id, courseId: course.id}) }}"
                        class="js-publish-course"><i class="es-icon es-icon--check-circle mrm"></i>{{ '发布'|trans }}</a><!-- 已发布的不能删除，可关闭 -->
                    </li>
                  {% endif %}
                </ul>
              </div>
            {% else %}
              <span class="color-gray">无权限管理</span>
            {% endif %}
            </td>
          </tr>
        {% endfor %}
        </tbody>
      </table>
      <nav class="text-center">{{ web_macro.paginator(paginator) }}</nav>
    </div>
  </div>
{% endblock %}

