{% extends 'admin/layout.html.twig' %}

{% set menu = 'admin_course_manage' %}

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

{% block main %}
  {% include 'admin/course-set/tab.html.twig' %}
  <br>
  <div class="well well-sm mtl">
    <form id="message-search-form" class="form-inline" action="" method="get" novalidate>
      {% include 'org/org-tree-select.html.twig' with {orgCode: app.request.get('orgCode'), modal: 'list'} %}

      <div class="form-group">
        <select style="max-width:150px;" class="form-control" name="categoryId">
          {{ select_options(category_choices('course'), app.request.query.get('categoryId'), '课程分类'|trans) }}
        </select>
      </div>
      <div class="form-group">
        <select class="form-control" name="status">
          {{ select_options(dict('courseStatus'), app.request.query.get('status'), '课程状态'|trans) }}
        </select>
      </div>

      <div class="form-group">
        <input class="form-control" type="text" placeholder="{{'标题'|trans}}" name="title" value="{{ app.request.get('title') }}">
      </div>
      <div class="form-group">
        <input class="form-control" type="text" placeholder="{{'创建者'|trans}}" name="creatorName" value="{{ app.request.get('creatorName') }}">
      </div>
      <button class="btn btn-primary">{{'搜索'|trans}}</button>

      {% include 'admin/widget/tooltip-widget.html.twig' with { icon: 'glyphicon-question-sign', content: '课程说明Tooltip'|trans|raw, placement: 'left'} %}
    </form>
  </div>
  
  <p class="text-muted">
    <span class="mrl">{{'课程：'|trans}}<strong class="inflow-num">{{ searchCourseSetsNum }}</strong> {{ '个'|trans }}</span>
    <span class="mrl">{{'已发布：'|trans}}<strong class="inflow-num">{{ publishedCourseSetsNum }}</strong> {{ '个'|trans }}</span>
    <span class="mrl">{{'已关闭：'|trans}}<strong class="outflow-num">{{ closedCourseSetsNum }}</strong> {{ '个'|trans }}</span>
    <span class="mrl">{{'未发布：'|trans}}<strong class="outflow-num">{{ unPublishedCourseSetsNum }}</strong> {{ '个'|trans }}</span>
  </p>

  <table class="table table-striped table-hover" id="course-table" style="word-break:break-all;">
    <thead>
    <tr>
      {% if setting('magic.enable_org','0') %}
        <th><input type="checkbox"  data-role="batch-select"></th>
      {% endif %}
      <th width="5%">{{'编号'|trans}}</th>
      <th width="20%">{{'名称'|trans}}</th>
      <th width="10%">{{'价格'|trans}}</th>
      {% include 'org/parts/table-thead-tr.html.twig' %}
      <th width="">{{'连载状态'|trans}}</th>
      {% if filter == 'classroom' %}
        <th width="15%">{{'所在'|trans}}{{ setting("classroom.name")|default('班级'|trans) }}</th>
      {% else %}
        <th>{% if setting('default.user_name') %}{{ setting('default.user_name')|default('学员'|trans) }}{% else %}{{ '学员'|trans }}{% endif %}数
        </th>

      {% endif %}

      {% if filter == 'course' %}
        <th>{{'收入(元)'|trans}}</th>
      {% endif %}

      {% if filter == 'vip' %}
        <th>{{ '会员等级'|trans }}</th>
      {% endif %}

      <th>{{'状态'|trans}}</th>
      <th>{{'创建者'|trans}}</th>
      <th>{{'操作'|trans}}</th>
    </tr>
    </thead>
    <tbody>
    {% for courseSet in courseSets %}
      {% set user = users[courseSet.creator]|default(null) %}
      {% set category = categories[courseSet.categoryId]|default(null) %}
      {% include 'admin/course-set/tr.html.twig' %}
    {% else %}
      <tr>
        <td colspan="20">
          <div class="empty">{{'暂无课程记录'|trans}}</div>
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
  {% include 'org/batch-update-org-btn.html.twig' with {module:'courseSet', formId:'course-table'} %}
  {{ admin_macro.paginator(paginator) }}

{% endblock %}