{% extends 'TopxiaAdminBundle:Course:layout.html.twig' %}

{% block title %}课程管理 - {{ parent() }}{% endblock %}

{% set script_controller = 'course/manage' %}

{% set menu = 'course' %}

{% block main %}

  <div class="page-header">
{#   {% if liveSetEnabled == 1 %}
    <a href="{{ path('course_create',{flag:'isLive'}) }}" class="btn btn-info btn-sm pull-right mls" target="_blank">创建直播课程</a>
  {% endif %} #}
    <a href="{{ path('course_create') }}" class="btn btn-info btn-sm pull-right" target="_blank">创建公有课程</a>
    <h1>课程管理</h1>
  </div>

  <form id="message-search-form" class="form-inline well well-sm" action="" method="get" novalidate>
    <div class="form-group">
      <input type="text" id="class_name" name="class_name" data-url="{{path('admin_class_list')}}" class="form-control" size="8" value="{{ app.request.query.get('class_name') }}" placeholder="按班级">
      
      <input type="hidden" id="class_id" name="classId" class="form-control" value="{{ app.request.query.get('classId') }}" >
    </div>

    {# <div class="form-group">
      <select style="max-width:150px;" class="form-control" name="categoryId">
        {{ select_options(category_choices('course'), app.request.query.get('categoryId'), '课程分类') }}
      </select>
    </div> #}
    <div class="form-group">
      <select class="form-control" name="status">
        {{ select_options(dict('courseStatus'), app.request.query.get('status'), '课程状态') }}
      </select>
    </div>
    <div class="form-group">
      <select class="form-control" name="courseCopyType">
        {{ select_options({'public': '公有课程', 'linked':'关联课程', 'private':'私有课程' }, app.request.query.get('courseCopyType'), '课程类型') }}
      </select>
    </div>
    <div class="form-group">
      <input class="form-control" type="text" size="40" placeholder="标题" name="title" value="{{ app.request.get('title') }}">
    </div>
    {# <div class="form-group">
      <input class="form-control" type="text" placeholder="创建者" name="creator" value="{{ app.request.get('creator') }}">
    </div> #}
    <button class="btn btn-primary">搜索</button>
  </form>

  <table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
    <thead>
    <tr>
      {# <th>编号</th> #}
      <th width="40%">名称</th>
      <th>所属班级</th>
      <th  class="text-center">学生数</th>
{#       <th>收入(元)</th> hidden by wenqin #}
      <th  class="text-center">状态</th>
      <th>创建者</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
      {% for course in courses %}
        {% set user = users[course.userId]|default(null) %}
        {% set category = categories[course.categoryId]|default(null) %}
        {% set class=classes[course.classId]|default('') %}
        {% include 'TopxiaAdminBundle:Course:tr.html.twig' %}
      {% else %}
        <tr><td colspan="20"><div class="empty">暂无课程记录</div></td></tr>
      {% endfor %}
    </tbody>
  </table>

  {{ web_macro.paginator(paginator) }}

{% endblock %}