{% extends 'admin/layout.html.twig' %}
{% import 'admin/macro.html.twig' as admin_macro %}

{% set menu = 'admin_user_learn_statistics' %}

{% set script_controller = 'user/user-learn-statistics' %}

{% block main %}
    <form id="user-search" class="form-inline well well-sm" action="" method="get" novalidate="">
      <div class="form-group ">
        <input class="form-control" type="text" id="startDate" name="startDate" value="{{ app.request.query.get('startDate') }}" data-min-time="{{ recordEndTime }}" placeholder="{{ 'user.learn.statistics.start_time'|trans }}"  autocomplete="off">
        -
        <input class="form-control" type="text" id="endDate" name="endDate" value="{{ app.request.query.get('endDate') }}" placeholder="{{ 'user.learn.statistics.end_time'|trans }}" autocomplete="off">
        <input class="form-control" type="text" name="nickname" placeholder="{{'user.learn.statistics.nickname'|trans}}" value="{{ app.request.query.get('nickname') }}">
        <input type="hidden" name="isDefault" value="{{ isDefault|default(false) }}">
      </div>
      <a class="btn btn-primary" id="search">{{'user.learn.statistics.search'|trans}}</a>
      {# <a class="btn btn-primary" id="default-search">{{ 'user.learn.statistics.default.search'|trans }}</a> #}
      {% include 'export/export-btn.html.twig' with 
      { 'exportFileName': 'user-learn-statistics', 
        'targetFormId': 'user-search'}  
      %}
      {% include 'admin/widget/tooltip-widget.html.twig' with { icon: 'glyphicon-question-sign', content: 'user.learn.statistics.manage.describe_tips'|trans|raw, placement: 'left'} %}
    </form>
    <table id="user-table" class="table table-striped table-hover" data-search-form="#user-search-form">
      <thead>
        <tr>
          <th>{{'user.learn.statistics.nickname'|trans}}</th>
          <th>{{'user.learn.statistics.join.classroom.num'|trans}}</th>
          <th>{{'user.learn.statistics.exit.classroom.num'|trans}}</th>
          {# <th>加入课程数</th>
          <th>退出课程数</th> #}
          <th>{{'user.learn.statistics.join.course.num'|trans}}</th>
          <th>{{'user.learn.statistics.exit.course.num'|trans}}</th>
          <th>{{'user.learn.statistics.finished.task.num'|trans}}</th>
          <th>{{'user.learn.statistics.learned.seconds'|trans}}</th>
          <th>{{'user.learn.statistics.actual.amount'|trans}}</th>
          <th>{{ 'operation'|trans }}</th>
        </tr>
      </thead>
      <tbody>
      {% if isInit %}
          {% for user in users|default() %}
            {% set statistic = statistics[user.id]|default(null) %}
              <tr>
              <td>
                {% if has_permission('admin_user_manage') %}
                  <a href="javascript:" class="" data-toggle="modal" data-target="#modal" data-url="{{ path('admin_user_show', {id:user.id}) }}">{{ user.nickname|default('--') }}</a>
                {% else %}
                  <span><a target="_blank" href="{{ path('user_show', {id: user.id}) }}">
                  {{ user.nickname }}</a></span>
                {% endif %}
              </td>
              <td>{{ statistic.joinedClassroomNum|default(0) }}</td>
              <td>{{ statistic.exitClassroomNum|default(0) }}</td>
              {# <td>{{ statistic.joinedCourseSetNum }}</td>
              <td>{{ statistic.exitCourseSetNum }}</td> #}
              <td>{{ statistic.joinedCourseNum|default(0) }}</td>
              <td>{{ statistic.exitCourseNum|default(0) }}</td>
              <td>{{ statistic.finishedTaskNum|default(0) }}</td>
              <td>{{ (statistic.learnedSeconds|default(0)/60)|number_format(0) }}</td>
              <td>{{ statistic.actualAmount|default(0)|to_cash(0) }}</td>
              <td><a href="{{ path('admin_user_learn_detail', {userId:user.id}) }}">{{ 'site.btn.detail'|trans }}</a></td>
            </tr>
          {% endfor %}
          {% if users is empty %}
            <tr><td colspan="20"><div class="empty">{{'user.learn.statistics.empty'|trans}}</div></td></tr>
          {% endif %}  
      {% else %}
        <tr><td colspan="20"><div class="empty">{{'user.learn.statistics.init'|trans}}</div></td></tr>   
      {% endif %}
      </tbody>
    </table>

    {% if isInit %}
      {{ admin_macro.paginator(paginator) }}
    {% endif %}
{% endblock %}