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

{% set menu = 'admin_v2_course_manage' %}

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

{% block main %}
  <div class="well well-sm mtl">
    <form id="message-search-form" class="form-inline" action="" method="get" novalidate>
      <div class="mbm">
        <div class="form-group">
          <select style="max-width:150px;" class="form-control" name="filter">
            {{ select_options(dict('adminCourseTypes'), app.request.query.get('filter')) }}
          </select>
        </div>
        {% 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'), 'admin.course_manage.category_placeholder'|trans) }}
          </select>
        </div>
        <div class="form-group ">
          <div class="controls">
            <input class="form-control" style="width: 200px" id="tag" type="text" data-tag-value="{{ tag|default('')|json_encode }}" value="{{ tag.name|default('') }}" data-url="{{ path('admin_v2_course_tag_match') }}">
            <input class="form-control hidden" name="tagId" type="text" value="{{ tag.id|default('') }}">
          </div>
        </div>
        <div class="form-group">
          <select class="form-control" name="status">
            {{ select_options(dict('courseStatus'), app.request.query.get('status'), 'admin.course_manage.manage.status_placeholder'|trans) }}
          </select>
        </div>
        <div class="form-group">
          <select class="form-control" name="type">
            {{ select_options(dict('nonOpenCourseCateogry'), app.request.query.get('type'), 'type'|trans) }}
          </select>
        </div>

        <div class="form-group">
          <input class="form-control" type="text" placeholder="{{ 'admin.course_manage.title_placeholder'|trans }}" name="title" value="{{ app.request.get('title') }}">
        </div>
      </div>
      <div class="form-group">
        <input class="form-control" type="text" placeholder="{{ 'admin.course_manage.creator_placeholer'|trans }}" name="creatorName" value="{{ app.request.get('creatorName') }}">
      </div>
      <button class="btn btn-primary">{{ 'form.btn.search'|trans }}</button>

      {% include 'admin-v2/widget/tooltip-widget.html.twig' with { icon: 'glyphicon-question-sign', content: 'admin.course_manage.manage.course_tips'|trans|raw, placement: 'left'} %}
    </form>
  </div>
  
  <p class="text-muted">
    <span class="mrl">{{ 'admin.course_manage.manage.count'|trans({'%courseNum%':courseSetStatusNum.total})|raw }}</span>
    <span class="mrl">{{ 'admin.course_manage.manage.published_count'|trans({'%publishedNum%':courseSetStatusNum.published})|raw }}</span>
    <span class="mrl">{{ 'admin.course_manage.manage.closed_count'|trans({'%closedNum%':courseSetStatusNum.closed})|raw }}</span>
    <span class="mrl">{{ 'admin.course_manage.manage.unpublish_count'|trans({'%unPublishedNum%':courseSetStatusNum.draft})|raw }}</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>{{ 'admin.course_set_manage.manage.number'|trans }}</th>
      <th width="20%">{{ 'admin.course_manage.manage.name'|trans }}</th>
      <th width="10%">{{ 'admin.course_manage.manage.price'|trans }}</th>
      {% if filter == 'normal' %}
        <th>{{ 'admin.course_manage.manage.course_num'|trans }}</th>
      {% endif %}
      <th>{{ 'admin.course_manage.manage.tags'|trans }}</th>
      {% include 'org/parts/table-thead-tr.html.twig' %}
      
      {% if filter == 'classroom' %}
        <th width="15%">{{ 'admin.course_manage.manage.classroom_course_location'|trans({'%classroom%':setting("classroom.name")|default('classroom'|trans)}) }}</th>
      {% else %}
        <th>
          {{ 'admin.course_manage.manage.student_number'|trans }}
        </th>
      {% endif %}

      {% if filter == 'course' %}
        <th>{{ 'admin.course_manage.manage.income_RMB'|trans }}</th>
      {% endif %}

      {% if filter == 'vip' %}
        <th>{{ 'admin.course_manage.manage.vip_grade'|trans }}</th>
      {% endif %}

      
      <th>{{ 'admin.course_manage.manage.creator'|trans }}</th>
      <th>{{ 'admin.course_manage.manage.status'|trans }}</th>
      <th width="10%">{{'admin.course_manage.operater'|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-v2/teach/course-set/tr.html.twig' %}
    {% else %}
      <tr>
        <td colspan="20">
          <div class="empty">{{'admin.course_manage.manage.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 %}