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

{% set menu = 'admin_batch_notification' %}

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

{% block main %}
<table id="batchnotification-table" class="table table-striped">
    <thead>
        <tr>
            <th width="40%">{{'站内信通知标题'|trans}}</th>
            <th>{{'发布时间'|trans}}</th>
            <th>{{'创建时间'|trans}}</th>
            <th>{{'发布人'|trans}}</th>
            <th>{{'状态'|trans}}</th>
            <th>{{'操作'|trans}}</th>
        </tr>
    </thead>
    <tbody>
        {% if batchnotifications %}
            {% for batchnotification in batchnotifications %}
                <tr>
                    <td><a href="javascript:;" data-url="{{ path('batch_notification_show',{ id:batchnotification.id }) }}"data-toggle="modal" data-target="#modal">{{batchnotification.title|raw}}</a></td>
                    {% if batchnotification.sendedTime == 0 %}
                    <td>--</td>
                    {% else %}
                    <td>{{batchnotification.sendedTime|date('Y-m-d H:i')}}</td>
                    {% endif %}
                    <td>{{batchnotification.createdTime|date('Y-m-d H:i')}}</td>
                    <td>{{users[batchnotification.fromId].nickname}}</td>
                    {% if batchnotification.published %}<td class="text-success">{{'已发布'|trans}}</td>{% else %}<td>{{'未发布'|trans}}</td>{% endif %}
                    <td>
                        <div class="btn-group">
                            {% if batchnotification.published %}
                                <a  href="javascript:" data-url="{{ path('admin_batch_notification_delete',{id:batchnotification.id}) }}" data-role="delete-item" class="btn btn-default btn-sm" >{{'删除'|trans}}</a>
                            {% else %}
                                <a  href="{{ path('admin_batch_notification_edit',{id:batchnotification.id}) }}" class="btn btn-default btn-sm" >{{'编辑'|trans}}</a>
                                <a href="#" type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                <span class="caret"></span>
                                </a>
                                <ul class="dropdown-menu">
                                    <li><a href="javascript:" data-role="publish-item" data-url="{{ path('admin_batch_notification_send', {id:batchnotification.id}) }}">{{'发布'|trans}}</a></li>
                                    <li><a href="javascript:" data-role="delete-item" data-url="{{ path('admin_batch_notification_delete', {id:batchnotification.id}) }}">{{'删除'|trans}}</a></li>
                                </ul>
                            {% endif %}
                        </div>
                    </td>
                </tr>
            {% endfor %}
          {% endif %}
    </tbody>
</table>
  {% if not batchnotifications %}
    <div class="empty">{{'暂无站内信'|trans}}</div>
  {% endif %}
  <div class="alert alert-info text-center">
    全站站内通知将以网校通知的形式发给所有用户
  </div>

  {{ admin_macro.paginator(paginator) }}
{% endblock %}
