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

{% set menu = 'admin_course_data' %}

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

{% block main %}
  {% include 'admin/course/tab-data.html.twig' %}

    <form id="message-search-form" class="form-inline well well-sm mtl" 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="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">
        <input class="form-control" type="text" placeholder="{{'admin.course_manage.title_placeholder'|trans}}" name="title" value="{{ app.request.get('title') }}">
      </div>
      <div class="form-group">
        <input class="form-control" type="text" placeholder="{{'admin.course_manage.creator_placeholer'|trans}}" name="creator" value="{{ app.request.get('creator') }}">
      </div>
      <button class="btn btn-primary">{{'form.btn.search'|trans}}</button>
    </form>
    <div class="table-responsive">
        <table class="table table-bordered" style="word-break:break-all;text-align:center;">
          <tr class="active">
            <td width="30%">{{'admin.course_manage.manage.name'|trans}}</td>
            {% if filter == 'classroom' %}
              <td>
                {{'admin.course_manage.manage.classroom_course_location'|trans({'%classroom%': setting("classroom.name")|default('classroom'|trans)})}}
              </td>
            {% endif %}
            <td>{{ 'admin.course_manage.statistics.task_count'|trans({'%taskName%':setting('course.task_name')|default('admin.setting_course.task'|trans)}) }}</td>
            <td>{{'admin.course_manage.statistics.student_number'|trans }}</td>
            <td>{{'admin.course_manage.statistics.finished_number'|trans}}</td>
            <td>{{'admin.course_manage.statistics.study_time_minute'|trans}}</td>
            <td>{{'admin.course_manage.statistics.income_RMB'|trans}}</td>
            <td>{{'admin.course_manage.operater'|trans}}</td>
          </tr>

          {% if courses %}
            {% for course in courses %}
            <tr>
            <td><a data-toggle="modal" data-target="#modal" data-url="{{path('course_detail_data',{id:course.id})}}" href="javascript:">{{course.title}}</a></td>
            {% if filter == 'classroom' %}
            <td>
            {% set classroom = classrooms[course.id]|default(null) %}
            {% if classroom %}
            <a href="{{path('classroom_show',{id:classroom.classroomId})}}" target="_blank">{{classroom.classroomTitle}}</a>
            {% elseif not classroom %}
            <span class="label label-danger live-label mls">{{'admin.course_manage.statistics.no_introduce'|trans}}</span>
            {% endif %}
            </td>
            {% endif %}
            <td>{{course.lessonCount}}</td>
            <td>{{course.studentNum}}</td>
            <td>{{course.isLearnedNum}}</td>
            <td>{{(course.learnTime/60)|round(0, 'floor')}}</td>
            <td>{{course.income}}</td>
            <td><a href="{{path('admin_course_lesson_data',{id:course.id})}}">{{'admin.course_manage.statistics.watch_course_data'|trans}}</a></td>
            </tr>
            {% endfor %}
          {% endif %}
        </table>
     {{ admin_macro.paginator(paginator) }}
      </div>
{% endblock %}
