{% extends 'TopxiaAdminBundle:User:layout.html.twig' %}

{% block title %}私信管理 - {{ parent() }}{% endblock %}

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

{% set menu = 'message' %}

{% block main %}
  <div class="page-header">
    <h1>私信管理</h1>
  </div>
<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="起始时间">
      </div>

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

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

      <button class="btn btn-primary">搜索</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"> 发信人</th>
        <th width="10%">收信人</th>
        <th width="45%">内容</th>
        <th width="15%">发送时间</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]|default(null)) }}
            </td>

            <td>{{ admin_macro.user_link(users[message.toId]|default(null)) }} </td>
            <td>
                <div class="short-long-text">
                  <div class="short-text text-sm text-muted">{{ message.content|plain_text(60) }} <span class="trigger">(展开)</span></div>
                  <div class="long-text">{{ message.content }} <span class="trigger">(收起)</span></div>
                </div>
            </td>
            <td>{{ message.createdTime|date('Y-n-d H:i')}}</td>
          </tr>
        {% endfor %}
      {% else %}
        <tr><td colspan="20"><div class="empty">暂无私信记录</div></td></tr>
      {% endif %}
      
    </tbody>
  </table>
  <div>
    <label class="checkbox-inline"><input type="checkbox" data-role="batch-select"> 全选</label>
    <button class="btn btn-default btn-sm mlm" data-role="batch-delete"  data-name="私信" data-url="{{ path('admin_message_delete_messages') }}">删除</button>
  </div>

</div>

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

{% endblock %}
