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

{% set menu = 'admin_message' %}
{% set script_controller = 'message/list' %}

{% block main %}
  <div class="well well-sm">
    <form id="message-search-form" class="form-inline" action="" method="get" novalidate>
      <div class="form-group">
        <input class="form-control" type="text" id="startDate" name="startDate"
               value="{{ app.request.query.get('startDate') }}" placeholder="{{'起始时间'|trans}}">
      </div>

      <div class="form-group">
        <input class="form-control" type="text" id="endDate" name="endDate"
               value="{{ app.request.query.get('endDate') }}" placeholder="{{'结束时间'|trans}}">
      </div>
      <span></span>
      <div class="form-group">
        <input type="text" id="nickname" name="nickname" value="{{ app.request.query.get('nickname') }}"
               class="form-control" placeholder="{{ '发信人用户名'|trans }}">
      </div>

      <div class="form-group">
        <input type="text" id="content" name="content" value="{{ app.request.query.get('content') }}"
               class="form-control" placeholder="{{'私信内容关键词'|trans}}">
      </div>

      <button class="btn btn-primary">{{'搜索'|trans}}</button>
    </form>
  </div>

  <div id="message-table-container">

  <table class="table table-striped table-hover" id="message-table">
    <thead>
      <tr >
        <th width="10%"> <input type="checkbox"  data-role="batch-select"> {{'发信人'|trans}}</th>
        <th width="10%">{{'收信人'|trans}}</th>
        <th width="45%">{{'内容'|trans}}</th>
        <th width="15%">{{'发送时间'|trans}}</th>
      </tr>
      </thead>
      <tbody>
      {% if messages %}
        {% for message in messages %}
          <tr class="message-tr" id="message-table-tr-{{ message.id }}">
            <td><input value="{{ message.id }}" type="checkbox" data-role="batch-item">
              {{ admin_macro.user_link(users[message.fromId]) }}
            </td>

            <td>{{ admin_macro.user_link(users[message.toId]) }} </td>
            <td>
              <div class="short-long-text">
                <div class="short-text text-sm text-muted">{{ message.content|plain_text(60) }} <span class="trigger">{{ '(展开)'|trans }}</span>
                </div>
                <div class="long-text">{{ message.content }} <span class="trigger">{{ '(收起)'|trans }}</span></div>
              </div>
            </td>
            <td>{{ message.createdTime|date('Y-n-d H:i') }}</td>
          </tr>
        {% endfor %}
      {% else %}
        <tr>
          <td colspan="20">
            <div class="empty">{{ '暂无私信记录'|trans }}</div>
          </td>
        </tr>
      {% endif %}

      </tbody>
    </table>
    <div>
      <label class="checkbox-inline"><input type="checkbox" data-role="batch-select">{{ '全选'|trans }}</label>
      <button class="btn btn-default btn-sm mlm" data-role="batch-delete" data-name="{{ '私信'|trans }}"
              data-url="{{ path('admin_message_delete_messages') }}">{{ '删除'|trans }}
      </button>
    </div>

  </div>

  <div>
    {{ admin_macro.paginator(paginator) }}
  </div>

{% endblock %}
